From 68a6b55068c5d5a1a2656f642c6b870fbe3cd141 Mon Sep 17 00:00:00 2001
From: Andreas Fitzek <andreas.fitzek@iaik.tugraz.at>
Date: Fri, 6 Jun 2014 16:17:21 +0200
Subject: support for Locale Paramter including Mobile BKU

---
 .../java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java    | 16 ++++++++++++++++
 .../at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java |  3 +++
 pdf-as-web/src/main/resources/template_sl.html           |  1 +
 3 files changed, 20 insertions(+)

(limited to 'pdf-as-web/src/main')

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 98bbd660..85a36e17 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
@@ -80,6 +80,7 @@ public class PdfAsHelper {
 	private static final String PDF_SIGNER = "PDF_SIGNER";
 	private static final String PDF_SL_INTERACTIVE = "PDF_SL_INTERACTIVE";
 	private static final String PDF_SIGNED_DATA = "PDF_SIGNED_DATA";
+	private static final String PDF_LOCALE = "PDF_LOCALE";
 	private static final String PDF_ERR_MESSAGE = "PDF_ERR_MESSAGE";
 	private static final String PDF_ERR_THROWABLE = "PDF_ERR_THROWABLE";
 	private static final String PDF_ERROR_PAGE = "/ErrorPage";
@@ -547,11 +548,13 @@ public class PdfAsHelper {
 				String url = generateDataURL(request, response);
 				String slRequest = SLMarschaller.marshalToString(readRequest);
 				String template = getTemplateSL();
+				String locale = getLocale(request, response);
 				template = template.replace("##BKU##",
 						generateBKUURL(connector));
 				template = template.replace("##XMLRequest##",
 						StringEscapeUtils.escapeHtml4(slRequest));
 				template = template.replace("##DataURL##", url);
+				template = template.replace("##LOCALE##", locale);
 				
 				if(statusRequest.getSignParameter().getTransactionId() != null) {
 					template = template.replace("##ADDITIONAL##", "<input type=\"hidden\" name=\"TransactionId_\" value=\"" + 
@@ -658,6 +661,19 @@ public class PdfAsHelper {
 		HttpSession session = request.getSession();
 		session.setAttribute(PDF_SIGNED_DATA, signedData);
 	}
+	
+	public static void setLocale(HttpServletRequest request,
+			HttpServletResponse response, String locale) {
+		HttpSession session = request.getSession();
+		session.setAttribute(PDF_LOCALE, locale);
+	}
+
+	public static String getLocale(HttpServletRequest request,
+			HttpServletResponse response) {
+		HttpSession session = request.getSession();
+		Object obj = session.getAttribute(PDF_LOCALE);
+		return obj == null ? "DE" : obj.toString();
+	}
 
 	public static void setSessionException(HttpServletRequest request,
 			HttpServletResponse response, String message, Throwable e) {
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java
index 9d19fd45..f3c3fcca 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java
@@ -247,6 +247,9 @@ public class ExternSignServlet extends HttpServlet {
 		String errorUrl = PdfAsParameterExtractor.getInvokeErrorURL(request);
 		PdfAsHelper.setErrorURL(request, response, errorUrl);
 		
+		String locale = PdfAsParameterExtractor.getLocale(request);
+		PdfAsHelper.setLocale(request, response, locale);
+		
 		if(pdfData == null) {
 			throw new PdfAsException("No Signature data available");
 		}
diff --git a/pdf-as-web/src/main/resources/template_sl.html b/pdf-as-web/src/main/resources/template_sl.html
index b8ea4df7..8399706c 100644
--- a/pdf-as-web/src/main/resources/template_sl.html
+++ b/pdf-as-web/src/main/resources/template_sl.html
@@ -50,6 +50,7 @@ div.content {
 						name="Senden"> <input type="hidden"
 						name="XMLRequest" value="##XMLRequest##"> <input
 						type="hidden" name="DataURL" value="##DataURL##">
+						<input type="hidden" name="locale_" value="##LOCALE##" />
 						##ADDITIONAL##
 				</form>
 				<span id="spin" style="display:block;
-- 
cgit v1.2.3