Package org.bouncycastle.openpgp.api
Class OpenPGPMessageProcessor
java.lang.Object
org.bouncycastle.openpgp.api.OpenPGPMessageProcessor
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionCreate a newOpenPGPMessageProcessor
using the defaultOpenPGPImplementation
.OpenPGPMessageProcessor
(OpenPGPImplementation implementation) Create a newOpenPGPMessageProcessor
using the givenOpenPGPImplementation
.OpenPGPMessageProcessor
(OpenPGPImplementation implementation, OpenPGPPolicy policy) -
Method Summary
Modifier and TypeMethodDescriptionAdd anOpenPGPKey
as potential decryption key.addDecryptionKey
(OpenPGPKey key, char[] passphrase) Add anOpenPGPKey
as potential decryption key, along with aKeyPassphraseProvider
dedicated 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 anOpenPGPCertificate
for signature verification.process
(InputStream messageIn) Process an OpenPGP message.Set aMissingMessagePassphraseCallback
which will be invoked if the message is encrypted using a passphrase, but no working passphrase was provided.setMissingOpenPGPCertificateProvider
(OpenPGPKeyMaterialProvider.OpenPGPCertificateProvider certificateProvider) Set aOpenPGPKeyMaterialProvider.OpenPGPCertificateProvider
to 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 aPGPSessionKey
with 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 newOpenPGPMessageProcessor
using the defaultOpenPGPImplementation
. -
OpenPGPMessageProcessor
Create a newOpenPGPMessageProcessor
using the givenOpenPGPImplementation
.- Parameters:
implementation
- openpgp implementation
-
OpenPGPMessageProcessor
-
-
Method Details
-
addVerificationCertificate
Add anOpenPGPCertificate
for 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 anOpenPGPKey
as 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 anOpenPGPKey
as potential decryption key, along with aKeyPassphraseProvider
dedicated 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 correspondingOpenPGPKey
which 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.OpenPGPCertificateProvider
to allow dynamic requesting certificates for signature verification. This provider is called if the requestedOpenPGPCertificate
has 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 anOpenPGPKey
required 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 aMissingMessagePassphraseCallback
which will be invoked if the message is encrypted using a passphrase, but no working passphrase was provided.- Parameters:
callback
- callback- Returns:
- this
-
setSessionKey
Set aPGPSessionKey
with 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 thePGPSessionKey
of 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:
IOException
PGPException
-