From 8e6abe5d025bef0e8b7115d85b7e76fb3cdce6ca Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Thu, 27 May 2021 13:47:24 +0200 Subject: [PATCH] Add EncryptionOptions.addRecipients(PGPPublicKeyRingCollection) --- .../encryption_signing/EncryptionOptions.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pgpainless-core/src/main/java/org/pgpainless/encryption_signing/EncryptionOptions.java b/pgpainless-core/src/main/java/org/pgpainless/encryption_signing/EncryptionOptions.java index 9075aaef..ab91b99e 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/encryption_signing/EncryptionOptions.java +++ b/pgpainless-core/src/main/java/org/pgpainless/encryption_signing/EncryptionOptions.java @@ -26,6 +26,7 @@ import java.util.Set; import org.bouncycastle.openpgp.PGPPublicKey; import org.bouncycastle.openpgp.PGPPublicKeyRing; +import org.bouncycastle.openpgp.PGPPublicKeyRingCollection; import org.bouncycastle.openpgp.operator.PBEKeyEncryptionMethodGenerator; import org.bouncycastle.openpgp.operator.PGPKeyEncryptionMethodGenerator; import org.pgpainless.algorithm.SymmetricKeyAlgorithm; @@ -104,6 +105,19 @@ public class EncryptionOptions { return new EncryptionOptions(EncryptionStream.Purpose.STORAGE); } + /** + * Add all key rings in the provided key ring collection as recipients. + * + * @param keys keys + * @return this + */ + public EncryptionOptions addRecipients(PGPPublicKeyRingCollection keys) { + for (PGPPublicKeyRing key : keys) { + addRecipient(key); + } + return this; + } + /** * Add a recipient by providing a key and recipient user-id. * The user-id is used to determine the recipients preferences (algorithms etc.).