Class JAdESService
java.lang.Object
eu.europa.esig.dss.signature.AbstractSignatureService<JAdESSignatureParameters,JAdESTimestampParameters>
eu.europa.esig.dss.jades.signature.JAdESService
- All Implemented Interfaces:
CounterSignatureService<JAdESCounterSignatureParameters>,DocumentSignatureService<JAdESSignatureParameters,,JAdESTimestampParameters> MultipleDocumentsSignatureService<JAdESSignatureParameters,,JAdESTimestampParameters> Serializable
public class JAdESService
extends AbstractSignatureService<JAdESSignatureParameters,JAdESTimestampParameters>
implements MultipleDocumentsSignatureService<JAdESSignatureParameters,JAdESTimestampParameters>, CounterSignatureService<JAdESCounterSignatureParameters>
Contains methods for JAdES signature creation/extension
- See Also:
-
Field Summary
Fields inherited from class eu.europa.esig.dss.signature.AbstractSignatureService
certificateVerifier, tspSource -
Constructor Summary
ConstructorsConstructorDescriptionJAdESService(CertificateVerifier certificateVerifier) This is the constructor to create an instance of theJAdESService. -
Method Summary
Modifier and TypeMethodDescriptionaddSignaturePolicyStore(DSSDocument document, SignaturePolicyStore signaturePolicyStore) Incorporates a Signature Policy Store as a base64Url-encoded unsigned property into the JAdES SignatureaddSignaturePolicyStore(DSSDocument document, SignaturePolicyStore signaturePolicyStore, boolean base64UrlInstance) Incorporates a Signature Policy Store as an unsigned property into the JAdES Signatureprotected voidassertSigningCertificateValid(AbstractSignatureParameters<?> parameters) This method raises an exception if the signing rules forbid the use the certificate.counterSignSignature(DSSDocument signatureDocument, JAdESCounterSignatureParameters parameters, SignatureValue signatureValue) Counter signs thesignatureDocumentwith the provided signatureValue.extendDocument(DSSDocument toExtendDocument, JAdESSignatureParameters parameters) Extends the level of the signatures in thetoExtendDocumentgetContentTimestamp(DSSDocument toSignDocument, JAdESSignatureParameters parameters) This method allows to compute a content-timestamp (which is added in the signed properties)getContentTimestamp(List<DSSDocument> toSignDocuments, JAdESSignatureParameters parameters) This methods allows to create a TimestampToken for a detached JAdES (with a 'sigD' parameter).getDataToBeCounterSigned(DSSDocument signatureDocument, JAdESCounterSignatureParameters parameters) Retrieves the bytes of the data that need to be counter signed fromsignatureDocument.getDataToSign(DSSDocument toSignDocument, JAdESSignatureParameters parameters) Retrieves the bytes of the data that need to be signed based on thetoSignDocumentandparameters.getDataToSign(List<DSSDocument> toSignDocuments, JAdESSignatureParameters parameters) Retrieves the bytes of the data that need to be signed based on thetoSignDocumentsandparameters.protected JAdESBuildergetJAdESBuilder(JAdESSignatureParameters parameters, List<DSSDocument> documentsToSign) Returns the JAdESBuilder to be usedbooleanisValidSignatureValue(ToBeSigned toBeSigned, SignatureValue signatureValue, CertificateToken signingCertificate) Verifies the signature value against aToBeSignedand aCertificateTokensignDocument(DSSDocument toSignDocument, JAdESSignatureParameters parameters, SignatureValue signatureValue) Signs the toSignDocument with the provided signatureValue.signDocument(List<DSSDocument> toSignDocuments, JAdESSignatureParameters parameters, SignatureValue signatureValue) Signs the toSignDocuments with the provided signatureValue.timestamp(List<DSSDocument> toTimestampDocuments, JAdESTimestampParameters parameters) Timestamps the toSignDocuments with the provided signatureValue.Methods inherited from class eu.europa.esig.dss.signature.AbstractSignatureService
ensureSignatureValue, getFinalDocumentName, getFinalDocumentName, getFinalFileName, getFinalFileName, getFinalFileName, setTspSource, timestamp
-
Constructor Details
-
JAdESService
This is the constructor to create an instance of theJAdESService. A certificate verifier must be provided.- Parameters:
certificateVerifier-CertificateVerifierprovides information on the sources to be used in the validation process in the context of a signature.
-
-
Method Details
-
getContentTimestamp
public TimestampToken getContentTimestamp(DSSDocument toSignDocument, JAdESSignatureParameters parameters) Description copied from interface:DocumentSignatureServiceThis method allows to compute a content-timestamp (which is added in the signed properties)- Specified by:
getContentTimestampin interfaceDocumentSignatureService<JAdESSignatureParameters,JAdESTimestampParameters> - Parameters:
toSignDocument- document to sign or the already existing signatureparameters- set of the driving signing parameters- Returns:
- a timestamp token
-
getContentTimestamp
public TimestampToken getContentTimestamp(List<DSSDocument> toSignDocuments, JAdESSignatureParameters parameters) This methods allows to create a TimestampToken for a detached JAdES (with a 'sigD' parameter). NOTE: The toSignDocuments must be present in the same order they will be passed to signature computation process- Specified by:
getContentTimestampin interfaceMultipleDocumentsSignatureService<JAdESSignatureParameters,JAdESTimestampParameters> - Parameters:
toSignDocuments- a list ofDSSDocuments to be timestampedparameters-JAdESSignatureParameters- Returns:
- content
TimestampToken
-
getDataToSign
Description copied from interface:DocumentSignatureServiceRetrieves the bytes of the data that need to be signed based on thetoSignDocumentandparameters. WhentoSignDocumentcontains an already existing signature the returned bytes are related to a new parallel signature. - Enveloped signature (XML): a new signature is added and the signed data corresponds to that pointed by the first signature; - Enveloping signature: - - XML: The parallel signature is not possible - - CMS: A new parallel signature is added - Detached signature: - - XML: The parallel signature is added - - CMS: A new parallel signature is added- Specified by:
getDataToSignin interfaceDocumentSignatureService<JAdESSignatureParameters,JAdESTimestampParameters> - Parameters:
toSignDocument- document to sign or the already existing signatureparameters- set of the driving signing parameters- Returns:
- the data to be signed
-
getDataToSign
public ToBeSigned getDataToSign(List<DSSDocument> toSignDocuments, JAdESSignatureParameters parameters) Description copied from interface:MultipleDocumentsSignatureServiceRetrieves the bytes of the data that need to be signed based on thetoSignDocumentsandparameters. WhentoSignDocumentscontains an already existing signature the returned bytes are related to a new parallel signature.- Specified by:
getDataToSignin interfaceMultipleDocumentsSignatureService<JAdESSignatureParameters,JAdESTimestampParameters> - Parameters:
toSignDocuments- list of documents to signparameters- set of the driving signing parameters- Returns:
- the data to be signed
-
signDocument
public DSSDocument signDocument(DSSDocument toSignDocument, JAdESSignatureParameters parameters, SignatureValue signatureValue) Description copied from interface:DocumentSignatureServiceSigns the toSignDocument with the provided signatureValue.- Specified by:
signDocumentin interfaceDocumentSignatureService<JAdESSignatureParameters,JAdESTimestampParameters> - Parameters:
toSignDocument- document to signparameters- set of the driving signing parameterssignatureValue- the signature value to incorporate- Returns:
- the signed document (
toSignDocumentwith the incorporated signature or the detached signature)
-
signDocument
public DSSDocument signDocument(List<DSSDocument> toSignDocuments, JAdESSignatureParameters parameters, SignatureValue signatureValue) Description copied from interface:MultipleDocumentsSignatureServiceSigns the toSignDocuments with the provided signatureValue.- Specified by:
signDocumentin interfaceMultipleDocumentsSignatureService<JAdESSignatureParameters,JAdESTimestampParameters> - Parameters:
toSignDocuments- list of documents to signparameters- set of the driving signing parameterssignatureValue- the signature value to incorporate- Returns:
- the container with the signature and the documents (ASiC) or the signature file
-
getJAdESBuilder
protected JAdESBuilder getJAdESBuilder(JAdESSignatureParameters parameters, List<DSSDocument> documentsToSign) Returns the JAdESBuilder to be used- Parameters:
parameters-JAdESSignatureParametersdocumentsToSign- a list ofDSSDocuments- Returns:
JAdESBuilder
-
extendDocument
public DSSDocument extendDocument(DSSDocument toExtendDocument, JAdESSignatureParameters parameters) Description copied from interface:MultipleDocumentsSignatureServiceExtends the level of the signatures in thetoExtendDocument- Specified by:
extendDocumentin interfaceDocumentSignatureService<JAdESSignatureParameters,JAdESTimestampParameters> - Specified by:
extendDocumentin interfaceMultipleDocumentsSignatureService<JAdESSignatureParameters,JAdESTimestampParameters> - Parameters:
toExtendDocument- document to extendparameters- set of the driving signing parameters- Returns:
- the extended signature
-
timestamp
public DSSDocument timestamp(List<DSSDocument> toTimestampDocuments, JAdESTimestampParameters parameters) Description copied from interface:MultipleDocumentsSignatureServiceTimestamps the toSignDocuments with the provided signatureValue.- Specified by:
timestampin interfaceMultipleDocumentsSignatureService<JAdESSignatureParameters,JAdESTimestampParameters> - Parameters:
toTimestampDocuments- list of documents to timestampparameters- set of the driving timestamping parameters- Returns:
- the container with the added timestamp token
-
addSignaturePolicyStore
public DSSDocument addSignaturePolicyStore(DSSDocument document, SignaturePolicyStore signaturePolicyStore) Incorporates a Signature Policy Store as a base64Url-encoded unsigned property into the JAdES Signature- Parameters:
document-DSSDocumentcontaining a JAdES Signature to add a SignaturePolicyStore tosignaturePolicyStore-SignaturePolicyStoreto add- Returns:
DSSDocumentJAdESSignature with an incorporates SignaturePolicyStore
-
addSignaturePolicyStore
public DSSDocument addSignaturePolicyStore(DSSDocument document, SignaturePolicyStore signaturePolicyStore, boolean base64UrlInstance) Incorporates a Signature Policy Store as an unsigned property into the JAdES Signature- Parameters:
document-DSSDocumentcontaining a JAdES Signature to add a SignaturePolicyStore tosignaturePolicyStore-SignaturePolicyStoreto addbase64UrlInstance- defines if the SignaturePolicyStore shall be incorporated in its corresponding base64Url representation, otherwise if FALSE incorporates in the clear JSON representation- Returns:
DSSDocumentJAdESSignature with an incorporates SignaturePolicyStore
-
getDataToBeCounterSigned
public ToBeSigned getDataToBeCounterSigned(DSSDocument signatureDocument, JAdESCounterSignatureParameters parameters) Description copied from interface:CounterSignatureServiceRetrieves the bytes of the data that need to be counter signed fromsignatureDocument.signatureDocumentshall be a valid signature of the same type- Specified by:
getDataToBeCounterSignedin interfaceCounterSignatureService<JAdESCounterSignatureParameters>- Parameters:
signatureDocument-DSSDocumentrepresenting the original signature to be counter signedparameters- set of the driving signing parameters for a counter signature- Returns:
ToBeSignedto be counter signed byte array (signature value retrieved from thesignatureDocument)
-
counterSignSignature
public DSSDocument counterSignSignature(DSSDocument signatureDocument, JAdESCounterSignatureParameters parameters, SignatureValue signatureValue) Description copied from interface:CounterSignatureServiceCounter signs thesignatureDocumentwith the provided signatureValue.- Specified by:
counterSignSignaturein interfaceCounterSignatureService<JAdESCounterSignatureParameters>- Parameters:
signatureDocument-DSSDocumentto be counter signedparameters- set of the driving signing parameters for a counter signaturesignatureValue-SignatureValuethe signature value to incorporate- Returns:
DSSDocumentthe signature document enveloping a newly created counter signature
-
isValidSignatureValue
public boolean isValidSignatureValue(ToBeSigned toBeSigned, SignatureValue signatureValue, CertificateToken signingCertificate) Description copied from interface:DocumentSignatureServiceVerifies the signature value against aToBeSignedand aCertificateToken- Specified by:
isValidSignatureValuein interfaceDocumentSignatureService<JAdESSignatureParameters,JAdESTimestampParameters> - Specified by:
isValidSignatureValuein interfaceMultipleDocumentsSignatureService<JAdESSignatureParameters,JAdESTimestampParameters> - Overrides:
isValidSignatureValuein classAbstractSignatureService<JAdESSignatureParameters,JAdESTimestampParameters> - Parameters:
toBeSigned- the signed datasignatureValue- the signature valuesigningCertificate- the used certificate to create the signature value- Returns:
- true if the signature value is valid
-
assertSigningCertificateValid
Description copied from class:AbstractSignatureServiceThis method raises an exception if the signing rules forbid the use the certificate.- Overrides:
assertSigningCertificateValidin classAbstractSignatureService<JAdESSignatureParameters,JAdESTimestampParameters> - Parameters:
parameters- set of driving signing parameters
-