Class DefaultPDFBoxSignatureInterface

java.lang.Object
se.idsec.signservice.security.sign.pdf.impl.DefaultPDFBoxSignatureInterface
All Implemented Interfaces:
org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureInterface, PDFBoxSignatureInterface

public class DefaultPDFBoxSignatureInterface extends Object implements PDFBoxSignatureInterface
Implementation of the PDF box signing interface.
Author:
Martin Lindström (martin@idsec.se), Stefan Santesson (stefan@idsec.se)
  • Constructor Details

    • DefaultPDFBoxSignatureInterface

      public DefaultPDFBoxSignatureInterface(PrivateKey privateKey, List<X509Certificate> certificates, String algorithm, AdesProfileType pades)
      Constructor.
      Parameters:
      privateKey - private signing key
      certificates - signing certificate chain
      algorithm - signing algorithm
      pades - PAdES type (may be null)
  • Method Details

    • getCmsSignedData

      public byte[] getCmsSignedData()
      Gets the result of the signing process in the form of ContentInfo holding SignedData.
      Specified by:
      getCmsSignedData in interface PDFBoxSignatureInterface
      Returns:
      the CMS ContentInfo holding SignedData
    • getCmsSignedAttributes

      public byte[] getCmsSignedAttributes()
      Gets the signed attributes from the result of the signing process.
      Specified by:
      getCmsSignedAttributes in interface PDFBoxSignatureInterface
      Returns:
      the CMS SignedAttributes
    • 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()
      Tells whether the signature should be generated according to the PAdES requirement profile.
      Specified by:
      isPades in interface PDFBoxSignatureInterface
      Returns:
      true if the signature is created as a PAdES compliant signature