From 4852f856d9713ec07d1223417932cd5d5070ff8c Mon Sep 17 00:00:00 2001 From: tknall Date: Tue, 19 Jan 2010 21:59:41 +0000 Subject: - handling protected documents improved. - minor web application improvements git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@557 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../java/at/gv/egiz/pdfas/utils/PDFASUtils.java | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/main/java/at/gv/egiz/pdfas/utils/PDFASUtils.java (limited to 'src/main/java/at/gv/egiz/pdfas/utils') diff --git a/src/main/java/at/gv/egiz/pdfas/utils/PDFASUtils.java b/src/main/java/at/gv/egiz/pdfas/utils/PDFASUtils.java new file mode 100644 index 0000000..b26cc9b --- /dev/null +++ b/src/main/java/at/gv/egiz/pdfas/utils/PDFASUtils.java @@ -0,0 +1,30 @@ +package at.gv.egiz.pdfas.utils; + +import at.gv.egiz.pdfas.exceptions.ErrorCode; +import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException; + +import com.lowagie.text.pdf.PdfReader; + +/** + * @author tknall + */ +public class PDFASUtils { + + private PDFASUtils() { + } + + /** + * Verifies that a document could be opened with full permissions. + * @param pdfReader The PdfReader + * @throws PDFDocumentException Thrown if document has not been opened with full permissions. + */ + public static void checkReaderPermissions(PdfReader pdfReader) throws PDFDocumentException { + if (pdfReader.isEncrypted()) { + throw new PDFDocumentException(ErrorCode.DOCUMENT_IS_PROTECTED, "Document is encrypted."); + } + if (!pdfReader.isOpenedWithFullPermissions()) { + throw new PDFDocumentException(ErrorCode.DOCUMENT_IS_PROTECTED, "Document is protected."); + } + } + +} -- cgit v1.2.3