Package org.bouncycastle.openpgp.api
Class OpenPGPMessageProcessor
java.lang.Object
org.bouncycastle.openpgp.api.OpenPGPMessageProcessor
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionCreate a newOpenPGPMessageProcessorusing the defaultOpenPGPImplementation.OpenPGPMessageProcessor(OpenPGPImplementation implementation) Create a newOpenPGPMessageProcessorusing the givenOpenPGPImplementation.OpenPGPMessageProcessor(OpenPGPImplementation implementation, OpenPGPPolicy policy) -
Method Summary
Modifier and TypeMethodDescriptionAdd anOpenPGPKeyas potential decryption key.addDecryptionKey(OpenPGPKey key, char[] passphrase) Add anOpenPGPKeyas potential decryption key, along with aKeyPassphraseProviderdedicated to this key.addDecryptionKeyPassphrase(char[] passphrase) Add a passphrase for secret key decryption.addMessagePassphrase(char[] messagePassphrase) Set a passphrase to decrypt a symmetrically encrypted OpenPGP message.addVerificationCertificate(OpenPGPCertificate issuerCertificate) Add anOpenPGPCertificatefor signature verification.process(InputStream messageIn) Process an OpenPGP message.Set aMissingMessagePassphraseCallbackwhich will be invoked if the message is encrypted using a passphrase, but no working passphrase was provided.setMissingOpenPGPCertificateProvider(OpenPGPKeyMaterialProvider.OpenPGPCertificateProvider certificateProvider) Set aOpenPGPKeyMaterialProvider.OpenPGPCertificateProviderto allow dynamic requesting certificates for signature verification.setMissingOpenPGPKeyPassphraseProvider(KeyPassphraseProvider keyPassphraseProvider) Set a provider for dynamically requesting missing passphrases used to unlock encryptedOpenPGPKeys.Set a provider forOpenPGPKeys, which can be used to decrypt encrypted messages.setSessionKey(PGPSessionKey sessionKey) Set aPGPSessionKeywith which an encrypted OpenPGP message can be decrypted without the need for using a private key or passphrase.verifyNotAfter(Date date) verifyNotBefore(Date date)
-
Constructor Details
-
OpenPGPMessageProcessor
public OpenPGPMessageProcessor()Create a newOpenPGPMessageProcessorusing the defaultOpenPGPImplementation. -
OpenPGPMessageProcessor
Create a newOpenPGPMessageProcessorusing the givenOpenPGPImplementation.- Parameters:
implementation- openpgp implementation
-
OpenPGPMessageProcessor
-
-
Method Details
-
addVerificationCertificate
Add anOpenPGPCertificatefor signature verification. If the message contains any signatures, the provided certificate will be considered as a candidate to verify the signature.- Parameters:
issuerCertificate- OpenPGP certificate- Returns:
- this
-
verifyNotAfter
-
verifyNotBefore
-
addDecryptionKey
Add anOpenPGPKeyas potential decryption key. If the message is encrypted for anOpenPGPKey, this key can be tried to decrypt the message. Keys added via this method will also be available for message decryption if the message was encrypted to an anonymous recipient (wildcard key-id / fingerprint).- Parameters:
key- OpenPGP key- Returns:
- this
-
addDecryptionKey
Add anOpenPGPKeyas potential decryption key, along with aKeyPassphraseProviderdedicated to this key. If the message is encrypted for anOpenPGPKey, this key can be tried to decrypt the message. Keys added via this method will also be available for message decryption if the message was encrypted to an anonymous recipient (wildcard key-id / fingerprint).- Parameters:
key- OpenPGP key- Returns:
- this
-
addDecryptionKeyPassphrase
Add a passphrase for secret key decryption. If the correspondingOpenPGPKeywhich key this passphrase is for is known in advance, it is highly advised to calladdDecryptionKey(OpenPGPKey, char[])instead, due to performance reasons.- Parameters:
passphrase- key-passphrase- Returns:
- this
-
setMissingOpenPGPKeyPassphraseProvider
public OpenPGPMessageProcessor setMissingOpenPGPKeyPassphraseProvider(KeyPassphraseProvider keyPassphraseProvider) Set a provider for dynamically requesting missing passphrases used to unlock encryptedOpenPGPKeys. This provider is called, if a key cannot be unlocked using any passphrase provided viaaddDecryptionKey(OpenPGPKey, char[]).- Parameters:
keyPassphraseProvider- key passphrase provider- Returns:
- this
-
setMissingOpenPGPCertificateProvider
public OpenPGPMessageProcessor setMissingOpenPGPCertificateProvider(OpenPGPKeyMaterialProvider.OpenPGPCertificateProvider certificateProvider) Set aOpenPGPKeyMaterialProvider.OpenPGPCertificateProviderto allow dynamic requesting certificates for signature verification. This provider is called if the requestedOpenPGPCertificatehas not yet been added explicitly viaaddVerificationCertificate(OpenPGPCertificate). This allows lazily requesting verification certificates at runtime.- Parameters:
certificateProvider- provider for OpenPGP certificates- Returns:
- this
-
setMissingOpenPGPKeyProvider
public OpenPGPMessageProcessor setMissingOpenPGPKeyProvider(OpenPGPKeyMaterialProvider.OpenPGPKeyProvider keyProvider) Set a provider forOpenPGPKeys, which can be used to decrypt encrypted messages. This provider is called if anOpenPGPKeyrequired to decrypt the message has not yet been explicitly added viaaddDecryptionKey(OpenPGPKey). This allows lazily requesting decryption keys at runtime.- Parameters:
keyProvider- provider for OpenPGP keys- Returns:
- this
-
addMessagePassphrase
Set a passphrase to decrypt a symmetrically encrypted OpenPGP message.- Parameters:
messagePassphrase- passphrase for message decryption- Returns:
- this
-
setMissingMessagePassphraseCallback
public OpenPGPMessageProcessor setMissingMessagePassphraseCallback(MissingMessagePassphraseCallback callback) Set aMissingMessagePassphraseCallbackwhich will be invoked if the message is encrypted using a passphrase, but no working passphrase was provided.- Parameters:
callback- callback- Returns:
- this
-
setSessionKey
Set aPGPSessionKeywith which an encrypted OpenPGP message can be decrypted without the need for using a private key or passphrase. Typically, this method can be used, if thePGPSessionKeyof a message is already known (e.g. because the message has already been decrypted before). The benefit of this is, that public-key operations can be costly.- Parameters:
sessionKey- session key- Returns:
- this
-
process
Process an OpenPGP message.- Parameters:
messageIn- input stream of the OpenPGP message- Returns:
- plaintext input stream
- Throws:
IOExceptionPGPException
-