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
ConstructorDescriptionJAdESService
(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 void
assertSigningCertificateValid
(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 thesignatureDocument
with the provided signatureValue.extendDocument
(DSSDocument toExtendDocument, JAdESSignatureParameters parameters) Extends the level of the signatures in thetoExtendDocument
getContentTimestamp
(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 thetoSignDocument
andparameters
.getDataToSign
(List<DSSDocument> toSignDocuments, JAdESSignatureParameters parameters) Retrieves the bytes of the data that need to be signed based on thetoSignDocuments
andparameters
.protected JAdESBuilder
getJAdESBuilder
(JAdESSignatureParameters parameters, List<DSSDocument> documentsToSign) Returns the JAdESBuilder to be usedboolean
isValidSignatureValue
(ToBeSigned toBeSigned, SignatureValue signatureValue, CertificateToken signingCertificate) Verifies the signature value against aToBeSigned
and aCertificateToken
signDocument
(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
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface eu.europa.esig.dss.signature.CounterSignatureService
setTspSource
-
Constructor Details
-
JAdESService
This is the constructor to create an instance of theJAdESService
. A certificate verifier must be provided.- Parameters:
certificateVerifier
-CertificateVerifier
provides 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:DocumentSignatureService
This method allows to compute a content-timestamp (which is added in the signed properties)- Specified by:
getContentTimestamp
in 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:
getContentTimestamp
in interfaceMultipleDocumentsSignatureService<JAdESSignatureParameters,
JAdESTimestampParameters> - Parameters:
toSignDocuments
- a list ofDSSDocument
s to be timestampedparameters
-JAdESSignatureParameters
- Returns:
- content
TimestampToken
-
getDataToSign
Description copied from interface:DocumentSignatureService
Retrieves the bytes of the data that need to be signed based on thetoSignDocument
andparameters
. WhentoSignDocument
contains 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:
getDataToSign
in 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:MultipleDocumentsSignatureService
Retrieves the bytes of the data that need to be signed based on thetoSignDocuments
andparameters
. WhentoSignDocuments
contains an already existing signature the returned bytes are related to a new parallel signature.- Specified by:
getDataToSign
in 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:DocumentSignatureService
Signs the toSignDocument with the provided signatureValue.- Specified by:
signDocument
in interfaceDocumentSignatureService<JAdESSignatureParameters,
JAdESTimestampParameters> - Parameters:
toSignDocument
- document to signparameters
- set of the driving signing parameterssignatureValue
- the signature value to incorporate- Returns:
- the signed document (
toSignDocument
with the incorporated signature or the detached signature)
-
signDocument
public DSSDocument signDocument(List<DSSDocument> toSignDocuments, JAdESSignatureParameters parameters, SignatureValue signatureValue) Description copied from interface:MultipleDocumentsSignatureService
Signs the toSignDocuments with the provided signatureValue.- Specified by:
signDocument
in 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
-JAdESSignatureParameters
documentsToSign
- a list ofDSSDocument
s- Returns:
JAdESBuilder
-
extendDocument
public DSSDocument extendDocument(DSSDocument toExtendDocument, JAdESSignatureParameters parameters) Description copied from interface:DocumentSignatureService
Extends the level of the signatures in thetoExtendDocument
- Specified by:
extendDocument
in interfaceDocumentSignatureService<JAdESSignatureParameters,
JAdESTimestampParameters> - Specified by:
extendDocument
in 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:MultipleDocumentsSignatureService
Timestamps the toSignDocuments with the provided signatureValue.- Specified by:
timestamp
in 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
-DSSDocument
containing a JAdES Signature to add a SignaturePolicyStore tosignaturePolicyStore
-SignaturePolicyStore
to add- Returns:
DSSDocument
JAdESSignature 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
-DSSDocument
containing a JAdES Signature to add a SignaturePolicyStore tosignaturePolicyStore
-SignaturePolicyStore
to addbase64UrlInstance
- defines if the SignaturePolicyStore shall be incorporated in its corresponding base64Url representation, otherwise if FALSE incorporates in the clear JSON representation- Returns:
DSSDocument
JAdESSignature with an incorporates SignaturePolicyStore
-
getDataToBeCounterSigned
public ToBeSigned getDataToBeCounterSigned(DSSDocument signatureDocument, JAdESCounterSignatureParameters parameters) Description copied from interface:CounterSignatureService
Retrieves the bytes of the data that need to be counter-signed fromsignatureDocument
.signatureDocument
shall be a valid signature of the same type- Specified by:
getDataToBeCounterSigned
in interfaceCounterSignatureService<JAdESCounterSignatureParameters>
- Parameters:
signatureDocument
-DSSDocument
representing the original signature to be counter-signedparameters
- set of the driving signing parameters for a counter-signature- Returns:
ToBeSigned
to be counter-signed byte array (signature value retrieved from thesignatureDocument
)
-
counterSignSignature
public DSSDocument counterSignSignature(DSSDocument signatureDocument, JAdESCounterSignatureParameters parameters, SignatureValue signatureValue) Description copied from interface:CounterSignatureService
Counter-signs thesignatureDocument
with the provided signatureValue.- Specified by:
counterSignSignature
in interfaceCounterSignatureService<JAdESCounterSignatureParameters>
- Parameters:
signatureDocument
-DSSDocument
to be counter-signedparameters
- set of the driving signing parameters for a counter-signaturesignatureValue
-SignatureValue
the signature value to incorporate- Returns:
DSSDocument
the signature document enveloping a newly created counter-signature
-
isValidSignatureValue
public boolean isValidSignatureValue(ToBeSigned toBeSigned, SignatureValue signatureValue, CertificateToken signingCertificate) Description copied from interface:DocumentSignatureService
Verifies the signature value against aToBeSigned
and aCertificateToken
- Specified by:
isValidSignatureValue
in interfaceDocumentSignatureService<JAdESSignatureParameters,
JAdESTimestampParameters> - Specified by:
isValidSignatureValue
in interfaceMultipleDocumentsSignatureService<JAdESSignatureParameters,
JAdESTimestampParameters> - Overrides:
isValidSignatureValue
in 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:AbstractSignatureService
This method raises an exception if the signing rules forbid the use the certificate.- Overrides:
assertSigningCertificateValid
in classAbstractSignatureService<JAdESSignatureParameters,
JAdESTimestampParameters> - Parameters:
parameters
- set of driving signing parameters
-