From 77cc1a7b56632d36efba616d5fd8cf4aac93b30e Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Wed, 19 May 2021 17:37:55 +0200 Subject: change analyzing of PDF protection level because it's maybe to restricted --- .../gv/egiz/pdfas/lib/impl/pdfbox2/utils/PdfBoxUtils.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'pdf-as-pdfbox-2/src') diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/utils/PdfBoxUtils.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/utils/PdfBoxUtils.java index 1a6499ac..d072a474 100644 --- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/utils/PdfBoxUtils.java +++ b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/utils/PdfBoxUtils.java @@ -16,15 +16,18 @@ public class PdfBoxUtils { public static void checkPDFPermissions(PDDocument doc) throws PdfAsValidationException { - AccessPermission accessPermission = doc.getCurrentAccessPermission(); - if (doc.isEncrypted()) { - throw new PdfAsValidationException("error.pdf.sig.12", null); + if (doc.isEncrypted() || !accessPermission.isOwnerPermission()) { + if (accessPermission.canModify() || accessPermission.canModifyAnnotations() + || accessPermission.canFillInForm()) { + logger.debug("Document is protected, but Signing is allowed"); + + } else { + throw new PdfAsValidationException("error.pdf.sig.12", null); + + } } - if (!accessPermission.isOwnerPermission()) { - throw new PdfAsValidationException("error.pdf.sig.12", null); - } } -- cgit v1.2.3 From 6047c5d39b4c09cd45cf8642a990ede4eb2a7c2a Mon Sep 17 00:00:00 2001 From: Alexander Marsalek Date: Thu, 20 May 2021 09:50:11 +0200 Subject: Update checkPDFPermissions --- .../at/gv/egiz/pdfas/lib/impl/pdfbox2/utils/PdfBoxUtils.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'pdf-as-pdfbox-2/src') diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/utils/PdfBoxUtils.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/utils/PdfBoxUtils.java index d072a474..112d9a86 100644 --- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/utils/PdfBoxUtils.java +++ b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/utils/PdfBoxUtils.java @@ -18,7 +18,14 @@ public class PdfBoxUtils { throws PdfAsValidationException { AccessPermission accessPermission = doc.getCurrentAccessPermission(); if (doc.isEncrypted() || !accessPermission.isOwnerPermission()) { - if (accessPermission.canModify() || accessPermission.canModifyAnnotations() + //canFillInForm() + //This will tell if the user can fill in interactive form fields (including signature fields) even if + // canModifyAnnotations() returns false. + + //canModifyAnnotations() + //This will tell if the user can add or modify text annotations and fill in interactive forms fields and, if + // canModify() returns true, create or modify interactive form fields (including signature fields). + if ((accessPermission.canModify() && accessPermission.canModifyAnnotations()) || accessPermission.canFillInForm()) { logger.debug("Document is protected, but Signing is allowed"); -- cgit v1.2.3