Class AbstractASiCSignatureService<SP extends SerializableSignatureParameters,TP extends SerializableTimestampParameters,CSP extends SerializableCounterSignatureParameters>
java.lang.Object
eu.europa.esig.dss.signature.AbstractSignatureService<SP,TP>
eu.europa.esig.dss.asic.common.signature.AbstractASiCSignatureService<SP,TP,CSP>
- All Implemented Interfaces:
CounterSignatureService<CSP>
,DocumentSignatureService<SP,TP>
,MultipleDocumentsSignatureService<SP,TP>
,Serializable
- Direct Known Subclasses:
ASiCWithCAdESService
,ASiCWithXAdESService
public abstract class AbstractASiCSignatureService<SP extends SerializableSignatureParameters,TP extends SerializableTimestampParameters,CSP extends SerializableCounterSignatureParameters> extends AbstractSignatureService<SP,TP> implements MultipleDocumentsSignatureService<SP,TP>, CounterSignatureService<CSP>
The abstract class containing the main methods for ASiC signature creation/extension
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description protected ASiCExtractResult
archiveContent
The extracted content (documents) of the ASiC containerFields inherited from class eu.europa.esig.dss.signature.AbstractSignatureService
certificateVerifier, tspSource
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractASiCSignatureService(CertificateVerifier certificateVerifier)
The default constructor -
Method Summary
Modifier and Type Method Description protected void
assertAddSignaturePolicyStorePossible()
Verifies if incorporation of a SignaturePolicyStore is possibleprotected void
assertCounterSignatureParametersValid(CSP parameters)
Verifies a validity of counter signature parametersprotected DSSDocument
buildASiCContainer(List<DSSDocument> documentsToBeSigned, List<DSSDocument> signatures, List<DSSDocument> metaInfFolderDocuments, ASiCParameters asicParameters, Date creationTime)
Creates a ZIP-Archive by copying the provided documents to the new containerprotected void
extractCurrentArchive(DSSDocument archive)
Extracts the content (documents) of the ASiC containerprotected abstract AbstractASiCContainerExtractor
getArchiveExtractor(DSSDocument archive)
Returns a relevant ASiC container extractor for the given formatTimestampToken
getContentTimestamp(DSSDocument toSignDocument, SP parameters)
This method allows to compute a content-timestamp (which is added in the signed properties)ToBeSigned
getDataToSign(DSSDocument toSignDocument, SP parameters)
Retrieves the bytes of the data that need to be signed based on thetoSignDocument
andparameters
.protected List<DSSDocument>
getEmbeddedArchiveManifests()
Returns a list of archive manifest documents embedded into the ASiC containerprotected List<DSSDocument>
getEmbeddedManifests()
Returns a list of manifest documents embedded into the ASiC containerprotected DSSDocument
getEmbeddedMimetype()
Returns a mimetype document embedded into the ASiC containerprotected List<DSSDocument>
getEmbeddedSignatures()
Returns a list of signature documents embedded into the ASiC containerprotected List<DSSDocument>
getEmbeddedSignedDocuments()
Returns a list of signed documents embedded into the ASiC containerprotected List<DSSDocument>
getEmbeddedTimestamps()
Returns a list of timestamp documents embedded into the ASiC containerprotected abstract String
getExpectedSignatureExtension()
Returns the relevant signature document extension for the implemented formatprotected String
getFinalArchiveName(DSSDocument originalFile, SigningOperation operation, MimeType containerMimeType)
Generates and returns a final name for the archive to createprotected DSSDocument
mergeArchiveAndExtendedSignatures(DSSDocument archiveDocument, List<DSSDocument> filesToAdd, Date creationTime, String zipComment)
Creates a ZIP-Archive by copying the existingarchiveDocument
entries and overwriting matching ones withfilesToAdd
DSSDocument
signDocument(DSSDocument toSignDocument, SP parameters, SignatureValue signatureValue)
Signs the toSignDocument with the provided signatureValue.DSSDocument
timestamp(DSSDocument toTimestampDocument, TP parameters)
This method allows to add a timestamp to an unsigned documentMethods inherited from class eu.europa.esig.dss.signature.AbstractSignatureService
assertSigningDateInCertificateValidityRange, getFinalDocumentName, getFinalFileName, getFinalFileName, isValidSignatureValue, setTspSource
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
counterSignSignature, getDataToBeCounterSigned
Methods inherited from interface eu.europa.esig.dss.signature.DocumentSignatureService
extendDocument
Methods inherited from interface eu.europa.esig.dss.signature.MultipleDocumentsSignatureService
extendDocument, getContentTimestamp, getDataToSign, isValidSignatureValue, signDocument, timestamp
-
Field Details
-
archiveContent
The extracted content (documents) of the ASiC container
-
-
Constructor Details
-
AbstractASiCSignatureService
The default constructor- Parameters:
certificateVerifier
-CertificateVerifier
-
-
Method Details
-
getExpectedSignatureExtension
Returns the relevant signature document extension for the implemented format- Returns:
String
signature extension
-
getContentTimestamp
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<SP extends SerializableSignatureParameters,TP extends SerializableTimestampParameters>
- Parameters:
toSignDocument
- document to sign or the already existing signatureparameters
- set of the driving signing parameters- Returns:
- a timestamp token
-
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<SP extends SerializableSignatureParameters,TP extends SerializableTimestampParameters>
- Parameters:
toSignDocument
- document to sign or the already existing signatureparameters
- set of the driving signing parameters- Returns:
- the data to be signed
-
signDocument
public DSSDocument signDocument(DSSDocument toSignDocument, SP parameters, SignatureValue signatureValue)Description copied from interface:DocumentSignatureService
Signs the toSignDocument with the provided signatureValue.- Specified by:
signDocument
in interfaceDocumentSignatureService<SP extends SerializableSignatureParameters,TP extends SerializableTimestampParameters>
- 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)
-
timestamp
Description copied from interface:DocumentSignatureService
This method allows to add a timestamp to an unsigned document- Specified by:
timestamp
in interfaceDocumentSignatureService<SP extends SerializableSignatureParameters,TP extends SerializableTimestampParameters>
- Overrides:
timestamp
in classAbstractSignatureService<SP extends SerializableSignatureParameters,TP extends SerializableTimestampParameters>
- Parameters:
toTimestampDocument
- the document to be timestampedparameters
- set of the driving timestamping parameters- Returns:
- the timestamped document
-
extractCurrentArchive
Extracts the content (documents) of the ASiC container- Parameters:
archive
-DSSDocument
representing an ASiC container
-
getArchiveExtractor
Returns a relevant ASiC container extractor for the given format- Parameters:
archive
-DSSDocument
to get an extractor for- Returns:
- an instance of
AbstractASiCContainerExtractor
-
getEmbeddedSignatures
Returns a list of signature documents embedded into the ASiC container- Returns:
- a list of
DSSDocument
s
-
getEmbeddedManifests
Returns a list of manifest documents embedded into the ASiC container- Returns:
- a list of
DSSDocument
s
-
getEmbeddedArchiveManifests
Returns a list of archive manifest documents embedded into the ASiC container- Returns:
- a list of
DSSDocument
s
-
getEmbeddedTimestamps
Returns a list of timestamp documents embedded into the ASiC container- Returns:
- a list of
DSSDocument
s
-
getEmbeddedSignedDocuments
Returns a list of signed documents embedded into the ASiC container- Returns:
- a list of
DSSDocument
s
-
getEmbeddedMimetype
Returns a mimetype document embedded into the ASiC container- Returns:
DSSDocument
-
mergeArchiveAndExtendedSignatures
protected DSSDocument mergeArchiveAndExtendedSignatures(DSSDocument archiveDocument, List<DSSDocument> filesToAdd, Date creationTime, String zipComment)Creates a ZIP-Archive by copying the existingarchiveDocument
entries and overwriting matching ones withfilesToAdd
- Parameters:
archiveDocument
-DSSDocument
the original ASiC container to extendfilesToAdd
- a list ofDSSDocument
signatures to embedcreationTime
-Date
of the archive creationzipComment
-String
- Returns:
DSSDocument
the merged ASiC Container
-
buildASiCContainer
protected DSSDocument buildASiCContainer(List<DSSDocument> documentsToBeSigned, List<DSSDocument> signatures, List<DSSDocument> metaInfFolderDocuments, ASiCParameters asicParameters, Date creationTime)Creates a ZIP-Archive by copying the provided documents to the new container- Parameters:
documentsToBeSigned
- a list ofDSSDocument
s to be originally signedsignatures
- a list ofDSSDocument
representing signaturemetaInfFolderDocuments
- a list ofDSSDocument
representing a META-INF directory contentasicParameters
-ASiCParameters
creationTime
-Date
of the archive creation- Returns:
DSSDocument
the created ASiC Container
-
assertCounterSignatureParametersValid
Verifies a validity of counter signature parameters- Parameters:
parameters
- counter signature parameters to verify
-
assertAddSignaturePolicyStorePossible
protected void assertAddSignaturePolicyStorePossible()Verifies if incorporation of a SignaturePolicyStore is possible -
getFinalArchiveName
protected String getFinalArchiveName(DSSDocument originalFile, SigningOperation operation, MimeType containerMimeType)Generates and returns a final name for the archive to create- Parameters:
originalFile
-DSSDocument
original signed/extended document containeroperation
-SigningOperation
the performed signing operationcontainerMimeType
-MimeType
the expected mimeType- Returns:
String
the archive filename
-