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 PDFServiceMode
serviceMode
protected SignatureDrawerFactory
signatureDrawerFactory
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractPDFSignatureService(PDFServiceMode serviceMode, SignatureDrawerFactory signatureDrawerFactory)
Constructor for the PDFSignatureService -
Method Summary
Modifier and Type Method Description DSSDocument
addDssDictionary(DSSDocument document, List<DSSDictionaryCallback> callbacks)
This method adds the DSS dictionary (Baseline-LT)DSSDocument
addNewSignatureField(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 void
checkDocumentPermissions(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 String
getTokenDigest(Token token)
protected String
getType()
protected boolean
isContentValueEqualsByteRangeExtraction(DSSDocument document, ByteRange byteRange, byte[] cms, List<String> signatureFieldNames)
protected boolean
isDocTimestamp(PdfSignatureDictionary pdfSigDict)
Checks if the given signature dictionary represents a DocTimeStampprotected boolean
isDocumentTimestampLayer()
protected boolean
isSignature(PdfSignatureDictionary pdfSigDict)
Checks if the given signature dictionary represents a Signatureprotected abstract PdfDocumentReader
loadPdfDocumentReader(byte[] binaries, String passwordProtection)
LoadsPdfDocumentReader
instanceprotected abstract PdfDocumentReader
loadPdfDocumentReader(DSSDocument dssDocument, String passwordProtection)
LoadsPdfDocumentReader
instanceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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
-String
password protection phrase used to encrypt the document
-
getRevisions
Description copied from interface:PDFSignatureService
Retrieves revisions from a PDF document- Specified by:
getRevisions
in 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
PdfRevision
s
-
addDssDictionary
Description copied from interface:PDFSignatureService
This method adds the DSS dictionary (Baseline-LT)- Specified by:
addDssDictionary
in 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:PDFSignatureService
This method returns not signed signature-fields- Specified by:
getAvailableSignatureFields
in interfacePDFSignatureService
- Parameters:
document
- the pdf document- Returns:
- the list of empty signature fields
-
addNewSignatureField
Description copied from interface:PDFSignatureService
This method allows to add a new signature field to an existing pdf document- Specified by:
addNewSignatureField
in 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, InvalidPasswordExceptionLoadsPdfDocumentReader
instance- 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 abstract PdfDocumentReader loadPdfDocumentReader(byte[] binaries, String passwordProtection) throws IOException, InvalidPasswordExceptionLoadsPdfDocumentReader
instance- 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
-
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
-PdfSignatureDictionary
to check- Returns:
- TRUE if the signature dictionary represents a DocTimeStamp, FALSE otherwise
-
isSignature
Checks if the given signature dictionary represents a Signature- Parameters:
pdfSigDict
-PdfSignatureDictionary
to 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
-