aboutsummaryrefslogtreecommitdiff
path: root/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/StartSignature.java
diff options
context:
space:
mode:
Diffstat (limited to 'simpleSigning/src/main/java/at/gv/egiz/simpleSigning/StartSignature.java')
-rw-r--r--simpleSigning/src/main/java/at/gv/egiz/simpleSigning/StartSignature.java102
1 files changed, 101 insertions, 1 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 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;
+
+ }
}