本文整理汇总了Java中org.bouncycastle.openpgp.bc.BcPGPSecretKeyRingCollection.getKeyRings方法的典型用法代码示例。如果您正苦于以下问题:Java BcPGPSecretKeyRingCollection.getKeyRings方法的具体用法?Java BcPGPSecretKeyRingCollection.getKeyRings怎么用?Java BcPGPSecretKeyRingCollection.getKeyRings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.openpgp.bc.BcPGPSecretKeyRingCollection
的用法示例。
在下文中一共展示了BcPGPSecretKeyRingCollection.getKeyRings方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadSecretKey
import org.bouncycastle.openpgp.bc.BcPGPSecretKeyRingCollection; //导入方法依赖的package包/类
public static PGPSecretKey loadSecretKey ( final InputStream input, final String keyId ) throws IOException, PGPException
{
final long keyIdNum = Long.parseUnsignedLong ( keyId, 16 );
final BcPGPSecretKeyRingCollection keyrings = new BcPGPSecretKeyRingCollection ( PGPUtil.getDecoderStream ( input ) );
final Iterator<?> keyRingIter = keyrings.getKeyRings ();
while ( keyRingIter.hasNext () )
{
final PGPSecretKeyRing secretKeyRing = (PGPSecretKeyRing)keyRingIter.next ();
final Iterator<?> secretKeyIterator = secretKeyRing.getSecretKeys ();
while ( secretKeyIterator.hasNext () )
{
final PGPSecretKey key = (PGPSecretKey)secretKeyIterator.next ();
if ( !key.isSigningKey () )
{
continue;
}
final long shortId = key.getKeyID () & 0xFFFFFFFFL;
if ( key.getKeyID () != keyIdNum && shortId != keyIdNum )
{
continue;
}
return key;
}
}
return null;
}
示例2: streamKeyring
import org.bouncycastle.openpgp.bc.BcPGPSecretKeyRingCollection; //导入方法依赖的package包/类
public static Stream<PGPKeyRing> streamKeyring ( final InputStream input ) throws IOException, PGPException
{
final BcPGPSecretKeyRingCollection keyrings = new BcPGPSecretKeyRingCollection ( PGPUtil.getDecoderStream ( input ) );
final Iterator<?> keyRingIter = keyrings.getKeyRings ();
final Stream<?> s = StreamSupport.stream ( Spliterators.spliteratorUnknownSize ( keyRingIter, Spliterator.ORDERED ), false );
return s.map ( o -> (PGPKeyRing)o );
}