From 626c4b14ebe1a629ec4120a55a3eda7e92faeeab Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Sun, 8 Jul 2018 18:05:55 +0200 Subject: [PATCH] Modify API --- .../encryption_signing/EncryptionBuilder.java | 13 +++++++++++++ .../EncryptionBuilderInterface.java | 2 ++ 2 files changed, 15 insertions(+) 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);