1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-12-27 13:28:00 +01:00

Add shortcut SigningOptions.addSignature() method

This commit is contained in:
Paul Schaub 2022-04-04 20:18:15 +02:00
parent d0b070f0f3
commit 0bce68d6ee
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
2 changed files with 16 additions and 1 deletions

View file

@ -98,6 +98,21 @@ public final class SigningOptions {
return new SigningOptions();
}
/**
* Sign the message using an inline signature made by the provided signing key.
*
* @param signingKeyProtector protector to unlock the signing key
* @param signingKey key ring containing the signing key
* @return this
*
* @throws PGPException if the key cannot be unlocked or a signing method cannot be created
*/
public SigningOptions addSignature(SecretKeyRingProtector signingKeyProtector,
PGPSecretKeyRing signingKey)
throws PGPException {
return addInlineSignature(signingKeyProtector, signingKey, DocumentSignatureType.BINARY_DOCUMENT);
}
/**
* Add inline signatures with all secret key rings in the provided secret key ring collection.
*

View file

@ -55,7 +55,7 @@ public class Sign {
EncryptionStream signingStream = PGPainless.encryptAndOrSign()
.onOutputStream(signedOut)
.withOptions(ProducerOptions.sign(SigningOptions.get()
.addInlineSignature(protector, secretKey, DocumentSignatureType.CANONICAL_TEXT_DOCUMENT))
.addSignature(protector, secretKey))
);
Streams.pipeAll(messageIn, signingStream);