aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2015-04-27 16:41:06 +0200
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2015-04-27 16:41:06 +0200
commit55194159de4eb2c6ce4c37d4367a788aa390ce5d (patch)
treedf6963de14df006e94d263fb1d2e39013165dfb3
parentdbd565ec8195117306ae869f4e7b507ff275ed32 (diff)
downloadeinfach-signieren-55194159de4eb2c6ce4c37d4367a788aa390ce5d.tar.gz
einfach-signieren-55194159de4eb2c6ce4c37d4367a788aa390ce5d.tar.bz2
einfach-signieren-55194159de4eb2c6ce4c37d4367a788aa390ce5d.zip
added locale parameter, and pdfas_innerdiv css class
-rw-r--r--simpleSigning/src/main/java/at/gv/egiz/simpleSigning/StartSignature.java16
-rw-r--r--simpleSigning/src/main/java/at/gv/egiz/simpleSigning/helper/SessionHelper.java15
-rw-r--r--simpleSigning/src/main/resources/js/pdfas.js31
3 files changed, 47 insertions, 15 deletions
diff --git a/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/StartSignature.java b/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/StartSignature.java
index 5c3927e..e065ea6 100644
--- a/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/StartSignature.java
+++ b/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/StartSignature.java
@@ -40,6 +40,7 @@ public class StartSignature extends HttpServlet {
private static final String PARAM_TYPE = "TYPE";
private static final String PARAM_TARGETURL = "TARGETURL";
private static final String PARAM_RESIZE = "RESIZE";
+ private static final String PARAM_LOCALE = "LOCALE";
private static final String PARAM_QRCODE = "QRCODE";
private static final String PARAM_NEW = "NEW";
@@ -136,6 +137,7 @@ public class StartSignature extends HttpServlet {
String type = req.getParameter(PARAM_TYPE);
String targetUrl = req.getParameter(PARAM_TARGETURL);
String qrCodeData = req.getParameter(PARAM_QRCODE);
+ String localeData = req.getParameter(PARAM_LOCALE);
// Step 1. Setup Parameters
if (type != null) {
@@ -153,6 +155,14 @@ public class StartSignature extends HttpServlet {
logger.info("[" + req.getSession().getId()
+ "]: setting QR Code Data to: " + qrCodeData);
}
+
+ if (localeData != null) {
+ // If we have a type set it
+ SessionHelper.setLocale(req, localeData);
+
+ logger.info("[" + req.getSession().getId()
+ + "]: setting Locale to: " + localeData);
+ }
if (eventId != null) {
SessionHelper.setEventID(req, eventId);
@@ -370,9 +380,13 @@ public class StartSignature extends HttpServlet {
}
String entry = "";
if (SessionHelper.getQRCodeContent(req) != null) {
- entry = "<input type=\"hidden\" name=\"qrcontent\" value=\""
+ entry += "<input type=\"hidden\" name=\"qrcontent\" value=\""
+ SessionHelper.getQRCodeContent(req) + "\">";
}
+ if (SessionHelper.getLocale(req) != null) {
+ entry += "<input type=\"hidden\" name=\"locale\" value=\""
+ + SessionHelper.getLocale(req) + "\">";
+ }
template = template.replace("##ADDITIONAL##",
entry);
diff --git a/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/helper/SessionHelper.java b/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/helper/SessionHelper.java
index 720c93c..bc86da6 100644
--- a/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/helper/SessionHelper.java
+++ b/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/helper/SessionHelper.java
@@ -15,7 +15,7 @@ public class SessionHelper {
private static final String SESSION_EVENTID = "SESSION_EVENTID";
private static final String SESSION_DOCUMENT = "SESSION_DOCUMENT";
private static final String SESSION_RESIZE_DONE = "SESSION_RESIZE_DONE";
-
+ private static final String SESSION_LOCALE = "SESSION_LOCALE";
private static final String SESSION_QRCODE_CONTENT = "SESSION_QRCODE_CONTENT";
private static final String SESSION_TYPE_TEXT = "TEXT";
@@ -65,6 +65,19 @@ public class SessionHelper {
}
}
+ public static void setLocale(HttpServletRequest request, String value) {
+ request.getSession().setAttribute(SESSION_LOCALE, value);
+ }
+
+ public static String getLocale(HttpServletRequest request) {
+ Object s = request.getSession().getAttribute(SESSION_LOCALE);
+ if (s != null) {
+ return s.toString();
+ } else {
+ return null;
+ }
+ }
+
public static void setContent(HttpServletRequest request, String value) {
request.getSession().setAttribute(SESSION_CONTENT, value);
}
diff --git a/simpleSigning/src/main/resources/js/pdfas.js b/simpleSigning/src/main/resources/js/pdfas.js
index 30f27f9..a96feee 100644
--- a/simpleSigning/src/main/resources/js/pdfas.js
+++ b/simpleSigning/src/main/resources/js/pdfas.js
@@ -1,9 +1,5 @@
/**
- *
- */
-
-/**
- * Operation Decsription
+ * Operation Description
*/
var operation = {
/**
@@ -19,7 +15,12 @@ var operation = {
/**
* DIV id where to place to UI
*/
- uiId: ""
+ uiId: "",
+
+ /**
+ * Locale to use
+ */
+ locale: "DE"
};
var pdfAsOrigin = "##REPLACE##DOMAIN##";
@@ -37,15 +38,15 @@ var pdfAs = {};
* @returns
*/
pdfAs.signText = function(content, error, success) {
- this.createAsyncSignature(content.content, content.connector, content.uiId, pdfAsUrl, content.qrdata, "TEXT", success, error);
+ this.createAsyncSignature(content.content, content.connector, content.uiId, pdfAsUrl, content.qrdata, content.locale, "TEXT", success, error);
};
pdfAs.signPdf = function(content, error, success) {
- this.createAsyncSignature(content.content, content.connector, content.uiId, pdfAsUrl, content.qrdata, "PDF", success, error);
+ this.createAsyncSignature(content.content, content.connector, content.uiId, pdfAsUrl, content.qrdata, content.locale, "PDF", success, error);
};
pdfAs.signPdfBase64 = function(content, error, success) {
- this.createAsyncSignature(content.content, content.connector, content.uiId, pdfAsUrl, content.qrdata, "B64", success, error);
+ this.createAsyncSignature(content.content, content.connector, content.uiId, pdfAsUrl, content.qrdata, content.locale, "B64", success, error);
};
pdfAs.getVersion = function(cb, err) {
@@ -124,7 +125,7 @@ pdfAs.autoResize = function(eventId, height, width){
var newheight = height;
var newwidth = width;
- console.log("Resising iframe " + width + "x" + height);
+ console.log("Resizing iframe " + width + "x" + height);
newheight = newheight + 20;
@@ -133,10 +134,12 @@ pdfAs.autoResize = function(eventId, height, width){
eventId = eventId.substring(0, eventId.length - 7);
var custDiv = eventId + "_div";
var element = document.getElementById(custDiv);
- element.style.margin = '-' + element.scrollHeight / 2 + 'px 0 0 -' + element.scrollWidth / 2 + 'px';
+ if ((typeof(element) !== 'undefined') && (element !== null)) {
+ element.style.margin = '-' + element.scrollHeight / 2 + 'px 0 0 -' + element.scrollWidth / 2 + 'px';
+ }
};
-pdfAs.createAsyncSignature = function(pdfUrl, connector, divID, pdfAsURL, qrcode, type, success, error) {
+pdfAs.createAsyncSignature = function(pdfUrl, connector, divID, pdfAsURL, qrcode, locale, type, success, error) {
// generate EventID
var eventId = guid();
@@ -147,7 +150,8 @@ pdfAs.createAsyncSignature = function(pdfUrl, connector, divID, pdfAsURL, qrcode
TYPE: type,
TARGETURL: document.URL,
NEW: "1",
- QRCODE: qrcode
+ QRCODE: qrcode,
+ LOCALE: locale
};
/*var querystring = encodeQueryData(parameters);
@@ -211,6 +215,7 @@ pdfAs.createAsyncSignature = function(pdfUrl, connector, divID, pdfAsURL, qrcode
var element = document.getElementById(divID);
var innerdiv = document.createElement('div');
+ innerdiv.setAttribute('class', 'pdfas_innerdiv');
innerdiv.style.display = 'block';
element.appendChild(innerdiv);
var innerdivbottom = document.createElement('div');