private PGPSecretKey getSecretKey ( InputStream input , String keyId ) throws IOException , PGPException { PGPSecretKeyRingCollection keyrings = new PGPSecretKeyRingCollection ( PGPUtil . getDecoderStream ( input ) , new JcaKeyFingerprintCalculator ( ) ) ; Iterator rIt = keyrings . getKeyRings ( ) ; while ( rIt . hasNext ( ) ) { PGPSecretKeyRing kRing = ( PGPSecretKeyRing ) rIt . next ( ) ; Iterator kIt = kRing . getSecretKeys ( ) ; while ( kIt . hasNext ( ) ) { PGPSecretKey key = ( PGPSecretKey ) kIt . next ( ) ; if ( key . isSigningKey ( ) && String . format ( "%08x" , key . getKeyID ( ) & 0xFFFFFFFF L ) . equals ( keyId . toLowerCase ( ) ) ) { return key ; } } } return null ; }
Returns the secret key matching the specified identifier .