summaryrefslogtreecommitdiff
path: root/BKULocal/src/main/java/at/gv/egiz
diff options
context:
space:
mode:
Diffstat (limited to 'BKULocal/src/main/java/at/gv/egiz')
-rw-r--r--BKULocal/src/main/java/at/gv/egiz/bku/local/gui/GUIProxy.java55
-rw-r--r--BKULocal/src/main/java/at/gv/egiz/bku/local/stal/BKUGuiProxy.java156
-rw-r--r--BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalBKUWorker.java6
-rw-r--r--BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSTALFactory.java18
-rw-r--r--BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/PINManagementServlet.java167
5 files changed, 241 insertions, 161 deletions
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 <clemens.orthacker@iaik.tugraz.at>
+ */
+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<HashDataInput> 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<STALResponse> handleRequest(List<? extends STALRequest> requestList) {
signatureCard = null;
List<STALResponse> 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 <clemens.orthacker@iaik.tugraz.at>
+ */
+public class PINManagementServlet extends HttpServlet {
+
+// static JAXBContext stalCtx;
+
+ /**
+ * 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 {
+
+ LocalSTALFactory sf = new LocalSTALFactory();
+
+ ArrayList<STALRequest> stalReqs = new ArrayList<STALRequest>();
+ stalReqs.add(new PINManagementRequest());
+ stalReqs.add(new QuitRequest());
+
+ List<STALResponse> 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("<html>");
+// out.println("<head>");
+// out.println("<title>Servlet PINManagementServlet</title>");
+// out.println("</head>");
+// out.println("<body>");
+// out.println("<h1>Servlet PINManagementServlet at " + request.getContextPath() + "</h1>");
+// out.println("<p>" + stalResps.size() + " responses:<ul>");
+// for (STALResponse resp : stalResps) {
+// out.println(" <li>" + resp.getClass());
+// }
+// Enumeration<String> headers = request.getHeaderNames();
+// out.println("</ul></p><p> headers: <ul>");
+// while (headers.hasMoreElements()) {
+// String header = headers.nextElement();
+// out.println("<li> " + header + ": " + request.getHeader(header));
+// }
+// Enumeration<String> params = request.getParameterNames();
+// out.println("</ul></p><p> params: <ul>");
+// while (params.hasMoreElements()) {
+// String param = params.nextElement();
+// out.println("<li> " + param + ": " + request.getParameter(param));
+// }
+// out.println("</ul></p></body>");
+// out.println("</html>");
+// } finally {
+// out.close();
+// }
+ }
+
+ // <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>
+}