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 ASiCExtractResultarchiveContentThe extracted content (documents) of the ASiC containerFields inherited from class eu.europa.esig.dss.signature.AbstractSignatureService
certificateVerifier, tspSource -
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractASiCSignatureService(CertificateVerifier certificateVerifier)The default constructor -
Method Summary
Modifier and Type Method Description protected voidassertAddSignaturePolicyStorePossible()Verifies if incorporation of a SignaturePolicyStore is possibleprotected voidassertCounterSignatureParametersValid(CSP parameters)Verifies a validity of counter signature parametersprotected DSSDocumentbuildASiCContainer(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 voidextractCurrentArchive(DSSDocument archive)Extracts the content (documents) of the ASiC containerprotected abstract AbstractASiCContainerExtractorgetArchiveExtractor(DSSDocument archive)Returns a relevant ASiC container extractor for the given formatTimestampTokengetContentTimestamp(DSSDocument toSignDocument, SP parameters)This method allows to compute a content-timestamp (which is added in the signed properties)ToBeSignedgetDataToSign(DSSDocument toSignDocument, SP parameters)Retrieves the bytes of the data that need to be signed based on thetoSignDocumentandparameters.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 DSSDocumentgetEmbeddedMimetype()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 StringgetExpectedSignatureExtension()Returns the relevant signature document extension for the implemented formatprotected StringgetFinalArchiveName(DSSDocument originalFile, SigningOperation operation, MimeType containerMimeType)Generates and returns a final name for the archive to createprotected DSSDocumentmergeArchiveAndExtendedSignatures(DSSDocument archiveDocument, List<DSSDocument> filesToAdd, Date creationTime, String zipComment)Creates a ZIP-Archive by copying the existingarchiveDocumententries and overwriting matching ones withfilesToAddDSSDocumentsignDocument(DSSDocument toSignDocument, SP parameters, SignatureValue signatureValue)Signs the toSignDocument with the provided signatureValue.DSSDocumenttimestamp(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, setTspSourceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface eu.europa.esig.dss.signature.CounterSignatureService
counterSignSignature, getDataToBeCounterSignedMethods inherited from interface eu.europa.esig.dss.signature.DocumentSignatureService
extendDocumentMethods 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:
Stringsignature extension
-
getContentTimestamp
Description copied from interface:DocumentSignatureServiceThis method allows to compute a content-timestamp (which is added in the signed properties)- Specified by:
getContentTimestampin 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: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<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:DocumentSignatureServiceSigns the toSignDocument with the provided signatureValue.- Specified by:
signDocumentin 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 (
toSignDocumentwith the incorporated signature or the detached signature)
-
timestamp
Description copied from interface:DocumentSignatureServiceThis method allows to add a timestamp to an unsigned document- Specified by:
timestampin interfaceDocumentSignatureService<SP extends SerializableSignatureParameters,TP extends SerializableTimestampParameters>- Overrides:
timestampin 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-DSSDocumentrepresenting an ASiC container
-
getArchiveExtractor
Returns a relevant ASiC container extractor for the given format- Parameters:
archive-DSSDocumentto 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
DSSDocuments
-
getEmbeddedManifests
Returns a list of manifest documents embedded into the ASiC container- Returns:
- a list of
DSSDocuments
-
getEmbeddedArchiveManifests
Returns a list of archive manifest documents embedded into the ASiC container- Returns:
- a list of
DSSDocuments
-
getEmbeddedTimestamps
Returns a list of timestamp documents embedded into the ASiC container- Returns:
- a list of
DSSDocuments
-
getEmbeddedSignedDocuments
Returns a list of signed documents embedded into the ASiC container- Returns:
- a list of
DSSDocuments
-
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 existingarchiveDocumententries and overwriting matching ones withfilesToAdd- Parameters:
archiveDocument-DSSDocumentthe original ASiC container to extendfilesToAdd- a list ofDSSDocumentsignatures to embedcreationTime-Dateof the archive creationzipComment-String- Returns:
DSSDocumentthe 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 ofDSSDocuments to be originally signedsignatures- a list ofDSSDocumentrepresenting signaturemetaInfFolderDocuments- a list ofDSSDocumentrepresenting a META-INF directory contentasicParameters-ASiCParameterscreationTime-Dateof the archive creation- Returns:
DSSDocumentthe 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-DSSDocumentoriginal signed/extended document containeroperation-SigningOperationthe performed signing operationcontainerMimeType-MimeTypethe expected mimeType- Returns:
Stringthe archive filename
-