Class AbstractSignatureService<SP extends eu.europa.esig.dss.model.SerializableSignatureParameters, TP extends eu.europa.esig.dss.model.SerializableTimestampParameters>

java.lang.Object
eu.europa.esig.dss.signature.AbstractSignatureService<SP,TP>
Type Parameters:
SP - SignatureParameters
TP - TimestampParameters
All Implemented Interfaces:
DocumentSignatureService<SP,TP>, Serializable

public abstract class AbstractSignatureService<SP extends eu.europa.esig.dss.model.SerializableSignatureParameters, TP extends eu.europa.esig.dss.model.SerializableTimestampParameters> extends Object implements DocumentSignatureService<SP,TP>
The abstract class containing the main methods for a signature creation/extension
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final eu.europa.esig.dss.spi.validation.CertificateVerifier
    The CertificateVerifier used for a certificate chain validation
    protected eu.europa.esig.dss.spi.x509.tsp.TSPSource
    The TSPSource to use for timestamp requests
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractSignatureService(eu.europa.esig.dss.spi.validation.CertificateVerifier certificateVerifier)
    To construct a signature service the CertificateVerifier must be set and cannot be null.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    This method raises an exception if the signing rules forbid the use the certificate.
    protected eu.europa.esig.dss.model.SignatureValue
    ensureSignatureValue(eu.europa.esig.dss.enumerations.SignatureAlgorithm targetSignatureAlgorithm, eu.europa.esig.dss.model.SignatureValue signatureValue)
    This method ensures the provided signatureValue has the expected targetSignatureAlgorithm
    protected String
    getFinalDocumentName(eu.europa.esig.dss.model.DSSDocument originalFile, eu.europa.esig.dss.enumerations.SigningOperation operation, eu.europa.esig.dss.enumerations.SignatureLevel level, eu.europa.esig.dss.enumerations.MimeType containerMimeType)
    Generates and returns a final name for the document to create
    protected String
    getFinalDocumentName(eu.europa.esig.dss.model.DSSDocument originalFile, eu.europa.esig.dss.enumerations.SigningOperation operation, eu.europa.esig.dss.enumerations.SignatureLevel level, eu.europa.esig.dss.enumerations.SignaturePackaging packaging, eu.europa.esig.dss.enumerations.MimeType containerMimeType)
    Generates and returns a final name for the document to create
    protected String
    getFinalFileName(eu.europa.esig.dss.model.DSSDocument originalFile, eu.europa.esig.dss.enumerations.SigningOperation operation)
    Returns the final name for the document to create
    protected String
    getFinalFileName(eu.europa.esig.dss.model.DSSDocument originalFile, eu.europa.esig.dss.enumerations.SigningOperation operation, eu.europa.esig.dss.enumerations.SignatureLevel level)
    Returns the final name for the document to create
    protected String
    getFinalFileName(eu.europa.esig.dss.model.DSSDocument originalFile, eu.europa.esig.dss.enumerations.SigningOperation operation, eu.europa.esig.dss.enumerations.SignatureLevel level, eu.europa.esig.dss.enumerations.SignaturePackaging packaging)
    Returns the final name for the document to create
    boolean
    isValidSignatureValue(eu.europa.esig.dss.model.ToBeSigned toBeSigned, eu.europa.esig.dss.model.SignatureValue signatureValue, eu.europa.esig.dss.model.x509.CertificateToken signingCertificate)
    Verifies the signature value against a ToBeSigned and a CertificateToken
    void
    setTspSource(eu.europa.esig.dss.spi.x509.tsp.TSPSource tspSource)
    This setter allows to define the TSP (timestamp provider) source.
    eu.europa.esig.dss.model.DSSDocument
    timestamp(eu.europa.esig.dss.model.DSSDocument toTimestampDocument, TP parameters)
    This method allows to add a timestamp to an unsigned document

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface DocumentSignatureService

    extendDocument, getContentTimestamp, getDataToSign, signDocument
    Modifier and Type
    Method
    Description
    eu.europa.esig.dss.model.DSSDocument
    extendDocument(eu.europa.esig.dss.model.DSSDocument toExtendDocument, SP parameters)
    Extends the level of the signatures in the toExtendDocument
    eu.europa.esig.dss.spi.x509.tsp.TimestampToken
    getContentTimestamp(eu.europa.esig.dss.model.DSSDocument toSignDocument, SP parameters)
    This method allows to compute a content-timestamp (which is added in the signed properties)
    eu.europa.esig.dss.model.ToBeSigned
    getDataToSign(eu.europa.esig.dss.model.DSSDocument toSignDocument, SP parameters)
    Retrieves the bytes of the data that need to be signed based on the toSignDocument and parameters.
    eu.europa.esig.dss.model.DSSDocument
    signDocument(eu.europa.esig.dss.model.DSSDocument toSignDocument, SP parameters, eu.europa.esig.dss.model.SignatureValue signatureValue)
    Signs the toSignDocument with the provided signatureValue.
  • Field Details

    • certificateVerifier

      protected final eu.europa.esig.dss.spi.validation.CertificateVerifier certificateVerifier
      The CertificateVerifier used for a certificate chain validation
    • tspSource

      protected eu.europa.esig.dss.spi.x509.tsp.TSPSource tspSource
      The TSPSource to use for timestamp requests
  • Constructor Details

    • AbstractSignatureService

      protected AbstractSignatureService(eu.europa.esig.dss.spi.validation.CertificateVerifier certificateVerifier)
      To construct a signature service the CertificateVerifier must be set and cannot be null.
      Parameters:
      certificateVerifier - CertificateVerifier provides information on the sources to be used in the validation process in the context of a signature.
  • Method Details

    • setTspSource

      public void setTspSource(eu.europa.esig.dss.spi.x509.tsp.TSPSource tspSource)
      Description copied from interface: DocumentSignatureService
      This setter allows to define the TSP (timestamp provider) source.
      Specified by:
      setTspSource in interface DocumentSignatureService<SP extends eu.europa.esig.dss.model.SerializableSignatureParameters, TP extends eu.europa.esig.dss.model.SerializableTimestampParameters>
      Parameters:
      tspSource - The time stamp source which is used when timestamping the signature.
    • assertSigningCertificateValid

      protected void assertSigningCertificateValid(AbstractSignatureParameters<?> parameters)
      This method raises an exception if the signing rules forbid the use the certificate.
      Parameters:
      parameters - set of driving signing parameters
    • ensureSignatureValue

      protected eu.europa.esig.dss.model.SignatureValue ensureSignatureValue(eu.europa.esig.dss.enumerations.SignatureAlgorithm targetSignatureAlgorithm, eu.europa.esig.dss.model.SignatureValue signatureValue)
      This method ensures the provided signatureValue has the expected targetSignatureAlgorithm
      Parameters:
      targetSignatureAlgorithm - SignatureAlgorithm to convert the signatureValue to
      signatureValue - SignatureValue obtained from a signing token
      Returns:
      SignatureValue with the defined SignatureAlgorithm in parameters
    • getFinalDocumentName

      protected String getFinalDocumentName(eu.europa.esig.dss.model.DSSDocument originalFile, eu.europa.esig.dss.enumerations.SigningOperation operation, eu.europa.esig.dss.enumerations.SignatureLevel level, eu.europa.esig.dss.enumerations.SignaturePackaging packaging, eu.europa.esig.dss.enumerations.MimeType containerMimeType)
      Generates and returns a final name for the document to create
      Parameters:
      originalFile - DSSDocument original signed/extended document
      operation - SigningOperation the performed signing operation
      level - SignatureLevel the final signature level
      packaging - SignaturePackaging the used packaging to create original signature
      containerMimeType - MimeType the expected mimeType
      Returns:
      String the document filename
    • getFinalFileName

      protected String getFinalFileName(eu.europa.esig.dss.model.DSSDocument originalFile, eu.europa.esig.dss.enumerations.SigningOperation operation)
      Returns the final name for the document to create
      Parameters:
      originalFile - DSSDocument original signed/extended document
      operation - SigningOperation the performed signing operation
      Returns:
      String the document filename
    • getFinalFileName

      protected String getFinalFileName(eu.europa.esig.dss.model.DSSDocument originalFile, eu.europa.esig.dss.enumerations.SigningOperation operation, eu.europa.esig.dss.enumerations.SignatureLevel level)
      Returns the final name for the document to create
      Parameters:
      originalFile - DSSDocument original signed/extended document
      operation - SigningOperation the performed signing operation
      level - SignatureLevel the final signature level
      Returns:
      String the document filename
    • getFinalFileName

      protected String getFinalFileName(eu.europa.esig.dss.model.DSSDocument originalFile, eu.europa.esig.dss.enumerations.SigningOperation operation, eu.europa.esig.dss.enumerations.SignatureLevel level, eu.europa.esig.dss.enumerations.SignaturePackaging packaging)
      Returns the final name for the document to create
      Parameters:
      originalFile - DSSDocument original signed/extended document
      operation - SigningOperation the performed signing operation
      level - SignatureLevel the final signature level
      packaging - SignaturePackaging the used packaging to create original signature
      Returns:
      String the document filename
    • getFinalDocumentName

      protected String getFinalDocumentName(eu.europa.esig.dss.model.DSSDocument originalFile, eu.europa.esig.dss.enumerations.SigningOperation operation, eu.europa.esig.dss.enumerations.SignatureLevel level, eu.europa.esig.dss.enumerations.MimeType containerMimeType)
      Generates and returns a final name for the document to create
      Parameters:
      originalFile - DSSDocument original signed/extended document
      operation - SigningOperation the performed signing operation
      level - SignatureLevel the final signature level
      containerMimeType - MimeType the expected mimeType
      Returns:
      String the document filename
    • timestamp

      public eu.europa.esig.dss.model.DSSDocument timestamp(eu.europa.esig.dss.model.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 eu.europa.esig.dss.model.SerializableSignatureParameters, TP extends eu.europa.esig.dss.model.SerializableTimestampParameters>
      Parameters:
      toTimestampDocument - the document to be timestamped
      parameters - set of the driving timestamping parameters
      Returns:
      the timestamped document
    • isValidSignatureValue

      public boolean isValidSignatureValue(eu.europa.esig.dss.model.ToBeSigned toBeSigned, eu.europa.esig.dss.model.SignatureValue signatureValue, eu.europa.esig.dss.model.x509.CertificateToken signingCertificate)
      Description copied from interface: DocumentSignatureService
      Verifies the signature value against a ToBeSigned and a CertificateToken
      Specified by:
      isValidSignatureValue in interface DocumentSignatureService<SP extends eu.europa.esig.dss.model.SerializableSignatureParameters, TP extends eu.europa.esig.dss.model.SerializableTimestampParameters>
      Parameters:
      toBeSigned - the signed data
      signatureValue - the signature value
      signingCertificate - the used certificate to create the signature value
      Returns:
      true if the signature value is valid