コード例 #1
0
  private PublicKeyRingImpl convert(final PGPPublicKeyRing pgpKeyRing) {
    PublicKeyRingImpl keyRing = new PublicKeyRingImpl();
    keyRing.setPublicKeys(new ArrayList<PublicKeyImpl>());

    Iterator publicKeys = pgpKeyRing.getPublicKeys();
    while (publicKeys.hasNext()) {
      PGPPublicKey pgpPublicKey = (PGPPublicKey) publicKeys.next();
      PublicKeyImpl publicKey = convert(pgpPublicKey);
      keyRing.addPublicKey(publicKey);
    }

    return keyRing;
  }
コード例 #2
0
 public PublicKeyRingImpl readPublicKeyRingFromAsciiArmor(final String keytext) {
   PGPPublicKeyRingCollection publicKeyRingCollection = null;
   try {
     publicKeyRingCollection = readPublicKey(keytext);
   } catch (Exception e) {
     new RuntimeException(e);
   }
   Iterator keyRings = publicKeyRingCollection.getKeyRings();
   if (keyRings.hasNext()) {
     PGPPublicKeyRing pgpPublicKeyRing = (PGPPublicKeyRing) keyRings.next();
     PublicKeyRingImpl publicKeyRing = convert(pgpPublicKeyRing);
     publicKeyRing.setRawData(keytext);
     return publicKeyRing;
   }
   return null;
 }