use of com.adaptris.security.exc.KeystoreException in project interlok by adaptris.
the class CompositeKeystore method getPrivateKey.
/**
* @see KeystoreProxy#getPrivateKey(String, char[])
*/
public PrivateKey getPrivateKey(String alias, char[] password) throws AdaptrisSecurityException {
PrivateKey pk = null;
if (aliasCache == null) {
load();
}
if (!containsAlias(alias)) {
return null;
}
String lca = alias.toLowerCase();
AliasListEntry kk = aliasCache.get(lca);
if (kk != null) {
if (password == null) {
logR.trace("No private key password passed as parameter, " + "using keystore password as key password");
}
try {
char[] pw = password == null ? kk.getLocation().getKeystorePassword() : password;
pk = kk.getProxy().getPrivateKey(lca, pw);
} catch (Exception e) {
if (AdaptrisSecurityException.class.isAssignableFrom(e.getClass())) {
throw (AdaptrisSecurityException) e;
} else {
throw new KeystoreException(e);
}
}
}
return pk;
}
Aggregations