Add EncryptionOptions.addRecipients(PGPPublicKeyRingCollection)

This commit is contained in:
Paul Schaub 2021-05-27 13:47:24 +02:00
parent e67854310d
commit 8e6abe5d02
Signed by: vanitasvitae
GPG Key ID: 62BEE9264BF17311
1 changed files with 14 additions and 0 deletions

View File

@ -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.).