Reads a private key from  keystore

@param alias
@param password
@return
@throws UnrecoverableKeyException
@throws KeyStoreException
@throws NoSuchAlgorithmException
1937
public Key getPrivateKey(String alias, String password) throws UnrecoverableKeyException, KeyStoreException, NoSuchAlgorithmException {
		return this.keystore.getKey(alias, password.toCharArray());
	}
765399
public static KeyStore loadKeyStore(File file, String password) throws KSIException {
        notNull(file, "Trust store file");
        FileInputStream input = null;
        KeyStore keyStore = null;
        try {
            keyStore = KeyStore.getInstance("JKS");
            char[] passwordCharArray = password == null ? null : password.toCharArray();
            input = new FileInputStream(file);
            keyStore.load(input, passwordCharArray);
        } catch (GeneralSecurityException | IOException e) {
            throw new KSIException("Loading java key store with path " + file + " failed", e);
        } finally {
            closeQuietly(input);
        }
        return keyStore;
    }
898399
private void readTrustStore() throws IOException, FormatNotUnderstoodException {
		if (((this.hocr.getSigTruststoreFile() != null) && (!"".equals(this.hocr.getSigTruststoreFile())))) {
			LOG.info("Reading truststore to validate certificate chain for signatures");
			FlinkKeyStoreManager fksm = new FlinkKeyStoreManager();
			try {
				fksm.openKeyStore(new Path(this.hocr.getSigTruststoreFile()), this.hocr.getSigTruststoreType(),
						this.hocr.getSigTruststorePassword());
				this.hocr.setX509CertificateChain(fksm.getAllX509Certificates());
			} catch (NoSuchAlgorithmException | CertificateException | KeyStoreException | IllegalArgumentException e) {
				LOG.error("Exception: ",e);
				throw new FormatNotUnderstoodException(
						"Cannot read truststore to establish certificate chain for signature validation " + e);
			}

		}
	}
666540
public Proxy setSocksPassword(String password) {
    verifyProxyTypeCompatibility(ProxyType.MANUAL);
    this.proxyType = ProxyType.MANUAL;
    this.socksPassword = password;
    return this;
  }
1190378
private SSLContext getSSLContext(String truststorePath,
                                     String truststorePassword,
                                     String keystorePath, 
                                     String keystorePassword) throws Exception {

        FileInputStream tsf = new FileInputStream(truststorePath);
        KeyStore ts = KeyStore.getInstance("JKS");
        ts.load(tsf, truststorePassword.toCharArray());
        TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
        tmf.init(ts);

        FileInputStream ksf = new FileInputStream(keystorePath);
        KeyStore ks = KeyStore.getInstance("JKS");
        ks.load(ksf, keystorePassword.toCharArray());
        KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
        kmf.init(ks, keystorePassword.toCharArray());

        SSLContext ctx = SSLContext.getInstance("SSL");
        ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), new SecureRandom());
        return ctx;
    }
180944
public static KeyStore load(String path, char[] password) {
        try {
            return load(new FileInputStream(path), password);
        } catch (FileNotFoundException e) {
            throw new TrustManagerLoadFailedException(e);
        }
    }
837600
public synchronized PrivateKey getPrivateKeyForLocalCert(final X509Certificate cert)
	throws CertificateEncodingException, KeyStoreException, UnrecoverableKeyException,
	NoSuchAlgorithmException
	{
		String thumbprint = ThumbprintUtil.getThumbprint(cert);

		return (PrivateKey)_ks.getKey(thumbprint, _keypassword);
	}
370079
public Iterable<DUser> queryByPassword(java.lang.String password) {
    return queryByField(null, DUserMapper.Field.PASSWORD.getFieldName(), password);
  }
161486
public static Certificate getCertificate(KeyStore keyStore, String alias) {
		try {
			return keyStore.getCertificate(alias);
		} catch (Exception e) {
			throw new CryptoException(e);
		}
	}
559030
public static byte[] hashPassword(String password) throws InvalidKeyException, NoSuchAlgorithmException {

        PasswordEncryptor encryptor = new PasswordEncryptor();
        return encryptor.generateEncryptedPassword(password, null, PasswordEncryptor.MD4, null, null);
    }
488861
@Override
	public void engineSetKeyEntry(String s, Key key, char[] chars,
			Certificate[] certificates) throws KeyStoreException {

		if (!(key instanceof PrivateKey)) {
			throw new KeyStoreException("PrivateKey expected");
		}

		if (!(certificates instanceof X509Certificate[])) {
			throw new KeyStoreException(
					"Certificate chain of X509Certificate expected");
		}
		CredentialWrapper wrapper;
		X509Credential credential = new X509Credential((PrivateKey) key,
				(X509Certificate[]) certificates);
		if (credential.isEncryptedKey()) {
			wrapper = createCertKeyCredential(s, credential);
		} else {
			wrapper = createProxyCredential(s, credential);
		}
		storeWrapper(wrapper);
		this.aliasObjectMap.put(wrapper.getAlias(), wrapper);
	}
1003183
public void setKeyManagerFactoryKeyStorePassword(String password) {
        if (password != null) {
            this.keyManagerFactoryKeyStorePassword = password.toCharArray();
        } else {
            this.keyManagerFactoryKeyStorePassword = null;
        }
    }
941391
private static KeyManagerFactory getKeyManagerFactory(InputStream keyStoreStream, StoreProperties storeProperties)
      throws IOException, GeneralSecurityException {
    // use provider if given, otherwise use the first matching security provider
    final KeyStore ks;
    if (StringUtils.isNotBlank(storeProperties.getProvider())) {
      ks = KeyStore.getInstance(storeProperties.getType(), storeProperties.getProvider());
    }
    else {
      ks = KeyStore.getInstance(storeProperties.getType());
    }
    ks.load(keyStoreStream, storeProperties.getPassword().toCharArray());
    KeyManagerFactory kmf = KeyManagerFactory.getInstance(storeProperties.getManagerType());
    kmf.init(ks, storeProperties.getPassword().toCharArray());
    return kmf;
  }
457781
private String keyStorePassword()
  {
    String password = _config.get(_prefix + ".ssl.key-store-password");
    
    if (password != null) {
      return password;
    }
    else {
      return _config.get(_prefix + ".ssl.password");
    }
  }
1093267
public String getPassword(String alias, String passwordPassword) throws NoSuchAlgorithmException, UnrecoverableEntryException, KeyStoreException, InvalidKeySpecException {
		SecretKey sk =  (SecretKey) this.keystore.getKey(alias,passwordPassword.toCharArray());
		return new String(sk.getEncoded());
	}
289363
public void readFrom(File keyFile) throws IOException, GeneralSecurityException {
        final String password = isPemEncrypted(keyFile)
                ? askForPasswd(keyFile.getCanonicalPath())
                : null
        ;
        privateKeys.add(loadKey(keyFile, password));
    }
792003
public EncryptionKey loadKeyUsingPassword(String password) {
        if (password == null || password.equals("")) {
            throw new IllegalArgumentException("password is required to be a non-null/non-empty " +
                    "string");
        }
        KeyData data = this.storage.getEncryptionKeyData();
        if (data == null || !validateEncryptionKeyData(data)) {
            return null;
        }

        EncryptionKey dpk = null;
        SecretKey aesKey = null;
        try {
            aesKey = pbkdf2DerivedKeyForPassword(password, data.getSalt(), data.iterations,
                    ENCRYPTION_KEYCHAIN_AES_KEY_SIZE);
            byte[] dpkBytes = DPKEncryptionUtil.decryptAES(aesKey, data.getIv(), data
                    .getEncryptedDPK());
            dpk = new EncryptionKey(dpkBytes);
        } catch (NoSuchAlgorithmException e) {
            throw new DPKException("Failed to decrypt DPK", e);
        } catch (InvalidKeySpecException e) {
            throw new DPKException("Failed to decrypt DPK", e);
        } catch (IllegalBlockSizeException e) {
            throw new DPKException("Failed to decrypt DPK", e);
        } catch (InvalidKeyException e) {
            throw new DPKException("Failed to decrypt DPK", e);
        } catch (BadPaddingException e) {
            throw new DPKException("Failed to decrypt DPK", e);
        } catch (InvalidAlgorithmParameterException e) {
            throw new DPKException("Failed to decrypt DPK", e);
        } catch (NoSuchPaddingException e) {
            throw new DPKException("Failed to decrypt DPK", e);
        }

        return dpk;
    }