diff options
author | clemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2008-11-27 15:25:58 +0000 |
---|---|---|
committer | clemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2008-11-27 15:25:58 +0000 |
commit | 66e441c808de4269103cecf31ffd09252983917e (patch) | |
tree | ccba03a0f7e8fc7389491e37fec4b8b0c13aa0d0 /BKUOnline/src | |
parent | 959130f29903568c6b7fe3d6538b33887b3b1aaf (diff) | |
download | mocca-66e441c808de4269103cecf31ffd09252983917e.tar.gz mocca-66e441c808de4269103cecf31ffd09252983917e.tar.bz2 mocca-66e441c808de4269103cecf31ffd09252983917e.zip |
locale config
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@222 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'BKUOnline/src')
-rw-r--r-- | BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java | 36 | ||||
-rw-r--r-- | BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/HashDataInputServlet.java | 144 | ||||
-rw-r--r-- | BKUOnline/src/main/webapp/HTTP-ohne.html | 1 | ||||
-rw-r--r-- | BKUOnline/src/main/webapp/WEB-INF/web.xml | 12 | ||||
-rw-r--r-- | BKUOnline/src/main/webapp/WEB-INF/wsdl/stal.xsd | 1 | ||||
-rw-r--r-- | BKUOnline/src/main/webapp/appletPage.jsp | 102 | ||||
-rw-r--r-- | BKUOnline/src/main/webapp/help.jsp | 18 | ||||
-rw-r--r-- | BKUOnline/src/main/webapp/js/deployJava.js | 15 |
8 files changed, 108 insertions, 221 deletions
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java index 660fee78..f31559cd 100644 --- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java +++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java @@ -37,12 +37,14 @@ import at.gv.egiz.bku.binding.HttpUtil; import at.gv.egiz.bku.binding.IdFactory; import at.gv.egiz.bku.utils.StreamUtil; import at.gv.egiz.org.apache.tomcat.util.http.AcceptLanguage; +import javax.servlet.RequestDispatcher; /** * Handles SL requests and instantiates BindingProcessors * */ public class BKURequestHandler extends SpringBKUServlet { + public static final String BKU_APPLET_JSP = "BKUApplet"; private static final long serialVersionUID = 1L; @@ -66,23 +68,26 @@ public class BKURequestHandler extends SpringBKUServlet { protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException { log.debug("Got new request"); - HttpSession session = req.getSession(); - String lang = req.getHeader("Accept-Language"); - Locale locale = AcceptLanguage.getLocale(lang); - log.debug("Using locale: " + locale); + String acceptLanguage = req.getHeader("Accept-Language"); + Locale locale = AcceptLanguage.getLocale(acceptLanguage); + log.debug("Accept-Language locale: " + locale); + HttpSession session = req.getSession(false); if (session != null) { log.warn("Already a session with id: " + session.getId() + " active, deleting this one"); getBindingProcessorManager().removeBindingProcessor( IdFactory.getInstance().createId(session.getId())); } - String id = req.getSession(true).getId(); - log.debug("Using session id: " + id); + session = req.getSession(true); + if (log.isDebugEnabled()) { + log.debug("Using session id: " + session.getId()); + } + HTTPBindingProcessor bindingProcessor; bindingProcessor = (HTTPBindingProcessor) getBindingProcessorManager() - .createBindingProcessor(req.getRequestURL().toString(), id, locale); + .createBindingProcessor(req.getRequestURL().toString(), session.getId(), locale); Map<String, String> headerMap = new HashMap<String, String>(); for (Enumeration<String> headerName = req.getHeaderNames(); headerName @@ -109,6 +114,7 @@ public class BKURequestHandler extends SpringBKUServlet { String background = getStringFromStream(bindingProcessor.getFormData("appletBackground"), charset); String guiStyle = getStringFromStream(bindingProcessor.getFormData("appletGuiStyle"), charset); String hashDataDisplay = getStringFromStream(bindingProcessor.getFormData("appletHashDataDisplay"), charset); + String localeFormParam = getStringFromStream(bindingProcessor.getFormData("locale"), charset); if (width != null) { try { log.trace("Found applet width parameter: " + width); @@ -139,9 +145,19 @@ public class BKURequestHandler extends SpringBKUServlet { log.trace("Found applet hash data display parameter: " + hashDataDisplay); session.setAttribute("appletHashDataDisplay", hashDataDisplay); } - String redirectUrl = REDIRECT_URL+";jsessionid="+session.getId(); - log.debug("Redirecting to: "+redirectUrl); - resp.sendRedirect(redirectUrl); + if (localeFormParam != null) { + log.debug("overrule accept-language locale " + locale + " with form param " + localeFormParam); + locale = new Locale(localeFormParam); + } + if (locale != null) { + log.debug("Using locale " + locale); + session.setAttribute("locale", locale.toString()); + } + + //TODO error if no dispatcher found + RequestDispatcher dispatcher = getServletContext().getNamedDispatcher(BKU_APPLET_JSP); + log.debug("forward to applet"); + dispatcher.forward(req, resp); } protected void doGet(HttpServletRequest req, HttpServletResponse resp) diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/HashDataInputServlet.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/HashDataInputServlet.java deleted file mode 100644 index c095fcc8..00000000 --- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/HashDataInputServlet.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright 2008 Federal Chancellery Austria and - * Graz University of Technology - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package at.gv.egiz.bku.online.webapp; - -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.Reader; -import java.io.Writer; -import java.util.List; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import at.gv.egiz.bku.binding.BindingProcessor; -import at.gv.egiz.bku.binding.Id; -import at.gv.egiz.bku.binding.IdFactory; -import at.gv.egiz.bku.slexceptions.SLRuntimeException; -import at.gv.egiz.bku.utils.StreamUtil; -import at.gv.egiz.stal.HashDataInput; -import at.gv.egiz.stal.STAL; -import at.gv.egiz.stal.service.impl.STALRequestBroker; - -public class HashDataInputServlet extends SpringBKUServlet { - - private static Log log = LogFactory.getLog(HashDataInputServlet.class); - - public HashDataInputServlet() { - - } - - private STALRequestBroker getSTAL(Id id) { - BindingProcessor bp = getBindingProcessorManager().getBindingProcessor(id); - if (bp == null) { - return null; - } - STAL stal = bp.getSTAL(); - if (stal instanceof STALRequestBroker) { - return (STALRequestBroker) stal; - } else { - throw new SLRuntimeException("Unexpected STAL type"); - } - } - - private static boolean isMSIE(HttpServletRequest req) { - String useragent = req.getHeader("User-Agent"); - String user = useragent.toLowerCase(); - return (user.indexOf("msie") != -1); - } - - @Override - protected void doGet(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - if ((req.getSession() == null) && (req.getSession().getId() != null)) { - log.warn("Got request for hashdatainput without session info"); - resp.sendRedirect("expired.html"); - return; - } - Id sessionId = IdFactory.getInstance().createId(req.getSession().getId()); - log.debug("Got request for hashdata for session " + sessionId); - STALRequestBroker rb = getSTAL(sessionId); - if (rb == null) { - log.info("STAL instance not found for session: " + sessionId); - resp.sendRedirect("expired.html"); - return; - } - List<HashDataInput> hdi = rb.getHashDataInput(); - log.debug("Got hashdata list with " + hdi.size() + " entries"); - String param = req.getParameter("refId"); - log.debug("Got request for refId:" + param); - if ((param == null) && (hdi.size() > 1)) { - resp.sendRedirect("multiHashDataInput.html"); - return; - } - - if ((param == null) && (hdi.size() == 1)) { - param = hdi.get(0).getReferenceId(); - log.debug("Request parameter not set, setting to: " + param); - } - for (HashDataInput hd : hdi) { - if (hd.getReferenceId().equals(param)) { - log.debug("Found hashdatainput for refId:" + param); - resp.setContentType(hd.getMimeType()); - - String charSet = hd.getEncoding(); - if (charSet == null) { - charSet = "UTF-8"; - } - resp.setCharacterEncoding(charSet); - if (isMSIE(req)) { - String fileExt = hd.getMimeType().equalsIgnoreCase("text/plain") ? ".txt" - : ".xhtml"; - if (fileExt.equals(".xhtml")) { - if (req.getParameter("ieCType") == null) { - resp.sendRedirect("ieView.html"); - return; - } else { - resp.setContentType(req.getParameter("ieCType")); - if (req.getParameter("ieCType").equals("application/xhtml+xml")) { - resp.addHeader("content-disposition", "attachment; filename=" - + param + ".xhtml"); - } - } - } - } - Reader r = new InputStreamReader(hd.getHashDataInput(), charSet); - Writer w = new OutputStreamWriter(resp.getOutputStream(), charSet); - StreamUtil.copyStream(r, w); - w.flush(); - return; - - } - } - log.error("Cannot find hashdata for id:" + param); - resp.sendError(404); - return; - } - - @Override - protected void doPost(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - doGet(req, resp); - } - -} diff --git a/BKUOnline/src/main/webapp/HTTP-ohne.html b/BKUOnline/src/main/webapp/HTTP-ohne.html index 607fa5d4..e5a35cf0 100644 --- a/BKUOnline/src/main/webapp/HTTP-ohne.html +++ b/BKUOnline/src/main/webapp/HTTP-ohne.html @@ -59,6 +59,7 @@ legend { <p> <form action="./http-security-layer-request" method="Post" enctype="application/x-www-form-urlencoded"> + <!--input name="locale" value="es_MX" type="hidden" /--> <fieldset><legend>Enter XML Request</legend> <p><label for="XMLRequest">XML Request</label> <textarea name="XMLRequest" rows=15 cols="60" id="XMLRequest"> diff --git a/BKUOnline/src/main/webapp/WEB-INF/web.xml b/BKUOnline/src/main/webapp/WEB-INF/web.xml index f6fdbefc..a9cdce13 100644 --- a/BKUOnline/src/main/webapp/WEB-INF/web.xml +++ b/BKUOnline/src/main/webapp/WEB-INF/web.xml @@ -48,10 +48,10 @@ <param-value>expired.html</param-value> </init-param> </servlet> - <servlet> - <servlet-name>HashDataInputServlet</servlet-name> - <servlet-class>at.gv.egiz.bku.online.webapp.HashDataInputServlet</servlet-class> - </servlet> + <servlet> + <servlet-name>BKUApplet</servlet-name> + <jsp-file>/appletPage.jsp</jsp-file> + </servlet> <servlet> <servlet-name>help</servlet-name> <jsp-file>/help.jsp</jsp-file> @@ -68,10 +68,6 @@ <servlet-name>ResultServlet</servlet-name> <url-pattern>/bkuResult</url-pattern> </servlet-mapping> - <servlet-mapping> - <servlet-name>HashDataInputServlet</servlet-name> - <url-pattern>/hashDataInput</url-pattern> - </servlet-mapping> <servlet-mapping> <servlet-name>help</servlet-name> <url-pattern>/help/*</url-pattern> diff --git a/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal.xsd b/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal.xsd index 6f3946dc..761b5556 100644 --- a/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal.xsd +++ b/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal.xsd @@ -74,6 +74,7 @@ <element name="InfoboxReadRequest" type="tns:InfoboxReadRequestType"/> <element name="SignRequest" type="tns:SignRequestType"/> <element name="QuitRequest" type="tns:QuitRequestType"/> + <!--any namespace="##other" /--> </choice> <attribute name="SessionId" type="string"/> </complexType> diff --git a/BKUOnline/src/main/webapp/appletPage.jsp b/BKUOnline/src/main/webapp/appletPage.jsp index e864612c..366a390a 100644 --- a/BKUOnline/src/main/webapp/appletPage.jsp +++ b/BKUOnline/src/main/webapp/appletPage.jsp @@ -15,57 +15,57 @@ limitations under the License. --> <%@ page language="java" contentType="text/html; charset=UTF-8" - pageEncoding="UTF-8"%> + pageEncoding="UTF-8"%> + <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> -<head> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> -<title>MOCCA Applet</title> -<link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon"> -<script type="text/javascript" src="js/deployJava.js"></script> -<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"> -<META HTTP-EQUIV="EXPIRES" CONTENT="Mon, 22 Jul 2002 11:12:01 GMT"> -<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> -</head> -<body> -<% - int width = session.getAttribute("appletWidth") == null ? 190 - : (Integer) session.getAttribute("appletWidth"); - int height = session.getAttribute("appletHeight") == null ? 130 - : (Integer) session.getAttribute("appletHeight"); - String backgroundImg = (String) session.getAttribute("appletBackground"); - String guiStyle = (String) session.getAttribute("appletGuiStyle"); - String hashDataDisplay = (String) session.getAttribute("appletHashDataDisplay"); -%> -<script> - if (!deployJava.versionCheck('1.6.0_04+')) { - document - .write('<b>Diese Anwendung benötigt die Java Platform Version 1.6.0_04 oder höher.</b>' + '<input type="submit" value="Java Platform 1.6.0_02 installieren" onclick="deployJava.installLatestJRE();">'); - } else { - var attributes = { - codebase :'applet', - code :'at.gv.egiz.bku.online.applet.BKUApplet.class', - archive :'BKUApplet-1.0.2-SNAPSHOT.jar, commons-logging-1.1.1.jar, iaik_jce_me4se-3.04.jar', - width : <%=width%>, - height :<%=height%> - }; - var parameters = { - GuiStyle : '<%=guiStyle%>', - Background : '<%=backgroundImg%>', - WSDL_URL :'../stal?wsdl', - HelpURL : '../help/', - HashDataDisplay : '<%=hashDataDisplay%>', - HashDataURL : '../hashDataInput', - SessionID : '<%=session.getId()%>', - RedirectURL : '../bkuResult', - RedirectTarget: '_parent' - }; - var version = '1.6.0_04'; - deployJava.runApplet(attributes, parameters, version); - } -</script> -<!--br /> -<hr/> -Powered by <img src="img/mocca-t_s.png" alt="mocca-logo" width="100"--> -</body> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <title>MOCCA Applet</title> + <link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon"> + <script type="text/javascript" src="js/deployJava.js"></script> + <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"> + <META HTTP-EQUIV="EXPIRES" CONTENT="Mon, 22 Jul 2002 11:12:01 GMT"> + <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> + </head> + <body> <!-- style="background:#e8f4fe"--> + <% + int width = session.getAttribute("appletWidth") == null ? 190 + : (Integer) session.getAttribute("appletWidth"); + int height = session.getAttribute("appletHeight") == null ? 130 + : (Integer) session.getAttribute("appletHeight"); + String backgroundImg = (String) session.getAttribute("appletBackground"); + String guiStyle = (String) session.getAttribute("appletGuiStyle"); + String hashDataDisplay = (String) session.getAttribute("appletHashDataDisplay"); + String locale = (String) session.getAttribute("locale"); + %> + <script> + if (!deployJava.versionCheck('1.6.0_04+')) { + document + .write('<b>Diese Anwendung benötigt die Java Platform Version 1.6.0_04 oder höher.</b>' + '<input type="submit" value="Java Platform 1.6.0_02 installieren" onclick="deployJava.installLatestJRE();">'); + } else { + var attributes = { + codebase :'applet', + code :'at.gv.egiz.bku.online.applet.BKUApplet.class', + archive :'BKUApplet-1.0.2-SNAPSHOT.jar, commons-logging-1.1.1.jar, iaik_jce_me4se-3.04.jar', + width : <%=width%>, + height :<%=height%> + }; + var parameters = { + GuiStyle : '<%=guiStyle%>', + Locale : '<%=locale%>', + Background : '<%=backgroundImg%>', + WSDL_URL :'../stal?wsdl', + HelpURL : '../help/', + HashDataDisplay : '<%=hashDataDisplay%>', + HashDataURL : '../hashDataInput', + SessionID : '<%=session.getId()%>', + RedirectURL : '../bkuResult', + RedirectTarget: '_parent' + }; + var version = '1.6.0_04'; + deployJava.runApplet(attributes, parameters, version); + } + </script> + </body> </html> diff --git a/BKUOnline/src/main/webapp/help.jsp b/BKUOnline/src/main/webapp/help.jsp index 72781e38..d7dbf0ef 100644 --- a/BKUOnline/src/main/webapp/help.jsp +++ b/BKUOnline/src/main/webapp/help.jsp @@ -16,14 +16,20 @@ --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> -<%@ page import="java.util.Locale"%> +<%@ page import="java.io.File"%> <% - String pathInfo[] = (request.getPathInfo() != null) ? request + String pathInfo[] = (request.getPathInfo() != null) ? request .getPathInfo().split("/") : new String[] {}; - String language = pathInfo[1].split("_")[0]; - String filename = pathInfo[2]; - String path = "/helpfiles/" + language.toLowerCase() + "/" + filename; - System.out.println(path); + String language = pathInfo[1].split("_")[0]; + String filename = pathInfo[2]; + String helpDir = "/helpfiles"; + String path; + if ((new File(helpDir + "/" + language.toLowerCase())).isDirectory()) { + path = helpDir + "/" + language.toLowerCase() + "/" + filename; + } else { + path = helpDir + "/de/" + filename; + } + System.out.println(path); %> <jsp:include page="<%=path%>" flush="true"/> diff --git a/BKUOnline/src/main/webapp/js/deployJava.js b/BKUOnline/src/main/webapp/js/deployJava.js index 4d8a0ca3..5466cbdd 100644 --- a/BKUOnline/src/main/webapp/js/deployJava.js +++ b/BKUOnline/src/main/webapp/js/deployJava.js @@ -40,7 +40,7 @@ * http://java.com/js/deployJava.js. * You are encouraged to link directly to the live copy of the file. * - * @version @(#)deployJava.js 1.11 08/07/11 + * @version @(#)deployJava.js 1.13 08/10/28 */ var deployJava = { @@ -88,7 +88,7 @@ var deployJava = { } } else { var browser = deployJava.getBrowser(); - + if (browser == 'MSIE') { if (deployJava.testUsingActiveX('1.8.0')) { list[0] = '1.8.0'; @@ -319,11 +319,18 @@ var deployJava = { document.write(s); if (parameters != 'undefined' && parameters != null) { + var codebaseParam = false; for (var parameter in parameters) { + if (parameter == 'codebase_lookup') { + codebaseParam = true; + } s = '<param name="' + parameter + '" value="' + parameters[parameter] + '">'; document.write(s); } + if (!codebaseParam) { + document.write('<param name="codebase_lookup" value="false">'); + } } document.write('<' + '/' + 'applet' + '>'); }, @@ -630,6 +637,10 @@ var deployJava = { alert('We claim to have detected "IE".'); } return 'MSIE'; +// } else if ((browser.indexOf('konqueror') != -1)) { +// if (deployJava.debug) { +// alert('We claim to have detected "Konqueror".'); +// } } else if ((browser.indexOf('mozilla') != -1) || (browser.indexOf('firefox') != -1)) { if (deployJava.debug) { |