Class AbstractOpenPGPDocumentSignatureGenerator<T extends AbstractOpenPGPDocumentSignatureGenerator<T>>
java.lang.Object
org.bouncycastle.openpgp.api.AbstractOpenPGPDocumentSignatureGenerator<T>
- Direct Known Subclasses:
OpenPGPDetachedSignatureGenerator, OpenPGPMessageGenerator
public class AbstractOpenPGPDocumentSignatureGenerator<T extends AbstractOpenPGPDocumentSignatureGenerator<T>>
extends Object
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final KeyPassphraseProvider.DefaultKeyPassphraseProviderprotected final OpenPGPImplementationprotected final OpenPGPPolicyprotected final List<SignatureParameters.Callback> protected final List<PGPSignatureGenerator> protected final List<KeyPassphraseProvider> protected final List<OpenPGPKey.OpenPGPSecretKey> protected SubkeySelector -
Constructor Summary
ConstructorsConstructorDescriptionAbstractOpenPGPDocumentSignatureGenerator(OpenPGPImplementation implementation, OpenPGPPolicy policy) -
Method Summary
Modifier and TypeMethodDescriptionaddKeyPassphrase(char[] passphrase) Add a passphrase for unlocking signing keys to the set of available passphrases.addSigningKey(OpenPGPKey key) Add anOpenPGPKeyfor message signing.addSigningKey(OpenPGPKey.OpenPGPSecretKey signingKey, char[] passphrase, SignatureParameters.Callback signatureCallback) Add the given signing (sub-)key for message signing, using the optional passphrase to unlock the key in case its locked, and using the givenSignatureParameters.Callbackto allow modification of the signature contents.addSigningKey(OpenPGPKey.OpenPGPSecretKey signingKey, KeyPassphraseProvider passphraseProvider, SignatureParameters.Callback signatureCallback) Add the given signing (sub-)key for message signing, using the passphrase provider to unlock the key in case its locked, and using the givenSignatureParameters.Callbackto allow modification of the signature contents.addSigningKey(OpenPGPKey key, KeyPassphraseProvider passphraseProvider) Add anOpenPGPKeyfor message signing, using the providedKeyPassphraseProviderto unlock protected subkeys.addSigningKey(OpenPGPKey key, KeyPassphraseProvider passphraseProvider, SignatureParameters.Callback signatureCallback) Add anOpenPGPKeyfor message signing, using the givenKeyPassphraseProviderfor unlocking protected subkeys and using theSignatureParameters.Callbackto allow modification of the signature contents.addSigningKey(OpenPGPKey key, SignatureParameters.Callback signatureCallback) Add anOpenPGPKeyfor message signing, using theSignatureParameters.Callbackto allow modification of the signature contents.protected voidprotected PGPSignatureGeneratorinitSignatureGenerator(OpenPGPKey.OpenPGPSecretKey signingKey, KeyPassphraseProvider passphraseProvider, SignatureParameters.Callback signatureCallback) Set a callback that will be fired, if a passphrase for a protected signing key is missing.setSigningKeySelector(SubkeySelector signingKeySelector) Replace the default signing key selector with a custom implementation.
-
Field Details
-
implementation
-
policy
-
signatureGenerators
-
signingKeys
-
signatureCallbacks
-
signingKeyPassphraseProviders
-
defaultKeyPassphraseProvider
-
signingKeySelector
-
-
Constructor Details
-
AbstractOpenPGPDocumentSignatureGenerator
public AbstractOpenPGPDocumentSignatureGenerator(OpenPGPImplementation implementation, OpenPGPPolicy policy)
-
-
Method Details
-
setSigningKeySelector
Replace the default signing key selector with a custom implementation. The signing key selector is responsible for selecting one or more signing subkeys from a signing key.- Parameters:
signingKeySelector- selector for signing (sub-)keys- Returns:
- this
-
addKeyPassphrase
Add a passphrase for unlocking signing keys to the set of available passphrases.- Parameters:
passphrase- passphrase- Returns:
- this
-
addSigningKey
Add anOpenPGPKeyfor message signing. ThesigningKeySelectoris responsible for selecting one or more subkeys of the key to sign with. If no (sub-)key in the signing key is capable of creating signatures, or if the key is expired or revoked, this method will throw anInvalidSigningKeyException.- Parameters:
key- OpenPGP key- Returns:
- this
- Throws:
InvalidSigningKeyException- if the key is not capable of signing
-
addSigningKey
public T addSigningKey(OpenPGPKey key, KeyPassphraseProvider passphraseProvider) throws InvalidSigningKeyException Add anOpenPGPKeyfor message signing, using the providedKeyPassphraseProviderto unlock protected subkeys. ThesigningKeySelectoris responsible for selecting one or more subkeys of the key to sign with. If no (sub-)key in the signing key is capable of creating signatures, or if the key is expired or revoked, this method will throw anInvalidSigningKeyException.- Parameters:
key- OpenPGP keypassphraseProvider- provides the passphrase to unlock the signing key- Returns:
- this
- Throws:
InvalidSigningKeyException- if the OpenPGP key does not contain a usable signing subkey
-
addSigningKey
public T addSigningKey(OpenPGPKey key, SignatureParameters.Callback signatureCallback) throws InvalidSigningKeyException Add anOpenPGPKeyfor message signing, using theSignatureParameters.Callbackto allow modification of the signature contents. ThesigningKeySelectoris responsible for selecting one or more subkeys of the key to sign with. If no (sub-)key in the signing key is capable of creating signatures, or if the key is expired or revoked, this method will throw anInvalidSigningKeyException.- Parameters:
key- OpenPGP keysignatureCallback- optional callback to modify the signature contents with- Returns:
- this
- Throws:
InvalidSigningKeyException- if the OpenPGP key does not contain a usable signing subkey
-
addSigningKey
public T addSigningKey(OpenPGPKey key, KeyPassphraseProvider passphraseProvider, SignatureParameters.Callback signatureCallback) throws InvalidSigningKeyException Add anOpenPGPKeyfor message signing, using the givenKeyPassphraseProviderfor unlocking protected subkeys and using theSignatureParameters.Callbackto allow modification of the signature contents. ThesigningKeySelectoris responsible for selecting one or more subkeys of the key to sign with. If no (sub-)key in the signing key is capable of creating signatures, or if the key is expired or revoked, this method will throw anInvalidSigningKeyException.- Parameters:
key- OpenPGP keypassphraseProvider- key passphrase providersignatureCallback- optional callback to modify the signature contents with- Returns:
- this
- Throws:
InvalidSigningKeyException- if the OpenPGP key does not contain a usable signing subkey
-
addSigningKey
public T addSigningKey(OpenPGPKey.OpenPGPSecretKey signingKey, char[] passphrase, SignatureParameters.Callback signatureCallback) throws InvalidSigningKeyException Add the given signing (sub-)key for message signing, using the optional passphrase to unlock the key in case its locked, and using the givenSignatureParameters.Callbackto allow modification of the signature contents.- Parameters:
signingKey- signing (sub-)keypassphrase- optional subkey passphrasesignatureCallback- optional callback to modify the signature contents- Returns:
- this
- Throws:
InvalidSigningKeyException- if the subkey is not signing-capable
-
addSigningKey
public T addSigningKey(OpenPGPKey.OpenPGPSecretKey signingKey, KeyPassphraseProvider passphraseProvider, SignatureParameters.Callback signatureCallback) throws InvalidSigningKeyException Add the given signing (sub-)key for message signing, using the passphrase provider to unlock the key in case its locked, and using the givenSignatureParameters.Callbackto allow modification of the signature contents.- Parameters:
signingKey- signing (sub-)keypassphraseProvider- passphrase provider for unlocking the subkeysignatureCallback- optional callback to modify the signature contents- Returns:
- this
- Throws:
InvalidSigningKeyException- if the subkey is not signing-capable
-
initSignatureGenerator
protected PGPSignatureGenerator initSignatureGenerator(OpenPGPKey.OpenPGPSecretKey signingKey, KeyPassphraseProvider passphraseProvider, SignatureParameters.Callback signatureCallback) throws PGPException - Throws:
PGPException
-
setMissingKeyPassphraseCallback
Set a callback that will be fired, if a passphrase for a protected signing key is missing. This can be used for example to implement interactive on-demand passphrase prompting.- Parameters:
callback- passphrase provider- Returns:
- builder
-
addSignToGenerator
- Throws:
PGPException
-