Class DefaultPDFDocTimestampSignatureInterface

java.lang.Object
se.swedenconnect.sigval.pdf.timestamp.issue.impl.DefaultPDFDocTimestampSignatureInterface
All Implemented Interfaces:
org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureInterface, se.idsec.signservice.security.sign.pdf.PDFBoxSignatureInterface, PDFDocTimestampSignatureInterface

public class DefaultPDFDocTimestampSignatureInterface extends Object implements PDFDocTimestampSignatureInterface
Implementation of the PDF box signing interface used to add a document timestamp to a PDF document which includes a SVT token. This implementation generates the timestamp as part of this service. Another implementation of this interface could allow an external time stamp service to provide the timestamp.
Author:
Martin Lindström (martin@idsec.se), Stefan Santesson (stefan@idsec.se)
  • Constructor Details

    • DefaultPDFDocTimestampSignatureInterface

      public DefaultPDFDocTimestampSignatureInterface(PrivateKey privateKey, List<X509Certificate> certificates, String algorithm)
      Constructor.
      Parameters:
      privateKey - private signing key
      certificates - signing certificate chain
      algorithm - signing algorithm
  • Method Details

    • getCmsSignedData

      public byte[] getCmsSignedData()
      Specified by:
      getCmsSignedData in interface se.idsec.signservice.security.sign.pdf.PDFBoxSignatureInterface
    • getCmsSignedAttributes

      public byte[] getCmsSignedAttributes()
      Specified by:
      getCmsSignedAttributes in interface se.idsec.signservice.security.sign.pdf.PDFBoxSignatureInterface
    • getCertificateChain

      public List<X509Certificate> getCertificateChain()
      Specified by:
      getCertificateChain in interface PDFDocTimestampSignatureInterface
    • setSvt

      public void setSvt(String svt)
      Specified by:
      setSvt in interface PDFDocTimestampSignatureInterface
    • getSvt

      public String getSvt()
      Specified by:
      getSvt in interface PDFDocTimestampSignatureInterface
    • sign

      public byte[] sign(InputStream content) throws IOException
      SignatureInterface implementation.

      This method will be called from inside of the pdfbox and creates the PKCS #7 signature (CMS ContentInfo). The given InputStream contains the bytes that are given by the byte range.

      Specified by:
      sign in interface org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureInterface
      Parameters:
      content - the message bytes being signed (specified by ByteRange in the signature dictionary)
      Returns:
      CMS ContentInfo bytes holding the complete PKCS#7 signature structure
      Throws:
      IOException - error during signature creation
    • isPades

      public boolean isPades()
      Specified by:
      isPades in interface se.idsec.signservice.security.sign.pdf.PDFBoxSignatureInterface