Java 类org.bouncycastle.openpgp.jcajce.JcaPGPPublicKeyRingCollection 实例源码

项目:base    文件:PGPEncryptionUtilTest.java   
@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();
    }
}