* @return Key if there is a one , otherwise null
*/
protected Key getKey(String alias, String keyPassword) {
if (alias == null || "".equals(alias)) {
throw new SecureVaultException("The alias need to provided to get certificate", log);
}
if (keyPassword != null) {
try {
return keyStore.getKey(alias, keyPassword.toCharArray());
} catch (KeyStoreException e) {
throw new SecureVaultException("Error loading key for alias : " + alias, e, log);
} catch (NoSuchAlgorithmException e) {
throw new SecureVaultException("Error loading key for alias : " + alias, e, log);
} catch (UnrecoverableKeyException e) {
throw new SecureVaultException("Error loading key for alias : " + alias, e, log);
}
}
return null;
}