public class PdfTwoPhaseSigner extends Object
PadesTwoPhaseSigningHelper for more info).
Firstly, this class allows to prepare the document for signing and calculate the document digest to sign. Secondly, it adds an existing signature to a PDF where space was already reserved.
| Constructor and Description |
|---|
PdfTwoPhaseSigner(PdfReader reader,
OutputStream outputStream)
Creates new
PdfTwoPhaseSigner instance. |
| Modifier and Type | Method and Description |
|---|---|
static void |
addSignatureToPreparedDocument(PdfDocument document,
String fieldName,
OutputStream outs,
byte[] signedContent)
Adds an existing signature to a PDF where space was already reserved.
|
static void |
addSignatureToPreparedDocument(PdfDocument document,
String fieldName,
OutputStream outs,
CMSContainer cmsContainer)
Adds an existing signature to a PDF where space was already reserved.
|
byte[] |
prepareDocumentForSignature(SignerProperties signerProperties,
String digestAlgorithm,
PdfName filter,
PdfName subFilter,
int estimatedSize,
boolean includeDate)
Prepares document for signing, calculates the document digest to sign and closes the document.
|
PdfTwoPhaseSigner |
setExternalDigest(IExternalDigest externalDigest)
Use the external digest to inject specific digest implementations
|
PdfTwoPhaseSigner |
setStampingProperties(StampingProperties stampingProperties)
Set stamping properties to be used during main signing operation.
|
public PdfTwoPhaseSigner(PdfReader reader, OutputStream outputStream)
PdfTwoPhaseSigner instance.reader - PdfReader instance to read the original PDF fileoutputStream - OutputStream output stream to write the resulting PDF file intopublic byte[] prepareDocumentForSignature(SignerProperties signerProperties, String digestAlgorithm, PdfName filter, PdfName subFilter, int estimatedSize, boolean includeDate) throws IOException, GeneralSecurityException
signerProperties - SignerProperties properties to be used for main signing operationdigestAlgorithm - the algorithm to generate the digest withfilter - PdfName of the signature handler to use when validating this signaturesubFilter - PdfName that describes the encoding of the signatureestimatedSize - the estimated size of the signature, this is the size of the space reserved for
the Cryptographic Message ContainerincludeDate - specifies if the signing date should be set to the signature dictionaryIOException - if some I/O problem occurs.GeneralSecurityException - if some problem during apply security algorithms occurs.public static void addSignatureToPreparedDocument(PdfDocument document, String fieldName, OutputStream outs, CMSContainer cmsContainer) throws IOException, GeneralSecurityException
document - the original PDFfieldName - the field to sign. It must be the last fieldouts - the output PDFcmsContainer - the finalized CMS containerIOException - if some I/O problem occurs.GeneralSecurityException - if some problem during apply security algorithms occurs.public static void addSignatureToPreparedDocument(PdfDocument document, String fieldName, OutputStream outs, byte[] signedContent) throws IOException, GeneralSecurityException
document - the original PDFfieldName - the field to sign. It must be the last fieldouts - the output PDFsignedContent - the bytes for the signed dataIOException - if some I/O problem occurs.GeneralSecurityException - if some problem during apply security algorithms occurs.public PdfTwoPhaseSigner setExternalDigest(IExternalDigest externalDigest)
externalDigest - the IExternalDigest instance to use to generate DigestsPdfTwoPhaseSignerpublic PdfTwoPhaseSigner setStampingProperties(StampingProperties stampingProperties)
If none is set, stamping properties with append mode enabled will be used
stampingProperties - StampingProperties instance to be used during main signing operationPdfTwoPhaseSignerCopyright © 1998–2024 Apryse Group NV. All rights reserved.