public class OpenPGPMessageProcessor
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
OpenPGPMessageProcessor.Configuration |
static interface |
OpenPGPMessageProcessor.PGPExceptionCallback
Callback to handle
PGPExceptions . |
Constructor and Description |
---|
OpenPGPMessageProcessor()
Create a new
OpenPGPMessageProcessor using the default OpenPGPImplementation . |
OpenPGPMessageProcessor(OpenPGPImplementation implementation)
Create a new
OpenPGPMessageProcessor using the given OpenPGPImplementation . |
OpenPGPMessageProcessor(OpenPGPImplementation implementation,
OpenPGPPolicy policy) |
Modifier and Type | Method and Description |
---|---|
OpenPGPMessageProcessor |
addDecryptionKey(OpenPGPKey key)
Add an
OpenPGPKey as potential decryption key. |
OpenPGPMessageProcessor |
addDecryptionKey(OpenPGPKey key,
char[] passphrase)
Add an
OpenPGPKey as potential decryption key, along with a KeyPassphraseProvider dedicated
to this key. |
OpenPGPMessageProcessor |
addDecryptionKeyPassphrase(char[] passphrase)
Add a passphrase for secret key decryption.
|
OpenPGPMessageProcessor |
addMessagePassphrase(char[] messagePassphrase)
Set a passphrase to decrypt a symmetrically encrypted OpenPGP message.
|
OpenPGPMessageProcessor |
addVerificationCertificate(OpenPGPCertificate issuerCertificate)
Add an
OpenPGPCertificate for signature verification. |
OpenPGPMessageInputStream |
process(java.io.InputStream messageIn)
Process an OpenPGP message.
|
OpenPGPMessageProcessor |
setMissingMessagePassphraseCallback(MissingMessagePassphraseCallback callback)
Set a
MissingMessagePassphraseCallback which will be invoked if the message is encrypted using a passphrase,
but no working passphrase was provided. |
OpenPGPMessageProcessor |
setMissingOpenPGPCertificateProvider(OpenPGPKeyMaterialProvider.OpenPGPCertificateProvider certificateProvider)
Set a
OpenPGPKeyMaterialProvider.OpenPGPCertificateProvider to allow dynamic requesting certificates
for signature verification. |
OpenPGPMessageProcessor |
setMissingOpenPGPKeyPassphraseProvider(KeyPassphraseProvider keyPassphraseProvider)
Set a provider for dynamically requesting missing passphrases used to unlock encrypted
OpenPGPKeys . |
OpenPGPMessageProcessor |
setMissingOpenPGPKeyProvider(OpenPGPKeyMaterialProvider.OpenPGPKeyProvider keyProvider)
Set a provider for
OpenPGPKeys , which can be used to decrypt encrypted messages. |
OpenPGPMessageProcessor |
setSessionKey(PGPSessionKey sessionKey)
Set a
PGPSessionKey with which an encrypted OpenPGP message can be decrypted without the need for
using a private key or passphrase. |
OpenPGPMessageProcessor |
verifyNotAfter(java.util.Date date) |
OpenPGPMessageProcessor |
verifyNotBefore(java.util.Date date) |
public OpenPGPMessageProcessor()
OpenPGPMessageProcessor
using the default OpenPGPImplementation
.public OpenPGPMessageProcessor(OpenPGPImplementation implementation)
OpenPGPMessageProcessor
using the given OpenPGPImplementation
.implementation
- openpgp implementationpublic OpenPGPMessageProcessor(OpenPGPImplementation implementation, OpenPGPPolicy policy)
public OpenPGPMessageProcessor addVerificationCertificate(OpenPGPCertificate issuerCertificate)
OpenPGPCertificate
for signature verification.
If the message contains any signatures, the provided certificate will be considered as a candidate to verify
the signature.issuerCertificate
- OpenPGP certificatepublic OpenPGPMessageProcessor verifyNotAfter(java.util.Date date)
public OpenPGPMessageProcessor verifyNotBefore(java.util.Date date)
public OpenPGPMessageProcessor addDecryptionKey(OpenPGPKey key)
OpenPGPKey
as potential decryption key.
If the message is encrypted for an OpenPGPKey
, 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).key
- OpenPGP keypublic OpenPGPMessageProcessor addDecryptionKey(OpenPGPKey key, char[] passphrase)
OpenPGPKey
as potential decryption key, along with a KeyPassphraseProvider
dedicated
to this key.
If the message is encrypted for an OpenPGPKey
, 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).key
- OpenPGP keypublic OpenPGPMessageProcessor addDecryptionKeyPassphrase(char[] passphrase)
OpenPGPKey
which key this passphrase is for is known in advance,
it is highly advised to call addDecryptionKey(OpenPGPKey, char[])
instead, due to performance reasons.passphrase
- key-passphrasepublic OpenPGPMessageProcessor setMissingOpenPGPKeyPassphraseProvider(KeyPassphraseProvider keyPassphraseProvider)
OpenPGPKeys
.
This provider is called, if a key cannot be unlocked using any passphrase provided via
addDecryptionKey(OpenPGPKey, char[])
.keyPassphraseProvider
- key passphrase providerpublic OpenPGPMessageProcessor setMissingOpenPGPCertificateProvider(OpenPGPKeyMaterialProvider.OpenPGPCertificateProvider certificateProvider)
OpenPGPKeyMaterialProvider.OpenPGPCertificateProvider
to allow dynamic requesting certificates
for signature verification.
This provider is called if the requested OpenPGPCertificate
has not yet been added explicitly
via addVerificationCertificate(OpenPGPCertificate)
.
This allows lazily requesting verification certificates at runtime.certificateProvider
- provider for OpenPGP certificatespublic OpenPGPMessageProcessor setMissingOpenPGPKeyProvider(OpenPGPKeyMaterialProvider.OpenPGPKeyProvider keyProvider)
OpenPGPKeys
, which can be used to decrypt encrypted messages.
This provider is called if an OpenPGPKey
required to decrypt the message has not yet been
explicitly added via addDecryptionKey(OpenPGPKey)
.
This allows lazily requesting decryption keys at runtime.keyProvider
- provider for OpenPGP keyspublic OpenPGPMessageProcessor addMessagePassphrase(char[] messagePassphrase)
messagePassphrase
- passphrase for message decryptionpublic OpenPGPMessageProcessor setMissingMessagePassphraseCallback(MissingMessagePassphraseCallback callback)
MissingMessagePassphraseCallback
which will be invoked if the message is encrypted using a passphrase,
but no working passphrase was provided.callback
- callbackpublic OpenPGPMessageProcessor setSessionKey(PGPSessionKey sessionKey)
PGPSessionKey
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 the PGPSessionKey
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.sessionKey
- session keypublic OpenPGPMessageInputStream process(java.io.InputStream messageIn) throws java.io.IOException, PGPException
messageIn
- input stream of the OpenPGP messagejava.io.IOException
PGPException