diff --git a/src/main/java/org/pgpainless/pgpainless/encryption_signing/EncryptionBuilder.java b/src/main/java/org/pgpainless/pgpainless/encryption_signing/EncryptionBuilder.java index c2e8a4a2..56e7ce6c 100644 --- a/src/main/java/org/pgpainless/pgpainless/encryption_signing/EncryptionBuilder.java +++ b/src/main/java/org/pgpainless/pgpainless/encryption_signing/EncryptionBuilder.java @@ -179,6 +179,19 @@ public class EncryptionBuilder implements EncryptionBuilderInterface { return this; } + @Override + public WithAlgorithms andToSelf(PGPPublicKeyRingCollection keys) { + for (PGPPublicKeyRing ring : keys) { + for (Iterator i = ring.getPublicKeys(); i.hasNext(); ) { + PGPPublicKey key = i.next(); + if (encryptionKeySelector().accept(null, key)) { + EncryptionBuilder.this.encryptionKeys.add(key); + } + } + } + return this; + } + public WithAlgorithms andToSelf(PublicKeyRingSelectionStrategy ringSelectionStrategy, MultiMap keys) { if (keys.isEmpty()) { diff --git a/src/main/java/org/pgpainless/pgpainless/encryption_signing/EncryptionBuilderInterface.java b/src/main/java/org/pgpainless/pgpainless/encryption_signing/EncryptionBuilderInterface.java index c599bfdb..e2e4f703 100644 --- a/src/main/java/org/pgpainless/pgpainless/encryption_signing/EncryptionBuilderInterface.java +++ b/src/main/java/org/pgpainless/pgpainless/encryption_signing/EncryptionBuilderInterface.java @@ -59,6 +59,8 @@ public interface EncryptionBuilderInterface { WithAlgorithms andToSelf(PGPPublicKeyRing... keys); + WithAlgorithms andToSelf(PGPPublicKeyRingCollection keys); + WithAlgorithms andToSelf(PublicKeyRingSelectionStrategy selectionStrategy, MultiMap keys);