java.lang.Object
eu.europa.esig.dss.signature.AbstractSignatureService<SP,TP>
eu.europa.esig.dss.asic.common.signature.AbstractASiCSignatureService<SP,TP,CSP,ERP>
Type Parameters:
SP - implementation of signature parameters corresponding to the supported signature format
TP - implementation of timestamp parameters corresponding to the supported document format
CSP - implementation of counter-signature parameters corresponding to the supported signature format
ERP - implementation of parameters used for evidince record embedding
All Implemented Interfaces:
EvidenceRecordIncorporationService<ERP>, CounterSignatureService<CSP>, DocumentSignatureService<SP,TP>, MultipleDocumentsSignatureService<SP,TP>, Serializable
Direct Known Subclasses:
ASiCWithCAdESService, ASiCWithXAdESService

The abstract class containing the main methods for ASiC signature creation/extension
See Also:
  • Constructor Details

    • AbstractASiCSignatureService

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

    • 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
    • addContainerEvidenceRecord

      public DSSDocument addContainerEvidenceRecord(DSSDocument document, DSSDocument evidenceRecordDocument, ASiCContainerEvidenceRecordParameters parameters)
      Creates a new ASiC container with the evidenceRecordDocument applied to the document.

      If the provided original document is an existing ASiC container, then the evidenceRecordDocument will be evaluated against the container files and places within the container.

      Parameters:
      document - a list of DSSDocuments preserved by an evidence record
      evidenceRecordDocument - DSSDocument to add
      parameters - ASiCContainerEvidenceRecordParameters providing configuration for the evidence record incorporation
      Returns:
      DSSDocument ASiC container containing the evidence record file document
    • addContainerEvidenceRecord

      public abstract DSSDocument addContainerEvidenceRecord(List<DSSDocument> documents, DSSDocument evidenceRecordDocument, ASiCContainerEvidenceRecordParameters parameters)
      Creates a new ASiC container with the evidenceRecordDocument applied to the documents.

      If the provided original document is an existing ASiC container, then the evidenceRecordDocument will be evaluated against the container files and places within the container.

      Parameters:
      documents - a list of DSSDocuments preserved by an evidence record
      evidenceRecordDocument - DSSDocument to add
      parameters - ASiCContainerEvidenceRecordParameters providing configuration for the evidence record incorporation
      Returns:
      DSSDocument ASiC container containing the evidence record file document
    • extractCurrentArchive

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

      protected abstract DefaultASiCContainerExtractor 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 DefaultASiCContainerExtractor
    • buildASiCContainer

      protected DSSDocument buildASiCContainer(ASiCContent asicContent)
      Creates a ZIP-Archive by copying the provided documents to the new container using the current time as ZIP creation time
      Parameters:
      asicContent - ASiCContent to create a new ZIP archive from
      Returns:
      DSSDocument the created ASiC Container
    • buildASiCContainer

      protected DSSDocument buildASiCContainer(ASiCContent asicContent, Date creationTime)
      Creates a ZIP-Archive by copying the provided documents to the new container
      Parameters:
      asicContent - ASiCContent to create a new ZIP archive from
      creationTime - Date of the archive creation (optional)
      Returns:
      DSSDocument the created ASiC Container
    • assertSignaturePossible

      protected void assertSignaturePossible(List<DSSDocument> documentsToSign)
      This method verifies whether the signature creation is possible with the provided documents
      Parameters:
      documentsToSign - a list of DSSDocuments
    • assertCounterSignatureParametersValid

      protected void assertCounterSignatureParametersValid(CSP parameters)
      Verifies a validity of counter signature parameters
      Parameters:
      parameters - counter signature parameters to verify
    • assertAddSignaturePolicyStorePossible

      protected void assertAddSignaturePolicyStorePossible(ASiCContent asicContent)
      Verifies if incorporation of a SignaturePolicyStore is possible
      Parameters:
      asicContent - ASiCContent
    • 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