Class DefaultPDFBoxSignatureInterface
java.lang.Object
se.idsec.signservice.security.sign.pdf.impl.DefaultPDFBoxSignatureInterface
- All Implemented Interfaces:
org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureInterface,PDFBoxSignatureInterface
Implementation of the PDF box signing interface.
- Author:
- Martin Lindström (martin@idsec.se), Stefan Santesson (stefan@idsec.se)
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultPDFBoxSignatureInterface(PrivateKey privateKey, List<X509Certificate> certificates, String algorithm, AdesProfileType pades) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]Gets the signed attributes from the result of the signing process.byte[]Gets the result of the signing process in the form of ContentInfo holding SignedData.booleanisPades()Tells whether the signature should be generated according to the PAdES requirement profile.byte[]sign(InputStream content) SignatureInterface implementation.
-
Constructor Details
-
DefaultPDFBoxSignatureInterface
public DefaultPDFBoxSignatureInterface(PrivateKey privateKey, List<X509Certificate> certificates, String algorithm, AdesProfileType pades) Constructor.- Parameters:
privateKey- private signing keycertificates- signing certificate chainalgorithm- signing algorithmpades- 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:
getCmsSignedDatain interfacePDFBoxSignatureInterface- Returns:
- the CMS ContentInfo holding SignedData
-
getCmsSignedAttributes
public byte[] getCmsSignedAttributes()Gets the signed attributes from the result of the signing process.- Specified by:
getCmsSignedAttributesin interfacePDFBoxSignatureInterface- Returns:
- the CMS SignedAttributes
-
sign
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:
signin interfaceorg.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:
isPadesin interfacePDFBoxSignatureInterface- Returns:
- true if the signature is created as a PAdES compliant signature
-