From 6b692931c81fd0e09d8d21eb81e05a5f08af8342 Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Tue, 4 Feb 2014 08:36:05 +0100 Subject: Implemented PDF Document permission check --- .../src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'pdf-as-lib/src/main/java/at/gv/egiz/pdfas') diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java index 540fd572..2553ccf3 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java @@ -16,6 +16,7 @@ import org.apache.pdfbox.cos.COSDictionary; import org.apache.pdfbox.cos.COSName; import org.apache.pdfbox.cos.COSString; import org.apache.pdfbox.pdmodel.PDDocument; +import org.apache.pdfbox.pdmodel.encryption.AccessPermission; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -95,6 +96,14 @@ public class PdfAsImpl implements PdfAs, IConfigurationConstants { throw new PdfAsValidationException("error.pdf.sig.11", null); } + try { + PDDocument doc = PDDocument.load(new ByteArrayInputStream(parameter.getDataSource().getByteData())); + PDFUtils.checkPDFPermissions(doc); + doc.close(); + } catch(IOException e) { + throw new PdfAsValidationException("error.pdf.sig.12", null, e); + } + // TODO: verify Sign Parameter } -- cgit v1.2.3