Package org.bouncycastle.openpgp.api
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.DefaultKeyPassphraseProvider
protected final OpenPGPImplementation
protected final OpenPGPPolicy
protected 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 anOpenPGPKey
for 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.Callback
to 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.Callback
to allow modification of the signature contents.addSigningKey
(OpenPGPKey key, KeyPassphraseProvider passphraseProvider) Add anOpenPGPKey
for message signing, using the providedKeyPassphraseProvider
to unlock protected subkeys.addSigningKey
(OpenPGPKey key, KeyPassphraseProvider passphraseProvider, SignatureParameters.Callback signatureCallback) Add anOpenPGPKey
for message signing, using the givenKeyPassphraseProvider
for unlocking protected subkeys and using theSignatureParameters.Callback
to allow modification of the signature contents.addSigningKey
(OpenPGPKey key, SignatureParameters.Callback signatureCallback) Add anOpenPGPKey
for message signing, using theSignatureParameters.Callback
to allow modification of the signature contents.protected void
protected PGPSignatureGenerator
initSignatureGenerator
(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 anOpenPGPKey
for message signing. ThesigningKeySelector
is 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 anOpenPGPKey
for message signing, using the providedKeyPassphraseProvider
to unlock protected subkeys. ThesigningKeySelector
is 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 anOpenPGPKey
for message signing, using theSignatureParameters.Callback
to allow modification of the signature contents. ThesigningKeySelector
is 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 anOpenPGPKey
for message signing, using the givenKeyPassphraseProvider
for unlocking protected subkeys and using theSignatureParameters.Callback
to allow modification of the signature contents. ThesigningKeySelector
is 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.Callback
to 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.Callback
to 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
-