+# -------- 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. \
+
+
+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
---
.../online/applet/InternalSSLSocketFactory.java | 4 +-
.../at/gv/egiz/bku/online/conf/Configurator.java | 8 +--
.../gv/egiz/bku/online/webapp/ResultServlet.java | 3 +-
.../gv/egiz/bku/online/webapp/ShutdownHandler.java | 31 ++++++++
.../egiz/bku/online/conf/accessControlConfig.xml | 3 +-
.../src/main/webapp/WEB-INF/applicationContext.xml | 6 +-
.../accesscontroller/AuthenticationClassifier.java | 82 +++++++++++++++-------
.../egiz/bku/binding/BindingProcessorManager.java | 4 +-
.../bku/binding/BindingProcessorManagerImpl.java | 11 ++-
.../AuthenticationClassifierTest.java | 28 ++++++++
.../egiz/bku/accesscontroller/www.a-trust.at.crt | 28 ++++++++
11 files changed, 169 insertions(+), 39 deletions(-)
create mode 100644 BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ShutdownHandler.java
create mode 100644 bkucommon/src/test/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifierTest.java
create mode 100644 bkucommon/src/test/resources/at/gv/egiz/bku/accesscontroller/www.a-trust.at.crt
(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;
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java
index a0a268e4..de577139 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/conf/Configurator.java
@@ -52,9 +52,9 @@ public class Configurator {
protected void configureProviders() {
log.debug("Registering security providers");
- Security.insertProviderAt(new IAIK(), 1);
- Security.insertProviderAt(new ECCProvider(false), 2);
- Security.addProvider(new STALProvider());
+ Security.insertProviderAt(new IAIK(), 1);
+ Security.insertProviderAt(new ECCProvider(false), 2);
+ Security.addProvider(new STALProvider());
XSecProvider.addAsProvider(false);
StringBuilder sb = new StringBuilder();
sb.append("Registered providers: ");
@@ -65,7 +65,7 @@ public class Configurator {
log.debug(sb.toString());
}
- public void configure() {
+ public void configure() {
configureProviders();
configUrlConnections();
}
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java
index 6c1a4c3a..bc3edf18 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java
@@ -115,6 +115,7 @@ public class ResultServlet extends SpringBKUServlet {
resp.setContentType(bp.getResultContentType());
resp.setCharacterEncoding(encoding);
bp.writeResultTo(resp.getOutputStream(), encoding);
- session.invalidate();
+ session.invalidate();
+ getBindingProcessorManager().removeBindingProcessor(bp.getId());
}
}
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ShutdownHandler.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ShutdownHandler.java
new file mode 100644
index 00000000..86da6c06
--- /dev/null
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ShutdownHandler.java
@@ -0,0 +1,31 @@
+package at.gv.egiz.bku.online.webapp;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.context.ApplicationEvent;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.event.ContextClosedEvent;
+
+import at.gv.egiz.bku.binding.BindingProcessorManager;
+
+public class ShutdownHandler implements ApplicationListener {
+
+ private static Log log = LogFactory.getLog(ShutdownHandler.class);
+
+ private BindingProcessorManager bindingProcessorManager;
+
+ public void setBindingProcessorManager(
+ BindingProcessorManager bindingProcessorManager) {
+ this.bindingProcessorManager = bindingProcessorManager;
+ }
+
+ @Override
+ public void onApplicationEvent(ApplicationEvent event) {
+ if (event instanceof ContextClosedEvent) {
+ log.info("Shutting down BKU");
+ bindingProcessorManager.shutdownNow();
+ }
+
+ }
+
+}
diff --git a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/accessControlConfig.xml b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/accessControlConfig.xml
index 69b45d1b..f8d1411c 100644
--- a/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/accessControlConfig.xml
+++ b/BKUOnline/src/main/resources/at/gv/egiz/bku/online/conf/accessControlConfig.xml
@@ -54,8 +54,7 @@
certified
-
-
+
IdentityLink
derived
diff --git a/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml b/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
index 4bb5e8e2..f87d09f5 100644
--- a/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml
@@ -49,5 +49,9 @@
scope="singleton" init-method="configure">
-
+
+
+
+
+
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifier.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifier.java
index ace8a75a..ed4b9bda 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifier.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifier.java
@@ -1,30 +1,31 @@
/*
-* 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.accesscontroller;
import static at.gv.egiz.bku.accesscontroller.AuthenticationClass.ANONYMOUS;
import static at.gv.egiz.bku.accesscontroller.AuthenticationClass.CERTIFIED;
-import static at.gv.egiz.bku.accesscontroller.AuthenticationClass.PSEUDO_ANONYMOUS;
import static at.gv.egiz.bku.accesscontroller.AuthenticationClass.CERTIFIED_GOV_AGENCY;
+import static at.gv.egiz.bku.accesscontroller.AuthenticationClass.PSEUDO_ANONYMOUS;
-import java.net.InetAddress;
import java.net.URL;
-import java.net.UnknownHostException;
+import java.security.cert.CertificateParsingException;
import java.security.cert.X509Certificate;
+import java.util.Collection;
+import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -37,6 +38,39 @@ public class AuthenticationClassifier {
private AuthenticationClassifier() {
}
+ 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];
+ log.trace("Analyzing cn dn: " + dns);
+ if (dns.endsWith(GOV_DOMAIN)) {
+ return true;
+ }
+ }
+ }
+ try {
+ Collection> sanList = cert.getSubjectAlternativeNames();
+ if (sanList != null) {
+ for (List> san : sanList) {
+ log.trace("Analyzing subj. alt name: " + san);
+ 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;
+ }
+
/**
* Client Certificates are currently not supported
*
@@ -45,13 +79,8 @@ public class AuthenticationClassifier {
URL url, X509Certificate cert) {
if (isDataUrl) {
if (url.getProtocol().equalsIgnoreCase("https")) {
- try {
- if (InetAddress.getByName(url.getHost()).getCanonicalHostName()
- .endsWith(GOV_DOMAIN)) {
- return CERTIFIED_GOV_AGENCY;
- }
- } catch (UnknownHostException e) {
- log.error("Cannot determine host name", e);
+ if (isGovAgency(cert)) {
+ return CERTIFIED_GOV_AGENCY;
}
if (cert.getExtensionValue("1.2.40.0.10.1.1.1") != null) {
return CERTIFIED_GOV_AGENCY;
@@ -68,7 +97,8 @@ public class AuthenticationClassifier {
/**
*
* @param isDataUrl
- * @param url if the url's protocol is https a cert parameter must be provided.
+ * @param url
+ * if the url's protocol is https a cert parameter must be provided.
* @param cert
* @return
*/
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManager.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManager.java
index ed37f08f..aaf81e51 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManager.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManager.java
@@ -99,5 +99,7 @@ public interface BindingProcessorManager {
*/
public Set getManagedIds();
- public void shutdown();
+ public void shutdown();
+
+ public void shutdownNow();
}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java
index 6f5ca2d2..0082de26 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java
@@ -149,6 +149,11 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager {
public void shutdown() {
log.info("Shutting down the BindingProcessorManager");
executorService.shutdown();
+ }
+
+ public void shutdownNow() {
+ log.info("Shutting down the BindingProcessorManager NOW!");
+ executorService.shutdownNow();
}
/**
@@ -223,7 +228,8 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager {
throw new SLRuntimeException(
"Clashing ids, cannot process bindingprocessor with id:"
+ aBindingProcessor.getId());
- }
+ }
+ log.debug("processing bindingprocessor: "+aBindingProcessor.getId());
Future> f = executorService.submit(aBindingProcessor);
bindingProcessorMap.put(aBindingProcessor.getId(), new MapEntityWrapper(f,
aBindingProcessor));
@@ -235,7 +241,8 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager {
}
@Override
- public void removeBindingProcessor(Id sessionId) {
+ public void removeBindingProcessor(Id sessionId) {
+ log.debug("Removing binding processor: "+sessionId);
MapEntityWrapper wrapper = bindingProcessorMap
.get(sessionId);
if (wrapper == null) {
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifierTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifierTest.java
new file mode 100644
index 00000000..c339704e
--- /dev/null
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifierTest.java
@@ -0,0 +1,28 @@
+package at.gv.egiz.bku.accesscontroller;
+
+import static org.junit.Assert.assertTrue;
+
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class AuthenticationClassifierTest {
+
+ private X509Certificate atrust;
+
+ @Before
+ public void setUp() throws Exception {
+ atrust = (X509Certificate) CertificateFactory.getInstance("X509")
+ .generateCertificate(
+ getClass().getClassLoader().getResourceAsStream(
+ "at/gv/egiz/bku/accesscontroller/www.a-trust.at.crt"));
+ }
+
+ @Test
+ public void testATrust() {
+ assertTrue(AuthenticationClassifier.isGovAgency(atrust));
+ }
+
+}
diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/accesscontroller/www.a-trust.at.crt b/bkucommon/src/test/resources/at/gv/egiz/bku/accesscontroller/www.a-trust.at.crt
new file mode 100644
index 00000000..11cde026
--- /dev/null
+++ b/bkucommon/src/test/resources/at/gv/egiz/bku/accesscontroller/www.a-trust.at.crt
@@ -0,0 +1,28 @@
+-----BEGIN CERTIFICATE-----
+MIIEyjCCA7KgAwIBAgIDA4LFMA0GCSqGSIb3DQEBBQUAMIGHMQswCQYDVQQGEwJB
+VDFIMEYGA1UECgw/QS1UcnVzdCBHZXMuIGYuIFNpY2hlcmhlaXRzc3lzdGVtZSBp
+bSBlbGVrdHIuIERhdGVudmVya2VociBHbWJIMRYwFAYDVQQLDA1hLXNpZ24tU1NM
+LTAzMRYwFAYDVQQDDA1hLXNpZ24tU1NMLTAzMB4XDTA3MTIxMTExMTQ0NFoXDTEy
+MTIxMTExMTQ0NFowYTELMAkGA1UEBhMCQVQxEDAOBgNVBAoMB0EtVHJ1c3QxEDAO
+BgNVBAsMB0EtVHJ1c3QxFzAVBgNVBAMMDnd3dy5hLXRydXN0LmF0MRUwEwYDVQQF
+Eww2NDk2ODY0MDkzMzkwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAK2oRtJ4
+R9ipr/NUH5F4p86cjWtzT1g+ytpjg1lwh4HNY+lTjdUcx/VKBrtf0N8qnMK1UHhA
+LLvvZeKTFi3L15i5or1WjZRi4RfH/4vcL0o1w/91liwMOKH3D30omnVceuxmQp2j
+V9QrGPbz0/IsP51cnBWCBTWGqgfBebB8v1FLAgMBAAGjggHmMIIB4jATBgNVHSME
+DDAKgAhAPqHTYrQD3TByBggrBgEFBQcBAQRmMGQwJwYIKwYBBQUHMAGGG2h0dHA6
+Ly9vY3NwLmEtdHJ1c3QuYXQvb2NzcDA5BggrBgEFBQcwAoYtaHR0cDovL3d3dy5h
+LXRydXN0LmF0L2NlcnRzL2Etc2lnbi1zc2wtMDMuY3J0MEsGA1UdIAREMEIwQAYG
+KigAEQEUMDYwNAYIKwYBBQUHAgEWKGh0dHA6Ly93d3cuYS10cnVzdC5hdC9kb2Nz
+L2NwL2Etc2lnbi1zc2wwgY8GA1UdHwSBhzCBhDCBgaB/oH2Ge2xkYXA6Ly9sZGFw
+LmEtdHJ1c3QuYXQvb3U9YS1zaWduLVNTTC0wMyxvPUEtVHJ1c3QsYz1BVD9jZXJ0
+aWZpY2F0ZXJldm9jYXRpb25saXN0P2Jhc2U/b2JqZWN0Y2xhc3M9ZWlkQ2VydGlm
+aWNhdGlvbkF1dGhvcml0eTARBgNVHQ4ECgQIRu1a/pOZZpMwDgYDVR0PAQH/BAQD
+AgWgMEoGA1UdEQRDMEGBEW9mZmljZUBhLXRydXN0LmF0gg53d3cuYS10cnVzdC5h
+dIIcemRhLnNvemlhbHZlcnNpY2hlcnVuZy5ndi5hdDAJBgNVHRMEAjAAMA0GCSqG
+SIb3DQEBBQUAA4IBAQCQGheDpci0lnSEoKw/N3tbJqn/KG49/OWZcsw6XZiAEHsx
+Rx9TlNJhL2d/SqFXBmmqfR496gdzTb4823WJsmXtyBY2t5ZnmD9tY5oJi5bHKchO
+50QCd1x24HzH1mxPReCJzRxzLEM/znojEMdYqQ5Y+BZuj7n9BY+l2nY0Qnhn09FE
+dxXAfNcuZnZavLJgk7vTBg8OFkAh6DJ21ACxf/y+rN53gKFK4Jh+PodRu0J2tK8B
+wAZg7HlnT8U7tcEsf1JnsBhlzAWCHgZc6whgBbDHFs6WSFWuobKN+maU91g/Tvgk
+Obos/EhVNti54Zhu1PO9RSKpKkwzTJT4kmGtaOJN
+-----END CERTIFICATE-----
--
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 ++-
.../src/main/java/at/gv/egiz/bku/gui/BKUGUI.java | 885 ++++++++++-----------
.../main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java | 2 +
.../at/gv/egiz/bku/gui/HashDataTableModel.java | 71 ++
.../main/java/at/gv/egiz/bku/gui/MimeFilter.java | 98 +++
.../main/java/at/gv/egiz/bku/gui/PinDocument.java | 58 ++
.../at/gv/egiz/bku/gui/Messages.properties | 15 +-
.../test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java | 276 +++----
BKUOnline/pom.xml | 13 +-
.../gv/egiz/bku/smccstal/SignRequestHandler.java | 6 +-
10 files changed, 840 insertions(+), 686 deletions(-)
create mode 100644 BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HashDataTableModel.java
create mode 100644 BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/MimeFilter.java
create mode 100644 BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/PinDocument.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 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);
+ }
}
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUI.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUI.java
index 044e6927..584dba1a 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUI.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUI.java
@@ -27,6 +27,7 @@ import java.awt.Component;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.Dimension;
+import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
@@ -75,13 +76,11 @@ import org.apache.commons.logging.LogFactory;
* @author clemens
*/
public class BKUGUI implements BKUGUIFacade {
-
+
private static final Log log = LogFactory.getLog(BKUGUI.class);
public static final String MESSAGES_BUNDLE = "at/gv/egiz/bku/gui/Messages";
public static final String LOGO_RESOURCE = "/images/logo.png";
-// public static final int MAIN_PANEL_WIDTH = 100;
-// public static final int MAIN_PANEL_HEIGHT = 20;
-// public static final int PREF_SIZE_PINFIELD = 118;
+ public static final String HASHDATA_FONT = "Monospaced";
public static final Color ERROR_COLOR = Color.RED;
public static final Color HYPERLINK_COLOR = Color.BLUE;
private static final String TITLE_WELCOME = "title.welcome";
@@ -94,6 +93,7 @@ public class BKUGUI implements BKUGUIFacade {
private static final String TITLE_WAIT = "title.wait";
private static final String TITLE_HASHDATA = "title.hashdata";
private static final String WINDOWTITLE_SAVE = "windowtitle.save";
+ private static final String WINDOWTITLE_SAVEDIR = "windowtitle.savedir";
private static final String WINDOWTITLE_OVERWRITE = "windowtitle.overwrite";
private static final String MESSAGE_WAIT = "message.wait";
private static final String MESSAGE_INSERTCARD = "message.insertcard";
@@ -104,19 +104,13 @@ public class BKUGUI implements BKUGUIFacade {
private static final String MESSAGE_OVERWRITE = "message.overwrite";
private static final String LABEL_PIN = "label.pin";
private static final String LABEL_PINSIZE = "label.pinsize";
- private static final String ERROR_HASHDATA = "error.hashdata";
+ private static final String ERROR_NO_HASHDATA = "error.no.hashdata";
private static final String BUTTON_OK = "button.ok";
private static final String BUTTON_CANCEL = "button.cancel";
private static final String BUTTON_BACK = "button.back";
private static final String BUTTON_SIGN = "button.sign";
private static final String BUTTON_SAVE = "button.save";
- private static final String MIMETYPE_DESC_XML = "mimetype.desc.xml";
- private static final String MIMETYPE_DESC_HTML = "mimetype.desc.html";
- private static final String MIMETYPE_DESC_XHTML = "mimetype.desc.xhtml";
- private static final String MIMETYPE_DESC_TXT = "mimetype.desc.txt";
- private static final String MIMETYPE_DESC_PDF = "mimetype.desc.pdf";
- private static final String MIMETYPE_DESC_BIN = "mimetype.desc.bin";
private static final String SAVE_HASHDATAINPUT_PREFIX = "save.hashdatainput.prefix";
protected Container contentPane;
protected ResourceBundle messages;
@@ -132,11 +126,11 @@ public class BKUGUI implements BKUGUIFacade {
/** remember the pinfield to return to worker */
protected JPasswordField pinField;
- protected JButton okButton;
- protected JButton cancelButton;
- protected JButton signButton;
- protected JButton saveButton;
- protected JButton backButton;
+// protected JButton okButton;
+// protected JButton cancelButton;
+// protected JButton signButton;
+// protected JButton saveButton;
+// protected JButton backButton;
protected int buttonSize;
private static final int CHECKBOX_WIDTH = new JCheckBox().getPreferredSize().width;
@@ -216,28 +210,43 @@ public class BKUGUI implements BKUGUIFacade {
java.awt.Font.BOLD, titleLabel.getFont().getSize() + 2));
// titleLabel.setForeground(defaultForground);
- okButton = new JButton();
- okButton.setText(messages.getString(BUTTON_OK));
- cancelButton = new JButton();
- cancelButton.setText(messages.getString(BUTTON_CANCEL));
- signButton = new JButton();
- signButton.setText(messages.getString(BUTTON_SIGN));
- backButton = new JButton();
- backButton.setText(messages.getString(BUTTON_BACK));
- saveButton = new JButton();
- saveButton.setText(messages.getString(BUTTON_SAVE));
+// okButton = new JButton();
+// okButton.setText(messages.getString(BUTTON_OK));
+// cancelButton = new JButton();
+// cancelButton.setText(messages.getString(BUTTON_CANCEL));
+// signButton = new JButton();
+// signButton.setText(messages.getString(BUTTON_SIGN));
+// backButton = new JButton();
+// backButton.setText(messages.getString(BUTTON_BACK));
+// saveButton = new JButton();
+// saveButton.setText(messages.getString(BUTTON_SAVE));
// contentPanelLayout.linkSize(cancelButton, okButton, signButton, backButton, saveButton);
- if (okButton.getPreferredSize().width > buttonSize)
- buttonSize = okButton.getPreferredSize().width;
- if (cancelButton.getPreferredSize().width > buttonSize)
- buttonSize = cancelButton.getPreferredSize().width;
- if (signButton.getPreferredSize().width > buttonSize)
- buttonSize = signButton.getPreferredSize().width;
- if (backButton.getPreferredSize().width > buttonSize)
- buttonSize = backButton.getPreferredSize().width;
- if (saveButton.getPreferredSize().width > buttonSize)
- buttonSize = saveButton.getPreferredSize().width;
+ JButton b = new JButton();
+ b.setText(messages.getString(BUTTON_CANCEL));
+ if (b.getPreferredSize().width > buttonSize)
+ buttonSize = b.getPreferredSize().width;
+ b.setText(messages.getString(BUTTON_OK));
+ if (b.getPreferredSize().width > buttonSize)
+ buttonSize = b.getPreferredSize().width;
+ b.setText(messages.getString(BUTTON_SIGN));
+ if (b.getPreferredSize().width > buttonSize)
+ buttonSize = b.getPreferredSize().width;
+ b.setText(messages.getString(BUTTON_BACK));
+ if (b.getPreferredSize().width > buttonSize)
+ buttonSize = b.getPreferredSize().width;
+ b.setText(messages.getString(BUTTON_SAVE));
+ if (b.getPreferredSize().width > buttonSize)
+ buttonSize = b.getPreferredSize().width;
+
+// if (cancelButton.getPreferredSize().width > buttonSize)
+// buttonSize = cancelButton.getPreferredSize().width;
+// if (signButton.getPreferredSize().width > buttonSize)
+// buttonSize = signButton.getPreferredSize().width;
+// if (backButton.getPreferredSize().width > buttonSize)
+// buttonSize = backButton.getPreferredSize().width;
+// if (saveButton.getPreferredSize().width > buttonSize)
+// buttonSize = saveButton.getPreferredSize().width;
GroupLayout headerPanelLayout = new GroupLayout(headerPanel);
@@ -349,6 +358,8 @@ public class BKUGUI implements BKUGUIFacade {
titleLabel.setText(messages.getString(TITLE_INSERTCARD));
+ JButton cancelButton = new JButton();
+ cancelButton.setText(messages.getString(BUTTON_CANCEL));
cancelButton.addActionListener(cancelListener);
cancelButton.setActionCommand(cancelCommand);
@@ -400,6 +411,8 @@ public class BKUGUI implements BKUGUIFacade {
// mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(errorMsgLabel));
+ JButton cancelButton = new JButton();
+ cancelButton.setText(messages.getString(BUTTON_CANCEL));
cancelButton.addActionListener(cancelListener);
cancelButton.setActionCommand(cancelCommand);
@@ -439,9 +452,13 @@ public class BKUGUI implements BKUGUIFacade {
titleLabel.setText(messages.getString(TITLE_RETRY));
}
+ JButton cancelButton = new JButton();
+ cancelButton.setText(messages.getString(BUTTON_CANCEL));
cancelButton.setActionCommand(cancelCommand);
cancelButton.addActionListener(cancelListener);
+ JButton okButton = new JButton();
+ okButton.setText(messages.getString(BUTTON_OK));
okButton.setEnabled(false);
okButton.setActionCommand(okCommand);
okButton.addActionListener(okListener);
@@ -592,9 +609,13 @@ public class BKUGUI implements BKUGUIFacade {
titleLabel.setText(messages.getString(TITLE_RETRY));
}
+ JButton cancelButton = new JButton();
+ cancelButton.setText(messages.getString(BUTTON_CANCEL));
cancelButton.setActionCommand(cancelCommand);
cancelButton.addActionListener(cancelListener);
+ JButton signButton = new JButton();
+ signButton.setText(messages.getString(BUTTON_SIGN));
signButton.setEnabled(false);
signButton.setActionCommand(signCommand);
signButton.addActionListener(signListener);
@@ -764,6 +785,8 @@ public class BKUGUI implements BKUGUIFacade {
mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(errorMsgLabel));
+ JButton okButton = new JButton();
+ okButton.setText(messages.getString(BUTTON_OK));
okButton.setActionCommand(okCommand);
okButton.addActionListener(okListener);
@@ -790,343 +813,386 @@ public class BKUGUI implements BKUGUIFacade {
@Override
public void showErrorDialog(final String errorMsg) {
- SwingUtilities.invokeLater(new Runnable() {
+ SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- mainPanel.removeAll();
- buttonPanel.removeAll();
+ @Override
+ public void run() {
+ mainPanel.removeAll();
+ buttonPanel.removeAll();
- titleLabel.setText(messages.getString(TITLE_ERROR));
+ titleLabel.setText(messages.getString(TITLE_ERROR));
// titleLabel.setForeground(defaultForground);
- JLabel errorMsgLabel = new JLabel();
- errorMsgLabel.setFont(errorMsgLabel.getFont().deriveFont(errorMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD));
- errorMsgLabel.setText("" + errorMsg + "");
- errorMsgLabel.setForeground(ERROR_COLOR);
+ JLabel errorMsgLabel = new JLabel();
+ errorMsgLabel.setFont(errorMsgLabel.getFont().deriveFont(errorMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD));
+ errorMsgLabel.setText("" + errorMsg + "");
+ errorMsgLabel.setForeground(ERROR_COLOR);
- GroupLayout mainPanelLayout = new GroupLayout(mainPanel);
- mainPanel.setLayout(mainPanelLayout);
+ GroupLayout mainPanelLayout = new GroupLayout(mainPanel);
+ mainPanel.setLayout(mainPanelLayout);
- mainPanelLayout.setHorizontalGroup(
- mainPanelLayout.createSequentialGroup()
+ mainPanelLayout.setHorizontalGroup(
+ mainPanelLayout.createSequentialGroup()
// mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
- .addComponent(errorMsgLabel)
- .addContainerGap()); //, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE));
- mainPanelLayout.setVerticalGroup(
- mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
- .addComponent(errorMsgLabel));
+ .addComponent(errorMsgLabel)
+ .addContainerGap()); //, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE));
+ mainPanelLayout.setVerticalGroup(
+ mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(errorMsgLabel));
- contentPanel.validate();
- }
- });
+ contentPanel.validate();
+ }
+ });
}
@Override
public void showHashDataInputDialog(final List signedReferences, final ActionListener okListener, final String okCommand) {
- SwingUtilities.invokeLater(new Runnable() {
+
+ if (signedReferences == null) {
+ showErrorDialog(messages.getString(ERROR_NO_HASHDATA), okListener, okCommand);
+ }
+
+ if (signedReferences.size() == 1) {
+
+// final HashDataInput signedRef = signedReferences.get(0);
+
+ if ("text/plain".equals(signedReferences.get(0).getMimeType())) {
+
+ ActionListener saveHashDataListener = new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ showSaveHashDataInputDialog(signedReferences, okListener, okCommand);
+ }
+ };
+ String hashDataText = getText(signedReferences.get(0));
+ if (hashDataText != null) {
+ showPlainTextHashDataInputDialog(hashDataText, saveHashDataListener, "save", okListener, okCommand);
+ } else {
+ showErrorDialog(messages.getString(ERROR_NO_HASHDATA), okListener, okCommand);
+ }
+
+ } else {
+ showSaveHashDataInputDialog(signedReferences, okListener, okCommand);
+ }
+
+ } else {
- @Override
- public void run() {
+ final HashDataTableModel tableModel = new HashDataTableModel(signedReferences);
- if (signedReferences != null && signedReferences.size() == 1) {
-
- final HashDataInput signedRef = signedReferences.get(0);
- if ("text/plain".equals(signedRef.getMimeType())) {
- //TODO get encoding from mimetype
- //read directly to byte[] since hashDataIS is backed by byte[] ?
- ByteArrayOutputStream baos = null;
- try {
- String refId = signedRef.getReferenceId();
- InputStream hashDataIS = signedRef.getHashDataInput();
- if (hashDataIS == null) {
- showErrorDialog("Failed to obtain HashDataInput for reference " + refId, okListener, okCommand);
- } else {
- baos = new ByteArrayOutputStream(hashDataIS.available());
- int c;
- while ((c = hashDataIS.read()) != -1) {
- baos.write(c);
- }
- String text = baos.toString("UTF-8");
-
- ActionListener al = new ActionListener() {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- showSaveHashDataInputDialog(signedRef, okListener, okCommand);
- }
- };
- showPlainTextHashDataInputDialog(text, refId, okListener, okCommand, al, "save");
- }
- } catch (IOException ex) {
- showErrorDialog("Failed to read HashDataInput for reference " + signedRef.getReferenceId() + ": " + ex.getMessage(), okListener, okCommand);
- } finally {
- try {
- baos.close();
- } catch (IOException ex) {
- }
- }
- } else {
- showSaveHashDataInputDialog(signedRef, okListener, okCommand);
- }
+ ActionListener saveHashDataListener = new ActionListener() {
- } else if (signedReferences != null && signedReferences.size() > 1) {
- final HashDataTableModel tableModel = new HashDataTableModel(signedReferences);
-
- ActionListener al = new ActionListener() {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- List selection = tableModel.getSelectedReferenceIds();
- StringBuilder sb = new StringBuilder("Not implemented yet. \n");
- for (String string : selection) {
- sb.append(string);
- sb.append('\n');
- }
- showErrorDialog(sb.toString(), okListener, okCommand);
-// showSaveHashDataInputDialog(signedRef, okListener, okCommand);
- }
- };
- showMultipleHashDataInputDialog(tableModel, okListener, okCommand, al, "save");
- } else {
- showErrorDialog(messages.getString(ERROR_HASHDATA), okListener, okCommand);
- }
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ showSaveHashDataInputDialog(tableModel.getSelectedHashData(), okListener, okCommand);
}
- });
+ };
+ showMultipleHashDataInputDialog(tableModel, okListener, okCommand, saveHashDataListener, "save");
+ }
+ }
+
+ private static String getText(HashDataInput hdi) {
+ ByteArrayOutputStream baos = null;
+ try {
+ InputStream hashDataIS = hdi.getHashDataInput();
+ if (hashDataIS == null) {
+ log.error("No HashDataInput stream for reference " + hdi.getReferenceId());
+ return null;
+ } else {
+ baos = new ByteArrayOutputStream(hashDataIS.available());
+ int c;
+ while ((c = hashDataIS.read()) != -1) {
+ baos.write(c);
+ }
+ return baos.toString("UTF-8");
+ }
+ } catch (IOException ex) {
+ log.error("Failed to read HashDataInput for reference " + hdi.getReferenceId() + ": " + ex.getMessage());
+ return null;
+ } finally {
+ try {
+ baos.close();
+ } catch (IOException ex) {
+ }
+ }
}
- private void showPlainTextHashDataInputDialog(String text, String refId, ActionListener cancelListener, String cancelCommand, ActionListener saveListener, String saveCommand) {
- mainPanel.removeAll();
- buttonPanel.removeAll();
+ private void showPlainTextHashDataInputDialog(final String hashDataText, final ActionListener saveListener, final String saveCommand, final ActionListener cancelListener, final String cancelCommand) {
+ SwingUtilities.invokeLater(new Runnable() {
- titleLabel.setText(messages.getString(TITLE_HASHDATA));
+ @Override
+ public void run() {
+ mainPanel.removeAll();
+ buttonPanel.removeAll();
+
+ titleLabel.setText(messages.getString(TITLE_HASHDATA));
+
+ JLabel refIdLabel = new JLabel();
+ refIdLabel.setFont(refIdLabel.getFont().deriveFont(refIdLabel.getFont().getStyle() & ~java.awt.Font.BOLD));
+ refIdLabel.setText(messages.getString(MESSAGE_HASHDATA)); //MessageFormat.format(refIdLabelPattern, new Object[]{refId}));
+
+ JScrollPane hashDataScrollPane = new JScrollPane();
+ JTextArea hashDataTextArea = new JTextArea(hashDataText);
+ hashDataTextArea.setEditable(false);
+ hashDataTextArea.setColumns(1);
+ hashDataTextArea.setRows(1);
+ hashDataTextArea.setFont(new Font(HASHDATA_FONT, hashDataTextArea.getFont().getStyle(), hashDataTextArea.getFont().getSize()));
+ hashDataScrollPane.setViewportView(hashDataTextArea);
+
+ GroupLayout mainPanelLayout = new GroupLayout(mainPanel);
+ mainPanel.setLayout(mainPanelLayout);
+
+ mainPanelLayout.setHorizontalGroup(
+ mainPanelLayout.createSequentialGroup()
+ .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(refIdLabel)
+ .addComponent(hashDataScrollPane, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addContainerGap());
+
+ mainPanelLayout.setVerticalGroup(
+ mainPanelLayout.createSequentialGroup()
+ .addComponent(refIdLabel)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(hashDataScrollPane, 0, GroupLayout.PREFERRED_SIZE, hashDataTextArea.getPreferredSize().height+3));
+
+
+
+ // GroupLayout mainPanelLayout = new GroupLayout(mainPanel);
+ // mainPanel.setLayout(mainPanelLayout);
+ //
+ // mainPanelLayout.setHorizontalGroup(
+ // mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(mainPanelLayout.createSequentialGroup().addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(refIdLabel).addComponent(hashDataScrollPane, GroupLayout.PREFERRED_SIZE, PREF_SIZE_PINFIELD, Short.MAX_VALUE)).addContainerGap()));
+ //
+ // mainPanelLayout.setVerticalGroup(
+ // mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(mainPanelLayout.createSequentialGroup().addComponent(refIdLabel).addGap(refIdLabel.getFont().getSize()).addComponent(hashDataScrollPane).addGap(refIdLabel.getFont().getSize())));
+
+ JButton backButton = new JButton();
+ backButton.setText(messages.getString(BUTTON_BACK));
+ backButton.setActionCommand(cancelCommand);
+ backButton.addActionListener(cancelListener);
+
+ JButton saveButton = new JButton();
+ saveButton.setText(messages.getString(BUTTON_SAVE));
+ saveButton.setActionCommand(saveCommand);
+ saveButton.addActionListener(saveListener);
+
+ GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel);
+ buttonPanel.setLayout(buttonPanelLayout);
+
+ // buttonPanelLayout.linkSize(cancelButton, okButton, signButton, backButton, saveButton);
+ buttonPanelLayout.setHorizontalGroup(
+ buttonPanelLayout.createSequentialGroup()
+ .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(saveButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(backButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)
+ .addContainerGap());
+ buttonPanelLayout.setVerticalGroup(
+ buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+ .addComponent(saveButton)
+ .addComponent(backButton));
+
+
+ // GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel);
+ // buttonPanel.setLayout(buttonPanelLayout);
+ //
+ // buttonPanelLayout.setHorizontalGroup(
+ // buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, buttonPanelLayout.createSequentialGroup().addContainerGap(15, Short.MAX_VALUE).addComponent(saveButton).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(cancelButton).addContainerGap()));
+ // buttonPanelLayout.setVerticalGroup(
+ // buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(saveButton).addComponent(cancelButton)));
+
+ contentPanel.validate();
+ }
+ });
+ }
- JLabel refIdLabel = new JLabel();
- refIdLabel.setFont(refIdLabel.getFont().deriveFont(refIdLabel.getFont().getStyle() & ~java.awt.Font.BOLD));
- String refIdLabelPattern = messages.getString(MESSAGE_HASHDATA);
- refIdLabel.setText(MessageFormat.format(refIdLabelPattern, new Object[]{refId}));
+ private void showMultipleHashDataInputDialog(final TableModel signedReferences, final ActionListener cancelListener, final String cancelCommand, final ActionListener saveListener, final String saveCommand) {
+ SwingUtilities.invokeLater(new Runnable() {
- JScrollPane hashDataScrollPane = new JScrollPane();
- JTextArea hashDataTextArea = new JTextArea(text);
- hashDataTextArea.setEditable(false);
- hashDataTextArea.setColumns(1);
- hashDataTextArea.setRows(1);
- hashDataScrollPane.setViewportView(hashDataTextArea);
+ @Override
+ public void run() {
+ mainPanel.removeAll();
+ buttonPanel.removeAll();
- GroupLayout mainPanelLayout = new GroupLayout(mainPanel);
- mainPanel.setLayout(mainPanelLayout);
+ titleLabel.setText(messages.getString(TITLE_HASHDATA));
- mainPanelLayout.setHorizontalGroup(
- mainPanelLayout.createSequentialGroup()
- .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
- .addComponent(refIdLabel)
- .addComponent(hashDataScrollPane, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addContainerGap());
+ JLabel refIdLabel = new JLabel();
+ refIdLabel.setFont(refIdLabel.getFont().deriveFont(refIdLabel.getFont().getStyle() & ~java.awt.Font.BOLD));
+ String refIdLabelPattern = messages.getString(MESSAGE_HASHDATALIST);
+ refIdLabel.setText(MessageFormat.format(refIdLabelPattern, new Object[]{signedReferences.getRowCount()}));
- mainPanelLayout.setVerticalGroup(
- mainPanelLayout.createSequentialGroup()
- .addComponent(refIdLabel)
- .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(hashDataScrollPane, 0, GroupLayout.PREFERRED_SIZE, hashDataTextArea.getPreferredSize().height+3));
+ JTable hashDataTable = new JTable();
+ hashDataTable.setModel(signedReferences);
+ hashDataTable.setTableHeader(null);
+ // hashDataTable.setShowVerticalLines(false);
+ // hashDataTable.setRowSelectionAllowed(false);
+ TableColumn selectCol = hashDataTable.getColumnModel().getColumn(1);
+ selectCol.setMinWidth(CHECKBOX_WIDTH);
+ selectCol.setMaxWidth(CHECKBOX_WIDTH);
+
+
+ hashDataTable.setPreferredScrollableViewportSize(mainPanel.getPreferredSize());
-
-
-// GroupLayout mainPanelLayout = new GroupLayout(mainPanel);
-// mainPanel.setLayout(mainPanelLayout);
-//
-// mainPanelLayout.setHorizontalGroup(
-// mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(mainPanelLayout.createSequentialGroup().addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(refIdLabel).addComponent(hashDataScrollPane, GroupLayout.PREFERRED_SIZE, PREF_SIZE_PINFIELD, Short.MAX_VALUE)).addContainerGap()));
-//
-// mainPanelLayout.setVerticalGroup(
-// mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(mainPanelLayout.createSequentialGroup().addComponent(refIdLabel).addGap(refIdLabel.getFont().getSize()).addComponent(hashDataScrollPane).addGap(refIdLabel.getFont().getSize())));
+ JScrollPane hashDataScrollPane = new JScrollPane(hashDataTable);
- backButton.setActionCommand(cancelCommand);
- backButton.addActionListener(cancelListener);
+ GroupLayout mainPanelLayout = new GroupLayout(mainPanel);
+ mainPanel.setLayout(mainPanelLayout);
- saveButton.setActionCommand(saveCommand);
- saveButton.addActionListener(saveListener);
-
- GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel);
- buttonPanel.setLayout(buttonPanelLayout);
-
-// buttonPanelLayout.linkSize(cancelButton, okButton, signButton, backButton, saveButton);
- buttonPanelLayout.setHorizontalGroup(
- buttonPanelLayout.createSequentialGroup()
- .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(saveButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(backButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)
- .addContainerGap());
- buttonPanelLayout.setVerticalGroup(
- buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
- .addComponent(saveButton)
- .addComponent(backButton));
-
-
-// GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel);
-// buttonPanel.setLayout(buttonPanelLayout);
-//
-// buttonPanelLayout.setHorizontalGroup(
-// buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, buttonPanelLayout.createSequentialGroup().addContainerGap(15, Short.MAX_VALUE).addComponent(saveButton).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(cancelButton).addContainerGap()));
-// buttonPanelLayout.setVerticalGroup(
-// buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(saveButton).addComponent(cancelButton)));
+ mainPanelLayout.setHorizontalGroup(
+ mainPanelLayout.createSequentialGroup()
+ .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(refIdLabel)
+ .addComponent(hashDataScrollPane, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addContainerGap());
- contentPanel.validate();
- }
+ mainPanelLayout.setVerticalGroup(
+ mainPanelLayout.createSequentialGroup()
+ .addComponent(refIdLabel)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(hashDataScrollPane, 0, GroupLayout.PREFERRED_SIZE, hashDataTable.getPreferredSize().height+3));
+ // .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED));
- private void showMultipleHashDataInputDialog(final TableModel signedReferences, final ActionListener cancelListener, final String cancelCommand, ActionListener saveListener, String saveCommand) {
- mainPanel.removeAll();
- buttonPanel.removeAll();
-
- titleLabel.setText(messages.getString(TITLE_HASHDATA));
-
- JLabel refIdLabel = new JLabel();
- refIdLabel.setFont(refIdLabel.getFont().deriveFont(refIdLabel.getFont().getStyle() & ~java.awt.Font.BOLD));
- String refIdLabelPattern = messages.getString(MESSAGE_HASHDATALIST);
- refIdLabel.setText(MessageFormat.format(refIdLabelPattern, new Object[]{signedReferences.getRowCount()}));
-
- JTable hashDataTable = new JTable();
- hashDataTable.setModel(signedReferences);
- hashDataTable.setTableHeader(null);
-// hashDataTable.setShowVerticalLines(false);
-// hashDataTable.setRowSelectionAllowed(false);
- TableColumn selectCol = hashDataTable.getColumnModel().getColumn(1);
- selectCol.setMinWidth(CHECKBOX_WIDTH);
- selectCol.setMaxWidth(CHECKBOX_WIDTH);
-
-
- hashDataTable.setPreferredScrollableViewportSize(mainPanel.getPreferredSize());
-
- JScrollPane hashDataScrollPane = new JScrollPane(hashDataTable);
-
- GroupLayout mainPanelLayout = new GroupLayout(mainPanel);
- mainPanel.setLayout(mainPanelLayout);
-
- mainPanelLayout.setHorizontalGroup(
- mainPanelLayout.createSequentialGroup()
- .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
- .addComponent(refIdLabel)
- .addComponent(hashDataScrollPane, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addContainerGap());
-
- mainPanelLayout.setVerticalGroup(
- mainPanelLayout.createSequentialGroup()
- .addComponent(refIdLabel)
- .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(hashDataScrollPane, 0, GroupLayout.PREFERRED_SIZE, hashDataTable.getPreferredSize().height+3));
-// .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED));
-
-
-//
-// GroupLayout mainPanelLayout = new GroupLayout(mainPanel);
-// mainPanel.setLayout(mainPanelLayout);
-//
-// mainPanelLayout.setHorizontalGroup(
-// mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
-// .addGroup(mainPanelLayout.createSequentialGroup()
-// .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
-// .addComponent(refIdLabel)
-// .addComponent(hashDataScrollPane, GroupLayout.PREFERRED_SIZE, PREF_SIZE_PINFIELD, Short.MAX_VALUE))
-// .addContainerGap()));
-//
-// mainPanelLayout.setVerticalGroup(
-// mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
-// .addGroup(mainPanelLayout.createSequentialGroup()
-// .addComponent(refIdLabel)
-// .addGap(refIdLabel.getFont().getSize())
-// .addComponent(hashDataScrollPane)
-// .addGap(refIdLabel.getFont().getSize())));
-
-
-
-
-
-
-
-
-
-
-
-// GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel);
-// buttonPanel.setLayout(buttonPanelLayout);
-//
-// buttonPanelLayout.setHorizontalGroup(
-// buttonPanelLayout.createSequentialGroup()
-//// buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
-//// .addGroup(GroupLayout.Alignment.TRAILING, buttonPanelLayout.createSequentialGroup()
-// .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-// .addComponent(saveButton)
-// .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
-// .addComponent(cancelButton)
-// .addContainerGap()); //);
-// buttonPanelLayout.setVerticalGroup(
-// buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
-// .addGroup(GroupLayout.Alignment.TRAILING, buttonPanelLayout.createSequentialGroup()
-// .addGroup(buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
-// .addComponent(saveButton)
-// .addComponent(cancelButton))
-// .addContainerGap()));
+ //
+ // GroupLayout mainPanelLayout = new GroupLayout(mainPanel);
+ // mainPanel.setLayout(mainPanelLayout);
+ //
+ // mainPanelLayout.setHorizontalGroup(
+ // mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ // .addGroup(mainPanelLayout.createSequentialGroup()
+ // .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ // .addComponent(refIdLabel)
+ // .addComponent(hashDataScrollPane, GroupLayout.PREFERRED_SIZE, PREF_SIZE_PINFIELD, Short.MAX_VALUE))
+ // .addContainerGap()));
+ //
+ // mainPanelLayout.setVerticalGroup(
+ // mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ // .addGroup(mainPanelLayout.createSequentialGroup()
+ // .addComponent(refIdLabel)
+ // .addGap(refIdLabel.getFont().getSize())
+ // .addComponent(hashDataScrollPane)
+ // .addGap(refIdLabel.getFont().getSize())));
-
- backButton.setActionCommand(cancelCommand);
- backButton.addActionListener(cancelListener);
- saveButton.setActionCommand(saveCommand);
- saveButton.addActionListener(saveListener);
-
- GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel);
- buttonPanel.setLayout(buttonPanelLayout);
-
-// buttonPanelLayout.linkSize(cancelButton, okButton, signButton, backButton, saveButton);
- buttonPanelLayout.setHorizontalGroup(
- buttonPanelLayout.createSequentialGroup()
- .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(saveButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(backButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)
- .addContainerGap());//);
- buttonPanelLayout.setVerticalGroup(
- buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
- .addComponent(saveButton)
- .addComponent(backButton));
-
- contentPanel.validate();
+
+
+
+
+
+
+
+
+
+
+ // GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel);
+ // buttonPanel.setLayout(buttonPanelLayout);
+ //
+ // buttonPanelLayout.setHorizontalGroup(
+ // buttonPanelLayout.createSequentialGroup()
+ //// buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ //// .addGroup(GroupLayout.Alignment.TRAILING, buttonPanelLayout.createSequentialGroup()
+ // .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ // .addComponent(saveButton)
+ // .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ // .addComponent(cancelButton)
+ // .addContainerGap()); //);
+ // buttonPanelLayout.setVerticalGroup(
+ // buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ // .addGroup(GroupLayout.Alignment.TRAILING, buttonPanelLayout.createSequentialGroup()
+ // .addGroup(buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+ // .addComponent(saveButton)
+ // .addComponent(cancelButton))
+ // .addContainerGap()));
+
+
+ JButton backButton = new JButton();
+ backButton.setText(messages.getString(BUTTON_BACK));
+ backButton.setActionCommand(cancelCommand);
+ backButton.addActionListener(cancelListener);
+
+ JButton saveButton = new JButton();
+ saveButton.setText(messages.getString(BUTTON_SAVE));
+ saveButton.setActionCommand(saveCommand);
+ saveButton.addActionListener(saveListener);
+
+ GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel);
+ buttonPanel.setLayout(buttonPanelLayout);
+
+ // buttonPanelLayout.linkSize(cancelButton, okButton, signButton, backButton, saveButton);
+ buttonPanelLayout.setHorizontalGroup(
+ buttonPanelLayout.createSequentialGroup()
+ .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(saveButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(backButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)
+ .addContainerGap());//);
+ buttonPanelLayout.setVerticalGroup(
+ buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+ .addComponent(saveButton)
+ .addComponent(backButton));
+
+ contentPanel.validate();
+ }
+ });
}
- private void showSaveHashDataInputDialog(HashDataInput signedRef, ActionListener okListener, String okCommand) {
- String dir = System.getProperty("user.home");
- JFileChooser fileDialog = new JFileChooser(dir);
- fileDialog.setFileSelectionMode(JFileChooser.FILES_ONLY);
- fileDialog.setMultiSelectionEnabled(false);
- fileDialog.setDialogTitle(messages.getString(WINDOWTITLE_SAVE));
- fileDialog.setDialogType(JFileChooser.SAVE_DIALOG);
- fileDialog.setFileHidingEnabled(true);
- MimeFilter mimeFilter = new MimeFilter(signedRef.getMimeType());
- fileDialog.setFileFilter(mimeFilter);
- String filename = messages.getString(SAVE_HASHDATAINPUT_PREFIX) + mimeFilter.getExtension();
- fileDialog.setSelectedFile(new File(dir, filename));
- switch (fileDialog.showSaveDialog(contentPane)) {
+// private DisposableFileChooser fileDialog;
+
+ private void showSaveHashDataInputDialog(final List signedRefs, final ActionListener okListener, final String okCommand) {
+
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ String userHome = System.getProperty("user.home");
+
+ JFileChooser fileDialog = new JFileChooser(userHome);
+ fileDialog.setMultiSelectionEnabled(false);
+ fileDialog.setDialogType(JFileChooser.SAVE_DIALOG);
+ fileDialog.setFileHidingEnabled(true);
+ if (signedRefs.size() == 1) {
+ fileDialog.setDialogTitle(messages.getString(WINDOWTITLE_SAVE));
+ fileDialog.setFileSelectionMode(JFileChooser.FILES_ONLY);
+ String mimeType = signedRefs.get(0).getMimeType();
+ MimeFilter mimeFilter = new MimeFilter(mimeType, messages);
+ fileDialog.setFileFilter(mimeFilter);
+ String filename = messages.getString(SAVE_HASHDATAINPUT_PREFIX) + MimeFilter.getExtension(mimeType);
+ fileDialog.setSelectedFile(new File(userHome, filename));
+ } else {
+ fileDialog.setDialogTitle(messages.getString(WINDOWTITLE_SAVEDIR));
+ fileDialog.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ }
+
+ //parent contentPane -> placed over applet
+ switch (fileDialog.showSaveDialog(fileDialog)) {
case JFileChooser.APPROVE_OPTION:
- File f = fileDialog.getSelectedFile();
- if (f.exists()) {
-// log.debug("hashDataInput file exists, overwrite?");
- String ovrwrt = messages.getString(MESSAGE_OVERWRITE);
- int overwrite = JOptionPane.showConfirmDialog(contentPane, MessageFormat.format(ovrwrt, filename), messages.getString(WINDOWTITLE_OVERWRITE), JOptionPane.OK_CANCEL_OPTION);
- if (overwrite != JOptionPane.OK_OPTION) {
-// log.debug("User canceled overwrite HashDataInput, returning to SignaturePin dialog");
- okListener.actionPerformed(new ActionEvent(fileDialog, ActionEvent.ACTION_PERFORMED, okCommand));
- return;
- }
+ File f = fileDialog.getSelectedFile();
+ for (HashDataInput hashDataInput : signedRefs) {
+ String mimeType = hashDataInput.getMimeType();
+ String id = hashDataInput.getReferenceId();
+ File file;
+ if (f.isDirectory()) {
+ String filename = messages.getString(SAVE_HASHDATAINPUT_PREFIX) + '_' + id + MimeFilter.getExtension(mimeType);
+ file = new File(f, filename);
+ } else {
+ file = f;
+ }
+ if (file.exists()) {
+ String ovrwrt = messages.getString(MESSAGE_OVERWRITE);
+ int overwrite = JOptionPane.showConfirmDialog(fileDialog, MessageFormat.format(ovrwrt, file), messages.getString(WINDOWTITLE_OVERWRITE), JOptionPane.OK_CANCEL_OPTION);
+ if (overwrite != JOptionPane.OK_OPTION) {
+ continue;
+ }
}
if (log.isDebugEnabled()) {
- log.debug("Writing HashDataInput " + signedRef.getReferenceId() + " (" + signedRef.getMimeType() + ") to file " + f);
+ log.debug("Writing HashDataInput " + id + " (" + mimeType + ") to file " + file);
}
FileOutputStream fos = null;
try {
- fos = new FileOutputStream(f);
+ fos = new FileOutputStream(file);
BufferedOutputStream bos = new BufferedOutputStream(fos);
- InputStream hdi = signedRef.getHashDataInput();
+ InputStream hdi = hashDataInput.getHashDataInput();
int b;
while ((b = hdi.read()) != -1) {
bos.write(b);
@@ -1134,7 +1200,7 @@ public class BKUGUI implements BKUGUIFacade {
bos.flush();
bos.close();
} catch (IOException ex) {
- log.error("Failed to write HashDataInput to file " + f + ": " + ex.getMessage());
+ log.error("Failed to write HashDataInput to file " + file + ": " + ex.getMessage());
showErrorDialog("Failed to write signed reference to file: " + ex.getMessage(), null, null);
ex.printStackTrace();
} finally {
@@ -1142,11 +1208,15 @@ public class BKUGUI implements BKUGUIFacade {
fos.close();
} catch (IOException ex) {
}
- }
+ }
+ }
+ }
+ log.debug("done saving hashdatainput");
+ okListener.actionPerformed(new ActionEvent(fileDialog, ActionEvent.ACTION_PERFORMED, okCommand));
}
- okListener.actionPerformed(new ActionEvent(fileDialog, ActionEvent.ACTION_PERFORMED, okCommand));
+ });
}
-
+
@Override
public void showWaitDialog(final String waitMessage) {
SwingUtilities.invokeLater(new Runnable() {
@@ -1190,149 +1260,4 @@ public class BKUGUI implements BKUGUIFacade {
return null;
}
- class PINDocument extends PlainDocument {
-
- private PINSpec pinSpec;
- private Pattern pinPattern;
- private JButton enterButton;
-
- public PINDocument(PINSpec pinSpec, JButton enterButton) {
- this.pinSpec = pinSpec;
- if (pinSpec.getRexepPattern() != null) {
- pinPattern = Pattern.compile(pinSpec.getRexepPattern());
- } else {
- pinPattern = Pattern.compile(".");
- }
- this.enterButton = enterButton;
- }
-
- @Override
- public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
- if (pinSpec.getMaxLength() >= (getLength() + str.length())) {
- boolean matches = true;
- for (int i = 0; i < str.length(); i++) {
- Matcher m = pinPattern.matcher(str.substring(i, i + 1));
- if (!m.matches()) {
- matches = false;
- }
- }
- if (matches) {
- super.insertString(offs, str, a);
- }
- }
- enterButton.setEnabled(getLength() >= pinSpec.getMinLength());
- }
-
- @Override
- public void remove(int offs, int len) throws BadLocationException {
- super.remove(offs, len);
- enterButton.setEnabled(getLength() >= pinSpec.getMinLength());
- }
- }
-
- class MimeFilter extends FileFilter {
-
- protected String mimeType;
-
- public MimeFilter(String mimeType) {
- this.mimeType = mimeType;
- }
-
- @Override
- public boolean accept(File f) {
-
- if (f.isDirectory()) {
- return true;
- }
-
- String ext = getExtension(f);
- if ("text/xml".equals(mimeType)) {
- return "xml".equalsIgnoreCase(ext);
- } else if ("text/html".equals(mimeType)) {
- return "html".equalsIgnoreCase(ext) || "htm".equalsIgnoreCase(ext);
- } else if ("application/xhtml+xml".equals(mimeType)) {
- return "xhtml".equalsIgnoreCase(ext);
- } else if ("text/plain".equals(mimeType)) {
- return "txt".equalsIgnoreCase(ext);
- } else if ("application/pdf".equals(mimeType)) {
- return "pdf".equalsIgnoreCase(ext);
- } else {
- return true;
- }
- }
-
- private String getExtension(File f) {
- String ext = null;
- String s = f.getName();
- int i = s.lastIndexOf('.');
-
- if (i > 0 && i < s.length() - 1) {
- ext = s.substring(i + 1).toLowerCase();
- }
- return ext;
- }
-
- @Override
- public String getDescription() {
- if ("text/xml".equals(mimeType)) {
- return messages.getString(MIMETYPE_DESC_XML);
- } else if ("text/html".equals(mimeType)) {
- return messages.getString(MIMETYPE_DESC_HTML);
- } else if ("application/xhtml+xml".equals(mimeType)) {
- return messages.getString(MIMETYPE_DESC_XHTML);
- } else if ("text/plain".equals(mimeType)) {
- return messages.getString(MIMETYPE_DESC_TXT);
- } else if ("application/pdf".equals(mimeType)) {
- return messages.getString(MIMETYPE_DESC_PDF);
- } else {
- return messages.getString(MIMETYPE_DESC_BIN);
- }
- }
-
- public String getExtension() {
- if ("text/xml".equals(mimeType)) {
- return ".xml";
- } else if ("text/html".equals(mimeType)) {
- return ".html";
- } else if ("application/xhtml+xml".equals(mimeType)) {
- return ".xhtml";
- } else if ("text/plain".equals(mimeType)) {
- return ".txt";
- } else if ("application/pdf".equals(mimeType)) {
- return ".pdf";
- } else {
- return ".bin";
- }
- }
- }
-
- class HashDataTableModel extends DefaultTableModel {
-
- Class[] types = new Class[]{
- java.lang.String.class, java.lang.Boolean.class
- };
-
- public HashDataTableModel(List signedReferences) {
- super(0, 2);
- for (HashDataInput hashDataInput : signedReferences) {
- addRow(new Object[]{hashDataInput.getReferenceId(), new Boolean(true)});
- }
- }
-
- @Override
- public Class getColumnClass(int columnIndex) {
- return types [columnIndex];
- }
-
- public List getSelectedReferenceIds() {
- ArrayList selection = new ArrayList();
- for (Object row : dataVector) {
- if ((Boolean) ((Vector) row).elementAt(1)) {
- selection.add((String) ((Vector) row).elementAt(0));
- }
- }
- return selection;
- }
-
- }
}
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java
index f8b80556..f4b6325d 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java
@@ -53,6 +53,8 @@ public interface BKUGUIFacade {
public void showHashDataInputDialog(List signedReferences, ActionListener okListener, String actionCommand);
+// public void showPlainTextHashDataInputDialog(String text, ActionListener saveListener, String saveCommand, ActionListener cancelListener, String cancelCommand);
+
public void showErrorDialog(String errorMsg, ActionListener okListener, String actionCommand);
public void showErrorDialog(String errorMsg);
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HashDataTableModel.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HashDataTableModel.java
new file mode 100644
index 00000000..061a2849
--- /dev/null
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HashDataTableModel.java
@@ -0,0 +1,71 @@
+/*
+* 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.gui;
+
+import at.gv.egiz.stal.HashDataInput;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Vector;
+import javax.swing.table.DefaultTableModel;
+
+/**
+ *
+ * @author clemens
+ */
+class HashDataTableModel extends DefaultTableModel {
+
+ protected List signedReferences;
+
+ Class[] types = new Class[]{
+ java.lang.String.class, java.lang.Boolean.class
+ };
+
+ public HashDataTableModel(List signedReferences) {
+ super(0, 2);
+ this.signedReferences = signedReferences;
+ for (HashDataInput hashDataInput : signedReferences) {
+ String desc = hashDataInput.getReferenceId() + " (" + hashDataInput.getMimeType() + ")";
+ addRow(new Object[]{desc, new Boolean(true)});
+ }
+ }
+
+ @Override
+ public Class getColumnClass(int columnIndex) {
+ return types [columnIndex];
+ }
+
+ public List getSelectedHashData() {
+ ArrayList selection = new ArrayList();
+ for (int i = 0; i < dataVector.size(); i++) {
+ if ((Boolean) ((Vector) dataVector.get(i)).elementAt(1)) {
+ selection.add(signedReferences.get(i));
+ }
+ }
+ return selection;
+ }
+
+// public List getSelectedReferenceIds() {
+// ArrayList selection = new ArrayList();
+// for (Object row : dataVector) {
+// if ((Boolean) ((Vector) row).elementAt(1)) {
+// selection.add((String) ((Vector) row).elementAt(0));
+// }
+// }
+// return selection;
+// }
+
+ }
\ No newline at end of file
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/MimeFilter.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/MimeFilter.java
new file mode 100644
index 00000000..6ee61a82
--- /dev/null
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/MimeFilter.java
@@ -0,0 +1,98 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package at.gv.egiz.bku.gui;
+
+import java.io.File;
+import java.util.ResourceBundle;
+import javax.swing.filechooser.FileFilter;
+
+/**
+ *
+ * @author clemens
+ */
+class MimeFilter extends FileFilter {
+
+ private static final String MIMETYPE_DESC_XML = "mimetype.desc.xml";
+ private static final String MIMETYPE_DESC_HTML = "mimetype.desc.html";
+ private static final String MIMETYPE_DESC_XHTML = "mimetype.desc.xhtml";
+ private static final String MIMETYPE_DESC_TXT = "mimetype.desc.txt";
+ private static final String MIMETYPE_DESC_PDF = "mimetype.desc.pdf";
+ private static final String MIMETYPE_DESC_BIN = "mimetype.desc.bin";
+
+ protected String mimeType;
+ protected ResourceBundle messages;
+
+ public MimeFilter(String mimeType, ResourceBundle messages) {
+ this.mimeType = mimeType;
+ this.messages = messages;
+ }
+
+ @Override
+ public boolean accept(File f) {
+
+ if (f.isDirectory()) {
+ return true;
+ }
+
+ String ext = getExtension(f);
+ if ("text/xml".equals(mimeType)) {
+ return "xml".equalsIgnoreCase(ext);
+ } else if ("text/html".equals(mimeType)) {
+ return "html".equalsIgnoreCase(ext) || "htm".equalsIgnoreCase(ext);
+ } else if ("application/xhtml+xml".equals(mimeType)) {
+ return "xhtml".equalsIgnoreCase(ext);
+ } else if ("text/plain".equals(mimeType)) {
+ return "txt".equalsIgnoreCase(ext);
+ } else if ("application/pdf".equals(mimeType)) {
+ return "pdf".equalsIgnoreCase(ext);
+ } else {
+ return true;
+ }
+ }
+
+ private String getExtension(File f) {
+ String ext = null;
+ String s = f.getName();
+ int i = s.lastIndexOf('.');
+
+ if (i > 0 && i < s.length() - 1) {
+ ext = s.substring(i + 1).toLowerCase();
+ }
+ return ext;
+ }
+
+ @Override
+ public String getDescription() {
+ if ("text/xml".equals(mimeType)) {
+ return messages.getString(MIMETYPE_DESC_XML);
+ } else if ("text/html".equals(mimeType)) {
+ return messages.getString(MIMETYPE_DESC_HTML);
+ } else if ("application/xhtml+xml".equals(mimeType)) {
+ return messages.getString(MIMETYPE_DESC_XHTML);
+ } else if ("text/plain".equals(mimeType)) {
+ return messages.getString(MIMETYPE_DESC_TXT);
+ } else if ("application/pdf".equals(mimeType)) {
+ return messages.getString(MIMETYPE_DESC_PDF);
+ } else {
+ return messages.getString(MIMETYPE_DESC_BIN);
+ }
+ }
+
+ public static String getExtension(String mimeType) {
+ if ("text/xml".equals(mimeType)) {
+ return ".xml";
+ } else if ("text/html".equals(mimeType)) {
+ return ".html";
+ } else if ("application/xhtml+xml".equals(mimeType)) {
+ return ".xhtml";
+ } else if ("text/plain".equals(mimeType)) {
+ return ".txt";
+ } else if ("application/pdf".equals(mimeType)) {
+ return ".pdf";
+ } else {
+ return ".bin";
+ }
+ }
+}
\ No newline at end of file
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/PinDocument.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/PinDocument.java
new file mode 100644
index 00000000..e8572742
--- /dev/null
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/PinDocument.java
@@ -0,0 +1,58 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package at.gv.egiz.bku.gui;
+
+import at.gv.egiz.smcc.PINSpec;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import javax.swing.JButton;
+import javax.swing.text.AttributeSet;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.PlainDocument;
+
+/**
+ *
+ * @author clemens
+ */
+class PINDocument extends PlainDocument {
+
+ private PINSpec pinSpec;
+ private Pattern pinPattern;
+ private JButton enterButton;
+
+ public PINDocument(PINSpec pinSpec, JButton enterButton) {
+ this.pinSpec = pinSpec;
+ if (pinSpec.getRexepPattern() != null) {
+ pinPattern = Pattern.compile(pinSpec.getRexepPattern());
+ } else {
+ pinPattern = Pattern.compile(".");
+ }
+ this.enterButton = enterButton;
+ }
+
+ @Override
+ public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
+ if (pinSpec.getMaxLength() >= (getLength() + str.length())) {
+ boolean matches = true;
+ for (int i = 0; i < str.length(); i++) {
+ Matcher m = pinPattern.matcher(str.substring(i, i + 1));
+ if (!m.matches()) {
+ matches = false;
+ }
+ }
+ if (matches) {
+ super.insertString(offs, str, a);
+ }
+ }
+ enterButton.setEnabled(getLength() >= pinSpec.getMinLength());
+ }
+
+ @Override
+ public void remove(int offs, int len) throws BadLocationException {
+ super.remove(offs, len);
+ enterButton.setEnabled(getLength() >= pinSpec.getMinLength());
+ }
+ }
\ No newline at end of file
diff --git a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties
index b651fa8d..a329ba86 100644
--- a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties
+++ b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties
@@ -23,6 +23,7 @@ title.retry=Falscher PIN
title.wait=Bitte warten
title.hashdata=Signaturdaten
windowtitle.save=Signaturdaten speichern
+windowtitle.savedir=Signaturdaten in Verzeichnis speichern
windowtitle.overwrite=Datei \u00FCberschreiben?
message.wait=Bitte warten...
message.insertcard=Bitte B\u00FCrgerkarte in den Kartenleser stecken
@@ -34,16 +35,16 @@ message.retries=Noch {0} Versuche
message.overwrite=M\u00F6chten Sie das existierende Dokument {0} \u00FCberschreiben?
label.pin={0}:
label.pinsize=({0} stellig)
-error.hashdata=Keine Signaturdaten verf\u00FCgbar
+error.no.hashdata=Keine Signaturdaten verf\u00FCgbar
button.ok=OK
button.cancel=Abbrechen
button.back=Zur\u00FCck
button.sign=Signieren
button.save=Speichern...
-mimetype.desc.xml=XML-Dateien (*.xml)
-mimetype.desc.html=HTML-Dateien (*.html, *.htm)
-mimetype.desc.xhtml=XHTML-Dateien (*.xhtml)
-mimetype.desc.txt=Textdateien (*.txt)
-mimetype.desc.pdf=Adobe PDF-Dateien (*.pdf)
-mimetype.desc.bin=Bin\u00E4rdateien (*.bin)
+mimetype.desc.xml=XML-Dateien (.xml)
+mimetype.desc.html=HTML-Dateien (.html, .htm)
+mimetype.desc.xhtml=XHTML-Dateien (.xhtml)
+mimetype.desc.txt=Textdateien (.txt)
+mimetype.desc.pdf=Adobe PDF-Dateien (.pdf)
+mimetype.desc.bin=Bin\u00E4rdateien (.bin)
save.hashdatainput.prefix=Signaturdaten
diff --git a/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java b/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java
index 4367f642..85f05435 100644
--- a/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java
+++ b/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUIWorker.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.
@@ -35,137 +35,137 @@ import java.util.List;
*/
public class BKUGUIWorker implements Runnable {
- BKUGUIFacade gui;
+ BKUGUIFacade gui;
- public void init(BKUGUIFacade gui) {
- this.gui = gui;
- }
+ public void init(BKUGUIFacade gui) {
+ this.gui = gui;
+ }
- @Override
- public void run() {
+ @Override
+ public void run() {
// try {
- final PINSpec signPinSpec = new PINSpec(6, 10, "[0-9]", "Signatur-PIN");
-
-
- final ActionListener cancelListener = new ActionListener() {
-
- public void actionPerformed(ActionEvent e) {
- System.out.println("CANCEL EVENT OCCURED: " + e);
- }
- };
- ActionListener okListener = new ActionListener() {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- System.out.println("OK EVENT OCCURED: " + e);
- }
- };
- final ActionListener signListener = new ActionListener() {
-
- public void actionPerformed(ActionEvent e) {
- System.out.println("SIGN EVENT OCCURED: " + e);
- }
- };
- ActionListener hashdataListener = new ActionListener() {
-
- public void actionPerformed(ActionEvent e) {
- System.out.println("HASHDATA EVENT OCCURED: " + e);
- ActionListener returnListener = new ActionListener() {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- gui.showSignaturePINDialog(signPinSpec, signListener, "sign", cancelListener, "cancel", null, "hashdata");
- }
- };
- HashDataInput signedRef1 = new HashDataInput() {
-
- @Override
- public InputStream getHashDataInput() {
- return new ByteArrayInputStream("HashDataInput_001\n12345\n\tHello, world!\n12345\n\n12345\n6789\nblabla".getBytes());
- }
-
- @Override
- public String getMimeType() {
- return "text/plain";
- }
-
- @Override
- public String getReferenceId() {
- return "Reference-ref1-00000000000000000000001";
- }
- };
- HashDataInput signedRef2 = new HashDataInput() {
-
- @Override
- public InputStream getHashDataInput() {
- return new ByteArrayInputStream("HashDataInput_002".getBytes());
- }
-
- @Override
- public String getMimeType() {
- return "text/xml";
- }
-
- @Override
- public String getReferenceId() {
- return "Reference-ref2-00000000000000000000002";
- }
- };
- HashDataInput signedRef3 = new HashDataInput() {
-
- @Override
- public InputStream getHashDataInput() {
- return new ByteArrayInputStream("HashDataInput_003".getBytes());
- }
-
- @Override
- public String getMimeType() {
- return "text/xml";
- }
-
- @Override
- public String getReferenceId() {
- return "Reference-ref3-00000000000000000000003";
- }
- };
- HashDataInput signedRef4 = new HashDataInput() {
-
- @Override
- public InputStream getHashDataInput() {
- return new ByteArrayInputStream("HashDataInput_004".getBytes());
- }
-
- @Override
- public String getMimeType() {
- return "text/xml";
- }
-
- @Override
- public String getReferenceId() {
- return "ref4";
- }
- };
-
- //
- List signedRefs = new ArrayList();
- signedRefs.add(signedRef1);
+ final PINSpec signPinSpec = new PINSpec(6, 10, "[0-9]", "Signatur-PIN");
+
+
+ final ActionListener cancelListener = new ActionListener() {
+
+ public void actionPerformed(ActionEvent e) {
+ System.out.println("CANCEL EVENT OCCURED: " + e);
+ }
+ };
+ ActionListener okListener = new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ System.out.println("OK EVENT OCCURED: " + e);
+ }
+ };
+ final ActionListener signListener = new ActionListener() {
+
+ public void actionPerformed(ActionEvent e) {
+ System.out.println("SIGN EVENT OCCURED: " + e);
+ }
+ };
+ ActionListener hashdataListener = new ActionListener() {
+
+ public void actionPerformed(ActionEvent e) {
+ System.out.println("HASHDATA EVENT OCCURED: " + e);
+ ActionListener returnListener = new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ gui.showSignaturePINDialog(signPinSpec, signListener, "sign", cancelListener, "cancel", null, "hashdata");
+ }
+ };
+ HashDataInput signedRef1 = new HashDataInput() {
+
+ @Override
+ public InputStream getHashDataInput() {
+ return new ByteArrayInputStream("oialfx HashDataInput_001\n12345\n\tHello, world!\n12345\n\n12345\n6789\nblabla".getBytes());
+ }
+
+ @Override
+ public String getMimeType() {
+ return "text/plain";
+ }
+
+ @Override
+ public String getReferenceId() {
+ return "Reference-ref1-00000000000000000000001";
+ }
+ };
+ HashDataInput signedRef2 = new HashDataInput() {
+
+ @Override
+ public InputStream getHashDataInput() {
+ return new ByteArrayInputStream("HashDataInput_002".getBytes());
+ }
+
+ @Override
+ public String getMimeType() {
+ return "text/xml";
+ }
+
+ @Override
+ public String getReferenceId() {
+ return "Reference-ref2-00000000000000000000002";
+ }
+ };
+ HashDataInput signedRef3 = new HashDataInput() {
+
+ @Override
+ public InputStream getHashDataInput() {
+ return new ByteArrayInputStream("HashDataInput_003".getBytes());
+ }
+
+ @Override
+ public String getMimeType() {
+ return "text/xml";
+ }
+
+ @Override
+ public String getReferenceId() {
+ return "Reference-ref3-00000000000000000000003";
+ }
+ };
+ HashDataInput signedRef4 = new HashDataInput() {
+
+ @Override
+ public InputStream getHashDataInput() {
+ return new ByteArrayInputStream("HashDataInput_004".getBytes());
+ }
+
+ @Override
+ public String getMimeType() {
+ return "text/xml";
+ }
+
+ @Override
+ public String getReferenceId() {
+ return "ref4";
+ }
+ };
+
+ //
+ List signedRefs = new ArrayList();
+ signedRefs.add(signedRef1);
signedRefs.add(signedRef2);
signedRefs.add(signedRef3);
signedRefs.add(signedRef4);
// signedRefs = Collections.singletonList(signedRef1);
- gui.showHashDataInputDialog(signedRefs, returnListener, "return");
- }
- };
-
+ gui.showHashDataInputDialog(signedRefs, returnListener, "return");
+ }
+ };
+
// gui.showWelcomeDialog();
//
// Thread.sleep(2000);
-
+
// gui.showInsertCardDialog(cancelListener, "cancel");
-
+
// Thread.sleep(2000);
//
// gui.showCardNotSupportedDialog(cancelListener, "cancel");
@@ -178,11 +178,11 @@ public class BKUGUIWorker implements Runnable {
//
// Thread.sleep(2000);
//
-
- gui.showSignaturePINDialog(signPinSpec, signListener, "sign", cancelListener, "cancel", hashdataListener, "hashdata");
+
+ gui.showSignaturePINDialog(signPinSpec, signListener, "sign", cancelListener, "cancel", hashdataListener, "hashdata");
// Thread.sleep(2000);
-
+
// gui.showSignaturePINRetryDialog(signPinSpec, 2, signListener, "sign", cancelListener, "cancel", hashdataListener, "hashdata");
//
// Thread.sleep(2000);
@@ -192,13 +192,13 @@ public class BKUGUIWorker implements Runnable {
// Thread.sleep(2000);
//
// gui.showErrorDialog("Testfehler occured");
-
-
+
+
// gui.showTextPlainHashDataInput("hallo,\n welt!", "12345", null, "cancel", null, "save");
// Thread.sleep(2000);
// } catch (InterruptedException ex) {
// ex.printStackTrace();
// }
- }
+ }
}
diff --git a/BKUOnline/pom.xml b/BKUOnline/pom.xml
index d31367a8..a50954cd 100644
--- a/BKUOnline/pom.xml
+++ b/BKUOnline/pom.xml
@@ -58,11 +58,13 @@
1.0-SNAPSHOTcompile
-
+
+
+ at.gv.egiz
+ BKUApplet
+ 1.0-SNAPSHOT
+ provided
+
@@ -177,4 +179,5 @@
+>>>>>>> .r33
diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java
index 1f84300a..d37d0551 100644
--- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java
+++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java
@@ -47,6 +47,8 @@ import at.gv.egiz.stal.signedinfo.ObjectFactory;
import at.gv.egiz.stal.signedinfo.ReferenceType;
import at.gv.egiz.stal.signedinfo.SignedInfoType;
import at.gv.egiz.stal.util.JCEAlgorithmNames;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -150,9 +152,6 @@ public class SignRequestHandler extends AbstractRequestHandler implements
hashDataInputs = getHashDataInputs(signedInfo.getReference());
}
gui.showHashDataInputDialog(hashDataInputs, this, "ok");
- waitForAction();
- gui.showSignaturePINDialog(spec, this, "sign", this, "cancel", this,
- "hashData");
} catch (Exception ex) {
//FIXME localize messages
log.error("Failed to obtain HashDataInputs: " + ex.getMessage());
@@ -178,6 +177,7 @@ public class SignRequestHandler extends AbstractRequestHandler implements
/**
* override by subclass
+ * @post-condition returned list != null
* @return
*/
protected List getHashDataInputs(List signedReferences) throws Exception {
--
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
---
.../at/gv/egiz/bku/online/applet/BKUWorker.java | 11 +
BKULocal/pom.xml | 5 +
.../at/gv/egiz/bku/local/stal/BKUGuiProxy.java | 130 ++++++++++
.../bku/local/stal/LocalSignRequestHandler.java | 84 +++++++
.../java/at/gv/egiz/bku/local/stal/PINDialog.java | 214 -----------------
.../gv/egiz/bku/local/stal/QuitRequestHandler.java | 41 ----
.../java/at/gv/egiz/bku/local/stal/SMCCSTAL.java | 100 ++------
.../at/gv/egiz/bku/local/stal/SMCCSTALFactory.java | 100 ++++++--
.../egiz/bku/local/stal/SwingInsertCardDialog.java | 147 ------------
.../gv/egiz/bku/local/stal/SwingPINProvider.java | 57 -----
.../at/gv/egiz/bku/local/stal/SwingPinDialog.java | 265 ---------------------
.../gv/egiz/bku/online/webapp/ResultServlet.java | 1 +
.../service/impl/RequestBrokerSTALFactory.java | 5 +
.../java/at/gv/egiz/bku/slxhtml/ValidatorTest.java | 5 +-
.../src/main/java/at/gv/egiz/stal/STALFactory.java | 6 +-
.../bku/binding/BindingProcessorManagerImpl.java | 1 +
.../gv/egiz/bku/binding/DataUrlConnectionImpl.java | 20 +-
.../egiz/bku/slcommands/impl/xsect/Signature.java | 25 ++
.../at/gv/egiz/bku/binding/DummyStalFactory.java | 8 +
19 files changed, 382 insertions(+), 843 deletions(-)
create mode 100644 BKULocal/src/main/java/at/gv/egiz/bku/local/stal/BKUGuiProxy.java
create mode 100644 BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSignRequestHandler.java
delete mode 100644 BKULocal/src/main/java/at/gv/egiz/bku/local/stal/PINDialog.java
delete mode 100644 BKULocal/src/main/java/at/gv/egiz/bku/local/stal/QuitRequestHandler.java
delete mode 100644 BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingInsertCardDialog.java
delete mode 100644 BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingPINProvider.java
delete mode 100644 BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingPinDialog.java
(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;
diff --git a/BKULocal/pom.xml b/BKULocal/pom.xml
index 3f77752a..341e574a 100644
--- a/BKULocal/pom.xml
+++ b/BKULocal/pom.xml
@@ -74,6 +74,11 @@
org.springframeworkspring-tx2.5.5
+
+
+ at.gv.egiz
+ BKUApplet
+ 1.0-SNAPSHOT
\ No newline at end of file
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/BKUGuiProxy.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/BKUGuiProxy.java
new file mode 100644
index 00000000..0bed928d
--- /dev/null
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/BKUGuiProxy.java
@@ -0,0 +1,130 @@
+package at.gv.egiz.bku.local.stal;
+
+import java.awt.Container;
+import java.awt.event.ActionListener;
+import java.util.List;
+
+import javax.swing.JDialog;
+
+import at.gv.egiz.bku.gui.BKUGUIFacade;
+import at.gv.egiz.smcc.PINSpec;
+import at.gv.egiz.stal.HashDataInput;
+
+public class BKUGuiProxy implements BKUGUIFacade {
+
+ private BKUGUIFacade delegate;
+ private JDialog dialog;
+
+ public BKUGuiProxy(JDialog dialog, BKUGUIFacade delegate) {
+ this.delegate = delegate;
+ this.dialog = dialog;
+ }
+
+ private void showDialog() {
+ dialog.setVisible(true);
+ dialog.setAlwaysOnTop(true);
+ }
+
+ @Override
+ public char[] getPin() {
+ return delegate.getPin();
+ }
+
+ @Override
+ public void init(Container contentPane, String localeString) {
+ delegate.init(contentPane, localeString);
+ }
+
+ @Override
+ public void showCardNotSupportedDialog(ActionListener cancelListener,
+ String actionCommand) {
+ showDialog();
+ delegate.showCardNotSupportedDialog(cancelListener, actionCommand);
+ }
+
+ @Override
+ public void showCardPINDialog(PINSpec pinSpec, ActionListener okListener,
+ String okCommand, ActionListener cancelListener, String cancelCommand) {
+ showDialog();
+ delegate.showCardPINDialog(pinSpec, okListener, okCommand, cancelListener,
+ cancelCommand);
+ }
+
+ @Override
+ public void showCardPINRetryDialog(PINSpec pinSpec, int numRetries,
+ ActionListener okListener, String okCommand,
+ ActionListener cancelListener, String cancelCommand) {
+ showDialog();
+ delegate.showCardPINRetryDialog(pinSpec, numRetries, okListener, okCommand,
+ cancelListener, cancelCommand);
+ }
+
+ @Override
+ public void showErrorDialog(String errorMsg, ActionListener okListener,
+ String actionCommand) {
+ showDialog();
+ delegate.showErrorDialog(errorMsg, okListener, actionCommand);
+ }
+
+ @Override
+ public void showErrorDialog(String errorMsg) {
+ showDialog();
+ delegate.showErrorDialog(errorMsg);
+ }
+
+ @Override
+ public void showHashDataInputDialog(List signedReferences,
+ ActionListener okListener, String actionCommand) {
+ showDialog();
+ delegate.showHashDataInputDialog(signedReferences, okListener,
+ actionCommand);
+ }
+
+ @Override
+ public void showInsertCardDialog(ActionListener cancelListener,
+ String actionCommand) {
+ showDialog();
+ delegate.showInsertCardDialog(cancelListener, actionCommand);
+ }
+
+ @Override
+ public void showLoginDialog(ActionListener loginListener, String actionCommand) {
+ showDialog();
+
+ delegate.showLoginDialog(loginListener, actionCommand);
+ }
+
+ @Override
+ public void showSignaturePINDialog(PINSpec pinSpec,
+ ActionListener signListener, String signCommand,
+ ActionListener cancelListener, String cancelCommand,
+ ActionListener hashdataListener, String hashdataCommand) {
+ showDialog();
+ delegate.showSignaturePINDialog(pinSpec, signListener, signCommand,
+ cancelListener, cancelCommand, hashdataListener, hashdataCommand);
+ }
+
+ @Override
+ public void showSignaturePINRetryDialog(PINSpec pinSpec, int numRetries,
+ ActionListener okListener, String okCommand,
+ ActionListener cancelListener, String cancelCommand,
+ ActionListener hashdataListener, String hashdataCommand) {
+ showDialog();
+ delegate.showSignaturePINRetryDialog(pinSpec, numRetries, okListener,
+ okCommand, cancelListener, cancelCommand, hashdataListener,
+ hashdataCommand);
+ }
+
+ @Override
+ public void showWaitDialog(String waitMessage) {
+ showDialog();
+ delegate.showWaitDialog(waitMessage);
+ }
+
+ @Override
+ public void showWelcomeDialog() {
+ showDialog();
+ delegate.showWelcomeDialog();
+ }
+
+}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSignRequestHandler.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSignRequestHandler.java
new file mode 100644
index 00000000..f8546e49
--- /dev/null
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSignRequestHandler.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.gv.egiz.bku.local.stal;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+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.STALRequest;
+import at.gv.egiz.stal.STALResponse;
+import at.gv.egiz.stal.SignRequest;
+import at.gv.egiz.stal.signedinfo.ReferenceType;
+
+/**
+ *
+ * @author clemens
+ */
+public class LocalSignRequestHandler extends SignRequestHandler {
+
+ private static final Log log = LogFactory
+ .getLog(LocalSignRequestHandler.class);
+ private List hashDataInput = Collections.EMPTY_LIST;
+
+ public LocalSignRequestHandler() {
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public STALResponse handleRequest(STALRequest request) {
+ if (request instanceof SignRequest) {
+ SignRequest signReq = (SignRequest) request;
+ hashDataInput = signReq.getHashDataInput();
+ }
+ return super.handleRequest(request);
+ }
+
+ @Override
+ protected List getHashDataInputs(
+ List dsigReferences) throws Exception {
+ ArrayList result = new ArrayList();
+ for (ReferenceType dsigRef : dsigReferences) {
+ // don't get Manifest, QualifyingProperties, ...
+ if (dsigRef.getType() == null) {
+ String dsigRefId = dsigRef.getId();
+ if (dsigRefId != null) {
+ for (HashDataInput hdi : hashDataInput) {
+ if (hdi.getReferenceId().equals(dsigRefId)) {
+ result.add(hdi);
+ }
+ }
+ } else {
+ throw new Exception(
+ "Cannot get HashDataInput for dsig:Reference without Id attribute");
+ }
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public SMCCSTALRequestHandler newInstance() {
+ return new LocalSignRequestHandler();
+ }
+}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/PINDialog.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/PINDialog.java
deleted file mode 100644
index 5bc6bab5..00000000
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/PINDialog.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
-* Copyright 2008 Federal Chancellery Austria and
-* Graz University of Technology
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package at.gv.egiz.bku.local.stal;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.swing.JButton;
-import javax.swing.JPasswordField;
-import javax.swing.text.AttributeSet;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.PlainDocument;
-
-import at.gv.egiz.smcc.PINSpec;
-
-public class PINDialog extends javax.swing.JDialog implements ActionListener {
-
- // Variables declaration - do not modify
- private javax.swing.JButton okButton;
- private javax.swing.JButton cancelButton;
- private javax.swing.JLabel label;
- private javax.swing.JPasswordField password;
- // End of variables declaration
-
- private PINSpec pinSpec;
- private String pinString;
- private boolean finished = false;
-
- class PinDocument extends PlainDocument {
- private Pattern pattern;
-
- public PinDocument() {
- pattern = Pattern.compile(pinSpec.getRexepPattern());
- }
-
- public void insertString(int offs, String str, AttributeSet a)
- throws BadLocationException {
- if (pinSpec.getMaxLength() >= (getLength() + str.length())) {
- Matcher matcher = pattern.matcher(str);
- if (matcher.matches()) {
- super.insertString(offs, str, a);
- }
- }
- okButton.setEnabled(getLength() >= pinSpec.getMinLength());
- }
-
- @Override
- public void remove(int offs, int len) throws BadLocationException {
- super.remove(offs, len);
- okButton.setEnabled(getLength() >= pinSpec.getMinLength());
- }
- }
-
- public PINDialog() {
- }
-
- private synchronized void finished(boolean ok) {
- if (ok) {
- pinString = password.getText();
- } else {
- pinString = null;
- }
- finished = true;
- notifyAll();
- }
-
- public synchronized void waitFinished() {
- while (!finished) {
- try {
- wait();
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
-
- public String getPIN() {
- return pinString;
- }
-
- /** Creates new form NewJDialog */
- public PINDialog(java.awt.Frame parent, boolean modal, PINSpec pinSpec,
- int retries) {
- super(parent, modal);
- this.pinSpec = pinSpec;
- initComponents();
- }
-
- private void initComponents() {
- okButton = new javax.swing.JButton();
- cancelButton = new javax.swing.JButton();
- password = new javax.swing.JPasswordField();
- label = new javax.swing.JLabel();
- setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
-
- setTitle("PIN Dialog"); // NOI18N
- setName("Form"); // NOI18N
-
- okButton.setText("OK"); // NOI18N
- okButton.setName("okButton"); // NOI18N
- okButton.setEnabled(false);
- okButton.addActionListener(this);
-
- cancelButton.setText("Cancel"); // NOI18N
- cancelButton.setName("cancelButton"); // NOI18N
- cancelButton.addActionListener(this);
-
- password.setText(""); // NOI18N
- password.setName("password"); // NOI18N
- password.addActionListener(this);
- password.setDocument(new PinDocument());
-
- label.setText("PIN: "); // NOI18N
- label.setName("jLabel1"); // NOI18N
-
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
- getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING).addGroup(
- layout.createSequentialGroup().addContainerGap().addGroup(
- layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING).addGroup(
- layout.createSequentialGroup().addComponent(label,
- javax.swing.GroupLayout.PREFERRED_SIZE, 61,
- javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.RELATED,
- javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(password,
- javax.swing.GroupLayout.PREFERRED_SIZE, 127,
- javax.swing.GroupLayout.PREFERRED_SIZE)).addGroup(
- javax.swing.GroupLayout.Alignment.TRAILING,
- layout.createSequentialGroup().addComponent(cancelButton)
- .addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(okButton))).addContainerGap()));
- layout.setVerticalGroup(layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING).addGroup(
- layout.createSequentialGroup().addContainerGap().addGroup(
- layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.BASELINE).addComponent(label,
- javax.swing.GroupLayout.PREFERRED_SIZE, 33,
- javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(password,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14,
- Short.MAX_VALUE).addGroup(
- layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.BASELINE).addComponent(
- okButton).addComponent(cancelButton)).addContainerGap()));
-
- pack();
- }
-
- /**
- * @param args
- * the command line arguments
- */
- public static void main(String args[]) {
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- PINDialog dialog = new PINDialog(new javax.swing.JFrame(), true,
- new PINSpec(1, 5, "[0-9]*", "Hansi"), 10);
- dialog.setResizable(false);
- dialog.addWindowListener(new java.awt.event.WindowAdapter() {
- public void windowClosing(java.awt.event.WindowEvent e) {
- System.exit(0);
- }
- });
- dialog.setVisible(true);
- }
- });
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
- if (e.getSource() instanceof JButton) {
- JButton pressed = (JButton) e.getSource();
- if (pressed.getName().equals("okButton")) {
- finished(true);
- } else if (pressed.getName().equals("cancelButton")) {
- finished(false);
- }
- } else if (e.getSource() instanceof JPasswordField) {
- JPasswordField pwf = (JPasswordField) e.getSource();
- if (pwf.getName().equals("password")) {
- if (password.getPassword().length >= pinSpec.getMinLength()) {
- finished(true);
- }
- }
- }
- }
-
-}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/QuitRequestHandler.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/QuitRequestHandler.java
deleted file mode 100644
index 5596b7bb..00000000
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/QuitRequestHandler.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-* Copyright 2008 Federal Chancellery Austria and
-* Graz University of Technology
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package at.gv.egiz.bku.local.stal;
-
-import at.gv.egiz.bku.smccstal.AbstractRequestHandler;
-import at.gv.egiz.bku.smccstal.SMCCSTALRequestHandler;
-import at.gv.egiz.stal.STALRequest;
-import at.gv.egiz.stal.STALResponse;
-
-public class QuitRequestHandler extends AbstractRequestHandler {
-
- @Override
- public STALResponse handleRequest(STALRequest request) {
- return null;
- }
-
- @Override
- public boolean requireCard() {
- return false;
- }
-
- @Override
- public SMCCSTALRequestHandler newInstance() {
- return this;
- }
-
-}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTAL.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTAL.java
index 26ec2aa8..6f9e72c5 100644
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTAL.java
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTAL.java
@@ -1,95 +1,33 @@
-/*
-* Copyright 2008 Federal Chancellery Austria and
-* Graz University of Technology
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
package at.gv.egiz.bku.local.stal;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.Locale;
+import java.util.List;
+import java.util.ResourceBundle;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import javax.swing.JDialog;
import at.gv.egiz.bku.gui.BKUGUIFacade;
-import at.gv.egiz.bku.local.ui.TrayIconDialog;
-import at.gv.egiz.bku.smccstal.AbstractRequestHandler;
-import at.gv.egiz.bku.smccstal.AbstractSMCCSTAL;
-import at.gv.egiz.bku.smccstal.STALMessageConsumer;
-import at.gv.egiz.smcc.PINProvider;
-import at.gv.egiz.smcc.util.SMCCHelper;
-import at.gv.egiz.stal.QuitRequest;
+import at.gv.egiz.bku.online.applet.BKUWorker;
+import at.gv.egiz.stal.STALRequest;
+import at.gv.egiz.stal.STALResponse;
+import at.gv.egiz.stal.SignRequest;
-public class SMCCSTAL extends AbstractSMCCSTAL implements STALMessageConsumer {
- private static Log log = LogFactory.getLog(SMCCSTAL.class);
+public class SMCCSTAL extends BKUWorker {
- protected PINProvider pinProvider = new SwingPINProvider();
- protected SwingInsertCardDialog insertCard = new SwingInsertCardDialog();
- private boolean canceled = false;
+ private JDialog container;
- static {
- addRequestHandler(QuitRequest.class, new QuitRequestHandler());
- }
-
- public SMCCSTAL() {
- AbstractRequestHandler.setMessageConsumer(this);
- }
-
- /**
- *
- * @return if the user canceled
- */
- protected boolean waitForCard() {
- canceled = false;
- while ((smccHelper.getResultCode() != SMCCHelper.CARD_FOUND) && (!canceled)) {
- insertCard.setVisible(true);
- insertCard.setAlwaysOnTop(true);
- insertCard.addCanceledListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- canceled = true;
- }
- });
- try {
- smccHelper.update(1000);
- } catch (Exception ex) {
- log.info(ex);
- }
- }
- insertCard.setVisible(false);
- signatureCard = smccHelper.getSignatureCard(locale);
- return canceled;
+ public SMCCSTAL(BKUGUIFacade gui, JDialog container,
+ ResourceBundle errorMessageBundle) {
+ super(gui, errorMessageBundle);
+ this.container = container;
+ addRequestHandler(SignRequest.class, new LocalSignRequestHandler());
}
@Override
- public void setLocale(Locale locale) {
- super.setLocale(locale);
- if (pinProvider instanceof SwingPINProvider) {
- ((SwingPINProvider) pinProvider).setLocale(locale);
- }
+ public List handleRequest(List requestList) {
+ signatureCard = null;
+ List responses = super.handleRequest(requestList);
+ container.setVisible(false);
+ return responses;
}
- @Override
- public void consumeNewSTALMessage(String captionId, String messageId) {
- TrayIconDialog.getInstance().displayInfo(captionId, messageId);
- }
-
- @Override
- protected BKUGUIFacade getGUI() {
- // TODO Auto-generated method stub
- //FIXME
- return null;
- }
}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTALFactory.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTALFactory.java
index 014d884a..97646d09 100644
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTALFactory.java
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTALFactory.java
@@ -1,27 +1,75 @@
/*
-* Copyright 2008 Federal Chancellery Austria and
-* Graz University of Technology
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package at.gv.egiz.bku.local.stal;
-
-import at.gv.egiz.stal.STAL;
-import at.gv.egiz.stal.STALFactory;
-
-public class SMCCSTALFactory implements STALFactory {
- @Override
- public STAL createSTAL() {
- return new SMCCSTAL();
- }
-}
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.gv.egiz.bku.local.stal;
+
+import java.awt.Dimension;
+import java.awt.Toolkit;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import javax.swing.JDialog;
+import javax.swing.WindowConstants;
+
+import at.gv.egiz.bku.gui.BKUGUIFacade;
+import at.gv.egiz.bku.gui.BKUGUIFactory;
+import at.gv.egiz.bku.online.applet.BKUApplet;
+import at.gv.egiz.stal.STAL;
+import at.gv.egiz.stal.STALFactory;
+
+public class SMCCSTALFactory implements STALFactory {
+
+ private Locale locale;
+ private SMCCSTAL stal;
+ private JDialog dialog;
+
+ @Override
+ public STAL createSTAL() {
+ if (stal == null) {
+ ResourceBundle resourceBundle;
+ if (locale != null) {
+ resourceBundle = ResourceBundle.getBundle(
+ BKUApplet.RESOURCE_BUNDLE_BASE, locale);
+ } else {
+ resourceBundle = ResourceBundle
+ .getBundle(BKUApplet.RESOURCE_BUNDLE_BASE);
+ }
+ dialog = new JDialog();
+ BKUGUIFacade gui = BKUGUIFactory.createGUI();
+ gui.init(dialog.getContentPane(), locale.toString());
+ stal = new SMCCSTAL(new BKUGuiProxy(dialog, gui), dialog, resourceBundle);
+ dialog.setPreferredSize(new Dimension(400, 200));
+ dialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ Dimension frameSize = dialog.getSize();
+ if (frameSize.height > screenSize.height) {
+ frameSize.height = screenSize.height;
+ }
+ if (frameSize.width > screenSize.width) {
+ frameSize.width = screenSize.width;
+ }
+ dialog.setLocation((screenSize.width - frameSize.width) / 2,
+ (screenSize.height - frameSize.height) / 2);
+ dialog.pack();
+ }
+ return stal;
+ }
+
+ @Override
+ public void setLocale(Locale locale) {
+ this.locale = locale;
+ }
+}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingInsertCardDialog.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingInsertCardDialog.java
deleted file mode 100644
index eb76f2f2..00000000
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingInsertCardDialog.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
-* Copyright 2008 Federal Chancellery Austria and
-* Graz University of Technology
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package at.gv.egiz.bku.local.stal;
-
-import java.awt.Dimension;
-import java.awt.Font;
-import java.awt.Toolkit;
-import java.awt.event.ActionListener;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-import javax.swing.ImageIcon;
-import javax.swing.JDialog;
-
-import at.gv.egiz.bku.utils.StreamUtil;
-
-public class SwingInsertCardDialog extends JDialog {
-
- private javax.swing.JButton cancelButton;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private Locale locale = Locale.getDefault();
-
- public SwingInsertCardDialog() {
- super((java.awt.Frame) null, false);
- initComponents();
- }
-
- public void setLocale(Locale locale) {
- this.locale = locale;
- }
-
- private void initComponents() {
- ResourceBundle rb = ResourceBundle.getBundle(
- "at/gv/egiz/bku/local/Userdialog", locale);
- setTitle(rb.getString("Insert.Header"));
- jLabel1 = new javax.swing.JLabel();
- jLabel2 = new javax.swing.JLabel();
- cancelButton = new javax.swing.JButton();
-
- setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
- setName("Form"); // NOI18N
- setUndecorated(true);
-
- jLabel1.setFont(new Font("Tahoma", Font.BOLD, 14));
- jLabel1.setText(rb.getString("Insert.Text")); // NOI18N
- jLabel1.setName("text"); // NOI18N
-
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- InputStream is = getClass().getClassLoader().getResourceAsStream(
- "at/gv/egiz/bku/local/logo.png");
- try {
- StreamUtil.copyStream(is, os);
- jLabel2.setIcon(new ImageIcon(os.toByteArray())); // NOI18N
- } catch (IOException e) {
- jLabel2.setText("Chipperling image missing"); // NOI18N
- }
- jLabel2.setName("jLabel2"); // NOI18N
- cancelButton.setText(rb.getString("Insert.Button.Cancel")); // NOI18N
- cancelButton.setName("jButton1"); // NOI18N
-
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
- getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING).addGroup(
- layout.createSequentialGroup().addContainerGap().addComponent(jLabel2)
- .addGroup(
- layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.TRAILING).addGroup(
- layout.createSequentialGroup().addGap(35, 35, 35)
- .addComponent(jLabel1,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- Short.MAX_VALUE)).addGroup(
- layout.createSequentialGroup().addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(cancelButton))).addGap(29, 29, 29)));
- layout.setVerticalGroup(layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING).addGroup(
- javax.swing.GroupLayout.Alignment.TRAILING,
- layout.createSequentialGroup().addContainerGap().addGroup(
- layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.TRAILING).addComponent(
- jLabel2).addGroup(
- layout.createSequentialGroup().addComponent(jLabel1,
- javax.swing.GroupLayout.DEFAULT_SIZE, 53, Short.MAX_VALUE)
- .addGap(35, 35, 35).addComponent(cancelButton).addGap(9, 9,
- 9))).addContainerGap()));
-
- Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- Dimension frameSize = getSize();
- if (frameSize.height > screenSize.height) {
- frameSize.height = screenSize.height;
- }
- if (frameSize.width > screenSize.width) {
- frameSize.width = screenSize.width;
- }
- setLocation((screenSize.width - frameSize.width) / 2,
- (screenSize.height - frameSize.height) / 2);
- setUndecorated(false);
- pack();
- }
-
- public void addCanceledListener(ActionListener al) {
- cancelButton.addActionListener(al);
- }
-
- /**
- * @param args
- * the command line arguments
- */
- public static void main(String args[]) {
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- SwingInsertCardDialog dialog = new SwingInsertCardDialog();
- dialog.addWindowListener(new java.awt.event.WindowAdapter() {
- public void windowClosing(java.awt.event.WindowEvent e) {
- System.exit(0);
- }
- });
- //
- }
- });
- }
-
-}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingPINProvider.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingPINProvider.java
deleted file mode 100644
index 7d36e68e..00000000
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingPINProvider.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
-* Copyright 2008 Federal Chancellery Austria and
-* Graz University of Technology
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package at.gv.egiz.bku.local.stal;
-
-import java.util.Locale;
-
-import at.gv.egiz.smcc.PINProvider;
-import at.gv.egiz.smcc.PINSpec;
-
-public class SwingPINProvider implements PINProvider {
-
- private Locale locale = Locale.getDefault();
- SwingPinDialog dialog;
-
- public SwingPINProvider() {
- this.locale = Locale.getDefault();
-
- }
-
- public Locale getLocale() {
- return locale;
- }
-
- public void setLocale(Locale locale) {
- this.locale = locale;
- }
-
- @Override
- public String providePIN(PINSpec pinSpec, int retries) {
- dialog = new SwingPinDialog(null, false);
- dialog.setResizable(false);
- dialog.setRetries(retries);
- dialog.setPinSpec(pinSpec);
- dialog.initComponents();
- dialog.setVisible(true);
- dialog.requestFocus();
- dialog.setAlwaysOnTop(true);
- dialog.waitFinished();
- dialog.dispose();
- return dialog.getPIN();
- }
-
-}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingPinDialog.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingPinDialog.java
deleted file mode 100644
index 3e91972c..00000000
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingPinDialog.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
-* Copyright 2008 Federal Chancellery Austria and
-* Graz University of Technology
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package at.gv.egiz.bku.local.stal;
-
-import java.awt.Dimension;
-import java.awt.Font;
-import java.awt.Toolkit;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.text.MessageFormat;
-import java.util.Locale;
-import java.util.ResourceBundle;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.swing.ImageIcon;
-import javax.swing.JButton;
-import javax.swing.JPasswordField;
-import javax.swing.text.AttributeSet;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.PlainDocument;
-
-import at.gv.egiz.bku.utils.StreamUtil;
-import at.gv.egiz.smcc.PINSpec;
-
-public class SwingPinDialog extends javax.swing.JDialog implements
- ActionListener {
-
- private javax.swing.JButton okButton;
- private javax.swing.JButton cancelButton;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JPasswordField password;
-
- private PINSpec pinSpec;
- private String pinString;
- private boolean finished = false;
- private int retries = -1;
- private Locale locale = Locale.getDefault();
- private boolean setUp = false;
-
- class PinDocument extends PlainDocument {
- private Pattern pattern;
-
- public PinDocument() {
- if ((pinSpec != null) && (pinSpec.getRexepPattern() != null)) {
- pattern = Pattern.compile(pinSpec.getRexepPattern());
- } else {
- pattern = Pattern.compile(".");
- }
- }
-
- public void insertString(int offs, String str, AttributeSet a)
- throws BadLocationException {
- if (pinSpec.getMaxLength() >= (getLength() + str.length())) {
- Matcher matcher = pattern.matcher(str);
- if (matcher.matches()) {
- super.insertString(offs, str, a);
- }
- }
- okButton.setEnabled(getLength() >= pinSpec.getMinLength());
- }
-
- @Override
- public void remove(int offs, int len) throws BadLocationException {
- super.remove(offs, len);
- okButton.setEnabled(getLength() >= pinSpec.getMinLength());
- }
- }
-
- /**
- * Make sure to call initComponents
- *
- * @param parent
- * @param modal
- */
- public SwingPinDialog(java.awt.Frame parent, boolean modal) {
- super(parent, modal);
- }
-
- public void setLocale(Locale locale) {
- this.locale = locale;
- }
-
- public void setPinSpec(PINSpec pinSpec) {
- this.pinSpec = pinSpec;
- }
-
- public void setRetries(int retries) {
- this.retries = retries;
- }
-
- public void initComponents() {
- ResourceBundle rb = ResourceBundle.getBundle(
- "at/gv/egiz/bku/local/Userdialog", locale);
- okButton = new javax.swing.JButton();
- cancelButton = new javax.swing.JButton();
- password = new javax.swing.JPasswordField();
- jLabel1 = new javax.swing.JLabel();
- jLabel2 = new javax.swing.JLabel();
-
- setTitle(rb.getString("Pin.Header"));
- setName("Form");
- setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
-
- okButton.setText(rb.getString("Pin.Button.OK"));
- okButton.setName("okButton");
- okButton.setEnabled(false);
- okButton.addActionListener(this);
-
- cancelButton.setText(rb.getString("Pin.Button.Cancel"));
- cancelButton.setName("cancelButton");
- cancelButton.addActionListener(this);
-
- password.setText("");
- password.setDocument(new PinDocument());
- password.setName("password");
- password.addActionListener(this);
- password.setDocument(new PinDocument());
- password.setRequestFocusEnabled(true);
- password.requestFocus();
-
- jLabel1.setFont(new Font("Tahoma", Font.BOLD, 14));
- String text = null;
- Object[] args;
- if (retries > 0) {
- text = rb.getString("Pin.Text.Retries");
- args = new Object[2];
- args[0] = pinSpec.getLocalizedName();
- args[1] = new Integer(retries);
- } else {
- text = rb.getString("Pin.Text.NoRetries");
- args = new Object[1];
- args[0] = pinSpec.getLocalizedName();
- }
- text = MessageFormat.format(text, args);
- jLabel1.setText(text); // NOI18N
- jLabel1.setName("jLabel1"); // NOI18N
-
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- InputStream is = getClass().getClassLoader().getResourceAsStream(
- "at/gv/egiz/bku/local/logo.png");
- try {
- StreamUtil.copyStream(is, os);
- jLabel2.setIcon(new ImageIcon(os.toByteArray())); // NOI18N
- } catch (Exception e) {
- jLabel2.setText("Chipperling image missing"); // NOI18N
- }
- jLabel2.setName("jLabel2"); // NOI18N
-
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
- getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING).addGroup(
- layout.createSequentialGroup().addContainerGap().addComponent(jLabel2)
- .addGap(73, 73, 73).addGroup(
- layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING).addComponent(
- jLabel1).addGroup(
- layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.TRAILING, false)
- .addComponent(password,
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(
- javax.swing.GroupLayout.Alignment.LEADING,
- layout.createSequentialGroup().addComponent(
- cancelButton).addGap(18, 18, 18).addComponent(
- okButton)))).addContainerGap(31,
- Short.MAX_VALUE)));
- layout.setVerticalGroup(layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING).addGroup(
- layout.createSequentialGroup().addContainerGap().addGroup(
- layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel2).addGroup(
- layout.createSequentialGroup().addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jLabel1,
- javax.swing.GroupLayout.PREFERRED_SIZE, 33,
- javax.swing.GroupLayout.PREFERRED_SIZE).addGap(18,
- 18, 18).addComponent(password,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- javax.swing.GroupLayout.PREFERRED_SIZE).addGap(20,
- 20, 20).addGroup(
- layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(cancelButton).addComponent(
- okButton)))).addGap(36, 36, 36)));
- Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- Dimension frameSize = getSize();
- if (frameSize.height > screenSize.height) {
- frameSize.height = screenSize.height;
- }
- if (frameSize.width > screenSize.width) {
- frameSize.width = screenSize.width;
- }
- setLocation((screenSize.width - frameSize.width) / 2,
- (screenSize.height - frameSize.height) / 2);
- setUndecorated(false);
- pack();
- }
-
- public String getPIN() {
- return pinString;
- }
-
- private synchronized void finished(boolean ok) {
- if (ok) {
- pinString = password.getText();
- } else {
- pinString = null;
- }
- finished = true;
- notifyAll();
- }
-
- public synchronized void waitFinished() {
- while (!finished) {
- try {
- wait();
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
- if (e.getSource() instanceof JButton) {
- JButton pressed = (JButton) e.getSource();
- if (pressed.getName().equals("okButton")) {
- finished(true);
- } else if (pressed.getName().equals("cancelButton")) {
- finished(false);
- }
- } else if (e.getSource() instanceof JPasswordField) {
- JPasswordField pwf = (JPasswordField) e.getSource();
- if (pwf.getName().equals("password")) {
- if (password.getPassword().length >= pinSpec.getMinLength()) {
- finished(true);
- }
- }
- }
- }
-
-}
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java
index 28c714c1..b70a6274 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java
@@ -123,6 +123,7 @@ public class ResultServlet extends SpringBKUServlet {
resp.setContentType(bp.getResultContentType());
resp.setCharacterEncoding(encoding);
bp.writeResultTo(resp.getOutputStream(), encoding);
+ resp.getOutputStream().flush();
session.invalidate();
getBindingProcessorManager().removeBindingProcessor(bp.getId());
}
diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/RequestBrokerSTALFactory.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/RequestBrokerSTALFactory.java
index 38c568ab..8e61230c 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/RequestBrokerSTALFactory.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/RequestBrokerSTALFactory.java
@@ -21,6 +21,8 @@
package at.gv.egiz.stal.service.impl;
+import java.util.Locale;
+
import at.gv.egiz.stal.STAL;
import at.gv.egiz.stal.STALFactory;
@@ -35,4 +37,7 @@ public class RequestBrokerSTALFactory implements STALFactory {
return new STALRequestBrokerImpl();
}
+ @Override
+ public void setLocale(Locale locale) {
+ }
}
diff --git a/BKUViewer/src/test/java/at/gv/egiz/bku/slxhtml/ValidatorTest.java b/BKUViewer/src/test/java/at/gv/egiz/bku/slxhtml/ValidatorTest.java
index 38c64262..4708d6e7 100644
--- a/BKUViewer/src/test/java/at/gv/egiz/bku/slxhtml/ValidatorTest.java
+++ b/BKUViewer/src/test/java/at/gv/egiz/bku/slxhtml/ValidatorTest.java
@@ -16,19 +16,20 @@
*/
package at.gv.egiz.bku.slxhtml;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertNotNull;
import java.io.InputStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.junit.Ignore;
import org.junit.Test;
import at.gv.egiz.bku.viewer.ValidationException;
import at.gv.egiz.bku.viewer.Validator;
import at.gv.egiz.bku.viewer.ValidatorFactory;
-
+@Ignore
public class ValidatorTest {
private static Log log = LogFactory.getLog(ValidatorTest.class);
diff --git a/STAL/src/main/java/at/gv/egiz/stal/STALFactory.java b/STAL/src/main/java/at/gv/egiz/stal/STALFactory.java
index e7b3edd1..f9cf00c6 100644
--- a/STAL/src/main/java/at/gv/egiz/stal/STALFactory.java
+++ b/STAL/src/main/java/at/gv/egiz/stal/STALFactory.java
@@ -15,8 +15,10 @@
* limitations under the License.
*/
package at.gv.egiz.stal;
+
+import java.util.Locale;
public interface STALFactory {
-
- public STAL createSTAL();
+ public STAL createSTAL();
+ public void setLocale(Locale locale);
}
\ No newline at end of file
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java
index 0082de26..22ee0d1d 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java
@@ -187,6 +187,7 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager {
}
BindingProcessor bindingProcessor = new HTTPBindingProcessor(aSessionId,
commandInvokerClass.newInstance(), url);
+ stalFactory.setLocale(locale);
STAL stal = stalFactory.createSTAL();
bindingProcessor.init(stal, commandInvokerClass.newInstance());
if (locale != null) {
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java
index bb0314b5..775f4136 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java
@@ -36,6 +36,8 @@ import javax.net.ssl.HttpsURLConnection;
import org.apache.commons.httpclient.methods.multipart.FilePart;
import org.apache.commons.httpclient.methods.multipart.Part;
import org.apache.commons.httpclient.methods.multipart.StringPart;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import at.gv.egiz.bku.binding.multipart.InputStreamPartSource;
import at.gv.egiz.bku.binding.multipart.SLResultPart;
@@ -49,6 +51,8 @@ import at.gv.egiz.bku.utils.binding.Protocol;
*
*/
public class DataUrlConnectionImpl implements DataUrlConnectionSPI {
+
+ private final static Log log = LogFactory.getLog(DataUrlConnectionImpl.class);
public final static Protocol[] SUPPORTED_PROTOCOLS = { Protocol.HTTP,
Protocol.HTTPS };
@@ -80,10 +84,6 @@ public class DataUrlConnectionImpl implements DataUrlConnectionSPI {
*/
public void connect() throws SocketTimeoutException, IOException {
connection = (HttpURLConnection) url.openConnection();
-
- // FIXXME move this to config.
- HttpURLConnection.setFollowRedirects(false);
-
connection.setDoOutput(true);
Set headers = requestHttpHeaders.keySet();
Iterator headerIt = headers.iterator();
@@ -146,10 +146,14 @@ public class DataUrlConnectionImpl implements DataUrlConnectionSPI {
Part[] parts = new Part[formParams.size()];
Part.sendParts(os, formParams.toArray(parts), boundary.getBytes());
os.close();
- // MultipartRequestEntity PostMethod
- result = new DataUrlResponse(url.toString(), connection.getResponseCode(),
- connection.getInputStream());
-
+ // MultipartRequestEntity PostMethod
+ InputStream is = null;
+ try {
+ is = connection.getInputStream();
+ } catch (IOException iox) {
+ log.info(iox);
+ }
+ result = new DataUrlResponse(url.toString(), connection.getResponseCode(), is);
Map responseHttpHeaders = new HashMap();
Map> httpHeaders = connection.getHeaderFields();
for (Iterator keyIt = httpHeaders.keySet().iterator(); keyIt
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/Signature.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/Signature.java
index 2330ed3f..8baa0137 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/Signature.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/Signature.java
@@ -463,6 +463,31 @@ public class Signature {
log.trace("Reference caching is not enabled.");
}
}
+ for (Reference reference : getReferences()) {
+ if (reference.getType() != null) {
+ InputStream digestInputStream = reference.getDigestInputStream();
+ if (digestInputStream != null) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("DigestInput for Reference with id='");
+ sb.append(reference.getId());
+ sb.append("'; Type:");
+ sb.append(reference.getType());
+ sb.append("):\n");
+ try {
+ byte[] b = new byte[512];
+ for (int l; (l = digestInputStream.read(b)) != -1;) {
+ sb.append(new String(b, 0, l));
+ }
+ } catch (IOException e) {
+ log.error(e);
+ }
+ log.trace(sb.toString());
+ } else {
+ log.trace("Reference caching is not enabled.");
+ }
+
+ }
+ }
}
}
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/DummyStalFactory.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/DummyStalFactory.java
index 45dcdc3a..f832f364 100644
--- a/bkucommon/src/test/java/at/gv/egiz/bku/binding/DummyStalFactory.java
+++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/DummyStalFactory.java
@@ -16,6 +16,8 @@
*/
package at.gv.egiz.bku.binding;
+import java.util.Locale;
+
import at.gv.egiz.stal.STAL;
import at.gv.egiz.stal.STALFactory;
@@ -25,6 +27,12 @@ public class DummyStalFactory implements STALFactory {
public STAL createSTAL() {
// TODO Auto-generated method stub
return new at.gv.egiz.stal.dummy.DummySTAL();
+ }
+
+ @Override
+ public void setLocale(Locale locale) {
+ // TODO Auto-generated method stub
+
}
}
--
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 +++++++----
.../gv/egiz/stal/impl/ByteArrayHashDataInput.java | 58 +++++
.../bku/local/stal/LocalSignRequestHandler.java | 14 +-
.../gv/egiz/stal/impl/ByteArrayHashDataInput.java | 58 -----
.../at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java | 2 +-
.../bku/smccstal/CashedHashDataInputResolver.java | 27 ++
.../gv/egiz/bku/smccstal/SignRequestHandler.java | 273 ++++++++++++++++-----
7 files changed, 404 insertions(+), 167 deletions(-)
create mode 100644 BKUCommonGUI/src/main/java/at/gv/egiz/stal/impl/ByteArrayHashDataInput.java
delete mode 100644 STALService/src/main/java/at/gv/egiz/stal/impl/ByteArrayHashDataInput.java
create mode 100644 smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/CashedHashDataInputResolver.java
(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);
+ }
}
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/stal/impl/ByteArrayHashDataInput.java b/BKUCommonGUI/src/main/java/at/gv/egiz/stal/impl/ByteArrayHashDataInput.java
new file mode 100644
index 00000000..b0285345
--- /dev/null
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/stal/impl/ByteArrayHashDataInput.java
@@ -0,0 +1,58 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package at.gv.egiz.stal.impl;
+
+import at.gv.egiz.stal.HashDataInput;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+/**
+ *
+ * @author clemens
+ */
+public class ByteArrayHashDataInput implements HashDataInput {
+
+ protected byte[] hashData;
+ protected String id;
+ protected String mimeType;
+ protected String encoding;
+
+ public ByteArrayHashDataInput(byte[] hashData, String id, String mimeType, String encoding) {
+ if (hashData == null) {
+ throw new NullPointerException("HashDataInput not provided.");
+ }
+ this.hashData = hashData;
+ this.id = id;
+ this.mimeType = mimeType;
+ this.encoding = encoding;
+ }
+
+ @Override
+ public String getReferenceId() {
+ return id;
+ }
+
+ @Override
+ public String getMimeType() {
+ return mimeType;
+ }
+
+ @Override
+ public InputStream getHashDataInput() {
+ return new ByteArrayInputStream(hashData);
+ }
+
+ /**
+ * may be null
+ * @return
+ */
+ @Override
+ public String getEncoding() {
+ return encoding;
+ }
+
+
+}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSignRequestHandler.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSignRequestHandler.java
index f8546e49..a288a716 100644
--- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSignRequestHandler.java
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSignRequestHandler.java
@@ -29,7 +29,10 @@ import at.gv.egiz.stal.HashDataInput;
import at.gv.egiz.stal.STALRequest;
import at.gv.egiz.stal.STALResponse;
import at.gv.egiz.stal.SignRequest;
+import at.gv.egiz.stal.impl.ByteArrayHashDataInput;
import at.gv.egiz.stal.signedinfo.ReferenceType;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
/**
*
@@ -55,7 +58,7 @@ public class LocalSignRequestHandler extends SignRequestHandler {
}
@Override
- protected List getHashDataInputs(
+ public List getCashedHashDataInputs(
List dsigReferences) throws Exception {
ArrayList result = new ArrayList();
for (ReferenceType dsigRef : dsigReferences) {
@@ -65,7 +68,14 @@ public class LocalSignRequestHandler extends SignRequestHandler {
if (dsigRefId != null) {
for (HashDataInput hdi : hashDataInput) {
if (hdi.getReferenceId().equals(dsigRefId)) {
- result.add(hdi);
+ InputStream hdIs = hdi.getHashDataInput();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(hdIs.available());
+ int b;
+ while ((b = hdIs.read()) != -1) {
+ baos.write(b);
+ }
+ ByteArrayHashDataInput baHdi = new ByteArrayHashDataInput(baos.toByteArray(), hdi.getReferenceId(), hdi.getMimeType(), hdi.getEncoding());
+ result.add(baHdi);
}
}
} else {
diff --git a/STALService/src/main/java/at/gv/egiz/stal/impl/ByteArrayHashDataInput.java b/STALService/src/main/java/at/gv/egiz/stal/impl/ByteArrayHashDataInput.java
deleted file mode 100644
index b0285345..00000000
--- a/STALService/src/main/java/at/gv/egiz/stal/impl/ByteArrayHashDataInput.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package at.gv.egiz.stal.impl;
-
-import at.gv.egiz.stal.HashDataInput;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
-/**
- *
- * @author clemens
- */
-public class ByteArrayHashDataInput implements HashDataInput {
-
- protected byte[] hashData;
- protected String id;
- protected String mimeType;
- protected String encoding;
-
- public ByteArrayHashDataInput(byte[] hashData, String id, String mimeType, String encoding) {
- if (hashData == null) {
- throw new NullPointerException("HashDataInput not provided.");
- }
- this.hashData = hashData;
- this.id = id;
- this.mimeType = mimeType;
- this.encoding = encoding;
- }
-
- @Override
- public String getReferenceId() {
- return id;
- }
-
- @Override
- public String getMimeType() {
- return mimeType;
- }
-
- @Override
- public InputStream getHashDataInput() {
- return new ByteArrayInputStream(hashData);
- }
-
- /**
- * may be null
- * @return
- */
- @Override
- public String getEncoding() {
- return encoding;
- }
-
-
-}
diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java
index 56c8340b..ac2b725c 100644
--- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java
+++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java
@@ -45,7 +45,7 @@ public abstract class AbstractSMCCSTAL implements STAL {
static {
addRequestHandler(InfoboxReadRequest.class, new InfoBoxReadRequestHandler());
- addRequestHandler(SignRequest.class, new SignRequestHandler());
+// addRequestHandler(SignRequest.class, new SignRequestHandler());
}
/**
diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/CashedHashDataInputResolver.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/CashedHashDataInputResolver.java
new file mode 100644
index 00000000..05af85d9
--- /dev/null
+++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/CashedHashDataInputResolver.java
@@ -0,0 +1,27 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package at.gv.egiz.bku.smccstal;
+
+import at.gv.egiz.stal.HashDataInput;
+import at.gv.egiz.stal.impl.ByteArrayHashDataInput;
+import at.gv.egiz.stal.signedinfo.ReferenceType;
+import java.security.DigestException;
+import java.util.List;
+import java.util.Set;
+
+/**
+ *
+ * @author clemens
+ */
+public interface CashedHashDataInputResolver {
+
+ /**
+ * implementations may verify the hashvalue
+ * @post-condition returned list != null
+ * @return
+ */
+ List getCashedHashDataInputs(List signedReferences) throws DigestException, Exception;
+}
diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java
index d37d0551..59eed55f 100644
--- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java
+++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java
@@ -21,8 +21,6 @@ import java.io.InputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
@@ -43,21 +41,26 @@ import at.gv.egiz.stal.STALRequest;
import at.gv.egiz.stal.STALResponse;
import at.gv.egiz.stal.SignRequest;
import at.gv.egiz.stal.SignResponse;
+import at.gv.egiz.stal.impl.ByteArrayHashDataInput;
import at.gv.egiz.stal.signedinfo.ObjectFactory;
import at.gv.egiz.stal.signedinfo.ReferenceType;
import at.gv.egiz.stal.signedinfo.SignedInfoType;
import at.gv.egiz.stal.util.JCEAlgorithmNames;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.security.DigestException;
+import java.security.DigestInputStream;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Set;
/**
* This class is NOT thread-safe.
* handleRequest() sets the SignedInfo which is used in providePIN.
*/
-public class SignRequestHandler extends AbstractRequestHandler implements
- PINProvider {
+public abstract class SignRequestHandler extends AbstractRequestHandler implements
+ CashedHashDataInputResolver {
private static Log log = LogFactory.getLog(SignRequestHandler.class);
private static JAXBContext jaxbContext;
@@ -71,10 +74,10 @@ public class SignRequestHandler extends AbstractRequestHandler implements
}
}
/** the SignedInfo of the current SignRequest */
- protected SignedInfoType signedInfo;
- protected List hashDataInputs;
+// protected SignedInfoType signedInfo;
+// protected List hashDataInputs;
- private int retryCounter = 0;
+// private int retryCounter = 0;
@SuppressWarnings("unchecked")
@Override
@@ -86,8 +89,7 @@ public class SignRequestHandler extends AbstractRequestHandler implements
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
InputStream is = new ByteArrayInputStream(signReq.getSignedInfo());
JAXBElement si = (JAXBElement) unmarshaller.unmarshal(is);
- signedInfo = si.getValue();
- String signatureMethod = signedInfo.getSignatureMethod().getAlgorithm();
+ String signatureMethod = si.getValue().getSignatureMethod().getAlgorithm();
log.debug("Found signature method: " + signatureMethod);
String jceName = JCEAlgorithmNames.getJCEHashName(signatureMethod);
if (jceName == null) {
@@ -97,7 +99,7 @@ public class SignRequestHandler extends AbstractRequestHandler implements
MessageDigest md = MessageDigest.getInstance(jceName);
md.update(signReq.getSignedInfo());
KeyboxName kb = SignatureCard.KeyboxName.getKeyboxName(signReq.getKeyIdentifier());
- byte[] resp = card.createSignature(md.digest(), kb, this);
+ byte[] resp = card.createSignature(md.digest(), kb, new STALPinProvider(si.getValue()));
if (resp == null) {
return new ErrorResponse(6001);
}
@@ -116,9 +118,7 @@ public class SignRequestHandler extends AbstractRequestHandler implements
} catch (NoSuchAlgorithmException e) {
log.error(e);
return new ErrorResponse(1000);
- } finally {
- signedInfo = null;
- }
+ }
} else {
log.fatal("Got unexpected STAL request: " + request);
return new ErrorResponse(1000);
@@ -130,59 +130,210 @@ public class SignRequestHandler extends AbstractRequestHandler implements
return true;
}
- @Override
- public String providePIN(PINSpec spec, int retries) {
- if (retryCounter++ > 0) {
- log.info("PIN wrong retrying ...");
- gui.showSignaturePINRetryDialog(spec, retries, this, "sign", this,
- "cancel", this, "hashData");
- } else {
- gui.showSignaturePINDialog(spec, this, "sign", this, "cancel", this,
- "hashData");
- }
- do {
- waitForAction();
- if (actionCommand.equals("cancel")) {
- return null;
- } else if (actionCommand.equals("hashData")) {
- if (signedInfo != null) {
- try {
- gui.showWaitDialog(null);
- if (hashDataInputs == null || hashDataInputs.size() == 0) {
- hashDataInputs = getHashDataInputs(signedInfo.getReference());
- }
- gui.showHashDataInputDialog(hashDataInputs, this, "ok");
- } catch (Exception ex) {
- //FIXME localize messages
- log.error("Failed to obtain HashDataInputs: " + ex.getMessage());
- gui.showErrorDialog("Failed to obtain HashDataInputs: " + ex.getMessage(), this, "ok");
- }
- } else {
- //FIXME get all hashdatainputs
- gui.showErrorDialog("Failed to obtain HashDataInputs: No dsig:SignedInfo provided.", this, "ok");
- }
- } else if (actionCommand.equals("sign")) {
- return new String(gui.getPin());
- } else if (actionCommand.equals("ok")) {
- gui.showSignaturePINDialog(spec, this, "sign", this, "cancel", this,
- "hashData");
- }
- } while (true);
- }
+// @Override
+// public String providePIN(PINSpec spec, int retries) {
+// if (retryCounter++ > 0) {
+// log.info("PIN wrong retrying ...");
+// gui.showSignaturePINRetryDialog(spec, retries, this, "sign", this,
+// "cancel", this, "hashData");
+// } else {
+// gui.showSignaturePINDialog(spec, this, "sign", this, "cancel", this,
+// "hashData");
+// }
+// do {
+// waitForAction();
+// if (actionCommand.equals("cancel")) {
+// return null;
+// } else if (actionCommand.equals("hashData")) {
+// if (signedInfo != null) {
+// try {
+// gui.showWaitDialog(null);
+// if (hashDataInputs == null || hashDataInputs.size() == 0) {
+// HashMap signedReferences = new HashMap();
+// for (ReferenceType reference : signedInfo.getReference()) {
+// //don't get Manifest, QualifyingProperties, ...
+// if (reference.getType() == null) {
+// signedReferences.put(reference.getId(), reference);
+// }
+// }
+// hashDataInputs = getHashDataInputs(signedReferences.keySet());
+// for (HashDataInput hashDataInput : hashDataInputs) {
+// ReferenceType reference = signedReferences.get(hashDataInput.getReferenceId());
+// String algorithm = reference.getDigestMethod().getAlgorithm();
+// MessageDigest md = MessageDigest.getInstance(algorithm);
+// DigestInputStream dis = new DigestInputStream(hashDataInput.getHashDataInput(), md);
+// while(dis.read() != -1) ;
+// byte[] digestValue = md.digest();
+// boolean valid = reference.getDigestValue().equals(digestValue);
+// }
+// }
+// gui.showHashDataInputDialog(hashDataInputs, this, "ok");
+// } catch (Exception ex) {
+// //FIXME localize messages
+// log.error("Failed to obtain HashDataInputs: " + ex.getMessage());
+// gui.showErrorDialog("Failed to obtain HashDataInputs: " + ex.getMessage(), this, "ok");
+// }
+// } else {
+// //FIXME get all hashdatainputs
+// gui.showErrorDialog("Failed to obtain HashDataInputs: No dsig:SignedInfo provided.", this, "ok");
+// }
+// } else if (actionCommand.equals("sign")) {
+// return new String(gui.getPin());
+// } else if (actionCommand.equals("ok")) {
+// gui.showSignaturePINDialog(spec, this, "sign", this, "cancel", this,
+// "hashData");
+// }
+// } while (true);
+// }
- @Override
- public SMCCSTALRequestHandler newInstance() {
- return new SignRequestHandler();
- }
+// @Override
+// public SMCCSTALRequestHandler newInstance() {
+// return new SignRequestHandler();
+// }
/**
- * override by subclass
+ * implementations may verify the hashvalue
* @post-condition returned list != null
* @return
*/
- protected List getHashDataInputs(List signedReferences) throws Exception {
- //TODO
- log.warn("Return empty HashDataInput");
- return new ArrayList();
+ @Override
+ public abstract List getCashedHashDataInputs(List signedReferences) throws Exception;
+// {
+// //TODO
+// log.warn("Return empty HashDataInput");
+// return new ArrayList();
+// }
+
+
+
+// protected void validateHashDataInputs(List signedReferences, List hashDataInputs) {
+// if (hashDataInputs != null) {
+//
+// Map hashDataIdMap = new HashMap();
+// for (HashDataInput hdi : hashDataInputs) {
+// if (log.isTraceEnabled()) {
+// log.trace("Provided HashDataInput for reference " + hdi.getReferenceId());
+// }
+// hashDataIdMap.put(hdi.getReferenceId(), hdi);
+// }
+//
+// List reqRefs = request.getReference();
+// for (GetHashDataInputType.Reference reqRef : reqRefs) {
+// String reqRefId = reqRef.getID();
+// HashDataInput reqHdi = hashDataIdMap.get(reqRefId);
+// if (reqHdi == null) {
+// String msg = "Failed to resolve HashDataInput for reference " + reqRefId;
+// log.error(msg);
+// GetHashDataInputFaultType faultInfo = new GetHashDataInputFaultType();
+// faultInfo.setErrorCode(1);
+// faultInfo.setErrorMessage(msg);
+// throw new GetHashDataInputFault(msg, faultInfo);
+// }
+//
+// InputStream hashDataIS = reqHdi.getHashDataInput();
+// if (hashDataIS == null) {
+// //HashDataInput not cached?
+// String msg = "Failed to obtain HashDataInput for reference " + reqRefId + ", reference not cached";
+// log.error(msg);
+// GetHashDataInputFaultType faultInfo = new GetHashDataInputFaultType();
+// faultInfo.setErrorCode(1);
+// faultInfo.setErrorMessage(msg);
+// throw new GetHashDataInputFault(msg, faultInfo);
+// }
+// ByteArrayOutputStream baos = null;
+// try {
+// if (log.isDebugEnabled()) {
+// log.debug("Resolved HashDataInput " + reqRefId + " (" + reqHdi.getMimeType() + ";charset=" + reqHdi.getEncoding() + ")");
+// }
+// baos = new ByteArrayOutputStream(hashDataIS.available());
+// int c;
+// while ((c = hashDataIS.read()) != -1) {
+// baos.write(c);
+// }
+// GetHashDataInputResponseType.Reference ref = new GetHashDataInputResponseType.Reference();
+// ref.setID(reqRefId);
+// ref.setMimeType(reqHdi.getMimeType());
+// ref.setEncoding(reqHdi.getEncoding());
+// ref.setValue(baos.toByteArray());
+// response.getReference().add(ref);
+// } catch (IOException ex) {
+// String msg = "Failed to get HashDataInput for reference " + reqRefId;
+// log.error(msg, ex);
+// GetHashDataInputFaultType faultInfo = new GetHashDataInputFaultType();
+// faultInfo.setErrorCode(1);
+// faultInfo.setErrorMessage(msg);
+// throw new GetHashDataInputFault(msg, faultInfo, ex);
+// } finally {
+// try {
+// baos.close();
+// } catch (IOException ex) {
+// }
+// }
+// }
+// return response;
+// }
+// for (ReferenceType reference : signedReferences) {
+// String algorithm = reference.getDigestMethod().getAlgorithm();
+//
+// }
+// }
+
+
+ /**
+ * cashes the HashDataInputs provided by SignRequestHandler.this.getHashDataInputs()
+ * (don't know whether outer class is LocalSignRequestHandler or WSSignRequestHandler, providing DataObjectHDI or ByteArrayHDI, resp)
+ */
+ class STALPinProvider implements PINProvider {
+
+ protected SignedInfoType signedInfo;
+ protected List hashDataInputs;
+ private int retryCounter = 0;
+
+ public STALPinProvider(SignedInfoType signedInfo) {
+ this.signedInfo = signedInfo;
+ }
+
+ @Override
+ public String providePIN(PINSpec spec, int retries) {
+ if (retryCounter++ > 0) {
+ log.info("PIN wrong retrying ...");
+ gui.showSignaturePINRetryDialog(spec, retries, SignRequestHandler.this, "sign", SignRequestHandler.this,
+ "cancel", SignRequestHandler.this, "hashData");
+ } else {
+ gui.showSignaturePINDialog(spec, SignRequestHandler.this, "sign", SignRequestHandler.this, "cancel", SignRequestHandler.this,
+ "hashData");
}
+ do {
+ waitForAction();
+ if (actionCommand.equals("cancel")) {
+ return null;
+ } else if (actionCommand.equals("hashData")) {
+ if (signedInfo != null) {
+ try {
+ gui.showWaitDialog(null);
+ if (hashDataInputs == null || hashDataInputs.size() == 0) {
+ hashDataInputs = getCashedHashDataInputs(signedInfo.getReference());
+ }
+ gui.showHashDataInputDialog(hashDataInputs, SignRequestHandler.this, "ok");
+ } catch (DigestException ex) {
+ log.error("Bad digest value: " + ex.getMessage());
+ gui.showErrorDialog(ex.getMessage());
+ } catch (Exception ex) {
+ //FIXME localize messages
+ log.error("Failed to obtain HashDataInputs: " + ex.getMessage());
+ gui.showErrorDialog("Failed to obtain HashDataInputs: " + ex.getMessage(), SignRequestHandler.this, "ok");
+ }
+ } else {
+ //FIXME get all hashdatainputs
+ gui.showErrorDialog("Failed to obtain HashDataInputs: No dsig:SignedInfo provided.", SignRequestHandler.this, "ok");
+ }
+ } else if (actionCommand.equals("sign")) {
+ return new String(gui.getPin());
+ } else if (actionCommand.equals("ok")) {
+ gui.showSignaturePINDialog(spec, SignRequestHandler.this, "sign", SignRequestHandler.this, "cancel", SignRequestHandler.this,
+ "hashData");
+ }
+ } while (true);
+ }
+ }
}
--
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 +-
BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUI.java | 3 ++-
smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java | 2 +-
3 files changed, 4 insertions(+), 3 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 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;
}
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUI.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUI.java
index 0b68962c..544b6eb3 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUI.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUI.java
@@ -246,7 +246,8 @@ public class BKUGUI implements BKUGUIFacade {
headerPanelLayout.setHorizontalGroup(
headerPanelLayout.createSequentialGroup()
// headerPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
- .addComponent(titleLabel, 0, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE));
+ .addComponent(titleLabel, 0, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
+ .addContainerGap());
headerPanelLayout.setVerticalGroup(
headerPanelLayout.createSequentialGroup()
// headerPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java
index 8f380eec..0b297283 100644
--- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java
+++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java
@@ -311,7 +311,7 @@ public abstract class SignRequestHandler extends AbstractRequestHandler implemen
} else if (actionCommand.equals("hashData")) {
if (signedInfo != null) {
try {
- gui.showWaitDialog(null);
+// gui.showWaitDialog(null);
if (hashDataInputs == null || hashDataInputs.size() == 0) {
hashDataInputs = getCashedHashDataInputs(signedInfo.getReference());
}
--
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 +++++++++++----------
BKUOnline/src/main/webapp/appletPage.jsp | 4 +-
2 files changed, 72 insertions(+), 63 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;
}
diff --git a/BKUOnline/src/main/webapp/appletPage.jsp b/BKUOnline/src/main/webapp/appletPage.jsp
index 041591f3..5f208a2a 100644
--- a/BKUOnline/src/main/webapp/appletPage.jsp
+++ b/BKUOnline/src/main/webapp/appletPage.jsp
@@ -26,9 +26,9 @@
-
-
+
diff --git a/BKUOnline/src/main/webapp/finanzonline/FinanzOnlineLogin/award.gif b/BKUOnline/src/main/webapp/finanzonline/FinanzOnlineLogin/award.gif
new file mode 100644
index 00000000..8807fcf6
Binary files /dev/null and b/BKUOnline/src/main/webapp/finanzonline/FinanzOnlineLogin/award.gif differ
diff --git a/BKUOnline/src/main/webapp/finanzonline/FinanzOnlineLogin/bmf_01.gif b/BKUOnline/src/main/webapp/finanzonline/FinanzOnlineLogin/bmf_01.gif
new file mode 100644
index 00000000..dd7697a4
Binary files /dev/null and b/BKUOnline/src/main/webapp/finanzonline/FinanzOnlineLogin/bmf_01.gif differ
diff --git a/BKUOnline/src/main/webapp/finanzonline/FinanzOnlineLogin/bmf_02.gif b/BKUOnline/src/main/webapp/finanzonline/FinanzOnlineLogin/bmf_02.gif
new file mode 100644
index 00000000..961d511e
Binary files /dev/null and b/BKUOnline/src/main/webapp/finanzonline/FinanzOnlineLogin/bmf_02.gif differ
diff --git a/BKUOnline/src/main/webapp/finanzonline/FinanzOnlineLogin/browser.js b/BKUOnline/src/main/webapp/finanzonline/FinanzOnlineLogin/browser.js
new file mode 100644
index 00000000..6fbf74f0
--- /dev/null
+++ b/BKUOnline/src/main/webapp/finanzonline/FinanzOnlineLogin/browser.js
@@ -0,0 +1,165 @@
+var BrowserDetect = {
+ init: function () {
+ this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
+ this.version = this.searchVersion(navigator.userAgent)
+ || this.searchVersion(navigator.appVersion)
+ || "an unknown version";
+ this.OS = this.searchString(this.dataOS) || "an unknown OS";
+ },
+ searchString: function (data) {
+ for (var i=0;i
Die Menüführung in FinanzOnline wurde aus technischen Gründen geändert. Da Sie möglicherweise eine veraltete und nicht mehr dem letzten Sicherheitsstandard entsprechende Version Ihres Webbrowsers verwenden, besteht ab diesem Zeitpunkt die Möglichkeit, dass das Menü in FinanzOnline nicht richtig angezeigt werden kann.
+ Elektronisches Lernprogramm zur Handhabung von FinanzOnline und Durchführung der Arbeitnehmerveranlagung
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/BKUOnline/src/main/webapp/index.html b/BKUOnline/src/main/webapp/index.html
index 8f1a338e..bf8b3ae0 100644
--- a/BKUOnline/src/main/webapp/index.html
+++ b/BKUOnline/src/main/webapp/index.html
@@ -49,6 +49,8 @@