aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-web/src/main/java/at/gv/egiz
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-web/src/main/java/at/gv/egiz')
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java21
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java19
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/PDFData.java1
3 files changed, 37 insertions, 4 deletions
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java
index 77c31c9a..12d7ffc5 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java
@@ -64,6 +64,7 @@ public class PdfAsHelper {
private static final String PDF_PDFDATA_PAGE = "/PDFData";
private static final String PDF_DATAURL_PAGE = "/DataURL";
private static final String PDF_ERR_URL = "PDF_ERR_URL";
+ private static final String PDF_FILE_NAME = "PDF_FILE_NAME";
private static final String PDF_INVOKE_URL = "PDF_INVOKE_URL";
private static final String REQUEST_FROM_DU = "REQ_DATA_URL";
private static final String SIGNATURE_DATA_HASH = "SIGNATURE_DATA_HASH";
@@ -627,17 +628,33 @@ public class PdfAsHelper {
}
public static void setSignatureDataHash(HttpServletRequest request, String value) {
- request.setAttribute(SIGNATURE_DATA_HASH, value);
+ HttpSession session = request.getSession();
+ session.setAttribute(SIGNATURE_DATA_HASH, value);
}
public static String getSignatureDataHash(HttpServletRequest request) {
- Object obj = request.getAttribute(SIGNATURE_DATA_HASH);
+ HttpSession session = request.getSession();
+ Object obj = session.getAttribute(SIGNATURE_DATA_HASH);
if (obj != null) {
return obj.toString();
}
return "";
}
+ public static void setPDFFileName(HttpServletRequest request, String value) {
+ HttpSession session = request.getSession();
+ session.setAttribute(PDF_FILE_NAME, value);
+ }
+
+ public static String getPDFFileName(HttpServletRequest request) {
+ HttpSession session = request.getSession();
+ Object obj = session.getAttribute(PDF_FILE_NAME);
+ if (obj != null) {
+ return obj.toString();
+ }
+ return "document.pdf";
+ }
+
public static void setSignatureActive(HttpServletRequest request, boolean value) {
request.setAttribute(SIGNATURE_ACTIVE, new Boolean(value));
}
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java
index 3a6bc971..dddd80dd 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java
@@ -151,7 +151,22 @@ public class ExternSignServlet extends HttpServlet {
FileItem item = (FileItem) obj;
if(item.getFieldName().equals(UPLOAD_PDF_DATA)) {
filecontent = item.get();
-
+ try {
+ File f = new File(item.getName());
+ String name = f.getName();
+ logger.debug("Got upload: " + item.getName());
+ if(name != null) {
+ if(!(name.endsWith(".pdf") || name.endsWith(".PDF"))) {
+ name += ".pdf";
+ }
+
+ logger.debug("Setting Filename in session: " + name);
+ PdfAsHelper.setPDFFileName(request, name);
+ }
+ }
+ catch(Throwable e) {
+ logger.error("In resolving filename", e);
+ }
if(filecontent.length < 10) {
filecontent = null;
} else {
@@ -162,7 +177,7 @@ public class ExternSignServlet extends HttpServlet {
logger.debug("Setting " + item.getFieldName() + " = " + item.getString());
}
} else {
- logger.info(obj.getClass().getName() + " - " + obj.toString());
+ logger.debug(obj.getClass().getName() + " - " + obj.toString());
}
}
}
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/PDFData.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/PDFData.java
index 9bf66fe9..0800c05c 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/PDFData.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/PDFData.java
@@ -70,6 +70,7 @@ public class PDFData extends HttpServlet {
return;
}
}
+ response.setHeader("Content-Disposition", "inline;filename=" + PdfAsHelper.getPDFFileName(request));
response.setContentType("application/pdf");
OutputStream os = response.getOutputStream();
os.write(signedData);