1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-23 04:42:06 +01:00

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

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