Class PAdESWithExternalCMSService
- All Implemented Interfaces:
Serializable
To create a signature with the current class, please follow the algorithm:
1) Create a message-digest computed on PDF ByteRange:
Digest messageDigest = getMessageDigest(DSSDocument toSignDocument, PAdESSignatureParameters parameters);
2) Create CMS signature signing the message-digest (e.g. using a remote-signing solution):
DSSDocument cmsDocument = *create CMS using message-digest*;
3) OPTIONAL : verify validity of the obtained CMS signature using the methods:
- isValidCMSSignedData(Digest messageDigest, DSSDocument cms) -
to check cryptographical validity of the signature;
- isValidPAdESBaselineCMSSignedData(Digest messageDigest, DSSDocument cms) -
to check CMS applicability rules for a PAdES signature creation;
4) Create PAdES signature by incorporating obtained CMS signature to a PDF document:
DSSDocument signedDocument =
signDocument(DSSDocument toSignDocument, PAdESSignatureParameters parameters, DSSDocument cmsDocument).
NOTES:
- Unlike configuration in PAdESService an instance of PAdESSignatureParameters in this class
does not need to have signingCertificate and certificateChain defined when using external signing.
- Signature extension to -T level with the current class will never lead to a signature-timestamp
incorporated within CMS Signed Data. It always creates a new revision with a document timestamp.
- Content timestamp is not supported by this service.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor to instantiate PAdESExternalCMSSignatureService -
Method Summary
Modifier and TypeMethodDescriptionprotected StringgetFinalDocumentName(DSSDocument originalFile, SignatureLevel level) Generates and returns a final name for the document to be createdgetMessageDigest(DSSDocument toSignDocument, PAdESSignatureParameters parameters) This method computes message-digest of the signature ByteRange to be used for CMS Signed Data creationprotected PAdESServiceThis method creates an instance of aPAdESServiceto be used for signature extensionprotected PDFSignatureServiceThis method is used to return a newPDFSignatureServicefor a signature creationbooleanisValidCMSSignedData(DSSMessageDigest messageDigest, DSSDocument cms) This method verifies if thecmsis cryptographically validbooleanisValidPAdESBaselineCMSSignedData(DSSMessageDigest messageDigest, DSSDocument cms) This method verifies if the givencmssignature is compliant for PAdES formatvoidsetCertificateVerifier(CertificateVerifier certificateVerifier) This setter allows to define the CertificateVerifier.voidsetPdfObjFactory(IPdfObjFactory pdfObjFactory) Set the IPdfObjFactory.voidsetTspSource(TSPSource tspSource) This setter allows to define the TSP (timestamp provider) source.signDocument(DSSDocument toSignDocument, PAdESSignatureParameters parameters, DSSDocument cmsDocument) This method embeds the provided externalcmsDocumentto a {code toSignDocument} within a new signature revision.
-
Constructor Details
-
PAdESWithExternalCMSService
public PAdESWithExternalCMSService()Default constructor to instantiate PAdESExternalCMSSignatureService
-
-
Method Details
-
setCertificateVerifier
This setter allows to define the CertificateVerifier. Used for signature extension and on CMS creation method. Not required for B-level remote-signing solutions.- Parameters:
certificateVerifier-CertificateVerifierused to verify the certificate chain
-
setTspSource
This setter allows to define the TSP (timestamp provider) source.- Parameters:
tspSource- The time stamp source which is used when timestamping the signature.
-
setPdfObjFactory
Set the IPdfObjFactory. Allow to set the used implementation. Cannot be null.- Parameters:
pdfObjFactory- the implementation to be used.
-
getMessageDigest
public DSSMessageDigest getMessageDigest(DSSDocument toSignDocument, PAdESSignatureParameters parameters) This method computes message-digest of the signature ByteRange to be used for CMS Signed Data creation- Parameters:
toSignDocument-DSSDocumentrepresented by a PDF document to be signedparameters-PAdESSignatureParametersfor signature configuration- Returns:
DSSMessageDigestof the PDF signature ByteRange to be signed
-
signDocument
public DSSDocument signDocument(DSSDocument toSignDocument, PAdESSignatureParameters parameters, DSSDocument cmsDocument) This method embeds the provided externalcmsDocumentto a {code toSignDocument} within a new signature revision.- Parameters:
toSignDocument-DSSDocumentrepresented by a PDF document to be signedparameters-PAdESSignatureParametersfor signature configurationcmsDocument-DSSDocumentrepresenting an external CMS Signed Data (e.g.CMSSignedDocumentorInMemoryDocument)- Returns:
DSSDocumentrepresenting a signed PDF document
-
getPAdESSignatureService
This method is used to return a newPDFSignatureServicefor a signature creation- Returns:
PDFSignatureService
-
getPAdESService
This method creates an instance of aPAdESServiceto be used for signature extension- Returns:
PAdESService
-
getFinalDocumentName
Generates and returns a final name for the document to be created- Parameters:
originalFile-DSSDocumentoriginal signed/extended documentlevel-SignatureLevelthe final signature level- Returns:
Stringthe document filename
-
isValidCMSSignedData
This method verifies if thecmsis cryptographically valid- Parameters:
messageDigest-DSSMessageDigestcomputed on PDF's signature ByteRangecms-DSSDocumentrepresenting an external CMSSignedData- Returns:
- TRUE if the given CMSSignedData is valid, FALSE otherwise
-
isValidPAdESBaselineCMSSignedData
This method verifies if the givencmssignature is compliant for PAdES format- Parameters:
messageDigest-DSSMessageDigestcomputed on PDF's signature ByteRangecms-DSSDocumentto be verified- Returns:
- TRUE if the CMS is compliant to PAdES specification, FALSE otherwise
-