public Key engineGetKey(String alias,char[] password) throws NoSuchAlgorithmException, UnrecoverableKeyException {
  Key key=null;
  Object entry=entries.get(alias.toLowerCase(Locale.ENGLISH));
  if (!((entry instanceof PrivateKeyEntry) || (entry instanceof SecretKeyEntry))) {
    return null;
  }
  KeyProtector keyProtector=new KeyProtector(password);
  if (entry instanceof PrivateKeyEntry) {
    byte[] encrBytes=((PrivateKeyEntry)entry).protectedKey;
    EncryptedPrivateKeyInfo encrInfo;
    try {
      encrInfo=new EncryptedPrivateKeyInfo(encrBytes);
    }
 catch (    IOException ioe) {
      throw new UnrecoverableKeyException("Private key not stored " + "as PKCS #8 " + "EncryptedPrivateKeyInfo");
    }
    key=keyProtector.recover(encrInfo);
  }
 else {
    key=keyProtector.unseal(((SecretKeyEntry)entry).sealedKey);
  }
  return key;
}

public Key engineGetKey ( String alias , char [ ] password ) throws NoSuchAlgorithmException , UnrecoverableKeyException { Key key = null ; Object entry = entries . get ( alias . toLowerCase ( Locale . ENGLISH ) ) ; if ( ! ( ( entry instanceof PrivateKeyEntry ) || ( entry instanceof SecretKeyEntry ) ) ) { return null ; } KeyProtector keyProtector = new KeyProtector ( password ) ; if ( entry instanceof PrivateKeyEntry ) { byte [ ] encrBytes = ( ( PrivateKeyEntry ) entry ) . protectedKey ; EncryptedPrivateKeyInfo encrInfo ; try { encrInfo = new EncryptedPrivateKeyInfo ( encrBytes ) ; } catch ( IOException ioe ) { throw new UnrecoverableKeyException ( "Private key not stored " + "as PKCS #8 " + "EncryptedPrivateKeyInfo" ) ; } key = keyProtector . recover ( encrInfo ) ; } else { key = keyProtector . unseal ( ( ( SecretKeyEntry ) entry ) . sealedKey ) ; } return key ; }
returns the key associated with the given alias , using the given password to recover it .
