aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-web/src/main/java/at/gv/egiz
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2015-10-14 13:03:51 +0200
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2015-10-14 13:03:51 +0200
commit389abe953bf582e522acdf2c0e7b17b8fab3e18d (patch)
tree6b8f123d4da72d8d0906922a3b38928de802f8bc /pdf-as-web/src/main/java/at/gv/egiz
parent7aadb86776f828f13ac16c18c2e16b17e62f5d9e (diff)
downloadpdf-as-4-389abe953bf582e522acdf2c0e7b17b8fab3e18d.tar.gz
pdf-as-4-389abe953bf582e522acdf2c0e7b17b8fab3e18d.tar.bz2
pdf-as-4-389abe953bf582e522acdf2c0e7b17b8fab3e18d.zip
JS changes to work with mobile ApplicationSnapshot
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/config/WebConfiguration.java14
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java22
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java9
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java4
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/PDFData.java14
5 files changed, 58 insertions, 5 deletions
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java
index 0ad96b04..28203683 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java
@@ -49,6 +49,7 @@ public class WebConfiguration implements IConfigurationConstants {
public static final String PDF_AS_WORK_DIR = "pdfas.dir";
public static final String STATISTIC_BACKEND_LIST = "statistic.backends";
public static final String ALLOW_EXT_OVERWRITE = "allow.ext.overwrite";
+ public static final String ACCESSCOUNT = "accesscount";
public static final String ALLOW_EXT_WHITELIST_VALUE_PRE = "ext.overwrite.wl.";
@@ -514,6 +515,19 @@ public class WebConfiguration implements IConfigurationConstants {
return false;
}
+ public static int getAccessCount() {
+ String value = properties.getProperty(ACCESSCOUNT);
+ int ivalue = 1;
+ if (value != null) {
+ try {
+ ivalue = Integer.parseInt(value);
+ } catch(NumberFormatException e) {
+ logger.warn(ACCESSCOUNT + " not a number", e);
+ }
+ }
+ return ivalue;
+ }
+
public static int getFilesizeThreshold() {
String value = properties.getProperty(UPLOAD_FILESIZE_THRESHOLD);
int ivalue = THRESHOLD_SIZE;
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 ab23e238..143df335 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
@@ -127,6 +127,7 @@ public class PdfAsHelper {
private static final String PRE_PROCESSOR_MAP = "PREPROCMAP";
private static final String OVERWRITE_MAP = "OVERWRITEMAP";
private static final String KEYID = "KEYID";
+ private static final String SESSION_ACCESS = "SESSION_ACCESS";
private static final String POSITIONING_URL = "/assets/js/pdf.js/web/viewer.html";
@@ -1229,7 +1230,7 @@ public class PdfAsHelper {
}
public static void regenerateSession(HttpServletRequest request) {
- request.getSession(false).invalidate();
+ request.getSession(true).invalidate();
request.getSession(true);
}
@@ -1539,6 +1540,25 @@ public class PdfAsHelper {
}
return false;
}
+
+ public static boolean isSessionAccessCounter(HttpServletRequest request) {
+ HttpSession session = request.getSession();
+ Object obj = session.getAttribute(SESSION_ACCESS);
+ if (obj == null) {
+ Integer value = 0;
+ session.setAttribute(SESSION_ACCESS, value);
+ obj = value;
+ }
+
+ if (obj instanceof Integer) {
+ Integer count = (Integer) obj;
+ count++;
+ session.setAttribute(SESSION_ACCESS, count);
+ return (count < WebConfiguration.getAccessCount());
+ } else {
+ return false;
+ }
+ }
public static String getVersion() {
return PdfAsFactory.getVersion();
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java
index 53335ba6..f701ca63 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java
@@ -75,6 +75,7 @@ public class PdfAsParameterExtractor {
public static final String PARAM_OVERWRITE_PREFIX = "ov:";
public static final String PARAM_QRCODE_CONTENT = "qrcontent";
public static final String PARAM_USER_POSITIONING = "upos";
+ public static final String PARAM_BASE64 = "base64";
public static boolean isUserPositioning(HttpServletRequest request) {
String paramerterValue = (String)request.getAttribute(PARAM_USER_POSITIONING);
@@ -84,6 +85,14 @@ public class PdfAsParameterExtractor {
return false;
}
+ public static boolean isBase64(HttpServletRequest request) {
+ String paramerterValue = (String)request.getAttribute(PARAM_BASE64);
+ if(paramerterValue != null) {
+ return Boolean.parseBoolean(paramerterValue);
+ }
+ return false;
+ }
+
public static String getConnector(HttpServletRequest request) {
String connector = (String)request.getAttribute(PARAM_CONNECTOR);
if(connector != null) {
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 210a3cc3..ce5501c1 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
@@ -103,7 +103,7 @@ public class ExternSignServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
- // PdfAsHelper.regenerateSession(request);
+ PdfAsHelper.regenerateSession(request);
logger.debug("Get signing request");
@@ -156,7 +156,7 @@ public class ExternSignServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
- // PdfAsHelper.regenerateSession(request);
+ PdfAsHelper.regenerateSession(request);
logger.debug("Post signing request");
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 4fce6860..cd2a8072 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
@@ -31,6 +31,7 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.codec.binary.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -78,7 +79,7 @@ public class PDFData extends HttpServlet {
protected void process(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
byte[] signedData = PdfAsHelper.getSignedPdf(request, response);
-
+
StatisticEvent statisticEvent = PdfAsHelper.getStatisticEvent(request,
response);
@@ -126,13 +127,22 @@ public class PDFData extends HttpServlet {
response.setHeader("ValueCheckCode",
String.valueOf(resp.getValueCode()));
}
+
+ //if(PdfAsParameterExtractor.isBase64(request)) {
+ // signedData = Base64.encodeBase64(signedData);
+ //}
+
+ response.setContentLength(signedData.length);
+
response.setContentType("application/pdf");
OutputStream os = response.getOutputStream();
os.write(signedData);
os.close();
// When data is collected destroy session!
- request.getSession().invalidate();
+ if(!PdfAsHelper.isSessionAccessCounter(request)) {
+ request.getSession().invalidate();
+ }
} else {
PdfAsHelper.setSessionException(request, response,
"No signed pdf document available.", null);