From dfb07c7b429b7e06c6dcd44bdbb1f84fd53481e1 Mon Sep 17 00:00:00 2001 From: knowcenter Date: Fri, 21 Sep 2007 07:29:47 +0000 Subject: Erweiterte MIME-Types werden akzeptiert (nun auch application/..) git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@218 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../wag/egov/egiz/web/servlets/VerifyServlet.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/main/java/at/knowcenter') 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 -- cgit v1.2.3