aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-pdfbox-2/src/main/java
diff options
context:
space:
mode:
authorAlexander Marsalek <amarsalek@iaik.tugraz.at>2021-06-01 11:26:16 +0200
committerAlexander Marsalek <amarsalek@iaik.tugraz.at>2021-06-01 11:26:59 +0200
commit90d2ec69b01a5622c462cde538e0c739322a81ba (patch)
treee4e89d78789c10ffa03b2ccb78c188e9dbffdaf8 /pdf-as-pdfbox-2/src/main/java
parentbf0aa0afbb336ec5d5acb719e130d42f15bc8900 (diff)
parent6047c5d39b4c09cd45cf8642a990ede4eb2a7c2a (diff)
downloadpdf-as-4-90d2ec69b01a5622c462cde538e0c739322a81ba.tar.gz
pdf-as-4-90d2ec69b01a5622c462cde538e0c739322a81ba.tar.bz2
pdf-as-4-90d2ec69b01a5622c462cde538e0c739322a81ba.zip
Merge branch 'feature/protected_pdf' into master
Diffstat (limited to 'pdf-as-pdfbox-2/src/main/java')
-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) {