aboutsummaryrefslogtreecommitdiff
path: root/simpleSigning/src/main/java/at/gv
diff options
context:
space:
mode:
Diffstat (limited to 'simpleSigning/src/main/java/at/gv')
-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
2 files changed, 164 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;
+
+ }
}
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;
+ }
+ }
}