public class OpenPGPDetachedSignatureProcessor
extends java.lang.Object
To use this class, first instantiate the processor, optionally passing in a concrete
OpenPGPImplementation
and OpenPGPPolicy
.
Then, pass in any detached signatures you want to verify using addSignatures(InputStream)
.
Next, provide the expected issuers OpenPGPCertificates
for signature
verification using addVerificationCertificate(OpenPGPCertificate)
.
Signatures for which no certificate was provided, and certificates for which no signature was added,
are ignored.
Optionally, you can specify a validity date range for the signatures using
verifyNotBefore(Date)
and verifyNotAfter(Date)
.
Signatures outside this range will be ignored as invalid.
Lastly, provide an InputStream
containing the original plaintext data, over which you want to
verify the detached signatures using process(InputStream)
.
As a result you will receive a list containing all processed
OpenPGPDocumentSignatures
.
For these, you can check validity by calling OpenPGPSignature.OpenPGPDocumentSignature.isValid()
.
Constructor and Description |
---|
OpenPGPDetachedSignatureProcessor()
Instantiate a signature processor using the default
OpenPGPImplementation and its OpenPGPPolicy . |
OpenPGPDetachedSignatureProcessor(OpenPGPImplementation implementation)
Instantiate a signature processor using a custom
OpenPGPImplementation and its OpenPGPPolicy . |
OpenPGPDetachedSignatureProcessor(OpenPGPImplementation implementation,
OpenPGPPolicy policy)
Instantiate a signature processor using a custom
OpenPGPImplementation and custom OpenPGPPolicy . |
Modifier and Type | Method and Description |
---|---|
OpenPGPDetachedSignatureProcessor |
addSignature(PGPSignature signature)
Add a single
detached signature to the processor. |
OpenPGPDetachedSignatureProcessor |
addSignatures(java.io.InputStream inputStream)
Read one or more
detached signatures from the provided InputStream and
add them to the processor. |
OpenPGPDetachedSignatureProcessor |
addSignatures(PGPSignatureList signatures)
Add one or more
detached signatures from the given PGPSignatureList to the
processor. |
OpenPGPDetachedSignatureProcessor |
addVerificationCertificate(OpenPGPCertificate certificate)
Add an issuers
OpenPGPCertificate for signature verification. |
java.util.List<OpenPGPSignature.OpenPGPDocumentSignature> |
process(java.io.InputStream inputStream)
Process the plaintext data from the given
InputStream and return a list of processed
detached signatures. |
OpenPGPDetachedSignatureProcessor |
setExceptionCallback(OpenPGPMessageProcessor.PGPExceptionCallback callback)
Add a callback to which any OpenPGP-related exceptions are forwarded.
|
OpenPGPDetachedSignatureProcessor |
verifyNotAfter(java.util.Date date)
Reject detached signatures made after the given date.
|
OpenPGPDetachedSignatureProcessor |
verifyNotBefore(java.util.Date date)
Reject detached signatures made before date.
|
public OpenPGPDetachedSignatureProcessor()
OpenPGPImplementation
and its OpenPGPPolicy
.public OpenPGPDetachedSignatureProcessor(OpenPGPImplementation implementation)
OpenPGPImplementation
and its OpenPGPPolicy
.implementation
- custom OpenPGP implementationpublic OpenPGPDetachedSignatureProcessor(OpenPGPImplementation implementation, OpenPGPPolicy policy)
OpenPGPImplementation
and custom OpenPGPPolicy
.implementation
- custom OpenPGP implementationpolicy
- custom OpenPGP policypublic OpenPGPDetachedSignatureProcessor addSignatures(java.io.InputStream inputStream) throws java.io.IOException
detached signatures
from the provided InputStream
and
add them to the processor.inputStream
- input stream of armored or unarmored detached OpenPGP signaturesjava.io.IOException
- if something goes wrong reading from the streampublic OpenPGPDetachedSignatureProcessor addSignatures(PGPSignatureList signatures)
detached signatures
from the given PGPSignatureList
to the
processor.signatures
- detached signature listpublic OpenPGPDetachedSignatureProcessor addSignature(PGPSignature signature)
detached signature
to the processor.signature
- detached signaturepublic OpenPGPDetachedSignatureProcessor addVerificationCertificate(OpenPGPCertificate certificate)
OpenPGPCertificate
for signature verification.certificate
- OpenPGP certificatepublic OpenPGPDetachedSignatureProcessor verifyNotBefore(java.util.Date date)
date. By default, this value is set to the beginning of time.
date
- datepublic OpenPGPDetachedSignatureProcessor verifyNotAfter(java.util.Date date)
date. By default, this value is set to the current time at instantiation time, in order to prevent verification of signatures from the future.
date
- datepublic java.util.List<OpenPGPSignature.OpenPGPDocumentSignature> process(java.io.InputStream inputStream) throws java.io.IOException
InputStream
and return a list of processed
detached signatures.
Note: This list will NOT contain any malformed signatures, or signatures for which no verification key was found.
Correctness of these signatures can be checked via OpenPGPSignature.OpenPGPDocumentSignature.isValid()
.inputStream
- data over which the detached signatures are calculatedjava.io.IOException
- if the data cannot be processedpublic OpenPGPDetachedSignatureProcessor setExceptionCallback(OpenPGPMessageProcessor.PGPExceptionCallback callback)
callback
- callback