aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-pdfbox-2/src/main/java/at/gv/egiz
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-pdfbox-2/src/main/java/at/gv/egiz')
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/utils/PdfBoxUtils.java22
1 files changed, 16 insertions, 6 deletions
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..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
@@ -16,16 +16,26 @@ 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()) {
+ //canFillInForm()
+ //This will tell if the user can fill in interactive form fields (including signature fields) even if
+ // canModifyAnnotations() returns false.
- if (!accessPermission.isOwnerPermission()) {
- throw new PdfAsValidationException("error.pdf.sig.12", null);
+ //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");
+
+ } else {
+ throw new PdfAsValidationException("error.pdf.sig.12", null);
+
+ }
}
+
}
public static int countSignatures(PDDocument doc, String sigName) {