summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-04-03 15:04:26 +0000
committerclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-04-03 15:04:26 +0000
commit78728a96af022bae87e4d0d11855f420736d87b7 (patch)
treeee855aba3e8bbc988f72c361406c2c0013f8030a
parent2dbf2347bc78fd835c857ad438514fb6251f6f7a (diff)
downloadmocca-78728a96af022bae87e4d0d11855f420736d87b7.tar.gz
mocca-78728a96af022bae87e4d0d11855f420736d87b7.tar.bz2
mocca-78728a96af022bae87e4d0d11855f420736d87b7.zip
applet dispatcher (prevent applet caching)
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@326 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
-rw-r--r--BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/ManagementPINProviderFactory.java6
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java2
-rw-r--r--BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties2
-rw-r--r--BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties2
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/AppletDispatcher.java111
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java2
-rw-r--r--BKUOnline/src/main/webapp/WEB-INF/web.xml16
-rw-r--r--BKUOnline/src/main/webapp/applet.jsp38
8 files changed, 155 insertions, 24 deletions
diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/ManagementPINProviderFactory.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/ManagementPINProviderFactory.java
index 090caf50..f54f89d4 100644
--- a/BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/ManagementPINProviderFactory.java
+++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/smccstal/ext/ManagementPINProviderFactory.java
@@ -122,8 +122,12 @@ public class ManagementPINProviderFactory extends PINProviderFactory {
String title, message;
Object[] params;
if (retry) {
+ if (retries == 1) {
+ message = BKUGUIFacade.MESSAGE_LAST_RETRY_PINPAD;
+ } else {
+ message = BKUGUIFacade.MESSAGE_RETRIES_PINPAD;
+ }
title = BKUGUIFacade.TITLE_RETRY;
- message = BKUGUIFacade.MESSAGE_RETRIES;
params = new Object[]{String.valueOf(retries)};
} else if (type == PINManagementGUIFacade.DIALOG.VERIFY) {
title = PINManagementGUIFacade.TITLE_VERIFY_PIN;
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java
index 4b079428..79fbfd6c 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java
@@ -77,6 +77,8 @@ public interface BKUGUIFacade {
public static final String MESSAGE_HASHDATALIST = "hashdatalist";
public static final String MESSAGE_RETRIES = "retries";
public static final String MESSAGE_LAST_RETRY = "retries.last";
+ public static final String MESSAGE_RETRIES_PINPAD = "retries.pinpad";
+ public static final String MESSAGE_LAST_RETRY_PINPAD = "retries.pinpad.last";
public static final String MESSAGE_OVERWRITE = "overwrite";
public static final String MESSAGE_HELP = "help";
diff --git a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties
index 9bfe8fb1..146d9353 100644
--- a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties
+++ b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties
@@ -46,6 +46,8 @@ hashdatalink.tiny=<html><a href=\"anzeige\">Signaturdaten</a></html>
hashdatalist=<html>{0} Signaturdaten:</html>
retries.last=<html>Letzter Versuch!</html>
retries=<html>Noch {0} Versuche</html>
+retries.pinpad.last=<html>Eingabe wiederholen, letzter Versuch!</html>
+retries.pinpad=<html>Eingabe wiederholen, noch {0} Versuche</html>
overwrite=<html>M\u00F6chten Sie das existierende Dokument {0} \u00FCberschreiben?</html>
help=<html>Hilfe zu {0}</html>
diff --git a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties
index a36f9b83..1a40aeea 100644
--- a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties
+++ b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties
@@ -44,6 +44,8 @@ hashdatalink.tiny=<html><a href=\"anzeige\">signature data</a></html>
hashdatalist=<html>{0} signature data objects:</html>
retries.last=<html>Last try!</html>
retries=<html>{0} tries left</html>
+retries.pinpad.last=<html>Re-enter pin, last try!</html>
+retries.pinpad=<html>Re-enter pin, {0} tries left</html>
overwrite=<html>Overwrite {0}?</html>
help=<html>Help topic {0}</html>
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/AppletDispatcher.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/AppletDispatcher.java
new file mode 100644
index 00000000..26349f7c
--- /dev/null
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/AppletDispatcher.java
@@ -0,0 +1,111 @@
+/*
+ * 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.PrintWriter;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * prevent applet caching,
+ * could be removed once applet is loaded via jnlp
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class AppletDispatcher extends HttpServlet {
+
+ protected final static Log log = LogFactory.getLog(AppletDispatcher.class);
+
+ public static final String DISPATCH_CTX = "dispatch/";
+ public static final String RAND_PREFIX = "__";
+ public static final String RAND_ATTRIBUTE = "rand";
+ public static final Pattern ctxPattern = Pattern.compile(DISPATCH_CTX);
+ public static final Pattern archivePattern = Pattern.compile(RAND_PREFIX + "[a-zA-Z0-9]*\\.jar$");
+
+ /**
+ * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ protected void processRequest(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+
+// String suffix = (String) request.getSession().getAttribute(RAND_CTX_ATTRIBUTE);
+// log.trace("expecting random suffix " + suffix);
+
+ String uri = request.getRequestURI();
+ uri = ctxPattern.matcher(uri).replaceAll("");
+// uri = uri.replaceAll(suffix, ""); //only the applet jar requests contains the randCtx
+ uri = archivePattern.matcher(uri).replaceAll(".jar");
+
+ if (log.isTraceEnabled()) {
+ log.trace("dispatching request URI " + request.getRequestURI() +
+ " to " + uri);
+ }
+
+ RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(uri);
+ dispatcher.forward(request, response);
+ }
+
+ // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
+ /**
+ * Handles the HTTP <code>GET</code> method.
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ processRequest(request, response);
+ }
+
+ /**
+ * Handles the HTTP <code>POST</code> method.
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ processRequest(request, response);
+ }
+
+ /**
+ * Returns a short description of the servlet.
+ * @return a String containing servlet description
+ */
+ @Override
+ public String getServletInfo() {
+ return "Short description";
+ }// </editor-fold>
+
+}
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 68a57fb5..1d0cb7e9 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
@@ -51,7 +51,7 @@ public class BKURequestHandler extends SpringBKUServlet {
private static final long serialVersionUID = 1L;
- public final static String REDIRECT_URL_SESSION_ATTRIBUTE="redirectUrl";
+ public final static String REDIRECT_URL_SESSION_ATTRIBUTE = "redirectUrl";
protected Log log = LogFactory.getLog(BKURequestHandler.class);
diff --git a/BKUOnline/src/main/webapp/WEB-INF/web.xml b/BKUOnline/src/main/webapp/WEB-INF/web.xml
index 1a9b7d78..2987ac57 100644
--- a/BKUOnline/src/main/webapp/WEB-INF/web.xml
+++ b/BKUOnline/src/main/webapp/WEB-INF/web.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
- <!--
+<!--
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
@@ -12,9 +12,7 @@
the specific language governing permissions and limitations under the
License.
-->
-<web-app id="bkuonline" version="2.5"
- xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+<web-app id="bkuonline" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>http-security-layer-request</display-name>
<!-- Begin Spring Config -->
@@ -53,6 +51,10 @@
<jsp-file>/applet.jsp</jsp-file>
</servlet>
<servlet>
+ <servlet-name>AppletDispatcher</servlet-name>
+ <servlet-class>at.gv.egiz.bku.online.webapp.AppletDispatcher</servlet-class>
+ </servlet>
+ <servlet>
<servlet-name>BKUAppletAlternative</servlet-name>
<jsp-file>/appletAlternative.jsp</jsp-file>
</servlet>
@@ -76,6 +78,10 @@
<servlet-name>help</servlet-name>
<url-pattern>/help/*</url-pattern>
</servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>AppletDispatcher</servlet-name>
+ <url-pattern>/applet/dispatch/*</url-pattern>
+ </servlet-mapping>
<!-- End BKU Config -->
@@ -106,4 +112,4 @@
<session-config>
<session-timeout>5</session-timeout>
</session-config>
-</web-app> \ No newline at end of file
+</web-app>
diff --git a/BKUOnline/src/main/webapp/applet.jsp b/BKUOnline/src/main/webapp/applet.jsp
index 591ed1bf..6af81578 100644
--- a/BKUOnline/src/main/webapp/applet.jsp
+++ b/BKUOnline/src/main/webapp/applet.jsp
@@ -15,7 +15,8 @@
limitations under the License.
-->
<%@ page language="java" contentType="text/html; charset=UTF-8"
- pageEncoding="UTF-8"%>
+ pageEncoding="UTF-8"
+ import="at.gv.egiz.bku.online.webapp.AppletDispatcher, org.apache.commons.lang.RandomStringUtils" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
@@ -41,16 +42,19 @@
String guiStyle = (String) session.getAttribute("appletGuiStyle");
String locale = (String) session.getAttribute("locale");
String extension = (String) session.getAttribute("extension");
+ String rand = AppletDispatcher.RAND_PREFIX +
+ RandomStringUtils.randomAlphanumeric(16);
+ //(String) session.getAttribute(AppletDispatcher.RAND_ATTRIBUTE);
String appletClass, appletArchive;
if ("activation".equals(extension)) {
- appletArchive = "BKUAppletExt.jar";
+ appletArchive = "BKUAppletExt";
appletClass = "at.gv.egiz.bku.online.applet.ActivationApplet.class";
} else if ("pin".equals(extension)) {
- appletArchive = "BKUAppletExt.jar";
+ appletArchive = "BKUAppletExt";
appletClass = "at.gv.egiz.bku.online.applet.PINManagementApplet.class";
} else {
- appletArchive = "BKUApplet.jar";
+ appletArchive = "BKUApplet";
appletClass = "at.gv.egiz.bku.online.applet.BKUApplet.class";
}
%>
@@ -61,21 +65,21 @@
.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 : '<%=appletClass%>',
- archive : '<%=appletArchive + ", commons-logging.jar, iaik_jce_me4se.jar"%>',
- width : <%=width%>,
- height :<%=height%>
+ codebase :'<%="applet/" + AppletDispatcher.DISPATCH_CTX %>',
+ code : '<%=appletClass%>',
+ archive : '<%=appletArchive + rand +".jar, commons-logging.jar, iaik_jce_me4se.jar"%>',
+ width : <%=width%>,
+ height :<%=height%>
};
var parameters = {
- GuiStyle : '<%=guiStyle%>',
- Locale : '<%=locale%>',
- Background : '<%=backgroundImg%>',
- WSDL_URL :'../stal;jsessionid=<%=session.getId()%>?wsdl',
- HelpURL : '../help/',
- SessionID : '<%=session.getId()%>',
- RedirectURL : '../bkuResult',
- RedirectTarget: '_parent'
+ GuiStyle : '<%=guiStyle%>',
+ Locale : '<%=locale%>',
+ Background : '<%=backgroundImg%>',
+ WSDL_URL :'../../stal;jsessionid=<%=session.getId()%>?wsdl',
+ HelpURL : '../../help/',
+ SessionID : '<%=session.getId()%>',
+ RedirectURL : '../../bkuResult',
+ RedirectTarget: '_parent'
};
var version = '1.6.0_04';
deployJava.runApplet(attributes, parameters, version);