From 22001c93bca360d1b15c252cb22d2a4147ff350d Mon Sep 17 00:00:00 2001
From: clemenso
Date: Thu, 20 Aug 2009 16:24:55 +0000
Subject: [#430] Activation/PIN-management in MOCCA Web Start - new Modules:
smccSTALExt, BKUGuiExt in order not to depend on BKUAppletExt in BKULocal -
provide stal-request handler de-registration in abstractSMCCSTAL
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@448 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
BKULocal/pom.xml | 25 +--
.../java/at/gv/egiz/bku/local/gui/GUIProxy.java | 55 +++++++
.../at/gv/egiz/bku/local/stal/BKUGuiProxy.java | 156 -------------------
.../at/gv/egiz/bku/local/stal/LocalBKUWorker.java | 6 +-
.../gv/egiz/bku/local/stal/LocalSTALFactory.java | 18 ++-
.../bku/local/webapp/PINManagementServlet.java | 167 +++++++++++++++++++++
BKULocal/src/main/webapp/WEB-INF/web.xml | 10 +-
BKULocal/src/main/webapp/index.html | 7 +-
8 files changed, 271 insertions(+), 173 deletions(-)
create mode 100644 BKULocal/src/main/java/at/gv/egiz/bku/local/gui/GUIProxy.java
delete mode 100644 BKULocal/src/main/java/at/gv/egiz/bku/local/stal/BKUGuiProxy.java
create mode 100644 BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/PINManagementServlet.java
(limited to 'BKULocal')
diff --git a/BKULocal/pom.xml b/BKULocal/pom.xml
index 9704b7db..81cb3df8 100644
--- a/BKULocal/pom.xml
+++ b/BKULocal/pom.xml
@@ -93,6 +93,21 @@
smccSTAL
1.2.2-SNAPSHOT
+
+ at.gv.egiz
+ BKUGuiExt
+ 1.2.2-SNAPSHOT
+
+
+ at.gv.egiz
+ smccSTALExt
+ 1.2.2-SNAPSHOT
+
+
+ at.gv.egiz
+ BKUViewer
+ 1.2.2-SNAPSHOT
+
BKUHelp
at.gv.egiz
@@ -117,16 +132,6 @@
commons-logging
commons-logging
-
- at.gv.egiz
- BKUApplet
- 1.2.2-SNAPSHOT
-
-
- at.gv.egiz
- BKUViewer
- 1.2.2-SNAPSHOT
-
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/gui/GUIProxy.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/gui/GUIProxy.java
new file mode 100644
index 00000000..38dd04d9
--- /dev/null
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/gui/GUIProxy.java
@@ -0,0 +1,55 @@
+/*
+ * 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.local.gui;
+
+import at.gv.egiz.bku.gui.BKUGUIFacade;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import javax.swing.JFrame;
+
+/**
+ *
+ * @author Clemens Orthacker
+ */
+public class GUIProxy implements InvocationHandler {
+
+ JFrame frame;
+ BKUGUIFacade delegate;
+
+ static public Object newInstance(BKUGUIFacade gui, JFrame frame, Class[] interfaces) {
+ return java.lang.reflect.Proxy.newProxyInstance(gui.getClass().getClassLoader(),
+ interfaces,
+ new GUIProxy(gui, frame));
+ }
+
+ private GUIProxy(BKUGUIFacade delegate, JFrame frame) {
+ this.frame = frame;
+ this.delegate = delegate;
+ }
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+
+ if (method.getName().startsWith("show")) {
+ frame.setVisible(true);
+ frame.toFront();
+ return method.invoke(delegate, args);
+ } else { //if (method.getName().startsWith("get")) {
+ return method.invoke(delegate, args);
+ }
+ }
+}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/BKUGuiProxy.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/BKUGuiProxy.java
deleted file mode 100644
index c724c071..00000000
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/BKUGuiProxy.java
+++ /dev/null
@@ -1,156 +0,0 @@
-package at.gv.egiz.bku.local.stal;
-
-import java.awt.event.ActionListener;
-import java.util.List;
-
-import java.util.Locale;
-import javax.swing.JDialog;
-
-import at.gv.egiz.bku.gui.BKUGUIFacade;
-import at.gv.egiz.smcc.PINSpec;
-import at.gv.egiz.stal.HashDataInput;
-import javax.swing.JFrame;
-
-public class BKUGuiProxy implements BKUGUIFacade {
-
- private BKUGUIFacade delegate;
- private JFrame dialog;
-
- public BKUGuiProxy(JFrame dialog, BKUGUIFacade delegate) {
- this.delegate = delegate;
- this.dialog = dialog;
- }
-
- private void showDialog() {
- dialog.setVisible(true);
- dialog.setAlwaysOnTop(true);
- }
-
- @Override
- public char[] getPin() {
- return delegate.getPin();
- }
-
-// @Override
-// public void init(Container contentPane, Locale locale, URL bgImage, ActionListener helpListener) {
-// delegate.init(contentPane, locale, bgImage, helpListener);
-// }
-
- @Override
- public Locale getLocale() {
- return delegate.getLocale();
- }
-
-// @Override
-// public void showCardNotSupportedDialog(ActionListener cancelListener,
-// String actionCommand) {
-// showDialog();
-// delegate.showCardNotSupportedDialog(cancelListener, actionCommand);
-// }
-//
-// @Override
-// public void showCardPINDialog(PINSpec pinSpec, ActionListener okListener,
-// String okCommand, ActionListener cancelListener, String cancelCommand) {
-// showDialog();
-// delegate.showCardPINDialog(pinSpec, okListener, okCommand, cancelListener,
-// cancelCommand);
-// }
-//
- @Override
- public void showCardPINDialog(PINSpec pinSpec, int numRetries,
- ActionListener okListener, String okCommand,
- ActionListener cancelListener, String cancelCommand) {
- showDialog();
- delegate.showCardPINDialog(pinSpec, numRetries, okListener, okCommand,
- cancelListener, cancelCommand);
- }
-
- @Override
- public void showErrorDialog(String errorMsgKey, Object[] errorMsgParams, ActionListener okListener,
- String actionCommand) {
- showDialog();
- delegate.showErrorDialog(errorMsgKey, errorMsgParams, okListener, actionCommand);
- }
-
- @Override
- public void showErrorDialog(String errorMsgKey, Object[] errorMsgParams) {
- showDialog();
- delegate.showErrorDialog(errorMsgKey, errorMsgParams);
- }
-
-// @Override
-// public void showInsertCardDialog(ActionListener cancelListener,
-// String actionCommand) {
-// showDialog();
-// delegate.showInsertCardDialog(cancelListener, actionCommand);
-// }
-//
-// @Override
-// public void showSignaturePINDialog(PINSpec pinSpec,
-// ActionListener signListener, String signCommand,
-// ActionListener cancelListener, String cancelCommand,
-// ActionListener hashdataListener, String hashdataCommand) {
-// showDialog();
-// delegate.showSignaturePINDialog(pinSpec, signListener, signCommand,
-// cancelListener, cancelCommand, hashdataListener, hashdataCommand);
-// }
-//
- @Override
- public void showSignaturePINDialog(PINSpec pinSpec, int numRetries,
- ActionListener okListener, String okCommand,
- ActionListener cancelListener, String cancelCommand,
- ActionListener hashdataListener, String hashdataCommand) {
- showDialog();
- delegate.showSignaturePINDialog(pinSpec, numRetries, okListener,
- okCommand, cancelListener, cancelCommand, hashdataListener,
- hashdataCommand);
- }
-//
-// @Override
-// public void showWaitDialog(String waitMessage) {
-// showDialog();
-// delegate.showWaitDialog(waitMessage);
-// }
-//
-// @Override
-// public void showWelcomeDialog() {
-// showDialog();
-// delegate.showWelcomeDialog();
-// }
-
- @Override
- public void showSecureViewer(List signedReferences,
- ActionListener okListener,
- String okCommand) {
- showDialog();
- delegate.showSecureViewer(signedReferences, okListener, okCommand);
- }
-
- @Override
- public void showMessageDialog(String titleKey,
- String msgKey, Object[] msgParams,
- String buttonKey, ActionListener okListener, String okCommand) {
- showDialog();
- delegate.showMessageDialog(titleKey, msgKey, msgParams, buttonKey, okListener, okCommand);
- }
-
- @Override
- public void showMessageDialog(String titleKey, String msgKey, Object[] msgParams) {
- showDialog();
- delegate.showMessageDialog(titleKey, msgKey, msgParams);
- }
-
- @Override
- public void showMessageDialog(String titleKey, String msgKey) {
- showDialog();
- delegate.showMessageDialog(titleKey, msgKey);
- }
-
- @Override
- public void showPinpadSignaturePINDialog(PINSpec pinSpec, int numRetries,
- ActionListener viewerListener, String viewerCommand) {
- showDialog();
- delegate.showPinpadSignaturePINDialog(pinSpec, numRetries,
- viewerListener, viewerCommand);
- }
-}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalBKUWorker.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalBKUWorker.java
index ca4d35d1..75f71be6 100644
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalBKUWorker.java
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalBKUWorker.java
@@ -18,11 +18,13 @@ package at.gv.egiz.bku.local.stal;
import at.gv.egiz.bku.gui.BKUGUIFacade;
import at.gv.egiz.bku.smccstal.AbstractBKUWorker;
+import at.gv.egiz.bku.smccstal.PINManagementRequestHandler;
import at.gv.egiz.stal.QuitRequest;
import at.gv.egiz.stal.STALRequest;
import at.gv.egiz.stal.STALResponse;
import at.gv.egiz.stal.SignRequest;
+import at.gv.egiz.stal.ext.PINManagementRequest;
import java.util.List;
import javax.swing.JFrame;
@@ -39,16 +41,18 @@ public class LocalBKUWorker extends AbstractBKUWorker {
this.container = container;
addRequestHandler(SignRequest.class,
new LocalSignRequestHandler(new LocalSecureViewer(gui)));
+ addRequestHandler(PINManagementRequest.class, new PINManagementRequestHandler());
}
+ /** does not change container's visibility (use quit request to close) */
@Override
public List handleRequest(List extends STALRequest> requestList) {
signatureCard = null;
List responses = super.handleRequest(requestList);
- // container.setVisible(false);
return responses;
}
+ /** overrides handle quit from abstract bku worker, make container invisible */
@Override
public STALResponse handleRequest(STALRequest request) {
if (request instanceof QuitRequest) {
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSTALFactory.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSTALFactory.java
index 4c9554e2..712fb969 100644
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSTALFactory.java
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSTALFactory.java
@@ -24,6 +24,9 @@ import java.util.Locale;
import at.gv.egiz.bku.gui.BKUGUIFacade;
import at.gv.egiz.bku.gui.BKUGUIImpl;
+import at.gv.egiz.bku.gui.PINManagementGUI;
+import at.gv.egiz.bku.gui.PINManagementGUIFacade;
+import at.gv.egiz.bku.local.gui.GUIProxy;
import at.gv.egiz.bku.local.gui.LocalHelpListener;
import at.gv.egiz.stal.STAL;
import at.gv.egiz.stal.STALFactory;
@@ -33,10 +36,16 @@ import javax.swing.JRootPane;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+/**
+ * Creates a PINManagementGUI and a LocalBKUWorker, which in turn registers
+ * PINManagementRequestHandler from smccSTALExt.
+ * The RequestHandler expects PINManagementGUIFacade, therefore BKUGUIProxy has to implement the extended GUI.
+ * @author clemens
+ */
public class LocalSTALFactory implements STALFactory {
protected static final Log log = LogFactory.getLog(LocalSTALFactory.class);
- protected static final Dimension PREFERRED_SIZE = new Dimension(300, 189);
+ protected static final Dimension PREFERRED_SIZE = new Dimension(318, 200);
protected String helpURL;
protected Locale locale;
@@ -47,7 +56,7 @@ public class LocalSTALFactory implements STALFactory {
//http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html
// use undecorated JFrame instead of JWindow,
// which creates an invisible owning frame and therefore cannot getFocusInWindow()
- JFrame dialog = new JFrame();
+ JFrame dialog = new JFrame("Bürgerkarte");
dialog.setUndecorated(true);
dialog.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
@@ -64,12 +73,13 @@ public class LocalSTALFactory implements STALFactory {
} catch (MalformedURLException ex) {
log.error("failed to configure help listener: " + ex.getMessage(), ex);
}
- BKUGUIFacade gui = new BKUGUIImpl(dialog.getContentPane(),
+ PINManagementGUIFacade gui = new PINManagementGUI(dialog.getContentPane(),
dialog.getLocale(),
BKUGUIFacade.Style.advanced,
null,
helpListener);
- stal = new LocalBKUWorker(new BKUGuiProxy(dialog, gui), dialog);
+ BKUGUIFacade proxy = (BKUGUIFacade) GUIProxy.newInstance(gui, dialog, new Class[] { PINManagementGUIFacade.class} );
+ stal = new LocalBKUWorker(proxy, dialog);
dialog.setPreferredSize(PREFERRED_SIZE);
dialog.pack();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/PINManagementServlet.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/PINManagementServlet.java
new file mode 100644
index 00000000..89e526ac
--- /dev/null
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/PINManagementServlet.java
@@ -0,0 +1,167 @@
+/*
+ * 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.local.webapp;
+
+import at.gv.egiz.bku.local.stal.LocalSTALFactory;
+import at.gv.egiz.marshal.MarshallerFactory;
+import at.gv.egiz.stal.QuitRequest;
+import at.gv.egiz.stal.STALRequest;
+import at.gv.egiz.stal.STALResponse;
+import at.gv.egiz.stal.ext.PINManagementRequest;
+import at.gv.egiz.stal.ext.PINManagementResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import org.apache.regexp.REUtil;
+
+/**
+ * PINManagementBKUWorker for non-applet version
+ * @author Clemens Orthacker
+ */
+public class PINManagementServlet extends HttpServlet {
+
+// static JAXBContext stalCtx;
+
+ /**
+ * Processes requests for both HTTP GET
and POST
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 {
+
+ LocalSTALFactory sf = new LocalSTALFactory();
+
+ ArrayList stalReqs = new ArrayList();
+ stalReqs.add(new PINManagementRequest());
+ stalReqs.add(new QuitRequest());
+
+ List stalResps = sf.createSTAL().handleRequest(stalReqs);
+
+ String redirect = request.getParameter("redirect");
+ if (redirect != null) {
+ String referer = request.getHeader("Referer");
+ if (referer != null) {
+ redirect = new URL(new URL(referer), redirect).toExternalForm();
+ }
+ response.sendRedirect(redirect);
+ } else {
+ response.setStatus(HttpServletResponse.SC_OK);
+// if (stalResps.get(0) != null) {
+// PrintWriter out = response.getWriter();
+// try {
+// response.setContentType("text/xml;charset=UTF-8");
+// // cannot directly marshal STALResponse, no ObjectFactory in at.gv.egiz.stal
+// if (stalCtx == null) {
+// stalCtx = JAXBContext.newInstance("at.gv.egiz.stal:at.gv.egiz.stal.ext");
+// }
+// Marshaller m = MarshallerFactory.createMarshaller(stalCtx);
+// m.marshal(stalResps.get(0), out);
+// out.close();
+// } catch (JAXBException ex) {
+// throw new ServletException("Failed to marshal STAL response", ex);
+// } finally {
+// out.close();
+// }
+// } else {
+// throw new ServletException("internal error");
+// }
+ }
+
+
+// try {
+// out.println("");
+// out.println("");
+// out.println("Servlet PINManagementServlet");
+// out.println("");
+// out.println("");
+// out.println("Servlet PINManagementServlet at " + request.getContextPath() + "
");
+// out.println("" + stalResps.size() + " responses:
");
+// for (STALResponse resp : stalResps) {
+// out.println(" - " + resp.getClass());
+// }
+// Enumeration headers = request.getHeaderNames();
+// out.println("
headers:
");
+// while (headers.hasMoreElements()) {
+// String header = headers.nextElement();
+// out.println("- " + header + ": " + request.getHeader(header));
+// }
+// Enumeration params = request.getParameterNames();
+// out.println("
params:
");
+// while (params.hasMoreElements()) {
+// String param = params.nextElement();
+// out.println("- " + param + ": " + request.getParameter(param));
+// }
+// out.println("
");
+// out.println("");
+// } finally {
+// out.close();
+// }
+ }
+
+ //
+ /**
+ * Handles the HTTP GET
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 POST
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";
+ }//
+}
diff --git a/BKULocal/src/main/webapp/WEB-INF/web.xml b/BKULocal/src/main/webapp/WEB-INF/web.xml
index 8e696570..83f33d9e 100644
--- a/BKULocal/src/main/webapp/WEB-INF/web.xml
+++ b/BKULocal/src/main/webapp/WEB-INF/web.xml
@@ -40,6 +40,10 @@
help
/help.jsp
+
+ PINManagementServlet
+ at.gv.egiz.bku.local.webapp.PINManagementServlet
+
BKUServlet
/http-security-layer-request
@@ -53,7 +57,11 @@
/help/*
-
+
+
+ PINManagementServlet
+ /PINManagement
+
index.html
index.htm
diff --git a/BKULocal/src/main/webapp/index.html b/BKULocal/src/main/webapp/index.html
index 215eec80..537c154a 100644
--- a/BKULocal/src/main/webapp/index.html
+++ b/BKULocal/src/main/webapp/index.html
@@ -23,7 +23,12 @@
BKU Web Start - Willkommen
- Diese Seite installiert das MOCCA Zertifikat in ihrem Browser.
+
+
Diese Seite installiert das MOCCA Zertifikat in ihrem Browser.
In jedem weiteren Browser können sie dieses durch Aufruf dieser Seite ebenso installieren.
+
+