private PGPPrivateKey findSecretKey ( PGPSecretKeyRingCollection pgpSec , long keyID , String passPhrase ) throws PGPException { PGPSecretKey pgpSecKey = pgpSec . getSecretKey ( keyID ) ; if ( pgpSecKey == null ) { return null ; } return pgpSecKey . extractPrivateKey ( new JcePBESecretKeyDecryptorBuilder ( ) . setProvider ( BouncyCastleProvider . PROVIDER_NAME ) . build ( passPhrase . toCharArray ( ) ) ) ; }
Private util function that finds the private key from keyring collection based on keyId and passPhrase