aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyServlet.java17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyServlet.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyServlet.java
index 8d9e293..7b935de 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyServlet.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyServlet.java
@@ -20,6 +20,7 @@ package at.knowcenter.wag.egov.egiz.web.servlets;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URL;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
@@ -286,7 +287,9 @@ public class VerifyServlet extends HttpServlet
throw new PDFDocumentException(250, "The document is empty."); //$NON-NLS-1$
}
- if (upload_fi.getContentType() != null && upload_fi.getContentType().startsWith("application/pdf"))
+
+ // TR: do not check MIME-type of incoming file - might vary depending on the browser used
+ if ((upload_fi.getContentType() != null ) && ((upload_fi.getContentType().startsWith("application/pdf") || upload_fi.getContentType().startsWith("application/x-download") )))
{
try
{
@@ -431,4 +434,16 @@ public class VerifyServlet extends HttpServlet
return toreturn;
}
+ public boolean isPDF(byte[] data) {
+ final byte[] PDF_MAGIC_NUMBER = { (byte) 0x25, (byte) 0x50, (byte)
+ 0x44, (byte) 0x46 }; // %PDF
+ if (data == null || data.length < PDF_MAGIC_NUMBER.length) {
+ return false;
+ }
+ byte[] documentHeader = new byte[PDF_MAGIC_NUMBER.length];
+ System.arraycopy(data, 0, documentHeader, 0, documentHeader.length);
+ return Arrays.equals(documentHeader, PDF_MAGIC_NUMBER);
+ }
+
+
} \ No newline at end of file