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 Details

    • archiveContent

      protected ASiCExtractResult archiveContent
      The extracted content (documents) of the ASiC container
  • Constructor Details

    • AbstractASiCSignatureService

      protected AbstractASiCSignatureService​(CertificateVerifier certificateVerifier)
      The default constructor
      Parameters:
      certificateVerifier - CertificateVerifier
  • Method Details

    • getExpectedSignatureExtension

      protected abstract String getExpectedSignatureExtension()
      Returns the relevant signature document extension for the implemented format
      Returns:
      String signature extension
    • getContentTimestamp

      public TimestampToken getContentTimestamp​(DSSDocument toSignDocument, SP 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 interface DocumentSignatureService<SP extends SerializableSignatureParameters,​TP extends SerializableTimestampParameters>
      Parameters:
      toSignDocument - document to sign or the already existing signature
      parameters - set of the driving signing parameters
      Returns:
      a timestamp token
    • getDataToSign

      public ToBeSigned getDataToSign​(DSSDocument toSignDocument, SP parameters)
      Description copied from interface: DocumentSignatureService
      Retrieves the bytes of the data that need to be signed based on the toSignDocument and parameters . When toSignDocument 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 interface DocumentSignatureService<SP extends SerializableSignatureParameters,​TP extends SerializableTimestampParameters>
      Parameters:
      toSignDocument - document to sign or the already existing signature
      parameters - 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 interface DocumentSignatureService<SP extends SerializableSignatureParameters,​TP extends SerializableTimestampParameters>
      Parameters:
      toSignDocument - document to sign
      parameters - set of the driving signing parameters
      signatureValue - the signature value to incorporate
      Returns:
      the signed document (toSignDocument with the incorporated signature or the detached signature)
    • timestamp

      public DSSDocument timestamp​(DSSDocument toTimestampDocument, TP parameters)
      Description copied from interface: DocumentSignatureService
      This method allows to add a timestamp to an unsigned document
      Specified by:
      timestamp in interface DocumentSignatureService<SP extends SerializableSignatureParameters,​TP extends SerializableTimestampParameters>
      Overrides:
      timestamp in class AbstractSignatureService<SP extends SerializableSignatureParameters,​TP extends SerializableTimestampParameters>
      Parameters:
      toTimestampDocument - the document to be timestamped
      parameters - set of the driving timestamping parameters
      Returns:
      the timestamped document
    • extractCurrentArchive

      protected void extractCurrentArchive​(DSSDocument archive)
      Extracts the content (documents) of the ASiC container
      Parameters:
      archive - DSSDocument representing an ASiC container
    • getArchiveExtractor

      protected abstract AbstractASiCContainerExtractor getArchiveExtractor​(DSSDocument archive)
      Returns a relevant ASiC container extractor for the given format
      Parameters:
      archive - DSSDocument to get an extractor for
      Returns:
      an instance of AbstractASiCContainerExtractor
    • getEmbeddedSignatures

      protected List<DSSDocument> getEmbeddedSignatures()
      Returns a list of signature documents embedded into the ASiC container
      Returns:
      a list of DSSDocuments
    • getEmbeddedManifests

      protected List<DSSDocument> getEmbeddedManifests()
      Returns a list of manifest documents embedded into the ASiC container
      Returns:
      a list of DSSDocuments
    • getEmbeddedArchiveManifests

      protected List<DSSDocument> getEmbeddedArchiveManifests()
      Returns a list of archive manifest documents embedded into the ASiC container
      Returns:
      a list of DSSDocuments
    • getEmbeddedTimestamps

      protected List<DSSDocument> getEmbeddedTimestamps()
      Returns a list of timestamp documents embedded into the ASiC container
      Returns:
      a list of DSSDocuments
    • getEmbeddedSignedDocuments

      protected List<DSSDocument> getEmbeddedSignedDocuments()
      Returns a list of signed documents embedded into the ASiC container
      Returns:
      a list of DSSDocuments
    • getEmbeddedMimetype

      protected DSSDocument 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 existing archiveDocument entries and overwriting matching ones with filesToAdd
      Parameters:
      archiveDocument - DSSDocument the original ASiC container to extend
      filesToAdd - a list of DSSDocument signatures to embed
      creationTime - Date of the archive creation
      zipComment - 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 of DSSDocuments to be originally signed
      signatures - a list of DSSDocument representing signature
      metaInfFolderDocuments - a list of DSSDocument representing a META-INF directory content
      asicParameters - ASiCParameters
      creationTime - Date of the archive creation
      Returns:
      DSSDocument the created ASiC Container
    • assertCounterSignatureParametersValid

      protected void assertCounterSignatureParametersValid​(CSP parameters)
      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 container
      operation - SigningOperation the performed signing operation
      containerMimeType - MimeType the expected mimeType
      Returns:
      String the archive filename