From 3d7d82dae1642a01dac69cf550ccdcb6b571357c Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Tue, 18 Feb 2014 09:25:47 +0100 Subject: Fixed PDF-AS Web Page parameters problem Signed-off-by: Andreas Fitzek --- .../at/gv/egiz/pdfas/web/helper/PdfAsHelper.java | 35 +++++++++++++--------- 1 file changed, 21 insertions(+), 14 deletions(-) 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 13e8159f..607c6228 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 @@ -164,13 +164,17 @@ public class PdfAsHelper { if (posP != null) { if (!(posP.equals("auto") || posP.equals("new"))) { - throw new PdfAsWebException( - PdfAsParameterExtractor.PARAM_SIG_POS_P - + " has invalid value! (auto | new )"); + try { + Integer.parseInt(posP); + } catch (NumberFormatException e) { + throw new PdfAsWebException( + PdfAsParameterExtractor.PARAM_SIG_POS_P + + " has invalid value! (auto | new )"); + } } sb.append("p:" + posP.trim() + ";"); } else { - sb.append("P:auto;"); + sb.append("p:auto;"); } return sb.toString(); @@ -284,7 +288,7 @@ public class PdfAsHelper { HttpSession session = request.getSession(); logger.info("Starting signature in session: " + session.getId()); - + Configuration config = pdfAs.getConfiguration(); session.setAttribute(PDF_CONFIG, config); @@ -354,10 +358,11 @@ public class PdfAsHelper { StatusRequest statusRequest = (StatusRequest) session .getAttribute(PDF_STATUS); - if(statusRequest == null) { - throw new PdfAsWebException("No Signature running in session:" + session.getId()); + if (statusRequest == null) { + throw new PdfAsWebException("No Signature running in session:" + + session.getId()); } - + statusRequest.setCertificate(getCertificate(infoboxReadResponseType)); statusRequest = pdfAs.process(statusRequest); session.setAttribute(PDF_STATUS, statusRequest); @@ -376,10 +381,11 @@ public class PdfAsHelper { StatusRequest statusRequest = (StatusRequest) session .getAttribute(PDF_STATUS); - if(statusRequest == null) { - throw new PdfAsWebException("No Signature running in session:" + session.getId()); + if (statusRequest == null) { + throw new PdfAsWebException("No Signature running in session:" + + session.getId()); } - + statusRequest.setSigature(createCMSSignatureResponseType .getCMSSignature()); statusRequest = pdfAs.process(statusRequest); @@ -387,10 +393,11 @@ public class PdfAsHelper { PdfAsHelper.process(request, response, context); } - + public static void logAccess(HttpServletRequest request) { HttpSession session = request.getSession(); - logger.debug("Access to " + request.getServletPath() + " in Session: " + session.getId()); + logger.debug("Access to " + request.getServletPath() + " in Session: " + + session.getId()); } public static void process(HttpServletRequest request, @@ -630,7 +637,7 @@ public class PdfAsHelper { logger.info("Generated URL: " + dataURL); return dataURL; } - + public static void regenerateSession(HttpServletRequest request) { request.getSession(false).invalidate(); request.getSession(true); -- cgit v1.2.3