aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/knowcenter/wag
diff options
context:
space:
mode:
authortknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2010-01-19 21:59:41 +0000
committertknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2010-01-19 21:59:41 +0000
commit4852f856d9713ec07d1223417932cd5d5070ff8c (patch)
tree2ff1a8b8d72865f9a4cbda0f2296b3f32fa1dc8e /src/main/java/at/knowcenter/wag
parent5161308e1650f1b7252c36bd39ec338e2471d54e (diff)
downloadpdf-as-3-4852f856d9713ec07d1223417932cd5d5070ff8c.tar.gz
pdf-as-3-4852f856d9713ec07d1223417932cd5d5070ff8c.tar.bz2
pdf-as-3-4852f856d9713ec07d1223417932cd5d5070ff8c.zip
- 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
Diffstat (limited to 'src/main/java/at/knowcenter/wag')
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java2
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/pdf/BinarySignature.java3
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/pdf/TextualSignature.java11
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignServlet.java5
4 files changed, 15 insertions, 6 deletions
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java b/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java
index 0ae2e8e..423c222 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java
@@ -43,6 +43,7 @@ import at.gv.egiz.pdfas.framework.signator.SignatorInformation;
import at.gv.egiz.pdfas.impl.api.commons.PdfDataSourceAdapter;
import at.gv.egiz.pdfas.impl.input.ByteArrayPdfDataSourceImpl;
import at.gv.egiz.pdfas.impl.input.helper.DataSourceHelper;
+import at.gv.egiz.pdfas.utils.PDFASUtils;
import at.gv.egiz.pdfas.web.VerifySessionInformation;
import at.knowcenter.wag.egov.egiz.cfg.SettingsReader;
import at.knowcenter.wag.egov.egiz.exceptions.ConnectorException;
@@ -1256,6 +1257,7 @@ public abstract class PdfAS
// first check pageinstruction in TablePos-object
// new,auto,absolut
PdfReader reader = readInPdfDocument(pdfDataSource);
+ PDFASUtils.checkReaderPermissions(reader);
// get pages of currentdocument
int doc_pages = reader.getNumberOfPages();
int page = doc_pages;
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/BinarySignature.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/BinarySignature.java
index 8cb0d42..d1e227a 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/BinarySignature.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/BinarySignature.java
@@ -37,11 +37,13 @@ import org.apache.commons.logging.LogFactory;
import at.gv.egiz.pdfas.api.timestamp.TimeStamper;
import at.gv.egiz.pdfas.exceptions.ErrorCode;
+import at.gv.egiz.pdfas.exceptions.framework.CorrectorException;
import at.gv.egiz.pdfas.exceptions.pdf.CaptionNotFoundException;
import at.gv.egiz.pdfas.exceptions.pdf.KZSettingNotFoundException;
import at.gv.egiz.pdfas.framework.input.PdfDataSource;
import at.gv.egiz.pdfas.framework.output.DataSink;
import at.gv.egiz.pdfas.framework.signator.SignatorInformation;
+import at.gv.egiz.pdfas.utils.PDFASUtils;
import at.knowcenter.wag.egov.egiz.cfg.SettingsReader;
import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException;
import at.knowcenter.wag.egov.egiz.exceptions.PlaceholderException;
@@ -795,6 +797,7 @@ public abstract class BinarySignature
// InputStream is = original_document.createInputStream();
byte[] pdf_data = original_document.getAsByteArray();
PdfReader reader = new PdfReader(pdf_data);
+ PDFASUtils.checkReaderPermissions(reader);
// is.close();
OutputStream baos = written_pdf.createOutputStream("application/pdf");
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/TextualSignature.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/TextualSignature.java
index 841e2a6..85bc4fd 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/TextualSignature.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/TextualSignature.java
@@ -30,6 +30,7 @@ import org.pdfbox.util.PDFTextStripper;
import at.gv.egiz.pdfas.exceptions.ErrorCode;
import at.gv.egiz.pdfas.framework.input.PdfDataSource;
import at.gv.egiz.pdfas.performance.PerformanceCounters;
+import at.gv.egiz.pdfas.utils.PDFASUtils;
import at.knowcenter.wag.egov.egiz.cfg.ConfigLogger;
import at.knowcenter.wag.egov.egiz.cfg.SettingsReader;
import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException;
@@ -85,11 +86,7 @@ public class TextualSignature
byte [] pdf_data = pdfDataSource.getAsByteArray();
PdfReader reader = new PdfReader(pdf_data);
- if (!reader.isOpenedWithFullPermissions()) {
- // cannot perform modification and extraction
- throw new PDFDocumentException(ErrorCode.DOCUMENT_IS_PROTECTED, "Document is protected.");
-
- }
+ PDFASUtils.checkReaderPermissions(reader);
//pdf_stream.close();
// PERF: PDF normalization needs byte array - this is costy
@@ -212,12 +209,14 @@ public class TextualSignature
* @return Returns the normalized pdf.
* @throws IOException
* @throws DocumentException
+ * @throws PDFDocumentException
*/
- public static byte[] normalizePDF(PdfDataSource pdfDataSource) throws IOException, DocumentException
+ public static byte[] normalizePDF(PdfDataSource pdfDataSource) throws IOException, DocumentException, PDFDocumentException
{
//iText
byte [] pdf_data = pdfDataSource.getAsByteArray();
PdfReader reader = new PdfReader(pdf_data);
+ PDFASUtils.checkReaderPermissions(reader);
//input_pdf.close();
// PERF: PDF Normalization needs byte array
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignServlet.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignServlet.java
index f30f0fb..c946225 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignServlet.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignServlet.java
@@ -315,6 +315,11 @@ public class SignServlet extends HttpServlet
log.error(e.getMessage(), e);
prepareDispatchToErrorPage(e, request);
dispatch(request, response, "/jsp/error.jsp");
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ PresentableException pe = new PresentableException(ErrorCode.UNKNOWN_ERROR, e);
+ prepareDispatchToErrorPage(pe, request);
+ dispatch(request, response, "/jsp/error.jsp");
}
}