@Test public void testExtractingContentFromClearSign() { PGPPublicKey key = null; try { InputStream in = findFile( PLUGIN_PRIVATE_KEY ); in = org.bouncycastle.openpgp.PGPUtil.getDecoderStream( in ); JcaPGPPublicKeyRingCollection pgpPub = new JcaPGPPublicKeyRingCollection( in ); in.close(); Iterator<PGPPublicKeyRing> rIt = pgpPub.getKeyRings(); while ( key == null && rIt.hasNext() ) { PGPPublicKeyRing kRing = rIt.next(); Iterator<PGPPublicKey> kIt = kRing.getPublicKeys(); while ( key == null && kIt.hasNext() ) { PGPPublicKey k = kIt.next(); if ( k.isEncryptionKey() ) { key = k; } } } } catch ( Exception e ) { e.printStackTrace(); } }