Class ExternalCMSService
java.lang.Object
eu.europa.esig.dss.pades.signature.ExternalCMSService
This service is used to generate a CMSSignedData used for incorporation
within a PDF document for a PAdES signature creation.
To create a CMS with the current class, please follow the algorithm:
1) Compute DTBS using message-digest of the PDF signature's ByteRange:
ToBeSigned toBeSigned = getDataToSign(Digest messageDigest, PAdESSignatureParameters parameters)
;
2) Create signature value using private-key signing:
SignatureValue signatureValue = *sign toBeSigned data*
;
3) Create CMS signature signing the message-digest:
CMSSignedDocument cmsSignature = signMessageDigest(
Digest messageDigest, PAdESSignatureParameters parameters, SignatureValue signatureValue)
;
NOTE : This class does not create CAdES-BASELINE signatures, but CAdES-Extended signatures as per ETSI EN 319 122-2, suitable for a PAdES-BASELINE creation.
-
Constructor Summary
ConstructorDescriptionExternalCMSService
(CertificateVerifier certificateVerifier) This is the default constructor forPAdESCMSGeneratorService
. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
assertConfigurationValid
(DSSMessageDigest messageDigest, PAdESSignatureParameters parameters) This method verifies whether the providedparameters
are valid for the external CMS creation processprotected void
assertSigningCertificateValid
(AbstractSignatureParameters<?> parameters) This method raises an exception if the signing rules forbid the use the certificate.protected org.bouncycastle.cms.CMSSignedData
buildCMSSignedData
(DSSMessageDigest messageDigest, PAdESSignatureParameters parameters, SignatureValue signatureValue) This method builds aCMSSignedData
without executing additional checks on provided configurationprotected ToBeSigned
buildToBeSignedData
(DSSMessageDigest messageDigest, PAdESSignatureParameters parameters) This method builds aCMSSignedData
without executing additional checks on provided configurationgetDataToSign
(DSSMessageDigest messageDigest, PAdESSignatureParameters parameters) This method is used to compute signed-attributes of a CMSSignedData to be used for a private-key signing.void
setTspSource
(TSPSource tspSource) This setter allows to define the TSP (timestamp provider) source for T-level signature creation.signMessageDigest
(DSSMessageDigest messageDigest, PAdESSignatureParameters parameters, SignatureValue signatureValue) This method is used to create a signed CMSSignedData to be used for incorporation within a PDF document for a PAdES signature creation
-
Constructor Details
-
ExternalCMSService
This is the default constructor forPAdESCMSGeneratorService
.- Parameters:
certificateVerifier
-CertificateVerifier
provides information on the sources to be used in the validation process in the context of a signature.
-
-
Method Details
-
setTspSource
This setter allows to define the TSP (timestamp provider) source for T-level signature creation.- Parameters:
tspSource
- The time stamp source which is used when timestamping the signature.
-
getDataToSign
public ToBeSigned getDataToSign(DSSMessageDigest messageDigest, PAdESSignatureParameters parameters) This method is used to compute signed-attributes of a CMSSignedData to be used for a private-key signing.- Parameters:
messageDigest
-DSSMessageDigest
representing message-digest of a ByteRange content prepared for a PDF signature creationparameters
-PAdESSignatureParameters
containing configuration for CMS creation- Returns:
ToBeSigned
representing the data to be cryptographically signed (used to compute SignatureValue)
-
buildToBeSignedData
protected ToBeSigned buildToBeSignedData(DSSMessageDigest messageDigest, PAdESSignatureParameters parameters) This method builds aCMSSignedData
without executing additional checks on provided configuration- Parameters:
messageDigest
-DSSMessageDigest
representing message-digest of a ByteRange content prepared for a PDF signature creationparameters
-PAdESSignatureParameters
- Returns:
CMSSignedData
-
signMessageDigest
public CMSSignedDocument signMessageDigest(DSSMessageDigest messageDigest, PAdESSignatureParameters parameters, SignatureValue signatureValue) This method is used to create a signed CMSSignedData to be used for incorporation within a PDF document for a PAdES signature creation- Parameters:
messageDigest
-DSSMessageDigest
representing digest of a ByteRange content prepared for a PDF signature creationparameters
-PAdESSignatureParameters
containing configuration for CMS creationsignatureValue
-SignatureValue
representing private-key signing of the DTBS- Returns:
CMSSignedDocument
representing a CMS signature suitable for PAdES signature creation
-
buildCMSSignedData
protected org.bouncycastle.cms.CMSSignedData buildCMSSignedData(DSSMessageDigest messageDigest, PAdESSignatureParameters parameters, SignatureValue signatureValue) This method builds aCMSSignedData
without executing additional checks on provided configuration- Parameters:
messageDigest
-DSSMessageDigest
representing digest of PDF ByteRange to be signedparameters
-PAdESSignatureParameters
signatureValue
-SignatureValue
- Returns:
CMSSignedData
-
assertConfigurationValid
protected void assertConfigurationValid(DSSMessageDigest messageDigest, PAdESSignatureParameters parameters) This method verifies whether the providedparameters
are valid for the external CMS creation process- Parameters:
messageDigest
-DSSMessageDigest
representing message-digest computed on PDF signature byte rangeparameters
-PAdESSignatureParameters
to be checked
-
assertSigningCertificateValid
This method raises an exception if the signing rules forbid the use the certificate.- Parameters:
parameters
- set of driving signing parameters
-