private PGPSecretKey readSecretKey ( InputStream input ) throws LRException { PGPSecretKeyRingCollection pgpSec ; try { pgpSec = new PGPSecretKeyRingCollection ( PGPUtil . getDecoderStream ( input ) ) ; } catch ( Exception e ) { throw new LRException ( LRException . NO_KEY ) ; } java . util . Iterator keyRingIter = pgpSec . getKeyRings ( ) ; while ( keyRingIter . hasNext ( ) ) { PGPSecretKeyRing keyRing = ( PGPSecretKeyRing ) keyRingIter . next ( ) ; java . util . Iterator keyIter = keyRing . getSecretKeys ( ) ; while ( keyIter . hasNext ( ) ) { PGPSecretKey key = ( PGPSecretKey ) keyIter . next ( ) ; if ( key . isSigningKey ( ) ) { return key ; } } } throw new LRException ( LRException . NO_KEY ) ; }
Reads private key from the provided InputStream