aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--simpleSigning/build.gradle2
-rw-r--r--simpleSigning/src/main/java/at/gv/egiz/simpleSigning/StartSignature.java102
-rw-r--r--simpleSigning/src/main/java/at/gv/egiz/simpleSigning/helper/SessionHelper.java63
-rw-r--r--simpleSigning/src/main/resources/js/pdfas.js15
-rw-r--r--simpleSigning/src/main/webapp/index.jsp36
5 files changed, 207 insertions, 11 deletions
diff --git a/simpleSigning/build.gradle b/simpleSigning/build.gradle
index 573b09f..91f99fb 100644
--- a/simpleSigning/build.gradle
+++ b/simpleSigning/build.gradle
@@ -4,7 +4,7 @@ apply plugin: 'eclipse-wtp'
apply plugin: 'war'
sourceCompatibility = 1.7
-version = '1.2'
+version = '1.3'
war {
manifest {
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 70741ed..69f60d5 100644
--- a/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/StartSignature.java
+++ b/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/StartSignature.java
@@ -45,6 +45,12 @@ public class StartSignature extends HttpServlet {
private static final String PARAM_QRCODE = "QRCODE";
private static final String PARAM_NEW = "NEW";
private static final String PARAM_NEW_V = "1";
+
+ private static final String PARAM_SIG_POS_X = "SIG_POS_X";
+ private static final String PARAM_SIG_POS_Y = "SIG_POS_Y";
+ private static final String PARAM_SIG_POS_P = "SIG_POS_P";
+ private static final String PARAM_SIG_POS_W = "SIG_POS_W";
+ private static final String PARAM_SIG_POS_F = "SIG_POS_F";
public StartSignature() {
super();
@@ -138,6 +144,12 @@ public class StartSignature extends HttpServlet {
String targetUrl = req.getParameter(PARAM_TARGETURL);
String qrCodeData = req.getParameter(PARAM_QRCODE);
String localeData = req.getParameter(PARAM_LOCALE);
+
+ String sigPosX = req.getParameter(PARAM_SIG_POS_X);
+ String sigPosY = req.getParameter(PARAM_SIG_POS_Y);
+ String sigPosP = req.getParameter(PARAM_SIG_POS_P);
+ String sigPosW = req.getParameter(PARAM_SIG_POS_W);
+ String sigPosF = req.getParameter(PARAM_SIG_POS_F);
// Step 1. Setup Parameters
if (type != null) {
@@ -200,6 +212,53 @@ public class StartSignature extends HttpServlet {
}
}
+
+ //Position Params
+ if (sigPosX != null && !sigPosX.isEmpty()) {
+ if(isNumeric(sigPosX, req, resp)==false)
+ return;
+ // If we have a type set it
+ SessionHelper.setSigPosX(req, sigPosX);
+
+ logger.trace("[" + req.getSession().getId()
+ + "]: setting SigPosX to: " + sigPosX);
+ }
+ if (sigPosY != null && !sigPosY.isEmpty()) {
+ if(isNumeric(sigPosY, req, resp)==false)
+ return;
+ // If we have a type set it
+ SessionHelper.setSigPosY(req, sigPosY);
+
+ logger.trace("[" + req.getSession().getId()
+ + "]: setting SigPosY to: " + sigPosY);
+ }
+ if (sigPosP != null && !sigPosP.isEmpty()) {
+ if(isNumeric(sigPosP, req, resp)==false)
+ return;
+ // If we have a type set it
+ SessionHelper.setSigPosP(req, sigPosP);
+
+ logger.trace("[" + req.getSession().getId()
+ + "]: setting SigPosP to: " + sigPosP);
+ }
+ if (sigPosW != null && !sigPosW.isEmpty()) {
+ if(isNumeric(sigPosW, req, resp)==false)
+ return;
+ // If we have a type set it
+ SessionHelper.setSigPosW(req, sigPosW);
+
+ logger.trace("[" + req.getSession().getId()
+ + "]: setting SigPosW to: " + sigPosW);
+ }
+ if (sigPosF != null && !sigPosF.isEmpty()) {
+ if(isNumeric(sigPosF, req, resp)==false)
+ return;
+ // If we have a type set it
+ SessionHelper.setSigPosF(req, sigPosF);
+
+ logger.trace("[" + req.getSession().getId()
+ + "]: setting SigPosF to: " + sigPosF);
+ }
if ((SessionHelper.getContent(req) == null && SessionHelper
.getDocument(req) == null)
@@ -386,7 +445,27 @@ public class StartSignature extends HttpServlet {
if (SessionHelper.getLocale(req) != null) {
entry += "<input type=\"hidden\" name=\"locale\" value=\""
+ SessionHelper.getLocale(req) + "\">";
- }
+ }
+ if (SessionHelper.getSigPosX(req) != null){
+ entry += "<input type=\"hidden\" name=\"sig-pos-x\" value=\""
+ + SessionHelper.getSigPosX(req) + "\">";
+ }
+ if (SessionHelper.getSigPosY(req) != null){
+ entry += "<input type=\"hidden\" name=\"sig-pos-y\" value=\""
+ + SessionHelper.getSigPosY(req) + "\">";
+ }
+ if (SessionHelper.getSigPosP(req) != null){
+ entry += "<input type=\"hidden\" name=\"sig-pos-p\" value=\""
+ + SessionHelper.getSigPosP(req) + "\">";
+ }
+ if (SessionHelper.getSigPosW(req) != null){
+ entry += "<input type=\"hidden\" name=\"sig-pos-w\" value=\""
+ + SessionHelper.getSigPosW(req) + "\">";
+ }
+ if (SessionHelper.getSigPosF(req) != null){
+ entry += "<input type=\"hidden\" name=\"sig-pos-f\" value=\""
+ + SessionHelper.getSigPosF(req) + "\">";
+ }
template = template.replace("##ADDITIONAL##",
entry);
@@ -415,4 +494,25 @@ public class StartSignature extends HttpServlet {
.toError(req, resp, "Something went wrong", e.getMessage());
}
}
+
+ private static boolean isNumeric(String nr, HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ try
+ {
+ Double.parseDouble(nr);
+ }
+ catch(NumberFormatException e)
+ {
+ logger.error("["
+ + req.getSession().getId()
+ + "]: Failed to generate signature Data!: Position Parameter is not numeric");
+ PDFHelper.toError(req, resp,
+ "Failed to get signature Data",
+ "Position Parameter is not numeric");
+ return false;
+
+ }
+ return true;
+
+ }
}
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 bc86da6..0d06a36 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
@@ -22,6 +22,12 @@ public class SessionHelper {
private static final String SESSION_TYPE_PDF = "PDF";
private static final String SESSION_TYPE_BASE64 = "B64";
+ private static final String SESSION_SIG_POS_X = "SESSION_SIG_POS_X";
+ private static final String SESSION_SIG_POS_Y = "SESSION_SIG_POS_Y";
+ private static final String SESSION_SIG_POS_P = "SESSION_SIG_POS_P";
+ private static final String SESSION_SIG_POS_W = "SESSION_SIG_POS_W";
+ private static final String SESSION_SIG_POS_F = "SESSION_SIG_POS_F";
+
private static final Logger logger = LoggerFactory
.getLogger(SessionHelper.class);
@@ -171,4 +177,61 @@ public class SessionHelper {
logger.info("Killing Session: " + request.getSession().getId());
request.getSession().invalidate();
}
+
+ public static void setSigPosX(HttpServletRequest request, String value) {
+ request.getSession().setAttribute(SESSION_SIG_POS_X, value);
+ }
+ public static void setSigPosY(HttpServletRequest request, String value) {
+ request.getSession().setAttribute(SESSION_SIG_POS_Y, value);
+ }
+ public static void setSigPosP(HttpServletRequest request, String value) {
+ request.getSession().setAttribute(SESSION_SIG_POS_P, value);
+ }
+ public static void setSigPosW(HttpServletRequest request, String value) {
+ request.getSession().setAttribute(SESSION_SIG_POS_W, value);
+ }
+ public static void setSigPosF(HttpServletRequest request, String value) {
+ request.getSession().setAttribute(SESSION_SIG_POS_F, value);
+ }
+
+ public static String getSigPosX(HttpServletRequest request) {
+ Object s = request.getSession().getAttribute(SESSION_SIG_POS_X);
+ if (s != null) {
+ return s.toString();
+ } else {
+ return null;
+ }
+ }
+ public static String getSigPosY(HttpServletRequest request) {
+ Object s = request.getSession().getAttribute(SESSION_SIG_POS_Y);
+ if (s != null) {
+ return s.toString();
+ } else {
+ return null;
+ }
+ }
+ public static String getSigPosP(HttpServletRequest request) {
+ Object s = request.getSession().getAttribute(SESSION_SIG_POS_P);
+ if (s != null) {
+ return s.toString();
+ } else {
+ return null;
+ }
+ }
+ public static String getSigPosW(HttpServletRequest request) {
+ Object s = request.getSession().getAttribute(SESSION_SIG_POS_W);
+ if (s != null) {
+ return s.toString();
+ } else {
+ return null;
+ }
+ }
+ public static String getSigPosF(HttpServletRequest request) {
+ Object s = request.getSession().getAttribute(SESSION_SIG_POS_F);
+ if (s != null) {
+ return s.toString();
+ } else {
+ return null;
+ }
+ }
}
diff --git a/simpleSigning/src/main/resources/js/pdfas.js b/simpleSigning/src/main/resources/js/pdfas.js
index 2fd3f83..daae998 100644
--- a/simpleSigning/src/main/resources/js/pdfas.js
+++ b/simpleSigning/src/main/resources/js/pdfas.js
@@ -38,15 +38,15 @@ var pdfAs = {};
* @returns
*/
pdfAs.signText = function(content, error, success) {
- this.createAsyncSignature(content.content, content.connector, content.uiId, pdfAsUrl, content.qrdata, content.locale, "TEXT", success, error);
+ this.createAsyncSignature(content.content, content.connector, content.uiId, pdfAsUrl, content.qrdata, content.locale, content.sig_pos_x, content.sig_pos_y, content.sig_pos_p, content.sig_pos_w, content.sig_pos_f, "TEXT", success, error);
};
pdfAs.signPdf = function(content, error, success) {
- this.createAsyncSignature(content.content, content.connector, content.uiId, pdfAsUrl, content.qrdata, content.locale, "PDF", success, error);
+ this.createAsyncSignature(content.content, content.connector, content.uiId, pdfAsUrl, content.qrdata, content.locale, content.sig_pos_x, content.sig_pos_y, content.sig_pos_p, content.sig_pos_w, content.sig_pos_f, "PDF", success, error);
};
pdfAs.signPdfBase64 = function(content, error, success) {
- this.createAsyncSignature(content.content, content.connector, content.uiId, pdfAsUrl, content.qrdata, content.locale, "B64", success, error);
+ this.createAsyncSignature(content.content, content.connector, content.uiId, pdfAsUrl, content.qrdata, content.locale, content.sig_pos_x, content.sig_pos_y, content.sig_pos_p, content.sig_pos_w, content.sig_pos_f, "B64", success, error);
};
pdfAs.getVersion = function(cb, err) {
@@ -139,7 +139,7 @@ pdfAs.autoResize = function(eventId, height, width){
}
};
-pdfAs.createAsyncSignature = function(pdfUrl, connector, divID, pdfAsURL, qrcode, locale, type, success, error) {
+pdfAs.createAsyncSignature = function(pdfUrl, connector, divID, pdfAsURL, qrcode, locale, sigPosX, sigPosY, sigPosP, sigPosW, sigPosF, type, success, error) {
// generate EventID
var eventId = guid();
@@ -151,7 +151,12 @@ pdfAs.createAsyncSignature = function(pdfUrl, connector, divID, pdfAsURL, qrcode
TARGETURL: document.URL,
NEW: "1",
QRCODE: qrcode,
- LOCALE: locale
+ LOCALE: locale,
+ SIG_POS_X: sigPosX,
+ SIG_POS_Y: sigPosY,
+ SIG_POS_P: sigPosP,
+ SIG_POS_W: sigPosW,
+ SIG_POS_F: sigPosF
};
/*var querystring = encodeQueryData(parameters);
diff --git a/simpleSigning/src/main/webapp/index.jsp b/simpleSigning/src/main/webapp/index.jsp
index f1da513..1cb85cd 100644
--- a/simpleSigning/src/main/webapp/index.jsp
+++ b/simpleSigning/src/main/webapp/index.jsp
@@ -155,6 +155,13 @@
var op = {
content : valueContent
};
+
+ op.sig_pos_x = document.getElementById("sig-pos-x").value;
+ op.sig_pos_y = document.getElementById("sig-pos-y").value;
+ op.sig_pos_p = document.getElementById("sig-pos-p").value;
+ op.sig_pos_w = document.getElementById("sig-pos-w").value;
+ op.sig_pos_f = document.getElementById("sig-pos-f").value;
+
var dispOption = document.getElementById("disp");
@@ -269,6 +276,13 @@
einem PDF Dokument, optional): </label> <input type="text" id="txtContent">
</div>
<div class="form-group">
+ <label for="sig-pos-x" style="width:230px">Signature X-Position (optional): </label> <input type="text" id="sig-pos-x" style="width:60px"><br>
+ <label for="sig-pos-y" style="width:230px">Signature Y-Position (optional): </label> <input type="text" id="sig-pos-y" style="width:60px"><br>
+ <label for="sig-pos-p" style="width:230px">Signature Page (optional): </label> <input type="text" id="sig-pos-p" style="width:60px"><br>
+ <label for="sig-pos-w" style="width:230px">Signature Width (optional): </label> <input type="text" id="sig-pos-w" style="width:60px"><br>
+ <label for="sig-pos-f" style="width:230px">Footer Height (optional): </label> <input type="text" id="sig-pos-f" style="width:60px">
+ </div>
+ <div class="form-group">
<button id="btnSign" onclick="return signWidthContent();">Unterschreiben</button>
</div>
<div class="form-group">
@@ -313,10 +327,18 @@
der lokalen BKU, &quot;onlinebku&quot; -&gt; Signatur mit der
online BKU, &quot;mobilebku&quot; -&gt; Signatur mit der Handy
Signatur<br>
- &nbsp;&nbsp;&nbsp;&nbsp;uiId: &quot;exampleDiv&quot; // Diese Eigenschaft
+ &nbsp;&nbsp;&nbsp;&nbsp;uiId: &quot;exampleDiv&quot;, // Diese Eigenschaft
ist optional, wenn ausgelassen wird ein Overlay erzeugt. Dies ist
die id eines div elements in das das iframe zur Benutzerinteraktion
- eingefuegt werden soll.<br>&nbsp;&nbsp; };<br> &nbsp;&nbsp;pdfAs.signText(op,
+ eingefuegt werden soll.<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;sig_pos_x: 100, // Die X-Koordinate der links-unten Signaturblockecke.<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;sig_pos_y: 100, // Die X-Koordinate der links-unten Signaturblockecke.<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;sig_pos_p: 2, // Die Seite auf der der Signaturblock platziert werden soll.<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;sig_pos_w: 250, //Die Breite des Signaturblocks<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;sig_pos_f: 40 // Die Hoehe der Fuszzeile ueber der der Signaturblock
+ platziert werden soll.<br>
+ };<br> &nbsp;&nbsp;
+ pdfAs.signText(op,
function(error, cause) {<br> &nbsp;&nbsp;&nbsp;&nbsp;//fehler error aufgetreten wegen
cause <br> &nbsp;&nbsp;}, function(pdfurl) { <br> &nbsp;&nbsp;&nbsp;&nbsp;//signiertes
Dokument liegt bei pdfurl<br> &nbsp;&nbsp;});<br> &lt;/script&gt;
@@ -338,10 +360,16 @@
der lokalen BKU, &quot;onlinebku&quot; -&gt; Signatur mit der
online BKU, &quot;mobilebku&quot; -&gt; Signatur mit der Handy
Signatur<br>
- &nbsp;&nbsp;&nbsp;&nbsp;uiId: &quot;exampleDiv&quot; // Diese Eigenschaft
+ &nbsp;&nbsp;&nbsp;&nbsp;uiId: &quot;exampleDiv&quot;, // Diese Eigenschaft
ist optional, wenn ausgelassen wird ein Overlay erzeugt. Dies ist
die id eines div elements in das das iframe zur Benutzerinteraktion
- eingefuegt werden soll.<br>
+ eingefuegt werden soll.<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;sig_pos_x: 100, // Die X-Koordinate der links-unten Signaturblockecke.<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;sig_pos_y: 100, // Die X-Koordinate der links-unten Signaturblockecke.<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;sig_pos_p: 2, // Die Seite auf der der Signaturblock platziert werden soll.<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;sig_pos_w: 250, //Die Breite des Signaturblocks<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;sig_pos_f: 40 // Die Hoehe der Fuszzeile ueber der der Signaturblock
+ platziert werden soll. <br>
&nbsp;&nbsp;};<br>
&nbsp;&nbsp;pdfAs.signPdf(op,
function(error, cause) {<br>