Package eu.europa.esig.dss.pdf.pdfbox
Class PdfBoxSignatureService
java.lang.Object
eu.europa.esig.dss.pdf.AbstractPDFSignatureService
eu.europa.esig.dss.pdf.pdfbox.PdfBoxSignatureService
- All Implemented Interfaces:
PDFSignatureService
public class PdfBoxSignatureService extends AbstractPDFSignatureService
-
Field Summary
Fields inherited from class eu.europa.esig.dss.pdf.AbstractPDFSignatureService
serviceMode, signatureDrawerFactory
-
Constructor Summary
Constructors Constructor Description PdfBoxSignatureService(PDFServiceMode serviceMode, PdfBoxSignatureDrawerFactory signatureDrawerFactory)
Constructor for the PdfBoxSignatureService -
Method Summary
Modifier and Type Method Description DSSDocument
addDssDictionary(DSSDocument document, List<DSSDictionaryCallback> callbacks, String pwd)
This method adds the DSS dictionary (Baseline-LT)DSSDocument
addNewSignatureField(DSSDocument document, SignatureFieldParameters parameters, String pwd)
This method allows to add a new signature field to an existing encrypted pdf documentprotected void
checkDocumentPermissions(DSSDocument document, String pwd)
This method checks if the document is not encrypted or with limited edition rightsvoid
checkEncryptedAndSaveIncrementally(org.apache.pdfbox.pdmodel.PDDocument pdDocument, OutputStream outputStream, PAdESCommonParameters parameters)
byte[]
digest(DSSDocument toSignDocument, PAdESCommonParameters parameters)
Returns the digest value of a PDF documentList<String>
getAvailableSignatureFields(DSSDocument document, String pwd)
Returns not-signed signature fields from an encrypted documentprotected PdfDocumentReader
loadPdfDocumentReader(byte[] binaries, String passwordProtection)
LoadsPdfDocumentReader
instanceprotected PdfDocumentReader
loadPdfDocumentReader(DSSDocument dssDocument, String passwordProtection)
LoadsPdfDocumentReader
instancevoid
saveDocumentIncrementally(org.apache.pdfbox.pdmodel.PDDocument pdDocument, OutputStream outputStream)
void
setMDPPermission(org.apache.pdfbox.pdmodel.PDDocument doc, org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature, int accessPermissions)
Set the access permissions granted for this document in the DocMDP transform parameters dictionary.void
setSecureRandomProvider(SecureRandomProvider secureRandomProvider)
Set theSecureRandomProvider
.DSSDocument
sign(DSSDocument toSignDocument, byte[] signatureValue, PAdESCommonParameters parameters)
Signs a PDF documentMethods inherited from class eu.europa.esig.dss.pdf.AbstractPDFSignatureService
addDssDictionary, addNewSignatureField, buildKnownObjects, extractBeforeSignatureValue, getAvailableSignatureFields, getRevisions, getSignatureValue, getTokenDigest, getType, isContentValueEqualsByteRangeExtraction, isDocTimestamp, isDocumentTimestampLayer, isSignature
-
Constructor Details
-
PdfBoxSignatureService
public PdfBoxSignatureService(PDFServiceMode serviceMode, PdfBoxSignatureDrawerFactory signatureDrawerFactory)Constructor for the PdfBoxSignatureService- Parameters:
serviceMode
- current instance is used to generate DocumentTypestamp or Signature signature layersignatureDrawerFactory
- drawer factory implementation to be used
-
-
Method Details
-
setSecureRandomProvider
Set theSecureRandomProvider
. Allows to modify a custom behavior for signing of encrypted documents.- Parameters:
secureRandomProvider
-SecureRandomProvider
-
checkDocumentPermissions
Description copied from class:AbstractPDFSignatureService
This method checks if the document is not encrypted or with limited edition rights- Specified by:
checkDocumentPermissions
in classAbstractPDFSignatureService
- Parameters:
document
- the document which will be modifiedpwd
-String
password protection phrase used to encrypt the document
-
digest
Description copied from interface:PDFSignatureService
Returns the digest value of a PDF document- Parameters:
toSignDocument
- the document to be signedparameters
- the signature/timestamp parameters- Returns:
- the digest value
-
sign
public DSSDocument sign(DSSDocument toSignDocument, byte[] signatureValue, PAdESCommonParameters parameters)Description copied from interface:PDFSignatureService
Signs a PDF document- Parameters:
toSignDocument
- the pdf documentsignatureValue
- the signature valueparameters
- the signature/timestamp parameters
-
setMDPPermission
public void setMDPPermission(org.apache.pdfbox.pdmodel.PDDocument doc, org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature signature, int accessPermissions)Set the access permissions granted for this document in the DocMDP transform parameters dictionary. Details are described in the table "Entries in the DocMDP transform parameters dictionary" in the PDF specification.- Parameters:
doc
- The document.signature
- The signature object.accessPermissions
- The permission value (1, 2 or 3).
-
checkEncryptedAndSaveIncrementally
public void checkEncryptedAndSaveIncrementally(org.apache.pdfbox.pdmodel.PDDocument pdDocument, OutputStream outputStream, PAdESCommonParameters parameters) -
saveDocumentIncrementally
public void saveDocumentIncrementally(org.apache.pdfbox.pdmodel.PDDocument pdDocument, OutputStream outputStream) -
addDssDictionary
public DSSDocument addDssDictionary(DSSDocument document, List<DSSDictionaryCallback> callbacks, String pwd)Description copied from interface:PDFSignatureService
This method adds the DSS dictionary (Baseline-LT)- Parameters:
document
- the document to be extendedcallbacks
- the callbacks to retrieve the revocation data,...pwd
- the password protection used to create the encrypted document- Returns:
- the pdf document with the added dss dictionary
-
getAvailableSignatureFields
Description copied from interface:PDFSignatureService
Returns not-signed signature fields from an encrypted document- Parameters:
document
- the pdf documentpwd
- the password protection phrase used to encrypt the document- Returns:
- the list of not signed signature field names
-
addNewSignatureField
public DSSDocument addNewSignatureField(DSSDocument document, SignatureFieldParameters parameters, String pwd)Description copied from interface:PDFSignatureService
This method allows to add a new signature field to an existing encrypted pdf document- Parameters:
document
- the pdf documentparameters
- the parameters with the coordinates,... of the signature fieldpwd
- the password protection used to create the encrypted document- Returns:
- the pdf document with the new added signature field
-
loadPdfDocumentReader
protected PdfDocumentReader loadPdfDocumentReader(DSSDocument dssDocument, String passwordProtection) throws IOException, InvalidPasswordExceptionDescription copied from class:AbstractPDFSignatureService
LoadsPdfDocumentReader
instance- Specified by:
loadPdfDocumentReader
in classAbstractPDFSignatureService
- Parameters:
dssDocument
-DSSDocument
to readpasswordProtection
-String
the password used to protect the document- Throws:
IOException
- in case of loading errorInvalidPasswordException
- if the password is not provided or invalid for a protected document
-
loadPdfDocumentReader
protected PdfDocumentReader loadPdfDocumentReader(byte[] binaries, String passwordProtection) throws IOException, InvalidPasswordExceptionDescription copied from class:AbstractPDFSignatureService
LoadsPdfDocumentReader
instance- Specified by:
loadPdfDocumentReader
in classAbstractPDFSignatureService
- Parameters:
binaries
- a byte arraypasswordProtection
-String
the password used to protect the document- Throws:
IOException
- in case of loading errorInvalidPasswordException
- if the password is not provided or invalid for a protected document
-