Class PAdESService

All Implemented Interfaces:
DocumentSignatureService<PAdESSignatureParameters,PAdESTimestampParameters>, Serializable

PAdES implementation of the DocumentSignatureService
See Also:
  • Constructor Details

    • PAdESService

      public PAdESService(CertificateVerifier certificateVerifier)
      This is the constructor to create an instance of the PAdESService. A certificate verifier must be provided.
      Parameters:
      certificateVerifier - CertificateVerifier provides information on the sources to be used in the validation process in the context of a signature.
  • Method Details

    • setPdfObjFactory

      public void setPdfObjFactory(IPdfObjFactory pdfObjFactory)
      Set the IPdfObjFactory. Allow to set the used implementation. Cannot be null.
      Parameters:
      pdfObjFactory - the implementation to be used.
    • setTspSource

      public void setTspSource(TSPSource tspSource)
      Description copied from interface: DocumentSignatureService
      This setter allows to define the TSP (timestamp provider) source.
      Specified by:
      setTspSource in interface DocumentSignatureService<PAdESSignatureParameters,PAdESTimestampParameters>
      Overrides:
      setTspSource in class AbstractSignatureService<PAdESSignatureParameters,PAdESTimestampParameters>
      Parameters:
      tspSource - The time stamp source which is used when timestamping the signature.
    • getContentTimestamp

      public TimestampToken getContentTimestamp(DSSDocument toSignDocument, PAdESSignatureParameters parameters)
      Description copied from interface: DocumentSignatureService
      This method allows to compute a content-timestamp (which is added in the signed properties)
      Parameters:
      toSignDocument - document to sign or the already existing signature
      parameters - set of the driving signing parameters
      Returns:
      a timestamp token
    • previewPageWithVisualSignature

      public DSSDocument previewPageWithVisualSignature(DSSDocument toSignDocument, PAdESSignatureParameters parameters)
      Returns a page preview with the visual signature
      Parameters:
      toSignDocument - the document to be signed
      parameters - the signature/timestamp parameters
      Returns:
      a DSSDocument with the PNG picture
    • previewSignatureField

      public DSSDocument previewSignatureField(DSSDocument toSignDocument, PAdESSignatureParameters parameters)
      Returns a preview of the signature field
      Parameters:
      toSignDocument - the document to be signed
      parameters - the signature/timestamp parameters
      Returns:
      a DSSDocument with the PNG picture
    • getDataToSign

      public ToBeSigned getDataToSign(DSSDocument toSignDocument, PAdESSignatureParameters parameters) throws DSSException
      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
      Parameters:
      toSignDocument - document to sign or the already existing signature
      parameters - set of the driving signing parameters
      Returns:
      the data to be signed
      Throws:
      DSSException
    • computeDocumentDigest

      protected DSSMessageDigest computeDocumentDigest(DSSDocument toSignDocument, PAdESSignatureParameters parameters)
      Computes digest of the document to be signed
      Parameters:
      toSignDocument - DSSDocument the to be signed PDF
      parameters - PAdESSignatureParameters
      Returns:
      DSSMessageDigest
    • signDocument

      public DSSDocument signDocument(DSSDocument toSignDocument, PAdESSignatureParameters parameters, SignatureValue signatureValue)
      Description copied from interface: DocumentSignatureService
      Signs the toSignDocument with the provided signatureValue.
      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)
    • generateCMSSignedData

      protected byte[] generateCMSSignedData(DSSDocument toSignDocument, PAdESSignatureParameters parameters, SignatureValue signatureValue)
      Generates the CMSSignedData
      Parameters:
      toSignDocument - DSSDocument to be signed
      parameters - PAdESSignatureParameters
      signatureValue - SignatureValue
      Returns:
      byte array representing the CMSSignedData
    • extendDocument

      public DSSDocument extendDocument(DSSDocument toExtendDocument, PAdESSignatureParameters parameters) throws DSSException
      Description copied from interface: DocumentSignatureService
      Extends the level of the signatures in the toExtendDocument
      Parameters:
      toExtendDocument - document to extend
      parameters - set of the driving signing parameters
      Returns:
      the extended signature
      Throws:
      DSSException
    • getAvailableSignatureFields

      public List<String> getAvailableSignatureFields(DSSDocument document)
      This method returns not signed signature-fields
      Parameters:
      document - the pdf document
      Returns:
      the list of empty signature fields
    • getAvailableSignatureFields

      @Deprecated public List<String> getAvailableSignatureFields(DSSDocument document, String passwordProtection)
      Deprecated.
      since DSS 5.12. Use #getAvailableSignatureFields(document, passwordProtection.toCharArray())
      This method returns not signed signature-fields from an encrypted document
      Parameters:
      document - the pdf document
      passwordProtection - the password protection used to create the encrypted document
      Returns:
      the list of empty signature fields
    • getAvailableSignatureFields

      public List<String> getAvailableSignatureFields(DSSDocument document, char[] passwordProtection)
      This method returns not signed signature-fields from an encrypted document
      Parameters:
      document - the pdf document
      passwordProtection - the password protection used to create the encrypted document
      Returns:
      the list of empty signature fields
    • addNewSignatureField

      public DSSDocument addNewSignatureField(DSSDocument document, SignatureFieldParameters parameters)
      This method allows to add a new signature field to an existing pdf document
      Parameters:
      document - the pdf document
      parameters - the parameters with the coordinates,... of the signature field
      Returns:
      the pdf document with the new added signature field
    • addNewSignatureField

      @Deprecated public DSSDocument addNewSignatureField(DSSDocument document, SignatureFieldParameters parameters, String passwordProtection)
      Deprecated.
      since DSS 5.12. Use #addNewSignatureField(document, parameters, passwordProtection.getBytes())
      This method allows to add a new signature field to an encrypted pdf document
      Parameters:
      document - the pdf document
      parameters - the parameters with the coordinates,... of the signature field
      passwordProtection - the password protection used to create the encrypted document
      Returns:
      the pdf document with the new added signature field
    • addNewSignatureField

      public DSSDocument addNewSignatureField(DSSDocument document, SignatureFieldParameters parameters, char[] passwordProtection)
      This method allows to add a new signature field to an encrypted pdf document
      Parameters:
      document - the pdf document
      parameters - the parameters with the coordinates,... of the signature field
      passwordProtection - the password protection used to create the encrypted document
      Returns:
      the pdf document with the new added signature field
    • timestamp

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

      protected PDFSignatureService getPAdESSignatureService()
      This method is used to return a new PDFSignatureService for a signature creation
      Returns:
      PDFSignatureService
    • getContentTimestampService

      protected PDFSignatureService getContentTimestampService()
      This method is used to return a new PDFSignatureService for a content timestamp creation
      Returns:
      PDFSignatureService
    • getSignatureTimestampService

      protected PDFSignatureService getSignatureTimestampService()
      This method is used to return a new PDFSignatureService for a timestamp creation
      Returns:
      PDFSignatureService