Package eu.europa.esig.dss.pdf
Class AbstractPDFSignatureService
java.lang.Object
eu.europa.esig.dss.pdf.AbstractPDFSignatureService
- All Implemented Interfaces:
PDFSignatureService
- Direct Known Subclasses:
ITextPDFSignatureService,PdfBoxSignatureService
public abstract class AbstractPDFSignatureService extends Object implements PDFSignatureService
-
Field Summary
Fields Modifier and Type Field Description protected PDFServiceModeserviceModeprotected SignatureDrawerFactorysignatureDrawerFactory -
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractPDFSignatureService(PDFServiceMode serviceMode, SignatureDrawerFactory signatureDrawerFactory)Constructor for the PDFSignatureService -
Method Summary
Modifier and Type Method Description DSSDocumentaddDssDictionary(DSSDocument document, List<DSSDictionaryCallback> callbacks)This method adds the DSS dictionary (Baseline-LT)DSSDocumentaddNewSignatureField(DSSDocument document, SignatureFieldParameters parameters)This method allows to add a new signature field to an existing pdf documentprotected Map<String,Long>buildKnownObjects(List<DSSDictionaryCallback> callbacks)This method builds a Map of known Objects (extracted from previous DSS Dictionaries).protected abstract voidcheckDocumentPermissions(DSSDocument toSignDocument, String pwd)This method checks if the document is not encrypted or with limited edition rightsprotected byte[]extractBeforeSignatureValue(ByteRange byteRange, byte[] signedContent)List<String>getAvailableSignatureFields(DSSDocument document)This method returns not signed signature-fieldsList<PdfRevision>getRevisions(DSSDocument document, String pwd)Retrieves revisions from a PDF documentprotected byte[]getSignatureValue(DSSDocument dssDocument, ByteRange byteRange)protected StringgetTokenDigest(Token token)protected StringgetType()protected booleanisContentValueEqualsByteRangeExtraction(DSSDocument document, ByteRange byteRange, byte[] cms, List<String> signatureFieldNames)protected booleanisDocTimestamp(PdfSignatureDictionary pdfSigDict)Checks if the given signature dictionary represents a DocTimeStampprotected booleanisDocumentTimestampLayer()protected booleanisSignature(PdfSignatureDictionary pdfSigDict)Checks if the given signature dictionary represents a Signatureprotected abstract PdfDocumentReaderloadPdfDocumentReader(byte[] binaries, String passwordProtection)LoadsPdfDocumentReaderinstanceprotected abstract PdfDocumentReaderloadPdfDocumentReader(DSSDocument dssDocument, String passwordProtection)LoadsPdfDocumentReaderinstanceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface eu.europa.esig.dss.pdf.PDFSignatureService
addDssDictionary, addNewSignatureField, digest, getAvailableSignatureFields, sign
-
Field Details
-
Constructor Details
-
AbstractPDFSignatureService
protected AbstractPDFSignatureService(PDFServiceMode serviceMode, SignatureDrawerFactory signatureDrawerFactory)Constructor for the PDFSignatureService- Parameters:
serviceMode- current instance is used to generate DocumentTypestamp or Signature signature layersignatureDrawerFactory- the factory ofSignatureDrawer
-
-
Method Details
-
isDocumentTimestampLayer
protected boolean isDocumentTimestampLayer() -
getType
-
checkDocumentPermissions
This method checks if the document is not encrypted or with limited edition rights- Parameters:
toSignDocument- the document which will be modifiedpwd-Stringpassword protection phrase used to encrypt the document
-
getRevisions
Description copied from interface:PDFSignatureServiceRetrieves revisions from a PDF document- Specified by:
getRevisionsin interfacePDFSignatureService- Parameters:
document- the document to extract revisions frompwd- the password protection phrase used to encrypt the PDF document use 'null' value for not an encrypted document- Returns:
- list of extracted
PdfRevisions
-
addDssDictionary
Description copied from interface:PDFSignatureServiceThis method adds the DSS dictionary (Baseline-LT)- Specified by:
addDssDictionaryin interfacePDFSignatureService- Parameters:
document- the document to be extendedcallbacks- the callbacks to retrieve the revocation data,...- Returns:
- the pdf document with the added dss dictionary
-
getAvailableSignatureFields
Description copied from interface:PDFSignatureServiceThis method returns not signed signature-fields- Specified by:
getAvailableSignatureFieldsin interfacePDFSignatureService- Parameters:
document- the pdf document- Returns:
- the list of empty signature fields
-
addNewSignatureField
Description copied from interface:PDFSignatureServiceThis method allows to add a new signature field to an existing pdf document- Specified by:
addNewSignatureFieldin interfacePDFSignatureService- Parameters:
document- the pdf documentparameters- the parameters with the coordinates,... of the signature field- Returns:
- the pdf document with the new added signature field
-
loadPdfDocumentReader
protected abstract PdfDocumentReader loadPdfDocumentReader(DSSDocument dssDocument, String passwordProtection) throws IOException, InvalidPasswordExceptionLoadsPdfDocumentReaderinstance- Parameters:
dssDocument-DSSDocumentto readpasswordProtection-Stringthe 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 abstract PdfDocumentReader loadPdfDocumentReader(byte[] binaries, String passwordProtection) throws IOException, InvalidPasswordExceptionLoadsPdfDocumentReaderinstance- Parameters:
binaries- a byte arraypasswordProtection-Stringthe 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
-
isContentValueEqualsByteRangeExtraction
protected boolean isContentValueEqualsByteRangeExtraction(DSSDocument document, ByteRange byteRange, byte[] cms, List<String> signatureFieldNames) -
getSignatureValue
protected byte[] getSignatureValue(DSSDocument dssDocument, ByteRange byteRange) throws IOException- Throws:
IOException
-
extractBeforeSignatureValue
-
isDocTimestamp
Checks if the given signature dictionary represents a DocTimeStamp- Parameters:
pdfSigDict-PdfSignatureDictionaryto check- Returns:
- TRUE if the signature dictionary represents a DocTimeStamp, FALSE otherwise
-
isSignature
Checks if the given signature dictionary represents a Signature- Parameters:
pdfSigDict-PdfSignatureDictionaryto check- Returns:
- TRUE if the signature dictionary represents a Signature, FALSE otherwise
-
buildKnownObjects
This method builds a Map of known Objects (extracted from previous DSS Dictionaries). This map will be used to avoid duplicate the same objects between layers.- Parameters:
callbacks-- Returns:
-
getTokenDigest
-