Class DocumentRevisionsValidator
- java.lang.Object
-
- com.itextpdf.signatures.validation.DocumentRevisionsValidator
-
public class DocumentRevisionsValidator extends java.lang.ObjectValidator, which is responsible for document revisions validation according to doc-MDP and field-MDP rules.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.lang.StringACCESS_PERMISSIONS_ADDEDprivate AccessPermissionsaccessPermissions(package private) static java.lang.StringACROFORM_REMOVEDprivate java.util.Set<PdfDictionary>addedTaggedObjects(package private) static java.lang.StringANNOTATIONS_MODIFIED(package private) static java.lang.StringBASE_VERSION_DECREASED(package private) static java.lang.StringBASE_VERSION_EXTENSION_NOT_PARSABLEprivate java.util.Set<PdfObject>checkedAnnots(package private) static java.lang.StringDEVELOPER_EXTENSION_REMOVED(package private) static java.lang.StringDIRECT_OBJECT(package private) static java.lang.StringDOC_MDP_CHECK(package private) static java.lang.StringDOCUMENT_WITHOUT_SIGNATURES(package private) static java.lang.StringDSS_REMOVEDprivate static PdfDictionaryDUMMY_STRUCT_TREE_ELEMENTprivate static floatEPS(package private) static java.lang.StringEXTENSION_LEVEL_DECREASED(package private) static java.lang.StringEXTENSIONS_REMOVED(package private) static java.lang.StringEXTENSIONS_TYPE(package private) static java.lang.StringFIELD_MDP_CHECK(package private) static java.lang.StringFIELD_NOT_DICTIONARY(package private) static java.lang.StringFIELD_REMOVED(package private) static java.lang.StringLOCKED_FIELD_KIDS_ADDED(package private) static java.lang.StringLOCKED_FIELD_KIDS_REMOVED(package private) static java.lang.StringLOCKED_FIELD_MODIFIED(package private) static java.lang.StringLOCKED_FIELD_REMOVEDprivate java.util.Set<java.lang.String>lockedFieldsprivate IMetaInfometaInfoprivate java.util.Set<PdfDictionary>newlyAddedFields(package private) static java.lang.StringNOT_ALLOWED_ACROFORM_CHANGES(package private) static java.lang.StringNOT_ALLOWED_CATALOG_CHANGES(package private) static java.lang.StringNOT_ALLOWED_CERTIFICATION_SIGNATURE(package private) static java.lang.StringOBJECT_REMOVED(package private) static java.lang.StringPAGE_ANNOTATIONS_MODIFIED(package private) static java.lang.StringPAGE_MODIFIED(package private) static java.lang.StringPAGES_MODIFIED(package private) static java.lang.StringPERMISSION_REMOVED(package private) static java.lang.StringPERMISSIONS_REMOVED(package private) static java.lang.StringPERMISSIONS_TYPEprivate SignatureValidationPropertiesproperties(package private) static java.lang.StringREFERENCE_REMOVEDprivate java.util.Set<PdfDictionary>removedTaggedObjectsprivate AccessPermissionsrequestedAccessPermissions(package private) static java.lang.StringREVISIONS_READING_EXCEPTION(package private) static java.lang.StringREVISIONS_RETRIEVAL_FAILED(package private) static java.lang.StringREVISIONS_RETRIEVAL_FAILED_UNEXPECTEDLY(package private) static java.lang.StringSIGNATURE_MODIFIED(package private) static java.lang.StringSIGNATURE_REVISION_NOT_FOUND(package private) static java.lang.StringSTRUCT_TREE_CONTENT_MODIFIED(package private) static java.lang.StringSTRUCT_TREE_ELEMENT_MODIFIED(package private) static java.lang.StringSTRUCT_TREE_ROOT_ADDED(package private) static java.lang.StringSTRUCT_TREE_ROOT_MODIFIED(package private) static java.lang.StringSTRUCT_TREE_ROOT_NOT_DICT(package private) static java.lang.StringSTRUCT_TREE_ROOT_REMOVED(package private) static java.lang.StringTABS_MODIFIED(package private) static java.lang.StringTOO_MANY_CERTIFICATION_SIGNATURES(package private) static java.lang.StringUNEXPECTED_ENTRY_IN_XREF(package private) static java.lang.StringUNEXPECTED_FORM_FIELDprivate ReportItem.ReportItemStatusunexpectedXrefChangesStatus(package private) static java.lang.StringUNKNOWN_ACCESS_PERMISSIONS(package private) static java.lang.StringUNRECOGNIZED_ACTIONprivate Tuple2<java.util.Set<PdfIndirectReference>,java.util.Set<PdfIndirectReference>>usuallyModifiedObjects
-
Constructor Summary
Constructors Modifier Constructor Description protectedDocumentRevisionsValidator(ValidatorChainBuilder chainBuilder)Creates new instance ofDocumentRevisionsValidator.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddAllNestedArrayEntries(java.util.Set<PdfIndirectReference> allowedReferences, PdfArray pdfArray)private voidaddAllNestedDictionaryEntries(java.util.Set<PdfIndirectReference> allowedReferences, PdfDictionary dictionary)private voidaddPageEntriesToSet(PdfDictionary page, java.util.Set<PdfIndirectReference> set)private voidaddStructTreeElementsToSet(PdfArray structTreeRootKids, java.util.Set<PdfIndirectReference> set)private voidaddStructTreeElementsToSet(PdfObject structTreeRootKids, java.util.Set<PdfIndirectReference> set)private voidaddWidgetAnnotation(java.util.Set<PdfIndirectReference> allowedReferences, PdfDictionary annotDict)private booleancheckAllowedReferences(java.util.Set<PdfIndirectReference> currentAllowedReferences, java.util.Set<PdfIndirectReference> previousAllowedReferences, PdfIndirectReference indirectReference, PdfDocument documentWithoutRevision)private voidcollectRemovedAndAddedAnnotations(PdfArray previousAnnotations, PdfArray currentAnnotations)private booleancompareAcroForms(PdfDictionary prevAcroForm, PdfDictionary currAcroForm, ValidationReport report)private booleancompareAcroFormsWithFieldMDP(PdfDocument documentWithoutRevision, PdfDocument documentWithRevision, ValidationReport report)private booleancompareCatalogs(PdfDocument documentWithoutRevision, PdfDocument documentWithRevision, ValidationReport report, ValidationContext context)private booleancompareDss(PdfObject previousDss, PdfObject currentDss, ValidationReport report)private booleancompareExtensions(PdfObject previousExtensions, PdfObject currentExtensions, ValidationReport report)private booleancompareFields(PdfDictionary previousField, PdfDictionary currentField, ValidationReport report)DocMDP level >= 2 allows setting values of the fields and accordingly update the widget appearances of them.private booleancompareFormFields(PdfArray prevFields, PdfArray currFields, ValidationReport report)private booleancompareFormFieldWithFieldMDP(PdfDictionary previousField, PdfDictionary currentField, java.lang.String fieldName, ValidationReport report)private booleancompareIndirectReferencesObjNums(PdfObject prevObj, PdfObject currObj, ValidationReport report, java.lang.String type)private booleancomparePageAnnotations(PdfArray prevAnnots, PdfArray currAnnots, ValidationReport report)private booleancomparePageAnnotations(PdfDictionary prevAnnot, PdfDictionary currAnnot, ValidationReport report)private booleancomparePages(PdfDictionary prevPages, PdfDictionary currPages, ValidationReport report)private static booleancomparePdfArrays(PdfArray array1, PdfArray array2, java.util.List<Tuple2<PdfObject,PdfObject>> visitedObjects, Tuple2<java.util.Set<PdfIndirectReference>,java.util.Set<PdfIndirectReference>> usuallyModifiedObjects)private static booleancomparePdfDictionaries(PdfDictionary dictionary1, PdfDictionary dictionary2, java.util.List<Tuple2<PdfObject,PdfObject>> visitedObjects, Tuple2<java.util.Set<PdfIndirectReference>,java.util.Set<PdfIndirectReference>> usuallyModifiedObjects)private static booleancomparePdfObjects(PdfObject pdfObject1, PdfObject pdfObject2, Tuple2<java.util.Set<PdfIndirectReference>,java.util.Set<PdfIndirectReference>> usuallyModifiedObjects)private static booleancomparePdfObjects(PdfObject pdfObject1, PdfObject pdfObject2, java.util.List<Tuple2<PdfObject,PdfObject>> visitedObjects, Tuple2<java.util.Set<PdfIndirectReference>,java.util.Set<PdfIndirectReference>> usuallyModifiedObjects)private static booleancomparePdfStreams(PdfStream stream1, PdfStream stream2, java.util.List<Tuple2<PdfObject,PdfObject>> visitedObjects, Tuple2<java.util.Set<PdfIndirectReference>,java.util.Set<PdfIndirectReference>> usuallyModifiedObjects)private booleancomparePermissions(PdfObject previousPerms, PdfObject currentPerms, ValidationReport report)private booleancompareSignatureDictionaries(PdfObject prevSigDict, PdfObject curSigDict, ValidationReport report)private booleancompareSignatureReferenceDictionaries(PdfArray previousReferences, PdfArray currentReferences, ValidationReport report)private booleancompareStructTreeContents(PdfObject previousStructTreeContent, PdfObject currentStructTreeContent, ValidationReport report)private booleancompareStructTreeElementKids(PdfDictionary previousStructElement, PdfDictionary currentStructElement, ValidationReport report)private booleancompareStructTreeElements(PdfDictionary previousStructElement, PdfDictionary currentStructElement, ValidationReport report)private booleancompareStructTreeRoot(PdfObject previousStructTreeRoot, PdfObject currentStructTreeRoot, ValidationReport report)private booleancompareTabs(PdfName previousTabs, PdfName currentTabs)private booleancompareWidgets(PdfArray prevFields, PdfArray currFields, ValidationReport report)private PdfDictionarycopyAcroformDictionary(PdfDictionary acroForm)private PdfDictionarycopyCatalogEntriesToCompare(PdfDictionary catalog)private PdfDictionarycopyFieldDictionary(PdfDictionary field)private java.util.Set<PdfIndirectReference>createAllowedDssEntries(PdfDocument document)private voidcreateAllowedFormFieldEntries(PdfArray fields, java.util.Set<PdfIndirectReference> allowedReferences)private java.util.Collection<PdfIndirectReference>createAllowedPagesEntries(PdfDictionary pagesDictionary)private java.util.Set<PdfIndirectReference>createAllowedReferences(PdfDocument document)private java.util.Set<PdfIndirectReference>createAllowedStructTreeRootEntries(PdfDictionary structTreeRoot)private voidcreateAllowedStructTreeRootKidsEntries(PdfArray structTreeRootKids, java.util.Set<PdfIndirectReference> allowedReferences)private voidcreateAllowedStructTreeRootKidsEntries(PdfObject structTreeRootKids, java.util.Set<PdfIndirectReference> allowedReferences)private voidcreateAllowedTreeEntries(PdfObject treeNode, java.util.Set<PdfIndirectReference> allowedReferences, PdfName contentName)private booleancreateDocumentAndPerformOperation(DocumentRevision revision, PdfDocument originalDocument, ValidationReport report, java.util.function.Function<PdfDocument,java.lang.Boolean> operation)private static java.io.InputStreamcreateInputStreamFromRevision(PdfDocument originalDocument, DocumentRevision revision)private java.util.Set<PdfIndirectReference>createUsuallyModifiedObjectsSet(PdfDocument document)(package private) AccessPermissionsgetAccessPermissions()private PdfArraygetAnnotsNotAllowedToBeModified(PdfDictionary page)private static PdfObjectgetObjectFromStructTreeContent(PdfObject structTreeContent)private booleanisAllowedSignatureField(PdfDictionary field, ValidationReport report)DocMDP level <=2 allows adding new fields in the following cases: docMDP level 1: allows adding only DocTimeStamp signature fields; docMDP level 2: same as level 1 and also adding and then signing signature fields, so signature dictionary shouldn't be null.private booleanisAllowedStreamObj(PdfIndirectReference indirectReference, PdfDocument document)private booleanisCertificationSignature(PdfSignature signature)private static booleanisLinearizedPdf(PdfDocument originalDocument)private static booleanisMaxGenerationObject(PdfIndirectReference indirectReference)private static booleanisSameReference(PdfIndirectReference indirectReference1, PdfIndirectReference indirectReference2)private static booleanisStructTreeElement(PdfObject object)private voidlockAllFormFields(DocumentRevision revision, java.util.List<java.lang.String> excludedFields, PdfDocument originalDocument, ValidationReport report)private voidmergeRevisionsInLinearizedDocument(PdfDocument document, java.util.List<DocumentRevision> documentRevisions)private java.util.Set<PdfDictionary>populateFormFields(PdfArray fieldsArray)private java.util.List<PdfDictionary>populateWidgetAnnotations(PdfArray fieldsArray)private voidremoveAppearanceRelatedProperties(PdfDictionary annotDict)private voidresetClassFields()private PdfDictionaryretrieveTheSameField(java.util.Set<PdfDictionary> currFields, PdfDictionary previousField)private booleanrevisionContainsSignature(DocumentRevision revision, java.lang.String signature, PdfDocument originalDocument, ValidationReport report)DocumentRevisionsValidatorsetAccessPermissions(AccessPermissions accessPermissions)Set access permissions to be used during docMDP validation.DocumentRevisionsValidatorsetEventCountingMetaInfo(IMetaInfo metaInfo)Sets theIMetaInfothat will be used during newPdfDocumentcreations.DocumentRevisionsValidatorsetUnexpectedXrefChangesStatus(ReportItem.ReportItemStatus status)Set the status to be used for the report items produced during docMDP validation in case revision contains unexpected changes in the XREF table.private booleanstopValidation(ValidationReport result, ValidationContext validationContext)private voidupdateApprovalSignatureAccessPermissions(PdfDictionary signatureField, ValidationReport report)private voidupdateApprovalSignatureFieldLock(DocumentRevision revision, PdfDictionary signatureField, PdfDocument document, ValidationReport report)private voidupdateCertificationSignatureAccessPermissions(PdfSignature signature, ValidationReport report)ValidationReportvalidateAllDocumentRevisions(ValidationContext context, PdfDocument document)Validate all document revisions according to docMDP and fieldMDP transform methods.(package private) ValidationReportvalidateAllDocumentRevisions(ValidationContext context, PdfDocument document, java.lang.String signatureName)Validate all document revisions according to docMDP and fieldMDP transform methods and collect validation report related to the single signature field checks if specified.(package private) voidvalidateRevision(DocumentRevision previousRevision, DocumentRevision currentRevision, PdfDocument originalDocument, ValidationReport validationReport, ValidationContext context)private booleanvalidateRevision(ValidationReport validationReport, ValidationContext context, PdfDocument documentWithoutRevision, PdfDocument documentWithRevision, DocumentRevision currentRevision)
-
-
-
Field Detail
-
DOC_MDP_CHECK
static final java.lang.String DOC_MDP_CHECK
- See Also:
- Constant Field Values
-
FIELD_MDP_CHECK
static final java.lang.String FIELD_MDP_CHECK
- See Also:
- Constant Field Values
-
ACCESS_PERMISSIONS_ADDED
static final java.lang.String ACCESS_PERMISSIONS_ADDED
- See Also:
- Constant Field Values
-
ACROFORM_REMOVED
static final java.lang.String ACROFORM_REMOVED
- See Also:
- Constant Field Values
-
ANNOTATIONS_MODIFIED
static final java.lang.String ANNOTATIONS_MODIFIED
- See Also:
- Constant Field Values
-
BASE_VERSION_DECREASED
static final java.lang.String BASE_VERSION_DECREASED
- See Also:
- Constant Field Values
-
BASE_VERSION_EXTENSION_NOT_PARSABLE
static final java.lang.String BASE_VERSION_EXTENSION_NOT_PARSABLE
- See Also:
- Constant Field Values
-
DEVELOPER_EXTENSION_REMOVED
static final java.lang.String DEVELOPER_EXTENSION_REMOVED
- See Also:
- Constant Field Values
-
DIRECT_OBJECT
static final java.lang.String DIRECT_OBJECT
- See Also:
- Constant Field Values
-
DOCUMENT_WITHOUT_SIGNATURES
static final java.lang.String DOCUMENT_WITHOUT_SIGNATURES
- See Also:
- Constant Field Values
-
DSS_REMOVED
static final java.lang.String DSS_REMOVED
- See Also:
- Constant Field Values
-
EXTENSIONS_REMOVED
static final java.lang.String EXTENSIONS_REMOVED
- See Also:
- Constant Field Values
-
EXTENSIONS_TYPE
static final java.lang.String EXTENSIONS_TYPE
- See Also:
- Constant Field Values
-
EXTENSION_LEVEL_DECREASED
static final java.lang.String EXTENSION_LEVEL_DECREASED
- See Also:
- Constant Field Values
-
FIELD_NOT_DICTIONARY
static final java.lang.String FIELD_NOT_DICTIONARY
- See Also:
- Constant Field Values
-
FIELD_REMOVED
static final java.lang.String FIELD_REMOVED
- See Also:
- Constant Field Values
-
LOCKED_FIELD_KIDS_ADDED
static final java.lang.String LOCKED_FIELD_KIDS_ADDED
- See Also:
- Constant Field Values
-
LOCKED_FIELD_KIDS_REMOVED
static final java.lang.String LOCKED_FIELD_KIDS_REMOVED
- See Also:
- Constant Field Values
-
LOCKED_FIELD_MODIFIED
static final java.lang.String LOCKED_FIELD_MODIFIED
- See Also:
- Constant Field Values
-
LOCKED_FIELD_REMOVED
static final java.lang.String LOCKED_FIELD_REMOVED
- See Also:
- Constant Field Values
-
NOT_ALLOWED_ACROFORM_CHANGES
static final java.lang.String NOT_ALLOWED_ACROFORM_CHANGES
- See Also:
- Constant Field Values
-
NOT_ALLOWED_CATALOG_CHANGES
static final java.lang.String NOT_ALLOWED_CATALOG_CHANGES
- See Also:
- Constant Field Values
-
NOT_ALLOWED_CERTIFICATION_SIGNATURE
static final java.lang.String NOT_ALLOWED_CERTIFICATION_SIGNATURE
- See Also:
- Constant Field Values
-
OBJECT_REMOVED
static final java.lang.String OBJECT_REMOVED
- See Also:
- Constant Field Values
-
PAGES_MODIFIED
static final java.lang.String PAGES_MODIFIED
- See Also:
- Constant Field Values
-
PAGE_ANNOTATIONS_MODIFIED
static final java.lang.String PAGE_ANNOTATIONS_MODIFIED
- See Also:
- Constant Field Values
-
PAGE_MODIFIED
static final java.lang.String PAGE_MODIFIED
- See Also:
- Constant Field Values
-
TABS_MODIFIED
static final java.lang.String TABS_MODIFIED
- See Also:
- Constant Field Values
-
PERMISSIONS_REMOVED
static final java.lang.String PERMISSIONS_REMOVED
- See Also:
- Constant Field Values
-
PERMISSIONS_TYPE
static final java.lang.String PERMISSIONS_TYPE
- See Also:
- Constant Field Values
-
PERMISSION_REMOVED
static final java.lang.String PERMISSION_REMOVED
- See Also:
- Constant Field Values
-
REFERENCE_REMOVED
static final java.lang.String REFERENCE_REMOVED
- See Also:
- Constant Field Values
-
REVISIONS_READING_EXCEPTION
static final java.lang.String REVISIONS_READING_EXCEPTION
- See Also:
- Constant Field Values
-
REVISIONS_RETRIEVAL_FAILED
static final java.lang.String REVISIONS_RETRIEVAL_FAILED
- See Also:
- Constant Field Values
-
REVISIONS_RETRIEVAL_FAILED_UNEXPECTEDLY
static final java.lang.String REVISIONS_RETRIEVAL_FAILED_UNEXPECTEDLY
- See Also:
- Constant Field Values
-
SIGNATURE_MODIFIED
static final java.lang.String SIGNATURE_MODIFIED
- See Also:
- Constant Field Values
-
SIGNATURE_REVISION_NOT_FOUND
static final java.lang.String SIGNATURE_REVISION_NOT_FOUND
- See Also:
- Constant Field Values
-
STRUCT_TREE_CONTENT_MODIFIED
static final java.lang.String STRUCT_TREE_CONTENT_MODIFIED
- See Also:
- Constant Field Values
-
STRUCT_TREE_ELEMENT_MODIFIED
static final java.lang.String STRUCT_TREE_ELEMENT_MODIFIED
- See Also:
- Constant Field Values
-
STRUCT_TREE_ROOT_ADDED
static final java.lang.String STRUCT_TREE_ROOT_ADDED
- See Also:
- Constant Field Values
-
STRUCT_TREE_ROOT_MODIFIED
static final java.lang.String STRUCT_TREE_ROOT_MODIFIED
- See Also:
- Constant Field Values
-
STRUCT_TREE_ROOT_NOT_DICT
static final java.lang.String STRUCT_TREE_ROOT_NOT_DICT
- See Also:
- Constant Field Values
-
STRUCT_TREE_ROOT_REMOVED
static final java.lang.String STRUCT_TREE_ROOT_REMOVED
- See Also:
- Constant Field Values
-
TOO_MANY_CERTIFICATION_SIGNATURES
static final java.lang.String TOO_MANY_CERTIFICATION_SIGNATURES
- See Also:
- Constant Field Values
-
UNEXPECTED_ENTRY_IN_XREF
static final java.lang.String UNEXPECTED_ENTRY_IN_XREF
- See Also:
- Constant Field Values
-
UNEXPECTED_FORM_FIELD
static final java.lang.String UNEXPECTED_FORM_FIELD
- See Also:
- Constant Field Values
-
UNKNOWN_ACCESS_PERMISSIONS
static final java.lang.String UNKNOWN_ACCESS_PERMISSIONS
- See Also:
- Constant Field Values
-
UNRECOGNIZED_ACTION
static final java.lang.String UNRECOGNIZED_ACTION
- See Also:
- Constant Field Values
-
EPS
private static final float EPS
- See Also:
- Constant Field Values
-
DUMMY_STRUCT_TREE_ELEMENT
private static final PdfDictionary DUMMY_STRUCT_TREE_ELEMENT
-
lockedFields
private final java.util.Set<java.lang.String> lockedFields
-
properties
private final SignatureValidationProperties properties
-
metaInfo
private IMetaInfo metaInfo
-
accessPermissions
private AccessPermissions accessPermissions
-
requestedAccessPermissions
private AccessPermissions requestedAccessPermissions
-
unexpectedXrefChangesStatus
private ReportItem.ReportItemStatus unexpectedXrefChangesStatus
-
checkedAnnots
private java.util.Set<PdfObject> checkedAnnots
-
newlyAddedFields
private java.util.Set<PdfDictionary> newlyAddedFields
-
removedTaggedObjects
private java.util.Set<PdfDictionary> removedTaggedObjects
-
addedTaggedObjects
private java.util.Set<PdfDictionary> addedTaggedObjects
-
usuallyModifiedObjects
private Tuple2<java.util.Set<PdfIndirectReference>,java.util.Set<PdfIndirectReference>> usuallyModifiedObjects
-
-
Constructor Detail
-
DocumentRevisionsValidator
protected DocumentRevisionsValidator(ValidatorChainBuilder chainBuilder)
Creates new instance ofDocumentRevisionsValidator.- Parameters:
chainBuilder- SeeValidatorChainBuilder
-
-
Method Detail
-
setEventCountingMetaInfo
public DocumentRevisionsValidator setEventCountingMetaInfo(IMetaInfo metaInfo)
Sets theIMetaInfothat will be used during newPdfDocumentcreations.- Parameters:
metaInfo- meta info to set- Returns:
- the same
DocumentRevisionsValidatorinstance.
-
setAccessPermissions
public DocumentRevisionsValidator setAccessPermissions(AccessPermissions accessPermissions)
Set access permissions to be used during docMDP validation. If value is provided, access permission related signature parameters will be ignored during the validation.- Parameters:
accessPermissions-AccessPermissionsdocMDP validation level- Returns:
- the same
DocumentRevisionsValidatorinstance.
-
setUnexpectedXrefChangesStatus
public DocumentRevisionsValidator setUnexpectedXrefChangesStatus(ReportItem.ReportItemStatus status)
Set the status to be used for the report items produced during docMDP validation in case revision contains unexpected changes in the XREF table. Default value isReportItem.ReportItemStatus.INFO.- Parameters:
status-ReportItem.ReportItemStatusto be used in case of unexpected changes in the XREF table- Returns:
- the same
DocumentRevisionsValidatorinstance.
-
validateAllDocumentRevisions
public ValidationReport validateAllDocumentRevisions(ValidationContext context, PdfDocument document)
Validate all document revisions according to docMDP and fieldMDP transform methods.- Parameters:
context- the validation context in which to validate document revisionsdocument- the document to be validated- Returns:
ValidationReportwhich contains detailed validation results.
-
validateAllDocumentRevisions
ValidationReport validateAllDocumentRevisions(ValidationContext context, PdfDocument document, java.lang.String signatureName)
Validate all document revisions according to docMDP and fieldMDP transform methods and collect validation report related to the single signature field checks if specified.- Parameters:
context- the validation context in which to validate document revisionsdocument- the document to be validatedsignatureName- signature field to collect validation result for. If null, all signatures will be checked- Returns:
ValidationReportwhich contains detailed validation results.
-
validateRevision
void validateRevision(DocumentRevision previousRevision, DocumentRevision currentRevision, PdfDocument originalDocument, ValidationReport validationReport, ValidationContext context)
-
mergeRevisionsInLinearizedDocument
private void mergeRevisionsInLinearizedDocument(PdfDocument document, java.util.List<DocumentRevision> documentRevisions)
-
validateRevision
private boolean validateRevision(ValidationReport validationReport, ValidationContext context, PdfDocument documentWithoutRevision, PdfDocument documentWithRevision, DocumentRevision currentRevision)
-
getAccessPermissions
AccessPermissions getAccessPermissions()
-
createInputStreamFromRevision
private static java.io.InputStream createInputStreamFromRevision(PdfDocument originalDocument, DocumentRevision revision)
-
isLinearizedPdf
private static boolean isLinearizedPdf(PdfDocument originalDocument)
-
isStructTreeElement
private static boolean isStructTreeElement(PdfObject object)
-
getObjectFromStructTreeContent
private static PdfObject getObjectFromStructTreeContent(PdfObject structTreeContent)
-
stopValidation
private boolean stopValidation(ValidationReport result, ValidationContext validationContext)
-
updateApprovalSignatureAccessPermissions
private void updateApprovalSignatureAccessPermissions(PdfDictionary signatureField, ValidationReport report)
-
updateApprovalSignatureFieldLock
private void updateApprovalSignatureFieldLock(DocumentRevision revision, PdfDictionary signatureField, PdfDocument document, ValidationReport report)
-
lockAllFormFields
private void lockAllFormFields(DocumentRevision revision, java.util.List<java.lang.String> excludedFields, PdfDocument originalDocument, ValidationReport report)
-
updateCertificationSignatureAccessPermissions
private void updateCertificationSignatureAccessPermissions(PdfSignature signature, ValidationReport report)
-
isCertificationSignature
private boolean isCertificationSignature(PdfSignature signature)
-
revisionContainsSignature
private boolean revisionContainsSignature(DocumentRevision revision, java.lang.String signature, PdfDocument originalDocument, ValidationReport report)
-
createDocumentAndPerformOperation
private boolean createDocumentAndPerformOperation(DocumentRevision revision, PdfDocument originalDocument, ValidationReport report, java.util.function.Function<PdfDocument,java.lang.Boolean> operation)
-
resetClassFields
private void resetClassFields()
-
compareCatalogs
private boolean compareCatalogs(PdfDocument documentWithoutRevision, PdfDocument documentWithRevision, ValidationReport report, ValidationContext context)
-
compareStructTreeRoot
private boolean compareStructTreeRoot(PdfObject previousStructTreeRoot, PdfObject currentStructTreeRoot, ValidationReport report)
-
compareStructTreeElementKids
private boolean compareStructTreeElementKids(PdfDictionary previousStructElement, PdfDictionary currentStructElement, ValidationReport report)
-
compareStructTreeElements
private boolean compareStructTreeElements(PdfDictionary previousStructElement, PdfDictionary currentStructElement, ValidationReport report)
-
compareStructTreeContents
private boolean compareStructTreeContents(PdfObject previousStructTreeContent, PdfObject currentStructTreeContent, ValidationReport report)
-
compareExtensions
private boolean compareExtensions(PdfObject previousExtensions, PdfObject currentExtensions, ValidationReport report)
-
comparePermissions
private boolean comparePermissions(PdfObject previousPerms, PdfObject currentPerms, ValidationReport report)
-
compareDss
private boolean compareDss(PdfObject previousDss, PdfObject currentDss, ValidationReport report)
-
compareAcroFormsWithFieldMDP
private boolean compareAcroFormsWithFieldMDP(PdfDocument documentWithoutRevision, PdfDocument documentWithRevision, ValidationReport report)
-
compareFormFieldWithFieldMDP
private boolean compareFormFieldWithFieldMDP(PdfDictionary previousField, PdfDictionary currentField, java.lang.String fieldName, ValidationReport report)
-
compareAcroForms
private boolean compareAcroForms(PdfDictionary prevAcroForm, PdfDictionary currAcroForm, ValidationReport report)
-
compareFormFields
private boolean compareFormFields(PdfArray prevFields, PdfArray currFields, ValidationReport report)
-
retrieveTheSameField
private PdfDictionary retrieveTheSameField(java.util.Set<PdfDictionary> currFields, PdfDictionary previousField)
-
compareFields
private boolean compareFields(PdfDictionary previousField, PdfDictionary currentField, ValidationReport report)
DocMDP level >= 2 allows setting values of the fields and accordingly update the widget appearances of them. But you cannot change the form structure, so it is not allowed to add, remove or rename fields, change most of their properties.- Parameters:
previousField- field from the previous revision to checkcurrentField- field from the current revision to checkreport- validation report- Returns:
trueif the changes of the field are allowed,falseotherwise.
-
compareSignatureDictionaries
private boolean compareSignatureDictionaries(PdfObject prevSigDict, PdfObject curSigDict, ValidationReport report)
-
compareSignatureReferenceDictionaries
private boolean compareSignatureReferenceDictionaries(PdfArray previousReferences, PdfArray currentReferences, ValidationReport report)
-
compareWidgets
private boolean compareWidgets(PdfArray prevFields, PdfArray currFields, ValidationReport report)
-
comparePages
private boolean comparePages(PdfDictionary prevPages, PdfDictionary currPages, ValidationReport report)
-
collectRemovedAndAddedAnnotations
private void collectRemovedAndAddedAnnotations(PdfArray previousAnnotations, PdfArray currentAnnotations)
-
comparePageAnnotations
private boolean comparePageAnnotations(PdfArray prevAnnots, PdfArray currAnnots, ValidationReport report)
-
comparePageAnnotations
private boolean comparePageAnnotations(PdfDictionary prevAnnot, PdfDictionary currAnnot, ValidationReport report)
-
compareIndirectReferencesObjNums
private boolean compareIndirectReferencesObjNums(PdfObject prevObj, PdfObject currObj, ValidationReport report, java.lang.String type)
-
isAllowedSignatureField
private boolean isAllowedSignatureField(PdfDictionary field, ValidationReport report)
DocMDP level <=2 allows adding new fields in the following cases: docMDP level 1: allows adding only DocTimeStamp signature fields; docMDP level 2: same as level 1 and also adding and then signing signature fields, so signature dictionary shouldn't be null.- Parameters:
field- newly added field entryreport- validation report- Returns:
- true if newly added field is allowed to be added, false otherwise.
-
populateFormFields
private java.util.Set<PdfDictionary> populateFormFields(PdfArray fieldsArray)
-
populateWidgetAnnotations
private java.util.List<PdfDictionary> populateWidgetAnnotations(PdfArray fieldsArray)
-
getAnnotsNotAllowedToBeModified
private PdfArray getAnnotsNotAllowedToBeModified(PdfDictionary page)
-
copyCatalogEntriesToCompare
private PdfDictionary copyCatalogEntriesToCompare(PdfDictionary catalog)
-
copyAcroformDictionary
private PdfDictionary copyAcroformDictionary(PdfDictionary acroForm)
-
copyFieldDictionary
private PdfDictionary copyFieldDictionary(PdfDictionary field)
-
removeAppearanceRelatedProperties
private void removeAppearanceRelatedProperties(PdfDictionary annotDict)
-
comparePdfObjects
private static boolean comparePdfObjects(PdfObject pdfObject1, PdfObject pdfObject2, Tuple2<java.util.Set<PdfIndirectReference>,java.util.Set<PdfIndirectReference>> usuallyModifiedObjects)
-
comparePdfObjects
private static boolean comparePdfObjects(PdfObject pdfObject1, PdfObject pdfObject2, java.util.List<Tuple2<PdfObject,PdfObject>> visitedObjects, Tuple2<java.util.Set<PdfIndirectReference>,java.util.Set<PdfIndirectReference>> usuallyModifiedObjects)
-
comparePdfArrays
private static boolean comparePdfArrays(PdfArray array1, PdfArray array2, java.util.List<Tuple2<PdfObject,PdfObject>> visitedObjects, Tuple2<java.util.Set<PdfIndirectReference>,java.util.Set<PdfIndirectReference>> usuallyModifiedObjects)
-
comparePdfDictionaries
private static boolean comparePdfDictionaries(PdfDictionary dictionary1, PdfDictionary dictionary2, java.util.List<Tuple2<PdfObject,PdfObject>> visitedObjects, Tuple2<java.util.Set<PdfIndirectReference>,java.util.Set<PdfIndirectReference>> usuallyModifiedObjects)
-
comparePdfStreams
private static boolean comparePdfStreams(PdfStream stream1, PdfStream stream2, java.util.List<Tuple2<PdfObject,PdfObject>> visitedObjects, Tuple2<java.util.Set<PdfIndirectReference>,java.util.Set<PdfIndirectReference>> usuallyModifiedObjects)
-
isSameReference
private static boolean isSameReference(PdfIndirectReference indirectReference1, PdfIndirectReference indirectReference2)
-
isMaxGenerationObject
private static boolean isMaxGenerationObject(PdfIndirectReference indirectReference)
-
createUsuallyModifiedObjectsSet
private java.util.Set<PdfIndirectReference> createUsuallyModifiedObjectsSet(PdfDocument document)
-
addStructTreeElementsToSet
private void addStructTreeElementsToSet(PdfObject structTreeRootKids, java.util.Set<PdfIndirectReference> set)
-
addStructTreeElementsToSet
private void addStructTreeElementsToSet(PdfArray structTreeRootKids, java.util.Set<PdfIndirectReference> set)
-
addPageEntriesToSet
private void addPageEntriesToSet(PdfDictionary page, java.util.Set<PdfIndirectReference> set)
-
createAllowedReferences
private java.util.Set<PdfIndirectReference> createAllowedReferences(PdfDocument document)
-
checkAllowedReferences
private boolean checkAllowedReferences(java.util.Set<PdfIndirectReference> currentAllowedReferences, java.util.Set<PdfIndirectReference> previousAllowedReferences, PdfIndirectReference indirectReference, PdfDocument documentWithoutRevision)
-
isAllowedStreamObj
private boolean isAllowedStreamObj(PdfIndirectReference indirectReference, PdfDocument document)
-
createAllowedDssEntries
private java.util.Set<PdfIndirectReference> createAllowedDssEntries(PdfDocument document)
-
createAllowedStructTreeRootEntries
private java.util.Set<PdfIndirectReference> createAllowedStructTreeRootEntries(PdfDictionary structTreeRoot)
-
createAllowedTreeEntries
private void createAllowedTreeEntries(PdfObject treeNode, java.util.Set<PdfIndirectReference> allowedReferences, PdfName contentName)
-
createAllowedStructTreeRootKidsEntries
private void createAllowedStructTreeRootKidsEntries(PdfObject structTreeRootKids, java.util.Set<PdfIndirectReference> allowedReferences)
-
createAllowedStructTreeRootKidsEntries
private void createAllowedStructTreeRootKidsEntries(PdfArray structTreeRootKids, java.util.Set<PdfIndirectReference> allowedReferences)
-
createAllowedPagesEntries
private java.util.Collection<PdfIndirectReference> createAllowedPagesEntries(PdfDictionary pagesDictionary)
-
createAllowedFormFieldEntries
private void createAllowedFormFieldEntries(PdfArray fields, java.util.Set<PdfIndirectReference> allowedReferences)
-
addWidgetAnnotation
private void addWidgetAnnotation(java.util.Set<PdfIndirectReference> allowedReferences, PdfDictionary annotDict)
-
addAllNestedDictionaryEntries
private void addAllNestedDictionaryEntries(java.util.Set<PdfIndirectReference> allowedReferences, PdfDictionary dictionary)
-
addAllNestedArrayEntries
private void addAllNestedArrayEntries(java.util.Set<PdfIndirectReference> allowedReferences, PdfArray pdfArray)
-
-