aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/gv/egiz/pdfas/web/helper/TempDirHelper.java12
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignServlet.java5
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyServlet.java6
3 files changed, 19 insertions, 4 deletions
diff --git a/src/main/java/at/gv/egiz/pdfas/web/helper/TempDirHelper.java b/src/main/java/at/gv/egiz/pdfas/web/helper/TempDirHelper.java
index 9f2b6fb..0745bcc 100644
--- a/src/main/java/at/gv/egiz/pdfas/web/helper/TempDirHelper.java
+++ b/src/main/java/at/gv/egiz/pdfas/web/helper/TempDirHelper.java
@@ -149,6 +149,8 @@ public class TempDirHelper
protected static String formatFileName(String fileNameSuffix)
{
+ // double check so that file name is always correct.
+ fileNameSuffix = extractFileNameSuffix(fileNameSuffix);
String fileName = "tmp" + formatIndex(runningIndex) + "_" + fileNameSuffix;
runningIndex++;
@@ -239,4 +241,14 @@ public class TempDirHelper
}
}
+ /**
+ * Given a file (maybe with path), extracts the file name suffix.
+ * @param file The file and maybe path.
+ * @return Returns the file name.
+ */
+ public static String extractFileNameSuffix (String file)
+ {
+ File f = new File(file);
+ return f.getName();
+ }
}
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 3f1342d..0ebe3ea 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
@@ -230,6 +230,7 @@ public class SignServlet extends HttpServlet
request.setAttribute("error", "Fehler beim Upload der Daten");
request.setAttribute("cause", "Beim Upload der Daten ist ein Fehler aufgetreten.");
dispatch(request, response, "/jsp/error.jsp");
+ return;
}
}
try
@@ -394,7 +395,7 @@ public class SignServlet extends HttpServlet
String sig_type = sig_type_fi.getString("UTF-8"); //$NON-NLS-1$
String sig_app = sig_app_fi.getString("UTF-8"); //$NON-NLS-1$
- String doc_file_name = file_upload_fi.getName();
+ String doc_file_name = TempDirHelper.extractFileNameSuffix(file_upload_fi.getName());
log.debug("file content type =" + file_upload_fi.getContentType()); //$NON-NLS-1$
String extension = VerifyServlet.extractExtension(doc_file_name);
@@ -415,7 +416,7 @@ public class SignServlet extends HttpServlet
}
catch (IOException e)
{
- throw new PDFDocumentException(201, "Couldn't store the file in the temp dir.");
+ throw new PDFDocumentException(201, "Couldn't store the file in the temp dir.", e);
}
// byte[] pdf = file_upload_fi.get();
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 bb6a13f..38f3e64 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
@@ -273,7 +273,8 @@ public class VerifyServlet extends HttpServlet
{
try
{
- PdfDataSource pdfDataSource = TempDirHelper.placePdfIntoTempDir(upload_fi.getInputStream(), upload_fi.getName());
+ String fileNameSuffix = TempDirHelper.extractFileNameSuffix(upload_fi.getName());
+ PdfDataSource pdfDataSource = TempDirHelper.placePdfIntoTempDir(upload_fi.getInputStream(), fileNameSuffix);
return pdfDataSource;
}
catch (IOException e)
@@ -285,8 +286,9 @@ public class VerifyServlet extends HttpServlet
try
{
+ String fileNameSuffix = TempDirHelper.extractFileNameSuffix(upload_fi.getName());
String text = new String(upload_fi.get(), "UTF-8"); //$NON-NLS-1$
- TextDataSource textDataSource = TempDirHelper.placeTextIntoTempDir(text, upload_fi.getName());
+ TextDataSource textDataSource = TempDirHelper.placeTextIntoTempDir(text, fileNameSuffix);
return textDataSource;
}
catch (IOException e)