From 32d17447a258188b2d534bcb0bf65a659ba7b7d0 Mon Sep 17 00:00:00 2001
From: mcentner
Date: Fri, 29 Aug 2008 12:11:34 +0000
Subject: Initial import.
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@1 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
BKUApplet/keystore.ks | Bin 0 -> 5635 bytes
BKUApplet/pom.xml | 117 +++++++++
BKUApplet/src/main/java/META-INF/MANIFEST.MF | 3 +
.../at/gv/egiz/bku/online/applet/BKUApplet.java | 101 ++++++++
.../at/gv/egiz/bku/online/applet/BKUWorker.java | 286 +++++++++++++++++++++
.../online/applet/InternalSSLSocketFactory.java | 101 ++++++++
.../applet/InternalSSLSocketFactoryException.java | 45 ++++
.../gv/egiz/bku/online/applet/Messages.properties | 58 +++++
.../egiz/bku/online/applet/Messages_de.properties | 42 +++
.../at/gv/egiz/bku/online/applet/images/logo.png | Bin 0 -> 4035 bytes
.../at/gv/egiz/stal/client/STALServiceTest.java | 96 +++++++
11 files changed, 849 insertions(+)
create mode 100644 BKUApplet/keystore.ks
create mode 100644 BKUApplet/pom.xml
create mode 100644 BKUApplet/src/main/java/META-INF/MANIFEST.MF
create mode 100644 BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java
create mode 100644 BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
create mode 100644 BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java
create mode 100644 BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactoryException.java
create mode 100644 BKUApplet/src/main/resources/at/gv/egiz/bku/online/applet/Messages.properties
create mode 100644 BKUApplet/src/main/resources/at/gv/egiz/bku/online/applet/Messages_de.properties
create mode 100644 BKUApplet/src/main/resources/at/gv/egiz/bku/online/applet/images/logo.png
create mode 100644 BKUApplet/src/test/java/at/gv/egiz/stal/client/STALServiceTest.java
(limited to 'BKUApplet')
diff --git a/BKUApplet/keystore.ks b/BKUApplet/keystore.ks
new file mode 100644
index 00000000..824c3a40
Binary files /dev/null and b/BKUApplet/keystore.ks differ
diff --git a/BKUApplet/pom.xml b/BKUApplet/pom.xml
new file mode 100644
index 00000000..35672e51
--- /dev/null
+++ b/BKUApplet/pom.xml
@@ -0,0 +1,117 @@
+
+
+
+ bku
+ at.gv.egiz
+ 1.0-SNAPSHOT
+
+ 4.0.0
+ at.gv.egiz
+ BKUApplet
+ BKU Applet
+ 1.0-SNAPSHOT
+
+
+
+
+ maven-dependency-plugin
+
+
+ unpack
+
+ unpack
+
+
+ ${project.build.outputDirectory}
+ META-INF\/
+
+
+ at.gv.egiz
+ smcc
+ jar
+
+
+ at.gv.egiz
+ smccSTAL
+ jar
+
+
+ at.gv.egiz
+ STAL
+ jar
+
+
+ at.gv.egiz
+ STALService
+ jar
+
+
+ at.gv.egiz
+ BKUCommonGUI
+ jar
+
+
+
+
+
+
+
+ maven-jar-plugin
+
+
+
+ sign
+
+
+
+
+
+ false
+ false
+
+ false
+ true
+
+
+ test-applet signer
+ ./keystore.ks
+ storepass
+ keypass
+ true
+
+
+
+
+
+
+ at.gv.egiz
+ smcc
+ 1.0-SNAPSHOT
+
+
+ at.gv.egiz
+ STAL
+ 1.0-SNAPSHOT
+
+
+ at.gv.egiz
+ STALService
+ 1.0-SNAPSHOT
+
+
+ at.gv.egiz
+ smccSTAL
+ 1.0-SNAPSHOT
+
+
+ at.gv.egiz
+ BKUCommonGUI
+ 1.0-SNAPSHOT
+
+
+ commons-logging
+ commons-logging
+
+
+
\ No newline at end of file
diff --git a/BKUApplet/src/main/java/META-INF/MANIFEST.MF b/BKUApplet/src/main/java/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..5e949512
--- /dev/null
+++ b/BKUApplet/src/main/java/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java
new file mode 100644
index 00000000..56cc5ea2
--- /dev/null
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java
@@ -0,0 +1,101 @@
+/*
+* 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.applet;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import javax.net.ssl.HttpsURLConnection;
+import javax.swing.JApplet;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.gui.BKUGUIFacade;
+import at.gv.egiz.bku.gui.BKUGUIFactory;
+
+/**
+ *
+ *
+ *
+ */
+public class BKUApplet extends JApplet {
+
+ private static Log log = LogFactory.getLog(BKUApplet.class);
+
+ public final static String RESOURCE_BUNDLE_BASE = "at/gv/egiz/bku/online/applet/Messages";
+
+ public final static String LOCALE_PARAM_KEY = "Locale";
+ public final static String LOGO_URL_KEY="LogoURL";
+ public final static String WSDL_URL="WSDL_URL";
+ public final static String SESSION_ID="SessionID";
+
+ protected ResourceBundle resourceBundle;
+ protected BKUWorker worker;
+ protected Thread workerThread;
+
+ public BKUApplet() {
+ }
+
+ public void init() {
+ log.debug("Called init()");
+ try {
+ HttpsURLConnection.setDefaultSSLSocketFactory(InternalSSLSocketFactory.getSocketFactory());
+ HttpsURLConnection.setDefaultHostnameVerifier(InternalSSLSocketFactory.getHostNameVerifier());
+ } catch (InternalSSLSocketFactoryException e) {
+ log.error(e);
+ }
+ String localeString = getMyAppletParameter(LOCALE_PARAM_KEY);
+ if (localeString != null) {
+ resourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE_BASE,
+ new Locale(localeString));
+ } else {
+ resourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE_BASE);
+ }
+ BKUGUIFacade gui = BKUGUIFactory.createGUI();
+ gui.init(getContentPane(), localeString);
+ worker = new BKUWorker(gui, this, resourceBundle);
+ }
+
+ public void start() {
+ log.debug("Called start()");
+ workerThread = new Thread(worker);
+ workerThread.start();
+ }
+
+ public void stop() {
+ log.debug("Called stop()");
+ if ((workerThread != null) && (workerThread.isAlive())) {
+ workerThread.interrupt();
+ }
+ }
+
+ public void destroy() {
+ log.debug("Called destroy()");
+ }
+
+ /**
+ * Applet configuration parameters
+ *
+ * @param paramKey
+ * @return
+ */
+ public String getMyAppletParameter(String paramKey) {
+ log.info("Getting parameter: "+paramKey+ ": "+ getParameter(paramKey));
+ return getParameter(paramKey);
+ }
+}
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
new file mode 100644
index 00000000..38fd6428
--- /dev/null
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
@@ -0,0 +1,286 @@
+/*
+* 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.applet;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ResourceBundle;
+
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.gui.BKUGUIFacade;
+import at.gv.egiz.bku.smccstal.AbstractSMCCSTAL;
+import at.gv.egiz.bku.smccstal.SMCCSTALRequestHandler;
+import at.gv.egiz.smcc.SignatureCard;
+import at.gv.egiz.smcc.util.SMCCHelper;
+import at.gv.egiz.stal.QuitRequest;
+import at.gv.egiz.stal.STALRequest;
+import at.gv.egiz.stal.STALResponse;
+import at.gv.egiz.stal.service.GetNextRequestResponseType;
+import at.gv.egiz.stal.service.GetNextRequestType;
+import at.gv.egiz.stal.service.ObjectFactory;
+import at.gv.egiz.stal.service.STALPortType;
+import at.gv.egiz.stal.service.STALService;
+
+public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
+ ActionListener, SMCCSTALRequestHandler {
+
+ private static Log log = LogFactory.getLog(BKUWorker.class);
+
+ protected BKUGUIFacade gui;
+ protected BKUApplet parent;
+ private STALPortType stalPort;
+ protected List actionCommandList = new ArrayList();
+ protected Boolean actionPerformed = false;
+ protected boolean finished = false;
+ protected ResourceBundle errorMessages;
+
+ /**
+ *
+ * @param gui
+ * must not be null
+ */
+ public BKUWorker(BKUGUIFacade gui, BKUApplet parent,
+ ResourceBundle errorMessageBundle) {
+ if ((gui == null) || (parent == null) || (errorMessageBundle == null)) {
+ throw new NullPointerException("Parameter must not be set to null");
+ }
+ this.gui = gui;
+ this.parent = parent;
+ this.errorMessages = errorMessageBundle;
+ addRequestHandler(QuitRequest.class, this);
+ }
+
+ private STALPortType getSTALPort() throws MalformedURLException {
+ URL wsdlURL = null;
+ String wsdlLocation = parent.getMyAppletParameter(BKUApplet.WSDL_URL);
+ URL codebase = parent.getCodeBase();
+ log.debug("Connecting to webservice: " + wsdlLocation);
+ if (wsdlLocation != null) {
+ try {
+ if (codebase.getProtocol().equalsIgnoreCase("file")) {
+ // for debugging in appletrunner
+ wsdlURL = new URL(wsdlLocation);
+ } else {
+ wsdlURL = new URL(codebase, wsdlLocation);
+ }
+ } catch (MalformedURLException ex) {
+ log.fatal("Paremeter 'wsdlLocation' is not a vailid URL.", ex);
+ throw new MalformedURLException(ex.getMessage());
+ }
+ } else {
+ log.fatal("Paremeter 'wsdlLocation' is not set.");
+ throw new MalformedURLException("Null WSDL url");
+ }
+ log.debug("Found WSDL url: " + wsdlURL);
+ QName endpointName = new QName("http://www.egiz.gv.at/wsdl/stal",
+ "STALService");
+ STALService stal = new STALService(wsdlURL, endpointName);
+ return stal.getSTALPort();
+ }
+
+ @Override
+ public void run() {
+ gui.showWelcomeDialog();
+ try {
+ stalPort = getSTALPort();
+ } catch (Exception e) {
+ log.fatal("Failed to call STAL service.", e);
+ actionCommandList.clear();
+ actionCommandList.add("ok");
+ gui.showErrorDialog(errorMessages.getString("failed.WS"));
+ try {
+ waitForAction();
+ } catch (InterruptedException e1) {
+ log.error(e1);
+ }
+ return;
+ }
+
+ ObjectFactory factory = new ObjectFactory();
+ GetNextRequestType nextRequest = factory.createGetNextRequestType();
+
+ String sessionId = parent.getMyAppletParameter(BKUApplet.SESSION_ID);
+ if (sessionId == null) {
+ // use the testsession for testing
+ sessionId = "TestSession";
+ }
+ nextRequest.setSessionId(sessionId);
+ do {
+ GetNextRequestResponseType resp = stalPort.getNextRequest(nextRequest);
+ log.info("Got " + resp.getRequest().size() + " requests from server.");
+ List stalRequests = resp.getRequest();
+ List responses = handleRequest(stalRequests);
+ log.info("Got " + responses.size() + " responses.");
+ nextRequest = factory.createGetNextRequestType();
+ nextRequest.setSessionId(sessionId);
+ nextRequest.getResponse().addAll(responses);
+ } while (!finished);
+ log.info("Done " + Thread.currentThread().getName());
+ gui.showWelcomeDialog();
+ sendRedirect();
+ }
+
+ protected void sendRedirect() {
+ log.info("Done, sending redirect to get BKU response");
+ String redirectURL = parent.getMyAppletParameter("redirectURL");
+ String redirectTarget = parent.getMyAppletParameter("redirectTarget");
+ log.info("Redirecting to: " + redirectURL + " target: " + redirectTarget);
+ URL url = null;
+ if (redirectURL != null) {
+ try {
+ url = new URL(parent.getCodeBase(),redirectURL + ";jsessionid="
+ + parent.getMyAppletParameter(BKUApplet.SESSION_ID));
+ } catch (MalformedURLException ex) {
+ log.warn("Parameter 'redirectURL': " + redirectURL
+ + " not a valid URL.", ex);
+ // gui.showErrorDialog(errorMsg, okListener, actionCommand)
+ }
+ if (url != null) {
+ if (redirectTarget == null) {
+ log.info("Done. Trying to redirect to " + url + " ...");
+ parent.getAppletContext().showDocument(url);
+ } else {
+ log.info("Done. Trying to redirect to " + url + " (target="
+ + redirectTarget + ") ...");
+ parent.getAppletContext().showDocument(url, redirectTarget);
+ }
+ }
+ } else {
+ log.error("No redirect URL set");
+ }
+ }
+
+ protected synchronized void waitForAction() throws InterruptedException {
+ log.info("Waiting for Action");
+ while (!actionPerformed) {
+ wait();
+ }
+ actionPerformed = false;
+ }
+
+ protected synchronized void actionOccured() {
+ log.info("Received Action");
+ actionPerformed = true;
+ notifyAll();
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ log.info("Action: " + e);
+ if (actionCommandList != null) {
+ if (actionCommandList.contains(e.getActionCommand())) {
+ actionOccured();
+ }
+ } else {
+ actionOccured();
+ }
+ }
+
+ @Override
+ protected boolean waitForCard() {
+ SMCCHelper smccHelper = new SMCCHelper();
+ actionCommandList.clear();
+ actionCommandList.add("cancel");
+ // while no sigcard found or cancel button pressed
+ int oldValue = SMCCHelper.PC_SC_NOT_SUPPORTED; // this is a save default
+ while ((signatureCard == null) && (!actionPerformed)) {
+ switch (smccHelper.getResultCode()) {
+ case SMCCHelper.PC_SC_NOT_SUPPORTED:
+ actionCommandList.clear();
+ actionCommandList.add("ok");
+ gui.showErrorDialog(errorMessages.getString("nopcscsupport"), this,
+ "ok");
+ try {
+ waitForAction();
+ } catch (InterruptedException e) {
+ log.error(e);
+ }
+ return true;
+ case SMCCHelper.TERMINAL_NOT_PRESENT:
+ actionCommandList.clear();
+ actionCommandList.add("ok");
+ gui.showErrorDialog(errorMessages.getString("nocardterminal"), this,
+ "ok");
+ try {
+ waitForAction();
+ } catch (InterruptedException e) {
+ log.error(e);
+ }
+ return true;
+ case SMCCHelper.CARD_NOT_SUPPORTED:
+ if (oldValue != SMCCHelper.CARD_NOT_SUPPORTED) {
+ actionCommandList.clear();
+ actionCommandList.add("cancel");
+ gui.showCardNotSupportedDialog(this, "cancel");
+ oldValue = SMCCHelper.CARD_NOT_SUPPORTED;
+ }
+ break;
+ case SMCCHelper.NO_CARD:
+ if (oldValue != SMCCHelper.NO_CARD) {
+ actionCommandList.clear();
+ actionCommandList.add("cancel");
+ gui.showInsertCardDialog(this, "cancel");
+ oldValue = SMCCHelper.NO_CARD;
+ }
+ break;
+ case SMCCHelper.CARD_FOUND:
+ gui.showWelcomeDialog();
+ signatureCard = smccHelper.getSignatureCard(errorMessages.getLocale());
+ return false;
+ }
+ smccHelper.update(3000);
+ }
+ return signatureCard == null;
+ }
+
+ @Override
+ public STALResponse handleRequest(STALRequest request) {
+ if (request instanceof QuitRequest) {
+ finished = true;
+ } else {
+ log.error("Unexpected request to handle: " + request);
+ }
+ return null;
+ }
+
+ @Override
+ public void init(SignatureCard sc, BKUGUIFacade gui) {
+ }
+
+ @Override
+ public SMCCSTALRequestHandler newInstance() {
+ return this;
+ }
+
+ @Override
+ public boolean requireCard() {
+ return false;
+ }
+
+ @Override
+ protected BKUGUIFacade getGUI() {
+ return gui;
+ }
+}
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java
new file mode 100644
index 00000000..ab04d2b6
--- /dev/null
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java
@@ -0,0 +1,101 @@
+/*
+* 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.
+*/
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package at.gv.egiz.bku.online.applet;
+
+import java.io.IOException;
+import java.security.KeyManagementException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.X509TrustManager;
+
+public class InternalSSLSocketFactory {
+
+ private SSLSocketFactory factory;
+
+ public static SSLSocketFactory getSocketFactory() throws InternalSSLSocketFactoryException {
+ return new InternalSSLSocketFactory().factory;
+ }
+
+ public static HostnameVerifier getHostNameVerifier() throws InternalSSLSocketFactoryException {
+ return (new HostnameVerifier() {
+ @Override
+ public boolean verify(String hostname, SSLSession session) {
+ return true;
+ }
+ });
+ }
+
+ public InternalSSLSocketFactory() throws InternalSSLSocketFactoryException {
+ SSLContext sslContext;
+ try {
+ sslContext = SSLContext.getInstance("TLSv1");
+ sslContext.getClientSessionContext().setSessionTimeout(0);
+ KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance("SunX509");
+
+ KeyStore keyStore = KeyStore.getInstance("JKS");
+ keyStore.load(null, null);
+ keyManagerFactory.init(keyStore, null);
+
+ sslContext.init(keyManagerFactory.getKeyManagers(),
+ new X509TrustManager[] { new AcceptAllTrustManager() },
+ null);
+ } catch (NoSuchAlgorithmException e) {
+ throw new InternalSSLSocketFactoryException(e);
+ } catch (CertificateException e) {
+ throw new InternalSSLSocketFactoryException(e);
+ } catch (IOException e) {
+ throw new InternalSSLSocketFactoryException(e);
+ } catch (KeyStoreException e) {
+ throw new InternalSSLSocketFactoryException(e);
+ } catch (UnrecoverableKeyException e) {
+ throw new InternalSSLSocketFactoryException(e);
+ } catch (KeyManagementException e) {
+ throw new InternalSSLSocketFactoryException(e);
+ }
+
+ this.factory = sslContext.getSocketFactory();
+ }
+
+ class AcceptAllTrustManager implements X509TrustManager {
+
+ public X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
+
+ public void checkClientTrusted(X509Certificate[] chain, String authType) {
+ }
+
+ public void checkServerTrusted(X509Certificate[] chain, String authType) {
+ //FIXME
+ }
+ }
+};
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactoryException.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactoryException.java
new file mode 100644
index 00000000..c620284a
--- /dev/null
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactoryException.java
@@ -0,0 +1,45 @@
+/*
+* 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.
+*/
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package at.gv.egiz.bku.online.applet;
+
+/**
+ *
+ * @author mcentner
+ */
+public class InternalSSLSocketFactoryException extends Exception {
+
+ public InternalSSLSocketFactoryException(Throwable cause) {
+ super(cause);
+ }
+
+ public InternalSSLSocketFactoryException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InternalSSLSocketFactoryException(String message) {
+ super(message);
+ }
+
+ public InternalSSLSocketFactoryException() {
+ }
+
+}
diff --git a/BKUApplet/src/main/resources/at/gv/egiz/bku/online/applet/Messages.properties b/BKUApplet/src/main/resources/at/gv/egiz/bku/online/applet/Messages.properties
new file mode 100644
index 00000000..752004e8
--- /dev/null
+++ b/BKUApplet/src/main/resources/at/gv/egiz/bku/online/applet/Messages.properties
@@ -0,0 +1,58 @@
+# 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.
+
+# -------- BEGIN bootstrap applet -----------#
+java16required=This Applet requires Java 1.6 or higher to run. \
+ Please download and install a recent version of Java. \
+ For Windows, Linux and Solaris plattforms you can download Java from \
+ http://java.sun.com/javase/downloads.\
+
+
+failedtostart=Failed to start Applet. \
+ {0}
+# -------- END bootstrap applet -----------#
+
+
+applet.name=Online Citicen Card Environment (CCE)
+
+nopcscsupport=The Java plattform does not seem to provide \
+a PC/SC interface to acces a smartcard.
+
+nocardterminal=Can not find a connected smartcard reader.\
+ Either there is no smartcard reader connected, or \
+ no PC/SC driver is installed for a connected smartcard reader.
+
+insertcard=Please insert your citicen card (B\u00FCrgerkarte) into your \
+ smartcard reader.
+
+unsupportedcard=The inserted smartcard is not supported.\
+ Please insert your citicen card (B\u00FCrgerkarte) \
+ into your smartcard reader.
+
+enterpin=Please enter {0} \(min {1}, max {2} digits\).
+
+enterpinretries=Please enter {0} \(min {1}, max {2} digits, {3} retries left\).
+
+pinwrong=Entered PIN is wrong.
+
+button.ok=Ok
+
+button.cancel=Cancel
+
+status.findpcsc=Looking for PC/SC support
+
+status.findsupportedcard=Looking for a supported smartcard
+
+failed.WS=Webservice cannot be reached.
\ No newline at end of file
diff --git a/BKUApplet/src/main/resources/at/gv/egiz/bku/online/applet/Messages_de.properties b/BKUApplet/src/main/resources/at/gv/egiz/bku/online/applet/Messages_de.properties
new file mode 100644
index 00000000..e6b815e9
--- /dev/null
+++ b/BKUApplet/src/main/resources/at/gv/egiz/bku/online/applet/Messages_de.properties
@@ -0,0 +1,42 @@
+# 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.
+
+# -------- BEGIN bootstrap applet -----------#
+java16required=Dieses Applet ben\u00F6tigt Java Version 1.6 oder h\u00F6her. \
+ Bitte installieren sie eine aktulle Version von Java. \
+ F\u00FCr Windows, Linux and Solaris kann Java von \
+ http://java.sun.com/javase/downloads \
+ heruntergeladen werden.
+
+failedtostart=Das Applet konnte nicht gestartet werden. \
+ {0}
+# -------- END bootstrap applet -----------#
+
+applet.name=Online B\u00FCrgerkartenumgebung (BKU)
+
+nopcscsupport=Die Java-Installation stellt keine \
+ PC/SC-Schnittstelle zum Zugriff auf eine Chipkarte zur Verf\u00FCgung.
+
+nocardterminal=Es konnte kein Chipkartenleser gefunden werden.\
+ Entweder, es ist kein Chipkartenleser angeschlossen, oder \
+ f\u00FCr den angeschlossenen Chipkartenleser ist kein PC/SC-Treiber \
+ installiert.
+
+insertcard=Bitte stecken Sie ihre B\u00FCrgerkarte in den Chipkartenleser.
+
+unsupportedcard=Die gesteckte Chipkarte wird nicht unterst\u00FCtzt.\
+ Bitte stecken Sie ihre B\u00FCrgerkare in den Chipkartenleser
+
+failed.WS=Das Webservice kann nicht erreicht werden.
\ No newline at end of file
diff --git a/BKUApplet/src/main/resources/at/gv/egiz/bku/online/applet/images/logo.png b/BKUApplet/src/main/resources/at/gv/egiz/bku/online/applet/images/logo.png
new file mode 100644
index 00000000..eee4be4f
Binary files /dev/null and b/BKUApplet/src/main/resources/at/gv/egiz/bku/online/applet/images/logo.png differ
diff --git a/BKUApplet/src/test/java/at/gv/egiz/stal/client/STALServiceTest.java b/BKUApplet/src/test/java/at/gv/egiz/stal/client/STALServiceTest.java
new file mode 100644
index 00000000..9b58798d
--- /dev/null
+++ b/BKUApplet/src/test/java/at/gv/egiz/stal/client/STALServiceTest.java
@@ -0,0 +1,96 @@
+/*
+* 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.
+*/
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package at.gv.egiz.stal.client;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+
+import org.junit.Test;
+
+import at.gv.egiz.stal.InfoboxReadRequest;
+import at.gv.egiz.stal.STALRequest;
+import at.gv.egiz.stal.service.GetHashDataInputFault;
+import at.gv.egiz.stal.service.GetHashDataInputResponseType;
+import at.gv.egiz.stal.service.GetHashDataInputType;
+import at.gv.egiz.stal.service.GetNextRequestResponseType;
+import at.gv.egiz.stal.service.GetNextRequestType;
+import at.gv.egiz.stal.service.STALPortType;
+import at.gv.egiz.stal.service.STALService;
+
+/**
+ *
+ * @author clemens
+ */
+public class STALServiceTest {
+
+// @Test
+ public void callSTAL() {
+ try {
+ URL endpointURL = new URL("http://localhost:8080/bkuonline/stal?wsdl");
+ QName endpointName = new QName("http://www.egiz.gv.at/wsdl/stal", "STALService");
+ STALService stal = new STALService(endpointURL, endpointName);
+// stal = new STALService();
+ STALPortType port = stal.getSTALPort();
+
+ GetNextRequestType nrReq = new GetNextRequestType();
+ nrReq.setSessionId("TestSession"); //STALServiceImpl.TEST_SESSION_ID);
+// req.getResponse().add(new ErrorResponse(1234));
+ GetNextRequestResponseType nrResp = port.getNextRequest(nrReq);
+ assertNotNull(nrResp);
+ System.out.println("got response: " + nrResp.getRequest().size());
+ for (STALRequest stalReq : nrResp.getRequest()) {
+ if (stalReq instanceof InfoboxReadRequest) {
+ String ibid = ((InfoboxReadRequest) stalReq).getInfoboxIdentifier();
+ String did = ((InfoboxReadRequest) stalReq).getDomainIdentifier();
+ System.out.println(" received InfoboxReadRequest for " + ibid + ", " + did);
+ } else {
+ System.out.println(" received STAL request " + stalReq.getClass().getName());
+ }
+ }
+
+ GetHashDataInputType hdReq = new GetHashDataInputType();
+ hdReq.setSessionId("TestSession"); //STALServiceImpl.TEST_SESSION_ID);
+ GetHashDataInputType.Reference ref = new GetHashDataInputType.Reference();
+ ref.setID("refId");
+ hdReq.getReference().add(ref);
+ GetHashDataInputResponseType hdResp = port.getHashDataInput(hdReq);
+ GetHashDataInputResponseType.Reference hdRef = hdResp.getReference().get(0);
+ System.out.println("got HashDataInput " + new String(hdRef.getValue()));
+
+
+ } catch (GetHashDataInputFault ex) {
+ ex.printStackTrace();
+ } catch (MalformedURLException ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testSTAL() {
+ //TODO
+ }
+
+}
--
cgit v1.2.3
From 63f2a4f1f098cc39bd092fef77a94d73056f51f6 Mon Sep 17 00:00:00 2001
From: clemenso
Date: Fri, 5 Sep 2008 13:38:24 +0000
Subject: HashDataInput
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@19 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../at/gv/egiz/bku/online/applet/BKUApplet.java | 4 +-
.../at/gv/egiz/bku/online/applet/BKUWorker.java | 543 +++++++++++----------
.../bku/online/applet/WSSignRequestHandler.java | 90 ++++
.../src/main/resources/commons-logging.properties | 16 +
BKUApplet/src/main/resources/simplelog.properties | 25 +
5 files changed, 405 insertions(+), 273 deletions(-)
create mode 100644 BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java
create mode 100644 BKUApplet/src/main/resources/commons-logging.properties
create mode 100644 BKUApplet/src/main/resources/simplelog.properties
(limited to 'BKUApplet')
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java
index 56cc5ea2..5d4d0dab 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java
@@ -29,9 +29,7 @@ import at.gv.egiz.bku.gui.BKUGUIFacade;
import at.gv.egiz.bku.gui.BKUGUIFactory;
/**
- *
- *
- *
+ * Note: all swing code is executed by the event dispatch thread (see BKUGUIFacade)
*/
public class BKUApplet extends JApplet {
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
index 38fd6428..f7b5fb2f 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
@@ -14,273 +14,276 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package at.gv.egiz.bku.online.applet;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.ResourceBundle;
-
-import javax.xml.namespace.QName;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import at.gv.egiz.bku.gui.BKUGUIFacade;
-import at.gv.egiz.bku.smccstal.AbstractSMCCSTAL;
-import at.gv.egiz.bku.smccstal.SMCCSTALRequestHandler;
-import at.gv.egiz.smcc.SignatureCard;
-import at.gv.egiz.smcc.util.SMCCHelper;
-import at.gv.egiz.stal.QuitRequest;
-import at.gv.egiz.stal.STALRequest;
-import at.gv.egiz.stal.STALResponse;
-import at.gv.egiz.stal.service.GetNextRequestResponseType;
-import at.gv.egiz.stal.service.GetNextRequestType;
-import at.gv.egiz.stal.service.ObjectFactory;
-import at.gv.egiz.stal.service.STALPortType;
-import at.gv.egiz.stal.service.STALService;
-
-public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
- ActionListener, SMCCSTALRequestHandler {
-
- private static Log log = LogFactory.getLog(BKUWorker.class);
-
- protected BKUGUIFacade gui;
- protected BKUApplet parent;
- private STALPortType stalPort;
- protected List actionCommandList = new ArrayList();
- protected Boolean actionPerformed = false;
- protected boolean finished = false;
- protected ResourceBundle errorMessages;
-
- /**
- *
- * @param gui
- * must not be null
- */
- public BKUWorker(BKUGUIFacade gui, BKUApplet parent,
- ResourceBundle errorMessageBundle) {
- if ((gui == null) || (parent == null) || (errorMessageBundle == null)) {
- throw new NullPointerException("Parameter must not be set to null");
- }
- this.gui = gui;
- this.parent = parent;
- this.errorMessages = errorMessageBundle;
- addRequestHandler(QuitRequest.class, this);
- }
-
- private STALPortType getSTALPort() throws MalformedURLException {
- URL wsdlURL = null;
- String wsdlLocation = parent.getMyAppletParameter(BKUApplet.WSDL_URL);
- URL codebase = parent.getCodeBase();
- log.debug("Connecting to webservice: " + wsdlLocation);
- if (wsdlLocation != null) {
- try {
- if (codebase.getProtocol().equalsIgnoreCase("file")) {
- // for debugging in appletrunner
- wsdlURL = new URL(wsdlLocation);
- } else {
- wsdlURL = new URL(codebase, wsdlLocation);
- }
- } catch (MalformedURLException ex) {
- log.fatal("Paremeter 'wsdlLocation' is not a vailid URL.", ex);
- throw new MalformedURLException(ex.getMessage());
- }
- } else {
- log.fatal("Paremeter 'wsdlLocation' is not set.");
- throw new MalformedURLException("Null WSDL url");
- }
- log.debug("Found WSDL url: " + wsdlURL);
- QName endpointName = new QName("http://www.egiz.gv.at/wsdl/stal",
- "STALService");
- STALService stal = new STALService(wsdlURL, endpointName);
- return stal.getSTALPort();
- }
-
- @Override
- public void run() {
- gui.showWelcomeDialog();
- try {
- stalPort = getSTALPort();
- } catch (Exception e) {
- log.fatal("Failed to call STAL service.", e);
- actionCommandList.clear();
- actionCommandList.add("ok");
- gui.showErrorDialog(errorMessages.getString("failed.WS"));
- try {
- waitForAction();
- } catch (InterruptedException e1) {
- log.error(e1);
- }
- return;
- }
-
- ObjectFactory factory = new ObjectFactory();
- GetNextRequestType nextRequest = factory.createGetNextRequestType();
-
- String sessionId = parent.getMyAppletParameter(BKUApplet.SESSION_ID);
- if (sessionId == null) {
- // use the testsession for testing
- sessionId = "TestSession";
- }
- nextRequest.setSessionId(sessionId);
- do {
- GetNextRequestResponseType resp = stalPort.getNextRequest(nextRequest);
- log.info("Got " + resp.getRequest().size() + " requests from server.");
- List stalRequests = resp.getRequest();
- List responses = handleRequest(stalRequests);
- log.info("Got " + responses.size() + " responses.");
- nextRequest = factory.createGetNextRequestType();
- nextRequest.setSessionId(sessionId);
- nextRequest.getResponse().addAll(responses);
- } while (!finished);
- log.info("Done " + Thread.currentThread().getName());
- gui.showWelcomeDialog();
- sendRedirect();
- }
-
- protected void sendRedirect() {
- log.info("Done, sending redirect to get BKU response");
- String redirectURL = parent.getMyAppletParameter("redirectURL");
- String redirectTarget = parent.getMyAppletParameter("redirectTarget");
- log.info("Redirecting to: " + redirectURL + " target: " + redirectTarget);
- URL url = null;
- if (redirectURL != null) {
- try {
- url = new URL(parent.getCodeBase(),redirectURL + ";jsessionid="
- + parent.getMyAppletParameter(BKUApplet.SESSION_ID));
- } catch (MalformedURLException ex) {
- log.warn("Parameter 'redirectURL': " + redirectURL
- + " not a valid URL.", ex);
- // gui.showErrorDialog(errorMsg, okListener, actionCommand)
- }
- if (url != null) {
- if (redirectTarget == null) {
- log.info("Done. Trying to redirect to " + url + " ...");
- parent.getAppletContext().showDocument(url);
- } else {
- log.info("Done. Trying to redirect to " + url + " (target="
- + redirectTarget + ") ...");
- parent.getAppletContext().showDocument(url, redirectTarget);
- }
- }
- } else {
- log.error("No redirect URL set");
- }
- }
-
- protected synchronized void waitForAction() throws InterruptedException {
- log.info("Waiting for Action");
- while (!actionPerformed) {
- wait();
- }
- actionPerformed = false;
- }
-
- protected synchronized void actionOccured() {
- log.info("Received Action");
- actionPerformed = true;
- notifyAll();
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
- log.info("Action: " + e);
- if (actionCommandList != null) {
- if (actionCommandList.contains(e.getActionCommand())) {
- actionOccured();
- }
- } else {
- actionOccured();
- }
- }
-
- @Override
- protected boolean waitForCard() {
- SMCCHelper smccHelper = new SMCCHelper();
- actionCommandList.clear();
- actionCommandList.add("cancel");
- // while no sigcard found or cancel button pressed
- int oldValue = SMCCHelper.PC_SC_NOT_SUPPORTED; // this is a save default
- while ((signatureCard == null) && (!actionPerformed)) {
- switch (smccHelper.getResultCode()) {
- case SMCCHelper.PC_SC_NOT_SUPPORTED:
- actionCommandList.clear();
- actionCommandList.add("ok");
- gui.showErrorDialog(errorMessages.getString("nopcscsupport"), this,
- "ok");
- try {
- waitForAction();
- } catch (InterruptedException e) {
- log.error(e);
- }
- return true;
- case SMCCHelper.TERMINAL_NOT_PRESENT:
- actionCommandList.clear();
- actionCommandList.add("ok");
- gui.showErrorDialog(errorMessages.getString("nocardterminal"), this,
- "ok");
- try {
- waitForAction();
- } catch (InterruptedException e) {
- log.error(e);
- }
- return true;
- case SMCCHelper.CARD_NOT_SUPPORTED:
- if (oldValue != SMCCHelper.CARD_NOT_SUPPORTED) {
- actionCommandList.clear();
- actionCommandList.add("cancel");
- gui.showCardNotSupportedDialog(this, "cancel");
- oldValue = SMCCHelper.CARD_NOT_SUPPORTED;
- }
- break;
- case SMCCHelper.NO_CARD:
- if (oldValue != SMCCHelper.NO_CARD) {
- actionCommandList.clear();
- actionCommandList.add("cancel");
- gui.showInsertCardDialog(this, "cancel");
- oldValue = SMCCHelper.NO_CARD;
- }
- break;
- case SMCCHelper.CARD_FOUND:
- gui.showWelcomeDialog();
- signatureCard = smccHelper.getSignatureCard(errorMessages.getLocale());
- return false;
- }
- smccHelper.update(3000);
- }
- return signatureCard == null;
- }
-
- @Override
- public STALResponse handleRequest(STALRequest request) {
- if (request instanceof QuitRequest) {
- finished = true;
- } else {
- log.error("Unexpected request to handle: " + request);
- }
- return null;
- }
-
- @Override
- public void init(SignatureCard sc, BKUGUIFacade gui) {
- }
-
- @Override
- public SMCCSTALRequestHandler newInstance() {
- return this;
- }
-
- @Override
- public boolean requireCard() {
- return false;
- }
-
- @Override
- protected BKUGUIFacade getGUI() {
- return gui;
- }
-}
+package at.gv.egiz.bku.online.applet;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ResourceBundle;
+
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.gui.BKUGUIFacade;
+import at.gv.egiz.bku.smccstal.AbstractSMCCSTAL;
+import at.gv.egiz.bku.smccstal.SMCCSTALRequestHandler;
+import at.gv.egiz.smcc.SignatureCard;
+import at.gv.egiz.smcc.util.SMCCHelper;
+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.service.GetNextRequestResponseType;
+import at.gv.egiz.stal.service.GetNextRequestType;
+import at.gv.egiz.stal.service.ObjectFactory;
+import at.gv.egiz.stal.service.STALPortType;
+import at.gv.egiz.stal.service.STALService;
+
+public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
+ ActionListener, SMCCSTALRequestHandler {
+
+ private static Log log = LogFactory.getLog(BKUWorker.class);
+
+ protected BKUGUIFacade gui;
+ protected BKUApplet parent;
+ private STALPortType stalPort;
+ protected List actionCommandList = new ArrayList();
+ protected Boolean actionPerformed = false;
+ protected boolean finished = false;
+ protected ResourceBundle errorMessages;
+
+ /**
+ *
+ * @param gui
+ * must not be null
+ */
+ public BKUWorker(BKUGUIFacade gui, BKUApplet parent,
+ ResourceBundle errorMessageBundle) {
+ if ((gui == null) || (parent == null) || (errorMessageBundle == null)) {
+ throw new NullPointerException("Parameter must not be set to null");
+ }
+ this.gui = gui;
+ this.parent = parent;
+ this.errorMessages = errorMessageBundle;
+ addRequestHandler(QuitRequest.class, this);
+ //register SignRequestHandler once we have a webservice port
+ }
+
+ private STALPortType getSTALPort() throws MalformedURLException {
+ URL wsdlURL = null;
+ String wsdlLocation = parent.getMyAppletParameter(BKUApplet.WSDL_URL);
+ URL codebase = parent.getCodeBase();
+ log.debug("Connecting to webservice: " + wsdlLocation);
+ if (wsdlLocation != null) {
+ try {
+ if (codebase.getProtocol().equalsIgnoreCase("file")) {
+ // for debugging in appletrunner
+ wsdlURL = new URL(wsdlLocation);
+ } else {
+ wsdlURL = new URL(codebase, wsdlLocation);
+ }
+ } catch (MalformedURLException ex) {
+ log.fatal("Paremeter 'wsdlLocation' is not a vailid URL.", ex);
+ throw new MalformedURLException(ex.getMessage());
+ }
+ } else {
+ log.fatal("Paremeter 'wsdlLocation' is not set.");
+ throw new MalformedURLException("Null WSDL url");
+ }
+ log.debug("Found WSDL url: " + wsdlURL);
+ QName endpointName = new QName("http://www.egiz.gv.at/wsdl/stal",
+ "STALService");
+ STALService stal = new STALService(wsdlURL, endpointName);
+ return stal.getSTALPort();
+ }
+
+ @Override
+ public void run() {
+ gui.showWelcomeDialog();
+ try {
+ stalPort = getSTALPort();
+ } catch (Exception e) {
+ log.fatal("Failed to call STAL service.", e);
+ actionCommandList.clear();
+ actionCommandList.add("ok");
+ gui.showErrorDialog(errorMessages.getString("failed.WS"));
+ try {
+ waitForAction();
+ } catch (InterruptedException e1) {
+ log.error(e1);
+ }
+ return;
+ }
+
+ ObjectFactory factory = new ObjectFactory();
+ GetNextRequestType nextRequest = factory.createGetNextRequestType();
+
+ String sessionId = parent.getMyAppletParameter(BKUApplet.SESSION_ID);
+ if (sessionId == null) {
+ // use the testsession for testing
+ sessionId = "TestSession";
+ }
+ nextRequest.setSessionId(sessionId);
+ addRequestHandler(SignRequest.class, new WSSignRequestHandler(sessionId, stalPort));
+ do {
+ GetNextRequestResponseType resp = stalPort.getNextRequest(nextRequest);
+ log.info("Got " + resp.getRequest().size() + " requests from server.");
+ List stalRequests = resp.getRequest();
+ List responses = handleRequest(stalRequests);
+ log.info("Got " + responses.size() + " responses.");
+ nextRequest = factory.createGetNextRequestType();
+ nextRequest.setSessionId(sessionId);
+ nextRequest.getResponse().addAll(responses);
+ } while (!finished);
+ log.info("Done " + Thread.currentThread().getName());
+ gui.showWelcomeDialog();
+ sendRedirect();
+ }
+
+ protected void sendRedirect() {
+ log.info("Done, sending redirect to get BKU response");
+ String redirectURL = parent.getMyAppletParameter("redirectURL");
+ String redirectTarget = parent.getMyAppletParameter("redirectTarget");
+ log.info("Redirecting to: " + redirectURL + " target: " + redirectTarget);
+ URL url = null;
+ if (redirectURL != null) {
+ try {
+ url = new URL(parent.getCodeBase(),redirectURL + ";jsessionid="
+ + parent.getMyAppletParameter(BKUApplet.SESSION_ID));
+ } catch (MalformedURLException ex) {
+ log.warn("Parameter 'redirectURL': " + redirectURL
+ + " not a valid URL.", ex);
+ // gui.showErrorDialog(errorMsg, okListener, actionCommand)
+ }
+ if (url != null) {
+ if (redirectTarget == null) {
+ log.info("Done. Trying to redirect to " + url + " ...");
+ parent.getAppletContext().showDocument(url);
+ } else {
+ log.info("Done. Trying to redirect to " + url + " (target="
+ + redirectTarget + ") ...");
+ parent.getAppletContext().showDocument(url, redirectTarget);
+ }
+ }
+ } else {
+ log.error("No redirect URL set");
+ }
+ }
+
+ protected synchronized void waitForAction() throws InterruptedException {
+ log.info("Waiting for Action");
+ while (!actionPerformed) {
+ wait();
+ }
+ actionPerformed = false;
+ }
+
+ protected synchronized void actionOccured() {
+ log.info("Received Action");
+ actionPerformed = true;
+ notifyAll();
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ log.info("Action: " + e);
+ if (actionCommandList != null) {
+ if (actionCommandList.contains(e.getActionCommand())) {
+ actionOccured();
+ }
+ } else {
+ actionOccured();
+ }
+ }
+
+ @Override
+ protected boolean waitForCard() {
+ SMCCHelper smccHelper = new SMCCHelper();
+ actionCommandList.clear();
+ actionCommandList.add("cancel");
+ // while no sigcard found or cancel button pressed
+ int oldValue = SMCCHelper.PC_SC_NOT_SUPPORTED; // this is a save default
+ while ((signatureCard == null) && (!actionPerformed)) {
+ switch (smccHelper.getResultCode()) {
+ case SMCCHelper.PC_SC_NOT_SUPPORTED:
+ actionCommandList.clear();
+ actionCommandList.add("ok");
+ gui.showErrorDialog(errorMessages.getString("nopcscsupport"), this,
+ "ok");
+ try {
+ waitForAction();
+ } catch (InterruptedException e) {
+ log.error(e);
+ }
+ return true;
+ case SMCCHelper.TERMINAL_NOT_PRESENT:
+ actionCommandList.clear();
+ actionCommandList.add("ok");
+ gui.showErrorDialog(errorMessages.getString("nocardterminal"), this,
+ "ok");
+ try {
+ waitForAction();
+ } catch (InterruptedException e) {
+ log.error(e);
+ }
+ return true;
+ case SMCCHelper.CARD_NOT_SUPPORTED:
+ if (oldValue != SMCCHelper.CARD_NOT_SUPPORTED) {
+ actionCommandList.clear();
+ actionCommandList.add("cancel");
+ gui.showCardNotSupportedDialog(this, "cancel");
+ oldValue = SMCCHelper.CARD_NOT_SUPPORTED;
+ }
+ break;
+ case SMCCHelper.NO_CARD:
+ if (oldValue != SMCCHelper.NO_CARD) {
+ actionCommandList.clear();
+ actionCommandList.add("cancel");
+ gui.showInsertCardDialog(this, "cancel");
+ oldValue = SMCCHelper.NO_CARD;
+ }
+ break;
+ case SMCCHelper.CARD_FOUND:
+ gui.showWelcomeDialog();
+ signatureCard = smccHelper.getSignatureCard(errorMessages.getLocale());
+ return false;
+ }
+ smccHelper.update(3000);
+ }
+ return signatureCard == null;
+ }
+
+ @Override
+ public STALResponse handleRequest(STALRequest request) {
+ if (request instanceof QuitRequest) {
+ finished = true;
+ } else {
+ log.error("Unexpected request to handle: " + request);
+ }
+ return null;
+ }
+
+ @Override
+ public void init(SignatureCard sc, BKUGUIFacade gui) {
+ }
+
+ @Override
+ public SMCCSTALRequestHandler newInstance() {
+ return this;
+ }
+
+ @Override
+ public boolean requireCard() {
+ return false;
+ }
+
+ @Override
+ protected BKUGUIFacade getGUI() {
+ return gui;
+ }
+}
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java
new file mode 100644
index 00000000..f9965240
--- /dev/null
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java
@@ -0,0 +1,90 @@
+/*
+ * 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.applet;
+
+import at.gv.egiz.stal.HashDataInput;
+import at.gv.egiz.bku.smccstal.SMCCSTALRequestHandler;
+import at.gv.egiz.bku.smccstal.SignRequestHandler;
+import at.gv.egiz.stal.impl.ByteArrayHashDataInput;
+import at.gv.egiz.stal.service.GetHashDataInputResponseType;
+import at.gv.egiz.stal.service.GetHashDataInputType;
+import at.gv.egiz.stal.service.STALPortType;
+import at.gv.egiz.stal.signedinfo.ReferenceType;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author clemens
+ */
+public class WSSignRequestHandler extends SignRequestHandler {
+
+ private static final Log log = LogFactory.getLog(WSSignRequestHandler.class);
+ STALPortType stalPort;
+ String sessId;
+
+ public WSSignRequestHandler(String sessId, STALPortType stalPort) {
+ if (stalPort == null || sessId == null) {
+ throw new NullPointerException("STAL port must not be null");
+ }
+ this.sessId = sessId;
+ this.stalPort = stalPort;
+ }
+
+ @Override
+ protected List getHashDataInputs(List dsigReferences) throws Exception {
+ GetHashDataInputType request = new GetHashDataInputType();
+ request.setSessionId(sessId);
+ for (ReferenceType dsigRef : dsigReferences) {
+ //don't get Manifest, QualifyingProperties, ...
+ if (dsigRef.getType() == null) {
+ String dsigRefId = dsigRef.getId();
+ if (dsigRefId != null) {
+ GetHashDataInputType.Reference reference = new GetHashDataInputType.Reference();
+ reference.setID(dsigRefId);
+ request.getReference().add(reference);
+ } else {
+ throw new Exception("Cannot get HashDataInput for dsig:Reference without Id attribute");
+ }
+ }
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("Calling GetHashDataInput for session " + sessId);
+ }
+ GetHashDataInputResponseType response = stalPort.getHashDataInput(request);
+ ArrayList hashDataInputs = new ArrayList();
+ for (GetHashDataInputResponseType.Reference reference : response.getReference()) {
+ byte[] hdi = reference.getValue();
+ String id = reference.getID();
+ String mimeType = reference.getMimeType();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Got HashDataInput " + id + " (" + mimeType + ")");
+ }
+ hashDataInputs.add(new ByteArrayHashDataInput(hdi, id, mimeType));
+ }
+ return hashDataInputs;
+ }
+
+ @Override
+ public SMCCSTALRequestHandler newInstance() {
+ return new WSSignRequestHandler(this.sessId, this.stalPort);
+ }
+}
diff --git a/BKUApplet/src/main/resources/commons-logging.properties b/BKUApplet/src/main/resources/commons-logging.properties
new file mode 100644
index 00000000..faa21c47
--- /dev/null
+++ b/BKUApplet/src/main/resources/commons-logging.properties
@@ -0,0 +1,16 @@
+# 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.
+
+org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
\ No newline at end of file
diff --git a/BKUApplet/src/main/resources/simplelog.properties b/BKUApplet/src/main/resources/simplelog.properties
new file mode 100644
index 00000000..d62508cf
--- /dev/null
+++ b/BKUApplet/src/main/resources/simplelog.properties
@@ -0,0 +1,25 @@
+# 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.
+
+# Logging detail level,
+# Must be one of ("trace", "debug", "info", "warn", "error", or "fatal").
+org.apache.commons.logging.simplelog.defaultlog=debug
+# Logs the Log instance used
+org.apache.commons.logging.simplelog.showlogname=true
+#Logs the class name with package(or Path)
+#( Valid Values "true","false". Default Value "true")
+org.apache.commons.logging.simplelog.showShortLogname=true
+#Logs date and time( Valid Values "true","false". Default Value "false")
+org.apache.commons.logging.simplelog.showdatetime=false
--
cgit v1.2.3
From c7cbf8a12db4fcb77fd374392e88c3fa04b1e100 Mon Sep 17 00:00:00 2001
From: wbauer
Date: Tue, 9 Sep 2008 09:54:32 +0000
Subject: added check to avoid sending baseid to non .gv.at domains
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@25 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../at/gv/egiz/bku/online/applet/BKUApplet.java | 139 ++++++------
.../at/gv/egiz/bku/online/applet/BKUWorker.java | 25 ++-
.../online/applet/InternalSSLSocketFactory.java | 237 +++++++++++++--------
.../applet/InternalSSLSocketFactoryException.java | 45 ----
4 files changed, 240 insertions(+), 206 deletions(-)
delete mode 100644 BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactoryException.java
(limited to 'BKUApplet')
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java
index 5d4d0dab..8289f30b 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java
@@ -1,19 +1,19 @@
/*
-* 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.
-*/
+ * 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.applet;
import java.util.Locale;
@@ -29,71 +29,68 @@ import at.gv.egiz.bku.gui.BKUGUIFacade;
import at.gv.egiz.bku.gui.BKUGUIFactory;
/**
- * Note: all swing code is executed by the event dispatch thread (see BKUGUIFacade)
+ * Note: all swing code is executed by the event dispatch thread (see
+ * BKUGUIFacade)
*/
public class BKUApplet extends JApplet {
- private static Log log = LogFactory.getLog(BKUApplet.class);
+ private static Log log = LogFactory.getLog(BKUApplet.class);
+
+ public final static String RESOURCE_BUNDLE_BASE = "at/gv/egiz/bku/online/applet/Messages";
- public final static String RESOURCE_BUNDLE_BASE = "at/gv/egiz/bku/online/applet/Messages";
+ public final static String LOCALE_PARAM_KEY = "Locale";
+ public final static String LOGO_URL_KEY = "LogoURL";
+ public final static String WSDL_URL = "WSDL_URL";
+ public final static String SESSION_ID = "SessionID";
- public final static String LOCALE_PARAM_KEY = "Locale";
- public final static String LOGO_URL_KEY="LogoURL";
- public final static String WSDL_URL="WSDL_URL";
- public final static String SESSION_ID="SessionID";
+ protected ResourceBundle resourceBundle;
+ protected BKUWorker worker;
+ protected Thread workerThread;
- protected ResourceBundle resourceBundle;
- protected BKUWorker worker;
- protected Thread workerThread;
-
- public BKUApplet() {
- }
+ public BKUApplet() {
+ }
- public void init() {
- log.debug("Called init()");
- try {
- HttpsURLConnection.setDefaultSSLSocketFactory(InternalSSLSocketFactory.getSocketFactory());
- HttpsURLConnection.setDefaultHostnameVerifier(InternalSSLSocketFactory.getHostNameVerifier());
- } catch (InternalSSLSocketFactoryException e) {
- log.error(e);
- }
- String localeString = getMyAppletParameter(LOCALE_PARAM_KEY);
- if (localeString != null) {
- resourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE_BASE,
- new Locale(localeString));
- } else {
- resourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE_BASE);
- }
- BKUGUIFacade gui = BKUGUIFactory.createGUI();
- gui.init(getContentPane(), localeString);
- worker = new BKUWorker(gui, this, resourceBundle);
- }
+ public void init() {
+ log.debug("Called init()");
+ HttpsURLConnection.setDefaultSSLSocketFactory(InternalSSLSocketFactory
+ .getInstance());
+ String localeString = getMyAppletParameter(LOCALE_PARAM_KEY);
+ if (localeString != null) {
+ resourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE_BASE,
+ new Locale(localeString));
+ } else {
+ resourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE_BASE);
+ }
+ BKUGUIFacade gui = BKUGUIFactory.createGUI();
+ gui.init(getContentPane(), localeString);
+ worker = new BKUWorker(gui, this, resourceBundle);
+ }
- public void start() {
- log.debug("Called start()");
- workerThread = new Thread(worker);
- workerThread.start();
- }
+ public void start() {
+ log.debug("Called start()");
+ workerThread = new Thread(worker);
+ workerThread.start();
+ }
- public void stop() {
- log.debug("Called stop()");
- if ((workerThread != null) && (workerThread.isAlive())) {
- workerThread.interrupt();
- }
- }
+ public void stop() {
+ log.debug("Called stop()");
+ if ((workerThread != null) && (workerThread.isAlive())) {
+ workerThread.interrupt();
+ }
+ }
- public void destroy() {
- log.debug("Called destroy()");
- }
+ public void destroy() {
+ log.debug("Called destroy()");
+ }
- /**
- * Applet configuration parameters
- *
- * @param paramKey
- * @return
- */
- public String getMyAppletParameter(String paramKey) {
- log.info("Getting parameter: "+paramKey+ ": "+ getParameter(paramKey));
- return getParameter(paramKey);
- }
+ /**
+ * Applet configuration parameters
+ *
+ * @param paramKey
+ * @return
+ */
+ public String getMyAppletParameter(String paramKey) {
+ log.info("Getting parameter: " + paramKey + ": " + getParameter(paramKey));
+ return getParameter(paramKey);
+ }
}
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
index f7b5fb2f..042c6a83 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
@@ -34,6 +34,8 @@ import at.gv.egiz.bku.smccstal.AbstractSMCCSTAL;
import at.gv.egiz.bku.smccstal.SMCCSTALRequestHandler;
import at.gv.egiz.smcc.SignatureCard;
import at.gv.egiz.smcc.util.SMCCHelper;
+import at.gv.egiz.stal.ErrorResponse;
+import at.gv.egiz.stal.InfoboxReadRequest;
import at.gv.egiz.stal.QuitRequest;
import at.gv.egiz.stal.STALRequest;
import at.gv.egiz.stal.STALResponse;
@@ -107,6 +109,8 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
gui.showWelcomeDialog();
try {
stalPort = getSTALPort();
+
+
} catch (Exception e) {
log.fatal("Failed to call STAL service.", e);
actionCommandList.clear();
@@ -134,7 +138,26 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
GetNextRequestResponseType resp = stalPort.getNextRequest(nextRequest);
log.info("Got " + resp.getRequest().size() + " requests from server.");
List stalRequests = resp.getRequest();
- List responses = handleRequest(stalRequests);
+ boolean handle = true;
+ for (STALRequest request : stalRequests) {
+ if (request instanceof InfoboxReadRequest) {
+ InfoboxReadRequest infobx = (InfoboxReadRequest) request;
+ if (infobx.getInfoboxIdentifier().equals("IdentityLink")) {
+ if (infobx.getDomainIdentifier() == null) {
+ if (!InternalSSLSocketFactory.getInstance().isEgovAgency()) {
+ handle = false;
+ }
+ }
+ }
+ }
+ }
+ List responses;
+ if (handle) {
+ responses = handleRequest(stalRequests);
+ } else {
+ responses = new ArrayList(1);
+ responses.add(new ErrorResponse(6002));
+ }
log.info("Got " + responses.size() + " responses.");
nextRequest = factory.createGetNextRequestType();
nextRequest.setSessionId(sessionId);
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java
index ab04d2b6..79c369a2 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java
@@ -1,19 +1,19 @@
/*
-* 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.
-*/
+ * 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.
+ */
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
@@ -22,80 +22,139 @@
package at.gv.egiz.bku.online.applet;
import java.io.IOException;
-import java.security.KeyManagementException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.CertificateException;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.security.cert.CertificateParsingException;
import java.security.cert.X509Certificate;
+import java.util.Collection;
+import java.util.List;
-import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSession;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLPeerUnverifiedException;
+import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
-import javax.net.ssl.X509TrustManager;
-
-public class InternalSSLSocketFactory {
-
- private SSLSocketFactory factory;
-
- public static SSLSocketFactory getSocketFactory() throws InternalSSLSocketFactoryException {
- return new InternalSSLSocketFactory().factory;
- }
-
- public static HostnameVerifier getHostNameVerifier() throws InternalSSLSocketFactoryException {
- return (new HostnameVerifier() {
- @Override
- public boolean verify(String hostname, SSLSession session) {
- return true;
- }
- });
- }
-
- public InternalSSLSocketFactory() throws InternalSSLSocketFactoryException {
- SSLContext sslContext;
- try {
- sslContext = SSLContext.getInstance("TLSv1");
- sslContext.getClientSessionContext().setSessionTimeout(0);
- KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance("SunX509");
-
- KeyStore keyStore = KeyStore.getInstance("JKS");
- keyStore.load(null, null);
- keyManagerFactory.init(keyStore, null);
-
- sslContext.init(keyManagerFactory.getKeyManagers(),
- new X509TrustManager[] { new AcceptAllTrustManager() },
- null);
- } catch (NoSuchAlgorithmException e) {
- throw new InternalSSLSocketFactoryException(e);
- } catch (CertificateException e) {
- throw new InternalSSLSocketFactoryException(e);
- } catch (IOException e) {
- throw new InternalSSLSocketFactoryException(e);
- } catch (KeyStoreException e) {
- throw new InternalSSLSocketFactoryException(e);
- } catch (UnrecoverableKeyException e) {
- throw new InternalSSLSocketFactoryException(e);
- } catch (KeyManagementException e) {
- throw new InternalSSLSocketFactoryException(e);
- }
-
- this.factory = sslContext.getSocketFactory();
- }
-
- class AcceptAllTrustManager implements X509TrustManager {
-
- public X509Certificate[] getAcceptedIssuers() {
- return null;
- }
-
- public void checkClientTrusted(X509Certificate[] chain, String authType) {
- }
-
- public void checkServerTrusted(X509Certificate[] chain, String authType) {
- //FIXME
- }
- }
-};
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class InternalSSLSocketFactory extends SSLSocketFactory {
+
+ private static InternalSSLSocketFactory instance = new InternalSSLSocketFactory();
+
+ private final static Log log = LogFactory
+ .getLog(InternalSSLSocketFactory.class);
+
+ private final static String GOV_DOMAIN = ".gv.at";
+
+ private SSLSocket sslSocket;
+
+ private SSLSocketFactory proxy;
+
+ private InternalSSLSocketFactory() {
+ proxy = HttpsURLConnection.getDefaultSSLSocketFactory();
+ }
+
+ public static InternalSSLSocketFactory getInstance() {
+ return instance;
+ }
+
+ @Override
+ public Socket createSocket() throws IOException {
+ sslSocket = (SSLSocket) proxy.createSocket();
+ return sslSocket;
+ }
+
+ @Override
+ public Socket createSocket(String arg0, int arg1) throws IOException,
+ UnknownHostException {
+ sslSocket = (SSLSocket) proxy.createSocket(arg0, arg1);
+
+ return sslSocket;
+ }
+
+ @Override
+ public Socket createSocket(InetAddress arg0, int arg1) throws IOException {
+ sslSocket = (SSLSocket) proxy.createSocket(arg0, arg1);
+ return sslSocket;
+ }
+
+ @Override
+ public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3)
+ throws IOException, UnknownHostException {
+ sslSocket = (SSLSocket) proxy.createSocket(arg0, arg1, arg2, arg3);
+ return sslSocket;
+ }
+
+ @Override
+ public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2,
+ int arg3) throws IOException {
+ sslSocket = (SSLSocket) proxy.createSocket(arg0, arg1, arg2, arg3);
+ return sslSocket;
+ }
+
+ @Override
+ public Socket createSocket(Socket arg0, String arg1, int arg2, boolean arg3)
+ throws IOException {
+ sslSocket = (SSLSocket) proxy.createSocket(arg0, arg1, arg2, arg3);
+ return sslSocket;
+ }
+
+ @Override
+ public String[] getDefaultCipherSuites() {
+ return proxy.getDefaultCipherSuites();
+ }
+
+ @Override
+ public String[] getSupportedCipherSuites() {
+ return proxy.getSupportedCipherSuites();
+ }
+
+ public boolean isEgovAgency() {
+ log.info("Checking if server is egov agency");
+ if (sslSocket != null) {
+ try {
+ X509Certificate cert = (X509Certificate) sslSocket.getSession()
+ .getPeerCertificates()[0];
+ log.info("Server cert: " + cert);
+ return isGovAgency(cert);
+ } catch (SSLPeerUnverifiedException e) {
+ log.error(e);
+ return false;
+ }
+ }
+ log.info("Not a SSL connection");
+ return false;
+ }
+
+ public static boolean isGovAgency(X509Certificate cert) {
+ String[] rdns = (cert.getSubjectX500Principal().getName()).split(",");
+ for (String rdn : rdns) {
+ if (rdn.startsWith("CN=")) {
+ String dns = rdn.split("=")[1];
+ if (dns.endsWith(GOV_DOMAIN)) {
+ return true;
+ }
+ }
+ }
+ try {
+ Collection> sanList = cert.getSubjectAlternativeNames();
+ if (sanList != null) {
+ for (List> san : sanList) {
+ if ((Integer) san.get(0) == 2) {
+ String dns = (String) san.get(1);
+ if (dns.endsWith(GOV_DOMAIN)) {
+ return true;
+ }
+ }
+ }
+ }
+ } catch (CertificateParsingException e) {
+ log.error(e);
+ }
+ if (cert.getExtensionValue("1.2.40.0.10.1.1.1") != null) {
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactoryException.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactoryException.java
deleted file mode 100644
index c620284a..00000000
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactoryException.java
+++ /dev/null
@@ -1,45 +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.
-*/
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package at.gv.egiz.bku.online.applet;
-
-/**
- *
- * @author mcentner
- */
-public class InternalSSLSocketFactoryException extends Exception {
-
- public InternalSSLSocketFactoryException(Throwable cause) {
- super(cause);
- }
-
- public InternalSSLSocketFactoryException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public InternalSSLSocketFactoryException(String message) {
- super(message);
- }
-
- public InternalSSLSocketFactoryException() {
- }
-
-}
--
cgit v1.2.3
From a3361b40aa8f92849c50db27e349e17b87bebb1e Mon Sep 17 00:00:00 2001
From: wbauer
Date: Tue, 9 Sep 2008 12:40:52 +0000
Subject: improved security handling and added shutdown handler
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@27 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'BKUApplet')
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java
index 79c369a2..fa3587e4 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java
@@ -40,13 +40,13 @@ import org.apache.commons.logging.LogFactory;
public class InternalSSLSocketFactory extends SSLSocketFactory {
+ private final static String GOV_DOMAIN = ".gv.at";
+
private static InternalSSLSocketFactory instance = new InternalSSLSocketFactory();
private final static Log log = LogFactory
.getLog(InternalSSLSocketFactory.class);
- private final static String GOV_DOMAIN = ".gv.at";
-
private SSLSocket sslSocket;
private SSLSocketFactory proxy;
--
cgit v1.2.3
From bdc1c691b571e55f6806d3ac9bc3dad4fcb2691d Mon Sep 17 00:00:00 2001
From: clemenso
Date: Wed, 10 Sep 2008 16:53:40 +0000
Subject: waitDialog
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@29 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'BKUApplet')
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
index 042c6a83..51ac243c 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
@@ -272,7 +272,7 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
}
break;
case SMCCHelper.CARD_FOUND:
- gui.showWelcomeDialog();
+ gui.showWaitDialog(null);
signatureCard = smccHelper.getSignatureCard(errorMessages.getLocale());
return false;
}
--
cgit v1.2.3
From 3794536434fdbb06067eddcfd248898ce85f85a1 Mon Sep 17 00:00:00 2001
From: clemenso
Date: Fri, 12 Sep 2008 13:06:34 +0000
Subject: gui 0.2
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@34 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../at/gv/egiz/bku/online/applet/BKUApplet.java | 102 ++++++++++-----------
1 file changed, 49 insertions(+), 53 deletions(-)
(limited to 'BKUApplet')
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java
index 8289f30b..c7df0871 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java
@@ -34,63 +34,59 @@ import at.gv.egiz.bku.gui.BKUGUIFactory;
*/
public class BKUApplet extends JApplet {
- private static Log log = LogFactory.getLog(BKUApplet.class);
+ private static Log log = LogFactory.getLog(BKUApplet.class);
+ public final static String RESOURCE_BUNDLE_BASE = "at/gv/egiz/bku/online/applet/Messages";
+ public final static String LOCALE_PARAM_KEY = "Locale";
+ public final static String LOGO_URL_KEY = "LogoURL";
+ public final static String WSDL_URL = "WSDL_URL";
+ public final static String SESSION_ID = "SessionID";
+ protected ResourceBundle resourceBundle;
+ protected BKUWorker worker;
+ protected Thread workerThread;
- public final static String RESOURCE_BUNDLE_BASE = "at/gv/egiz/bku/online/applet/Messages";
+ public BKUApplet() {
+ }
- public final static String LOCALE_PARAM_KEY = "Locale";
- public final static String LOGO_URL_KEY = "LogoURL";
- public final static String WSDL_URL = "WSDL_URL";
- public final static String SESSION_ID = "SessionID";
+ public void init() {
+ log.debug("Called init()");
+ HttpsURLConnection.setDefaultSSLSocketFactory(InternalSSLSocketFactory.getInstance());
+ String localeString = getMyAppletParameter(LOCALE_PARAM_KEY);
+ if (localeString != null) {
+ resourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE_BASE,
+ new Locale(localeString));
+ } else {
+ resourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE_BASE);
+ }
+ BKUGUIFacade gui = BKUGUIFactory.createGUI();
+ gui.init(getContentPane(), localeString);
+ worker = new BKUWorker(gui, this, resourceBundle);
+ }
- protected ResourceBundle resourceBundle;
- protected BKUWorker worker;
- protected Thread workerThread;
+ public void start() {
+ log.debug("Called start()");
+ workerThread = new Thread(worker);
+ workerThread.start();
+ }
- public BKUApplet() {
- }
+ public void stop() {
+ log.debug("Called stop()");
+ if ((workerThread != null) && (workerThread.isAlive())) {
+ workerThread.interrupt();
+ }
+ }
- public void init() {
- log.debug("Called init()");
- HttpsURLConnection.setDefaultSSLSocketFactory(InternalSSLSocketFactory
- .getInstance());
- String localeString = getMyAppletParameter(LOCALE_PARAM_KEY);
- if (localeString != null) {
- resourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE_BASE,
- new Locale(localeString));
- } else {
- resourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE_BASE);
- }
- BKUGUIFacade gui = BKUGUIFactory.createGUI();
- gui.init(getContentPane(), localeString);
- worker = new BKUWorker(gui, this, resourceBundle);
- }
+ public void destroy() {
+ log.debug("Called destroy()");
+ }
- public void start() {
- log.debug("Called start()");
- workerThread = new Thread(worker);
- workerThread.start();
- }
-
- public void stop() {
- log.debug("Called stop()");
- if ((workerThread != null) && (workerThread.isAlive())) {
- workerThread.interrupt();
- }
- }
-
- public void destroy() {
- log.debug("Called destroy()");
- }
-
- /**
- * Applet configuration parameters
- *
- * @param paramKey
- * @return
- */
- public String getMyAppletParameter(String paramKey) {
- log.info("Getting parameter: " + paramKey + ": " + getParameter(paramKey));
- return getParameter(paramKey);
- }
+ /**
+ * Applet configuration parameters
+ *
+ * @param paramKey
+ * @return
+ */
+ public String getMyAppletParameter(String paramKey) {
+ log.info("Getting parameter: " + paramKey + ": " + getParameter(paramKey));
+ return getParameter(paramKey);
+ }
}
--
cgit v1.2.3
From 0df8bb10302989f41ed420ec0ff29b2fc2005471 Mon Sep 17 00:00:00 2001
From: wbauer
Date: Mon, 15 Sep 2008 14:18:53 +0000
Subject: Migrated BKULocal to BKUCommonGUI and minor bug fixes
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@37 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java | 11 +++++++++++
1 file changed, 11 insertions(+)
(limited to 'BKUApplet')
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
index 51ac243c..cd96a481 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
@@ -75,6 +75,17 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
addRequestHandler(QuitRequest.class, this);
//register SignRequestHandler once we have a webservice port
}
+
+ /**
+ * Used for non applet variants
+ * @param gui
+ * @param errorMessageBundle
+ */
+ protected BKUWorker(BKUGUIFacade gui, ResourceBundle errorMessageBundle) {
+ this.gui = gui;
+ this.errorMessages = errorMessageBundle;
+ addRequestHandler(QuitRequest.class, this);
+ }
private STALPortType getSTALPort() throws MalformedURLException {
URL wsdlURL = null;
--
cgit v1.2.3
From 677bff2bdb7b2cb327930f0596d5f3133363295c Mon Sep 17 00:00:00 2001
From: clemenso
Date: Mon, 15 Sep 2008 18:00:30 +0000
Subject: encoding
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@38 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
(limited to 'BKUApplet')
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java
index f9965240..5186de1a 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java
@@ -74,11 +74,12 @@ public class WSSignRequestHandler extends SignRequestHandler {
byte[] hdi = reference.getValue();
String id = reference.getID();
String mimeType = reference.getMimeType();
+ String encoding = reference.getEncoding();
if (log.isDebugEnabled()) {
- log.debug("Got HashDataInput " + id + " (" + mimeType + ")");
+ log.debug("Got HashDataInput " + id + " (" + mimeType + ";" + encoding + ")");
}
- hashDataInputs.add(new ByteArrayHashDataInput(hdi, id, mimeType));
+ hashDataInputs.add(new ByteArrayHashDataInput(hdi, id, mimeType, encoding));
}
return hashDataInputs;
}
--
cgit v1.2.3
From cf82096145bbdd548e388c1bc25f0e703b9b4624 Mon Sep 17 00:00:00 2001
From: clemenso
Date: Wed, 17 Sep 2008 17:17:10 +0000
Subject: hashdatainput digest verification
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@44 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../bku/online/applet/WSSignRequestHandler.java | 139 ++++++++++++++-------
1 file changed, 94 insertions(+), 45 deletions(-)
(limited to 'BKUApplet')
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java
index 5186de1a..6dae264c 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java
@@ -16,15 +16,20 @@
*/
package at.gv.egiz.bku.online.applet;
-import at.gv.egiz.stal.HashDataInput;
import at.gv.egiz.bku.smccstal.SMCCSTALRequestHandler;
import at.gv.egiz.bku.smccstal.SignRequestHandler;
+import at.gv.egiz.stal.HashDataInput;
import at.gv.egiz.stal.impl.ByteArrayHashDataInput;
import at.gv.egiz.stal.service.GetHashDataInputResponseType;
import at.gv.egiz.stal.service.GetHashDataInputType;
import at.gv.egiz.stal.service.STALPortType;
+import at.gv.egiz.stal.signedinfo.DigestMethodType;
import at.gv.egiz.stal.signedinfo.ReferenceType;
+import java.security.DigestException;
+import java.security.MessageDigest;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -35,57 +40,101 @@ import org.apache.commons.logging.LogFactory;
*/
public class WSSignRequestHandler extends SignRequestHandler {
- private static final Log log = LogFactory.getLog(WSSignRequestHandler.class);
- STALPortType stalPort;
- String sessId;
+ private static final Log log = LogFactory.getLog(WSSignRequestHandler.class);
+ STALPortType stalPort;
+ String sessId;
- public WSSignRequestHandler(String sessId, STALPortType stalPort) {
- if (stalPort == null || sessId == null) {
- throw new NullPointerException("STAL port must not be null");
- }
- this.sessId = sessId;
- this.stalPort = stalPort;
+ public WSSignRequestHandler(String sessId, STALPortType stalPort) {
+ if (stalPort == null || sessId == null) {
+ throw new NullPointerException("STAL port must not be null");
}
+ this.sessId = sessId;
+ this.stalPort = stalPort;
+ }
- @Override
- protected List getHashDataInputs(List dsigReferences) throws Exception {
- GetHashDataInputType request = new GetHashDataInputType();
- request.setSessionId(sessId);
- for (ReferenceType dsigRef : dsigReferences) {
- //don't get Manifest, QualifyingProperties, ...
- if (dsigRef.getType() == null) {
- String dsigRefId = dsigRef.getId();
- if (dsigRefId != null) {
- GetHashDataInputType.Reference reference = new GetHashDataInputType.Reference();
- reference.setID(dsigRefId);
- request.getReference().add(reference);
- } else {
- throw new Exception("Cannot get HashDataInput for dsig:Reference without Id attribute");
- }
- }
- }
+ @Override
+ public List getCashedHashDataInputs(List signedReferences) throws Exception {
- if (log.isDebugEnabled()) {
- log.debug("Calling GetHashDataInput for session " + sessId);
- }
- GetHashDataInputResponseType response = stalPort.getHashDataInput(request);
- ArrayList hashDataInputs = new ArrayList();
- for (GetHashDataInputResponseType.Reference reference : response.getReference()) {
- byte[] hdi = reference.getValue();
- String id = reference.getID();
- String mimeType = reference.getMimeType();
- String encoding = reference.getEncoding();
+ GetHashDataInputType request = new GetHashDataInputType();
+ request.setSessionId(sessId);
+
+ HashMap idRefMap = new HashMap();
+ for (ReferenceType reference : signedReferences) {
+ //don't get Manifest, QualifyingProperties, ...
+ if (reference.getType() == null) {
+ String referenceId = reference.getId();
+ if (referenceId != null) {
+ idRefMap.put(referenceId, reference);
+ GetHashDataInputType.Reference ref = new GetHashDataInputType.Reference();
+ ref.setID(referenceId);
+ request.getReference().add(ref);
- if (log.isDebugEnabled()) {
- log.debug("Got HashDataInput " + id + " (" + mimeType + ";" + encoding + ")");
- }
- hashDataInputs.add(new ByteArrayHashDataInput(hdi, id, mimeType, encoding));
+ } else {
+ throw new Exception("Cannot resolve HashDataInput for reference without Id attribute");
}
- return hashDataInputs;
+ }
}
- @Override
- public SMCCSTALRequestHandler newInstance() {
- return new WSSignRequestHandler(this.sessId, this.stalPort);
+ if (log.isDebugEnabled()) {
+ log.debug("Calling GetHashDataInput for session " + sessId);
}
+ GetHashDataInputResponseType response = stalPort.getHashDataInput(request);
+ ArrayList hashDataInputs = new ArrayList();
+
+ for (GetHashDataInputResponseType.Reference reference : response.getReference()) {
+
+ String id = reference.getID();
+ byte[] hdi = reference.getValue();
+ if (hdi == null) {
+ throw new Exception("Failed to resolve digest value for reference " + id);
+ }
+ String mimeType = reference.getMimeType();
+ String encoding = reference.getEncoding();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Got HashDataInput " + id + " (" + mimeType + ";" + encoding + ")");
+ }
+
+ ReferenceType dsigRef = idRefMap.get(id);
+ DigestMethodType dm = dsigRef.getDigestMethod();
+ if (dm == null) {
+ throw new Exception("Failed to verify digest value for reference " + id + ": no digest algorithm");
+ }
+ //TODO
+ String mdAlg = dm.getAlgorithm();
+ if ("http://www.w3.org/2000/09/xmldsig#sha1".equals(mdAlg))
+ mdAlg = "SHA-1";
+ else if ("http://www.w3.org/2001/04/xmlenc#sha256".equals(mdAlg))
+ mdAlg = "SHA-256";
+ else if ("http://www.w3.org/2001/04/xmlenc#sha224 ".equals(mdAlg))
+ mdAlg = "SHA-224";
+ else if ("http://www.w3.org/2001/04/xmldsig-more#sha224 ".equals(mdAlg))
+ mdAlg = "SHA-224";
+ else if ("http://www.w3.org/2001/04/xmldsig-more#sha384".equals(mdAlg))
+ mdAlg = "SHA-384";
+ else if ("http://www.w3.org/2001/04/xmlenc#sha512".equals(mdAlg))
+ mdAlg = "SHA-512";
+ else if ("http://www.w3.org/2001/04/xmldsig-more#md2 ".equals(mdAlg))
+ mdAlg = "MD2";
+ else if ("http://www.w3.org/2001/04/xmldsig-more#md5".equals(mdAlg))
+ mdAlg = "MD5";
+ else if ("http://www.w3.org/2001/04/xmlenc#ripemd160 ".equals(mdAlg))
+ mdAlg = "RipeMD-160";
+ MessageDigest md = MessageDigest.getInstance(mdAlg);
+ byte[] hdiDigest = md.digest(hdi);
+ if (log.isDebugEnabled())
+ log.debug("Comparing digest values... ");
+ if (!Arrays.equals(hdiDigest, dsigRef.getDigestValue())) {
+ log.error("digest values differ: " + new String(hdiDigest) + ", " + new String(dsigRef.getDigestValue()));
+ throw new DigestException("Bad digest value for reference " + id + ": " + dsigRef.getDigestValue());
+ }
+ hashDataInputs.add(new ByteArrayHashDataInput(hdi, id, mimeType, encoding));
+ }
+ return hashDataInputs;
+ }
+
+ @Override
+ public SMCCSTALRequestHandler newInstance() {
+ return new WSSignRequestHandler(this.sessId, this.stalPort);
+ }
}
--
cgit v1.2.3
From 03f5ae9e9068168b294c042d68a58637e71a54ee Mon Sep 17 00:00:00 2001
From: clemenso
Date: Tue, 23 Sep 2008 14:09:02 +0000
Subject: bitte warten...
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@59 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'BKUApplet')
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
index cd96a481..465bde78 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
@@ -283,7 +283,7 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
}
break;
case SMCCHelper.CARD_FOUND:
- gui.showWaitDialog(null);
+// gui.showWaitDialog(null);
signatureCard = smccHelper.getSignatureCard(errorMessages.getLocale());
return false;
}
--
cgit v1.2.3
From 0168154a4a0777fd7ae2bc3a097c12b33781d75a Mon Sep 17 00:00:00 2001
From: clemenso
Date: Wed, 24 Sep 2008 13:08:04 +0000
Subject: git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@61
8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java | 1 +
BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
(limited to 'BKUApplet')
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java
index c7df0871..34dd9bbd 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java
@@ -48,6 +48,7 @@ public class BKUApplet extends JApplet {
}
public void init() {
+ log.info("Welcome to MOCCA\n");
log.debug("Called init()");
HttpsURLConnection.setDefaultSSLSocketFactory(InternalSSLSocketFactory.getInstance());
String localeString = getMyAppletParameter(LOCALE_PARAM_KEY);
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
index 465bde78..8190e5ec 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
@@ -175,7 +175,7 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
nextRequest.getResponse().addAll(responses);
} while (!finished);
log.info("Done " + Thread.currentThread().getName());
- gui.showWelcomeDialog();
+// gui.showWelcomeDialog();
sendRedirect();
}
--
cgit v1.2.3
From afa2741d7257ee3e98f400e211d96f584c4ef778 Mon Sep 17 00:00:00 2001
From: wbauer
Date: Fri, 26 Sep 2008 13:36:57 +0000
Subject: added error dialog for unexpected internal errors
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@74 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../at/gv/egiz/bku/online/applet/BKUWorker.java | 131 +++++++++++----------
1 file changed, 70 insertions(+), 61 deletions(-)
(limited to 'BKUApplet')
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
index 8190e5ec..35fe652f 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
@@ -1,19 +1,19 @@
/*
-* 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.
-*/
+ * 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.applet;
import java.awt.event.ActionEvent;
@@ -73,11 +73,12 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
this.parent = parent;
this.errorMessages = errorMessageBundle;
addRequestHandler(QuitRequest.class, this);
- //register SignRequestHandler once we have a webservice port
+ // register SignRequestHandler once we have a webservice port
}
-
+
/**
* Used for non applet variants
+ *
* @param gui
* @param errorMessageBundle
*/
@@ -96,7 +97,7 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
try {
if (codebase.getProtocol().equalsIgnoreCase("file")) {
// for debugging in appletrunner
- wsdlURL = new URL(wsdlLocation);
+ wsdlURL = new URL(wsdlLocation);
} else {
wsdlURL = new URL(codebase, wsdlLocation);
}
@@ -120,8 +121,7 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
gui.showWelcomeDialog();
try {
stalPort = getSTALPort();
-
-
+
} catch (Exception e) {
log.fatal("Failed to call STAL service.", e);
actionCommandList.clear();
@@ -134,48 +134,57 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
}
return;
}
+ try {
+ ObjectFactory factory = new ObjectFactory();
+ GetNextRequestType nextRequest = factory.createGetNextRequestType();
- ObjectFactory factory = new ObjectFactory();
- GetNextRequestType nextRequest = factory.createGetNextRequestType();
-
- String sessionId = parent.getMyAppletParameter(BKUApplet.SESSION_ID);
- if (sessionId == null) {
- // use the testsession for testing
- sessionId = "TestSession";
- }
- nextRequest.setSessionId(sessionId);
- addRequestHandler(SignRequest.class, new WSSignRequestHandler(sessionId, stalPort));
- do {
- GetNextRequestResponseType resp = stalPort.getNextRequest(nextRequest);
- log.info("Got " + resp.getRequest().size() + " requests from server.");
- List stalRequests = resp.getRequest();
- boolean handle = true;
- for (STALRequest request : stalRequests) {
- if (request instanceof InfoboxReadRequest) {
- InfoboxReadRequest infobx = (InfoboxReadRequest) request;
- if (infobx.getInfoboxIdentifier().equals("IdentityLink")) {
- if (infobx.getDomainIdentifier() == null) {
- if (!InternalSSLSocketFactory.getInstance().isEgovAgency()) {
- handle = false;
- }
- }
- }
- }
- }
- List responses;
- if (handle) {
- responses = handleRequest(stalRequests);
- } else {
- responses = new ArrayList(1);
- responses.add(new ErrorResponse(6002));
+ String sessionId = parent.getMyAppletParameter(BKUApplet.SESSION_ID);
+ if (sessionId == null) {
+ // use the testsession for testing
+ sessionId = "TestSession";
}
- log.info("Got " + responses.size() + " responses.");
- nextRequest = factory.createGetNextRequestType();
nextRequest.setSessionId(sessionId);
- nextRequest.getResponse().addAll(responses);
- } while (!finished);
- log.info("Done " + Thread.currentThread().getName());
-// gui.showWelcomeDialog();
+ addRequestHandler(SignRequest.class, new WSSignRequestHandler(sessionId,
+ stalPort));
+ do {
+ GetNextRequestResponseType resp = stalPort.getNextRequest(nextRequest);
+ log.info("Got " + resp.getRequest().size() + " requests from server.");
+ List stalRequests = resp.getRequest();
+ boolean handle = true;
+ for (STALRequest request : stalRequests) {
+ if (request instanceof InfoboxReadRequest) {
+ InfoboxReadRequest infobx = (InfoboxReadRequest) request;
+ if (infobx.getInfoboxIdentifier().equals("IdentityLink")) {
+ if (infobx.getDomainIdentifier() == null) {
+ if (!InternalSSLSocketFactory.getInstance().isEgovAgency()) {
+ handle = false;
+ }
+ }
+ }
+ }
+ }
+ List responses;
+ if (handle) {
+ responses = handleRequest(stalRequests);
+ } else {
+ responses = new ArrayList(1);
+ responses.add(new ErrorResponse(6002));
+ }
+ log.info("Got " + responses.size() + " responses.");
+ nextRequest = factory.createGetNextRequestType();
+ nextRequest.setSessionId(sessionId);
+ nextRequest.getResponse().addAll(responses);
+ } while (!finished);
+ log.info("Done " + Thread.currentThread().getName());
+ // gui.showWelcomeDialog();
+ } catch (Exception ex) {
+ gui.showErrorDialog("Sorry, an internal error occured: " + ex.getMessage());
+ try {
+ waitForAction();
+ } catch (InterruptedException e) {
+ log.error(e);
+ }
+ }
sendRedirect();
}
@@ -187,7 +196,7 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
URL url = null;
if (redirectURL != null) {
try {
- url = new URL(parent.getCodeBase(),redirectURL + ";jsessionid="
+ url = new URL(parent.getCodeBase(), redirectURL + ";jsessionid="
+ parent.getMyAppletParameter(BKUApplet.SESSION_ID));
} catch (MalformedURLException ex) {
log.warn("Parameter 'redirectURL': " + redirectURL
@@ -283,7 +292,7 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
}
break;
case SMCCHelper.CARD_FOUND:
-// gui.showWaitDialog(null);
+ // gui.showWaitDialog(null);
signatureCard = smccHelper.getSignatureCard(errorMessages.getLocale());
return false;
}
--
cgit v1.2.3
From d0879e9058943c6afa1912ccbeae936db2811f26 Mon Sep 17 00:00:00 2001
From: clemenso
Date: Tue, 30 Sep 2008 13:54:54 +0000
Subject: backport to JAXWS2.0 STALService initial connect()
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@76 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../at/gv/egiz/bku/online/applet/BKUWorker.java | 189 ++++++++++++---------
.../bku/online/applet/WSSignRequestHandler.java | 4 +-
.../at/gv/egiz/stal/client/STALServiceTest.java | 20 ++-
3 files changed, 119 insertions(+), 94 deletions(-)
(limited to 'BKUApplet')
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
index 35fe652f..a87b04c4 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
@@ -34,23 +34,23 @@ import at.gv.egiz.bku.smccstal.AbstractSMCCSTAL;
import at.gv.egiz.bku.smccstal.SMCCSTALRequestHandler;
import at.gv.egiz.smcc.SignatureCard;
import at.gv.egiz.smcc.util.SMCCHelper;
-import at.gv.egiz.stal.ErrorResponse;
-import at.gv.egiz.stal.InfoboxReadRequest;
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.service.GetNextRequestResponseType;
-import at.gv.egiz.stal.service.GetNextRequestType;
-import at.gv.egiz.stal.service.ObjectFactory;
+import at.gv.egiz.stal.service.types.GetNextRequestResponseType;
+import at.gv.egiz.stal.service.types.GetNextRequestType;
+import at.gv.egiz.stal.service.types.ObjectFactory;
import at.gv.egiz.stal.service.STALPortType;
import at.gv.egiz.stal.service.STALService;
+import at.gv.egiz.stal.service.types.ErrorResponseType;
+import at.gv.egiz.stal.service.types.RequestType;
+import at.gv.egiz.stal.service.types.ResponseType;
+import at.gv.egiz.stal.util.STALTranslator;
public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
- ActionListener, SMCCSTALRequestHandler {
+ ActionListener, SMCCSTALRequestHandler {
private static Log log = LogFactory.getLog(BKUWorker.class);
-
protected BKUGUIFacade gui;
protected BKUApplet parent;
private STALPortType stalPort;
@@ -65,7 +65,7 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
* must not be null
*/
public BKUWorker(BKUGUIFacade gui, BKUApplet parent,
- ResourceBundle errorMessageBundle) {
+ ResourceBundle errorMessageBundle) {
if ((gui == null) || (parent == null) || (errorMessageBundle == null)) {
throw new NullPointerException("Parameter must not be set to null");
}
@@ -73,7 +73,7 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
this.parent = parent;
this.errorMessages = errorMessageBundle;
addRequestHandler(QuitRequest.class, this);
- // register SignRequestHandler once we have a webservice port
+ // register SignRequestHandler once we have a webservice port
}
/**
@@ -111,7 +111,7 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
}
log.debug("Found WSDL url: " + wsdlURL);
QName endpointName = new QName("http://www.egiz.gv.at/wsdl/stal",
- "STALService");
+ "STALService");
STALService stal = new STALService(wsdlURL, endpointName);
return stal.getSTALPort();
}
@@ -135,49 +135,75 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
return;
}
try {
- ObjectFactory factory = new ObjectFactory();
- GetNextRequestType nextRequest = factory.createGetNextRequestType();
-
String sessionId = parent.getMyAppletParameter(BKUApplet.SESSION_ID);
if (sessionId == null) {
// use the testsession for testing
sessionId = "TestSession";
}
- nextRequest.setSessionId(sessionId);
- addRequestHandler(SignRequest.class, new WSSignRequestHandler(sessionId,
- stalPort));
+ addRequestHandler(at.gv.egiz.stal.SignRequest.class, new WSSignRequestHandler(sessionId, stalPort));
+
+ ObjectFactory of = new ObjectFactory();
+ GetNextRequestResponseType nextRequestResp = stalPort.connect(sessionId);
do {
- GetNextRequestResponseType resp = stalPort.getNextRequest(nextRequest);
- log.info("Got " + resp.getRequest().size() + " requests from server.");
- List stalRequests = resp.getRequest();
+ List requests = nextRequestResp.getInfoboxReadRequestOrSignRequestOrQuitRequest();
+ List stalRequests = STALTranslator.translateRequests(requests);
+
+ if (log.isInfoEnabled()) {
+ StringBuilder sb = new StringBuilder("Received ");
+ sb.append(stalRequests.size());
+ sb.append(" STAL requests: ");
+ for (STALRequest r : stalRequests) {
+ sb.append(r.getClass());
+ sb.append(' ');
+ }
+ log.info(sb.toString());
+ }
+
boolean handle = true;
for (STALRequest request : stalRequests) {
- if (request instanceof InfoboxReadRequest) {
- InfoboxReadRequest infobx = (InfoboxReadRequest) request;
- if (infobx.getInfoboxIdentifier().equals("IdentityLink")) {
- if (infobx.getDomainIdentifier() == null) {
- if (!InternalSSLSocketFactory.getInstance().isEgovAgency()) {
- handle = false;
- }
+ if (request instanceof at.gv.egiz.stal.InfoboxReadRequest) {
+ at.gv.egiz.stal.InfoboxReadRequest r = (at.gv.egiz.stal.InfoboxReadRequest) request;
+ String infoboxId = r.getInfoboxIdentifier();
+ String domainId = r.getDomainIdentifier();
+ if ("IdentityLink".equals(infoboxId) && domainId == null) {
+ if (!InternalSSLSocketFactory.getInstance().isEgovAgency()) {
+ handle = false;
}
}
}
}
- List responses;
+
+ List responses;
if (handle) {
- responses = handleRequest(stalRequests);
+ List stalResponses = handleRequest(stalRequests);
+ if (log.isInfoEnabled()) {
+ StringBuilder sb = new StringBuilder(stalResponses.size());
+ sb.append(" STAL responses: ");
+ for (STALResponse r : stalResponses) {
+ sb.append(r.getClass());
+ sb.append(' ');
+ }
+ log.info(sb.toString());
+ }
+ responses = STALTranslator.fromSTAL(stalResponses);
} else {
- responses = new ArrayList(1);
- responses.add(new ErrorResponse(6002));
+ responses = new ArrayList(1);
+ ErrorResponseType err = new ErrorResponseType();
+ err.setErrorCode(6002);
+// err.setErrorMessage();
+ responses.add(err);
+ }
+
+ if (!finished) {
+ GetNextRequestType nextRequest = of.createGetNextRequestType();
+ nextRequest.setSessionId(sessionId);
+ nextRequest.getInfoboxReadResponseOrSignResponseOrErrorResponse().addAll(responses);
+ nextRequestResp = stalPort.getNextRequest(nextRequest);
}
- log.info("Got " + responses.size() + " responses.");
- nextRequest = factory.createGetNextRequestType();
- nextRequest.setSessionId(sessionId);
- nextRequest.getResponse().addAll(responses);
} while (!finished);
log.info("Done " + Thread.currentThread().getName());
- // gui.showWelcomeDialog();
} catch (Exception ex) {
+ log.error(ex.getMessage(), ex);
gui.showErrorDialog("Sorry, an internal error occured: " + ex.getMessage());
try {
waitForAction();
@@ -196,20 +222,17 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
URL url = null;
if (redirectURL != null) {
try {
- url = new URL(parent.getCodeBase(), redirectURL + ";jsessionid="
- + parent.getMyAppletParameter(BKUApplet.SESSION_ID));
+ url = new URL(parent.getCodeBase(), redirectURL + ";jsessionid=" + parent.getMyAppletParameter(BKUApplet.SESSION_ID));
} catch (MalformedURLException ex) {
- log.warn("Parameter 'redirectURL': " + redirectURL
- + " not a valid URL.", ex);
- // gui.showErrorDialog(errorMsg, okListener, actionCommand)
+ log.warn("Parameter 'redirectURL': " + redirectURL + " not a valid URL.", ex);
+ // gui.showErrorDialog(errorMsg, okListener, actionCommand)
}
if (url != null) {
if (redirectTarget == null) {
log.info("Done. Trying to redirect to " + url + " ...");
parent.getAppletContext().showDocument(url);
} else {
- log.info("Done. Trying to redirect to " + url + " (target="
- + redirectTarget + ") ...");
+ log.info("Done. Trying to redirect to " + url + " (target=" + redirectTarget + ") ...");
parent.getAppletContext().showDocument(url, redirectTarget);
}
}
@@ -253,48 +276,48 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
int oldValue = SMCCHelper.PC_SC_NOT_SUPPORTED; // this is a save default
while ((signatureCard == null) && (!actionPerformed)) {
switch (smccHelper.getResultCode()) {
- case SMCCHelper.PC_SC_NOT_SUPPORTED:
- actionCommandList.clear();
- actionCommandList.add("ok");
- gui.showErrorDialog(errorMessages.getString("nopcscsupport"), this,
- "ok");
- try {
- waitForAction();
- } catch (InterruptedException e) {
- log.error(e);
- }
- return true;
- case SMCCHelper.TERMINAL_NOT_PRESENT:
- actionCommandList.clear();
- actionCommandList.add("ok");
- gui.showErrorDialog(errorMessages.getString("nocardterminal"), this,
- "ok");
- try {
- waitForAction();
- } catch (InterruptedException e) {
- log.error(e);
- }
- return true;
- case SMCCHelper.CARD_NOT_SUPPORTED:
- if (oldValue != SMCCHelper.CARD_NOT_SUPPORTED) {
+ case SMCCHelper.PC_SC_NOT_SUPPORTED:
actionCommandList.clear();
- actionCommandList.add("cancel");
- gui.showCardNotSupportedDialog(this, "cancel");
- oldValue = SMCCHelper.CARD_NOT_SUPPORTED;
- }
- break;
- case SMCCHelper.NO_CARD:
- if (oldValue != SMCCHelper.NO_CARD) {
+ actionCommandList.add("ok");
+ gui.showErrorDialog(errorMessages.getString("nopcscsupport"), this,
+ "ok");
+ try {
+ waitForAction();
+ } catch (InterruptedException e) {
+ log.error(e);
+ }
+ return true;
+ case SMCCHelper.TERMINAL_NOT_PRESENT:
actionCommandList.clear();
- actionCommandList.add("cancel");
- gui.showInsertCardDialog(this, "cancel");
- oldValue = SMCCHelper.NO_CARD;
- }
- break;
- case SMCCHelper.CARD_FOUND:
- // gui.showWaitDialog(null);
- signatureCard = smccHelper.getSignatureCard(errorMessages.getLocale());
- return false;
+ actionCommandList.add("ok");
+ gui.showErrorDialog(errorMessages.getString("nocardterminal"), this,
+ "ok");
+ try {
+ waitForAction();
+ } catch (InterruptedException e) {
+ log.error(e);
+ }
+ return true;
+ case SMCCHelper.CARD_NOT_SUPPORTED:
+ if (oldValue != SMCCHelper.CARD_NOT_SUPPORTED) {
+ actionCommandList.clear();
+ actionCommandList.add("cancel");
+ gui.showCardNotSupportedDialog(this, "cancel");
+ oldValue = SMCCHelper.CARD_NOT_SUPPORTED;
+ }
+ break;
+ case SMCCHelper.NO_CARD:
+ if (oldValue != SMCCHelper.NO_CARD) {
+ actionCommandList.clear();
+ actionCommandList.add("cancel");
+ gui.showInsertCardDialog(this, "cancel");
+ oldValue = SMCCHelper.NO_CARD;
+ }
+ break;
+ case SMCCHelper.CARD_FOUND:
+ // gui.showWaitDialog(null);
+ signatureCard = smccHelper.getSignatureCard(errorMessages.getLocale());
+ return false;
}
smccHelper.update(3000);
}
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java
index 6dae264c..5f422164 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java
@@ -20,9 +20,9 @@ import at.gv.egiz.bku.smccstal.SMCCSTALRequestHandler;
import at.gv.egiz.bku.smccstal.SignRequestHandler;
import at.gv.egiz.stal.HashDataInput;
import at.gv.egiz.stal.impl.ByteArrayHashDataInput;
-import at.gv.egiz.stal.service.GetHashDataInputResponseType;
-import at.gv.egiz.stal.service.GetHashDataInputType;
import at.gv.egiz.stal.service.STALPortType;
+import at.gv.egiz.stal.service.types.GetHashDataInputResponseType;
+import at.gv.egiz.stal.service.types.GetHashDataInputType;
import at.gv.egiz.stal.signedinfo.DigestMethodType;
import at.gv.egiz.stal.signedinfo.ReferenceType;
import java.security.DigestException;
diff --git a/BKUApplet/src/test/java/at/gv/egiz/stal/client/STALServiceTest.java b/BKUApplet/src/test/java/at/gv/egiz/stal/client/STALServiceTest.java
index 9b58798d..63da8225 100644
--- a/BKUApplet/src/test/java/at/gv/egiz/stal/client/STALServiceTest.java
+++ b/BKUApplet/src/test/java/at/gv/egiz/stal/client/STALServiceTest.java
@@ -33,12 +33,14 @@ import org.junit.Test;
import at.gv.egiz.stal.InfoboxReadRequest;
import at.gv.egiz.stal.STALRequest;
import at.gv.egiz.stal.service.GetHashDataInputFault;
-import at.gv.egiz.stal.service.GetHashDataInputResponseType;
-import at.gv.egiz.stal.service.GetHashDataInputType;
-import at.gv.egiz.stal.service.GetNextRequestResponseType;
-import at.gv.egiz.stal.service.GetNextRequestType;
import at.gv.egiz.stal.service.STALPortType;
import at.gv.egiz.stal.service.STALService;
+import at.gv.egiz.stal.service.types.GetHashDataInputResponseType;
+import at.gv.egiz.stal.service.types.GetHashDataInputType;
+import at.gv.egiz.stal.service.types.GetNextRequestResponseType;
+import at.gv.egiz.stal.service.types.GetNextRequestType;
+import at.gv.egiz.stal.service.types.InfoboxReadRequestType;
+import at.gv.egiz.stal.service.types.RequestType;
/**
*
@@ -60,11 +62,11 @@ public class STALServiceTest {
// req.getResponse().add(new ErrorResponse(1234));
GetNextRequestResponseType nrResp = port.getNextRequest(nrReq);
assertNotNull(nrResp);
- System.out.println("got response: " + nrResp.getRequest().size());
- for (STALRequest stalReq : nrResp.getRequest()) {
- if (stalReq instanceof InfoboxReadRequest) {
- String ibid = ((InfoboxReadRequest) stalReq).getInfoboxIdentifier();
- String did = ((InfoboxReadRequest) stalReq).getDomainIdentifier();
+ System.out.println("got response: " + nrResp.getInfoboxReadRequestOrSignRequestOrQuitRequest().size());
+ for (RequestType stalReq : nrResp.getInfoboxReadRequestOrSignRequestOrQuitRequest()) {
+ if (stalReq instanceof InfoboxReadRequestType) {
+ String ibid = ((InfoboxReadRequestType) stalReq).getInfoboxIdentifier();
+ String did = ((InfoboxReadRequestType) stalReq).getDomainIdentifier();
System.out.println(" received InfoboxReadRequest for " + ibid + ", " + did);
} else {
System.out.println(" received STAL request " + stalReq.getClass().getName());
--
cgit v1.2.3
From 8ccd9ab69dc74762567930f4c576a359502f1071 Mon Sep 17 00:00:00 2001
From: clemenso
Date: Tue, 30 Sep 2008 16:37:59 +0000
Subject: showErrorDialog l10n
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@77 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
(limited to 'BKUApplet')
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
index a87b04c4..12eb9d00 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
@@ -126,7 +126,7 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
log.fatal("Failed to call STAL service.", e);
actionCommandList.clear();
actionCommandList.add("ok");
- gui.showErrorDialog(errorMessages.getString("failed.WS"));
+ gui.showErrorDialog(BKUGUIFacade.ERR_SERVICE_UNREACHABLE, new Object[] {e.getMessage()});
try {
waitForAction();
} catch (InterruptedException e1) {
@@ -204,7 +204,7 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
log.info("Done " + Thread.currentThread().getName());
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
- gui.showErrorDialog("Sorry, an internal error occured: " + ex.getMessage());
+ gui.showErrorDialog(BKUGUIFacade.ERR_UNKNOWN, new Object[] {ex.getMessage()});
try {
waitForAction();
} catch (InterruptedException e) {
@@ -279,8 +279,7 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
case SMCCHelper.PC_SC_NOT_SUPPORTED:
actionCommandList.clear();
actionCommandList.add("ok");
- gui.showErrorDialog(errorMessages.getString("nopcscsupport"), this,
- "ok");
+ gui.showErrorDialog(BKUGUIFacade.ERR_NO_PCSC, null, this, "ok");
try {
waitForAction();
} catch (InterruptedException e) {
@@ -290,8 +289,7 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
case SMCCHelper.TERMINAL_NOT_PRESENT:
actionCommandList.clear();
actionCommandList.add("ok");
- gui.showErrorDialog(errorMessages.getString("nocardterminal"), this,
- "ok");
+ gui.showErrorDialog(BKUGUIFacade.ERR_NO_CARDTERMINAL,null,this,"ok");
try {
waitForAction();
} catch (InterruptedException e) {
--
cgit v1.2.3
From 35364f7492308692bd690c17f5527f4157eb583a Mon Sep 17 00:00:00 2001
From: clemenso
Date: Tue, 7 Oct 2008 17:59:28 +0000
Subject: hashdata digest
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@82 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
.../bku/online/applet/WSSignRequestHandler.java | 60 ++++++++++++++++------
BKUApplet/src/main/resources/simplelog.properties | 2 +-
2 files changed, 45 insertions(+), 17 deletions(-)
(limited to 'BKUApplet')
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java
index 5f422164..3a36a290 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java
@@ -31,6 +31,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
+import java.util.Map.Entry;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -58,15 +59,18 @@ public class WSSignRequestHandler extends SignRequestHandler {
GetHashDataInputType request = new GetHashDataInputType();
request.setSessionId(sessId);
- HashMap idRefMap = new HashMap();
- for (ReferenceType reference : signedReferences) {
+ HashMap idSignedRefMap = new HashMap();
+ for (ReferenceType signedRef : signedReferences) {
//don't get Manifest, QualifyingProperties, ...
- if (reference.getType() == null) {
- String referenceId = reference.getId();
- if (referenceId != null) {
- idRefMap.put(referenceId, reference);
+ if (signedRef.getType() == null) {
+ String signedRefId = signedRef.getId();
+ if (signedRefId != null) {
+ if (log.isTraceEnabled()) {
+ log.trace("requesting hashdata input for reference " + signedRefId);
+ }
+ idSignedRefMap.put(signedRefId, signedRef);
GetHashDataInputType.Reference ref = new GetHashDataInputType.Reference();
- ref.setID(referenceId);
+ ref.setID(signedRefId);
request.getReference().add(ref);
} else {
@@ -76,31 +80,52 @@ public class WSSignRequestHandler extends SignRequestHandler {
}
if (log.isDebugEnabled()) {
- log.debug("Calling GetHashDataInput for session " + sessId);
+ log.debug("Calling GetHashDataInput for " + request.getReference().size() + " references in session " + sessId);
}
GetHashDataInputResponseType response = stalPort.getHashDataInput(request);
ArrayList hashDataInputs = new ArrayList();
+ //hashdata inputs returned from service
+ HashMap idRefMap = new HashMap();
for (GetHashDataInputResponseType.Reference reference : response.getReference()) {
-
String id = reference.getID();
byte[] hdi = reference.getValue();
if (hdi == null) {
- throw new Exception("Failed to resolve digest value for reference " + id);
+ throw new Exception("Did not receive hashdata input for reference " + id);
+ }
+ idRefMap.put(id, reference);
+ }
+
+ for (String signedRefId : idSignedRefMap.keySet()) {
+ log.info("validating hashdata input for reference " + signedRefId);
+
+ GetHashDataInputResponseType.Reference reference = idRefMap.get(signedRefId);
+ if (reference == null) {
+ throw new Exception("No hashdata input for reference " + signedRefId + " returned by service");
}
+
+// }
+//
+// for (GetHashDataInputResponseType.Reference reference : response.getReference()) {
+//
+// String id = reference.getID();
+ byte[] hdi = reference.getValue();
String mimeType = reference.getMimeType();
String encoding = reference.getEncoding();
+ if (hdi == null) {
+ throw new Exception("No hashdata input provided for reference " + signedRefId);
+ }
if (log.isDebugEnabled()) {
- log.debug("Got HashDataInput " + id + " (" + mimeType + ";" + encoding + ")");
+ log.debug("Got HashDataInput " + signedRefId + " (" + mimeType + ";" + encoding + ")");
}
- ReferenceType dsigRef = idRefMap.get(id);
+ ReferenceType dsigRef = idSignedRefMap.get(signedRefId);
DigestMethodType dm = dsigRef.getDigestMethod();
+
if (dm == null) {
- throw new Exception("Failed to verify digest value for reference " + id + ": no digest algorithm");
+ throw new Exception("Failed to verify digest value for reference " + signedRefId + ": no digest algorithm");
}
- //TODO
String mdAlg = dm.getAlgorithm();
if ("http://www.w3.org/2000/09/xmldsig#sha1".equals(mdAlg))
mdAlg = "SHA-1";
@@ -120,15 +145,18 @@ public class WSSignRequestHandler extends SignRequestHandler {
mdAlg = "MD5";
else if ("http://www.w3.org/2001/04/xmlenc#ripemd160 ".equals(mdAlg))
mdAlg = "RipeMD-160";
+ else {
+ throw new Exception("Failed to verify digest value for reference " + signedRefId + ": unsupported digest algorithm " + mdAlg);
+ }
MessageDigest md = MessageDigest.getInstance(mdAlg);
byte[] hdiDigest = md.digest(hdi);
if (log.isDebugEnabled())
log.debug("Comparing digest values... ");
if (!Arrays.equals(hdiDigest, dsigRef.getDigestValue())) {
log.error("digest values differ: " + new String(hdiDigest) + ", " + new String(dsigRef.getDigestValue()));
- throw new DigestException("Bad digest value for reference " + id + ": " + dsigRef.getDigestValue());
+ throw new DigestException("Bad digest value for reference " + signedRefId + ": " + new String(dsigRef.getDigestValue()));
}
- hashDataInputs.add(new ByteArrayHashDataInput(hdi, id, mimeType, encoding));
+ hashDataInputs.add(new ByteArrayHashDataInput(hdi, signedRefId, mimeType, encoding));
}
return hashDataInputs;
}
diff --git a/BKUApplet/src/main/resources/simplelog.properties b/BKUApplet/src/main/resources/simplelog.properties
index d62508cf..51be76a8 100644
--- a/BKUApplet/src/main/resources/simplelog.properties
+++ b/BKUApplet/src/main/resources/simplelog.properties
@@ -15,7 +15,7 @@
# Logging detail level,
# Must be one of ("trace", "debug", "info", "warn", "error", or "fatal").
-org.apache.commons.logging.simplelog.defaultlog=debug
+org.apache.commons.logging.simplelog.defaultlog=trace
# Logs the Log instance used
org.apache.commons.logging.simplelog.showlogname=true
#Logs the class name with package(or Path)
--
cgit v1.2.3
From d7a3b8fdb62c881afb87838f2bb03b4c4b58e16d Mon Sep 17 00:00:00 2001
From: clemenso
Date: Wed, 8 Oct 2008 15:59:43 +0000
Subject: simpleGUI (header,chipperling removed)
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@87 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
BKUApplet/pom.xml | 30 ++++++++++++++++++++++++----
BKUApplet/src/test/resources/appletTest.html | 29 +++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 4 deletions(-)
create mode 100644 BKUApplet/src/test/resources/appletTest.html
(limited to 'BKUApplet')
diff --git a/BKUApplet/pom.xml b/BKUApplet/pom.xml
index 35672e51..130749c5 100644
--- a/BKUApplet/pom.xml
+++ b/BKUApplet/pom.xml
@@ -1,6 +1,5 @@
-
+
bku
at.gv.egiz
@@ -11,7 +10,6 @@
BKUApplet
BKU Applet
1.0-SNAPSHOT
-
@@ -81,6 +79,30 @@
true
+
+ maven-dependency-plugin
+
+
+ copytestlibs
+
+ copy
+
+
+
+
+ commons-logging
+ commons-logging
+
+
+ iaik
+ iaik_jce_me4se
+
+
+ ${project.build.directory}/test-libs
+
+
+
+
@@ -114,4 +136,4 @@
commons-logging
-
\ No newline at end of file
+
diff --git a/BKUApplet/src/test/resources/appletTest.html b/BKUApplet/src/test/resources/appletTest.html
new file mode 100644
index 00000000..3b944a40
--- /dev/null
+++ b/BKUApplet/src/test/resources/appletTest.html
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
--
cgit v1.2.3
From a8d050168ad30c59087d9b8f7b399f0ffbb671d8 Mon Sep 17 00:00:00 2001
From: clemenso
Date: Thu, 9 Oct 2008 07:54:29 +0000
Subject: SimpleGUI (one button)
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@88 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
---
BKUApplet/src/test/resources/appletTest.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'BKUApplet')
diff --git a/BKUApplet/src/test/resources/appletTest.html b/BKUApplet/src/test/resources/appletTest.html
index 3b944a40..5b10d6b5 100644
--- a/BKUApplet/src/test/resources/appletTest.html
+++ b/BKUApplet/src/test/resources/appletTest.html
@@ -19,7 +19,7 @@