summaryrefslogtreecommitdiff
path: root/BKUApplet/src/main/java/at/gv
diff options
context:
space:
mode:
Diffstat (limited to 'BKUApplet/src/main/java/at/gv')
-rw-r--r--BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletBKUWorker.java4
-rw-r--r--BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletHashDataDisplay.java3
-rw-r--r--BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java122
-rw-r--r--BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BrowserHashDataDisplay.java52
4 files changed, 79 insertions, 102 deletions
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletBKUWorker.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletBKUWorker.java
index 388f045f..5a57ef18 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletBKUWorker.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletBKUWorker.java
@@ -165,7 +165,7 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
showErrorDialog(BKUGUIFacade.ERR_CONFIG, ex);
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
- showErrorDialog(BKUGUIFacade.ERR_UNKNOWN, ex);
+ showErrorDialog(BKUGUIFacade.ERR_UNKNOWN_WITH_PARAM, ex);
} finally {
if (signatureCard != null) {
signatureCard.disconnect(false);
@@ -195,7 +195,7 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
}
}
- private void showErrorDialog(String err_code, Exception ex) {
+ protected void showErrorDialog(String err_code, Exception ex) {
actionCommandList.clear();
actionCommandList.add("ok");
gui.showErrorDialog(err_code,
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletHashDataDisplay.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletHashDataDisplay.java
index 7be40d65..2ed9aa5b 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletHashDataDisplay.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletHashDataDisplay.java
@@ -16,12 +16,10 @@
*/
package at.gv.egiz.bku.online.applet;
-import at.gv.egiz.bku.gui.BKUGUIFacade;
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;
@@ -34,7 +32,6 @@ import at.gv.egiz.stal.service.GetHashDataInputFault;
import at.gv.egiz.stal.service.STALPortType;
import at.gv.egiz.stal.service.types.GetHashDataInputResponseType;
import at.gv.egiz.stal.service.types.GetHashDataInputType;
-import at.gv.egiz.stal.signedinfo.DigestMethodType;
import at.gv.egiz.stal.signedinfo.ReferenceType;
import java.security.NoSuchAlgorithmException;
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 d4b2018d..a4337bbd 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
@@ -31,7 +31,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import at.gv.egiz.bku.gui.BKUGUIFacade;
-import at.gv.egiz.bku.gui.BKUGUIFactory;
+import at.gv.egiz.bku.gui.BKUGUIImpl;
import at.gv.egiz.stal.service.STALPortType;
import at.gv.egiz.stal.service.STALService;
import java.awt.Container;
@@ -57,8 +57,6 @@ public class BKUApplet extends JApplet {
public static final String BACKGROUND_IMG = "Background";
public static final String REDIRECT_URL = "RedirectURL";
public static final String REDIRECT_TARGET = "RedirectTarget";
-// public static final String HASHDATA_DISPLAY_INTERNAL = "internal";
-// public static final String HASHDATA_DISPLAY_BROWSER = "browser";
public static final String HASHDATA_DISPLAY_FRAME = "frame";
/**
* STAL WSDL namespace and service name
@@ -69,6 +67,14 @@ public class BKUApplet extends JApplet {
* Dummy session id, used if no sessionId parameter is provided
*/
protected static final String TEST_SESSION_ID = "TestSession";
+
+ static {
+ if (log.isTraceEnabled()) {
+ log.trace("enabling webservice communication dump");
+ System.setProperty("com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump", "true");
+ }
+ }
+
/**
* STAL
*/
@@ -82,7 +88,7 @@ public class BKUApplet extends JApplet {
@Override
public void init() {
log.info("Welcome to MOCCA");
- log.debug("Called init()");
+ log.trace("Called init()");
HttpsURLConnection.setDefaultSSLSocketFactory(InternalSSLSocketFactory.getInstance());
@@ -127,19 +133,19 @@ public class BKUApplet extends JApplet {
backgroundImgURL,
helpListener);
- worker = new AppletBKUWorker(this, gui);
+ worker = createBKUWorker(this, gui);
}
@Override
public void start() {
- log.debug("Called start()");
+ log.trace("Called start()");
workerThread = new Thread(worker);
workerThread.start();
}
@Override
public void stop() {
- log.debug("Called stop()");
+ log.trace("Called stop()");
if ((workerThread != null) && (workerThread.isAlive())) {
workerThread.interrupt();
}
@@ -147,52 +153,36 @@ public class BKUApplet extends JApplet {
@Override
public void destroy() {
- log.debug("Called destroy()");
+ log.trace("Called destroy()");
}
- protected URL getURLParameter(String paramKey, String sessionId) throws MalformedURLException {
- String urlParam = getParameter(paramKey);
- if (urlParam != null) {
- URL codebase = getCodeBase();
- try {
- URL url;
- if (codebase.getProtocol().equalsIgnoreCase("file")) {
- // for debugging in appletrunner
- url = new URL(urlParam);
- } else {
- if (sessionId != null) {
- urlParam = urlParam + ";jsessionid=" + sessionId;
- }
- url = new URL(codebase, urlParam);
- }
- log.info("applet parameter " + url);
- return url;
- } catch (MalformedURLException ex) {
- log.error("applet paremeter " + urlParam + " is not a valid URL: " + ex.getMessage());
- throw ex;
- }
- } else {
- log.error("applet paremeter " + urlParam + " not set");
- throw new MalformedURLException(urlParam + " not set");
- }
- }
-
- /**
- * provides a means to for subclasses to inject a different GUI
- */
+ /////////////////////////////////////////////////////////////////////////////
+ // factory methods for subclasses to inject different components
+ /////////////////////////////////////////////////////////////////////////////
+
protected BKUGUIFacade createGUI(Container contentPane,
Locale locale,
Style guiStyle,
URL backgroundImgURL,
AbstractHelpListener helpListener) {
- return BKUGUIFactory.createGUI(contentPane,
- locale,
- guiStyle,
- backgroundImgURL,
- helpListener);
+ return new BKUGUIImpl(contentPane, locale, guiStyle, backgroundImgURL, helpListener);
+ }
+
+ protected AppletBKUWorker createBKUWorker(BKUApplet applet, BKUGUIFacade gui) {
+ return new AppletBKUWorker(applet, gui);
}
- protected STALPortType getSTALPort() throws MalformedURLException {
+
+ /////////////////////////////////////////////////////////////////////////////
+ // callback for BKUWorker to allow extension
+ /////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Callback for BKUWorker to allow extension
+ * @return
+ * @throws java.net.MalformedURLException
+ */
+ public STALPortType getSTALPort() throws MalformedURLException {
URL wsdlURL = getURLParameter(WSDL_URL, null);
log.debug("setting STAL WSDL: " + wsdlURL);
QName endpointName = new QName(STAL_WSDL_NS, STAL_SERVICE);
@@ -200,10 +190,21 @@ public class BKUApplet extends JApplet {
return stal.getSTALPort();
}
- protected STALTranslator getSTALTranslator() {
+ /**
+ * Callback for BKUWorker to allow extension
+ * (TODO STALPort could know its STALTranslator)
+ * @return
+ * @throws java.net.MalformedURLException
+ */
+ public STALTranslator getSTALTranslator() {
return new STALTranslator();
}
+ /**
+ * Callback for BKUWorker to keep applet context out of BKUWorker
+ * @return
+ * @throws java.net.MalformedURLException
+ */
protected void sendRedirect(String sessionId) {
try {
URL redirectURL = getURLParameter(REDIRECT_URL, sessionId);
@@ -220,4 +221,35 @@ public class BKUApplet extends JApplet {
// gui.showErrorDialog(errorMsg, okListener, actionCommand)
}
}
+
+
+ /////////////////////////////////////////////////////////////////////////////
+ // utility methods
+ /////////////////////////////////////////////////////////////////////////////
+
+ protected URL getURLParameter(String paramKey, String sessionId) throws MalformedURLException {
+ String urlParam = getParameter(paramKey);
+ if (urlParam != null) {
+ URL codebase = getCodeBase();
+ try {
+ URL url;
+ if (codebase.getProtocol().equalsIgnoreCase("file")) {
+ // for debugging in appletrunner
+ url = new URL(urlParam);
+ } else {
+ if (sessionId != null) {
+ urlParam = urlParam + ";jsessionid=" + sessionId;
+ }
+ url = new URL(codebase, urlParam);
+ }
+ return url;
+ } catch (MalformedURLException ex) {
+ log.error("applet paremeter " + urlParam + " is not a valid URL: " + ex.getMessage());
+ throw ex;
+ }
+ } else {
+ log.error("applet paremeter " + urlParam + " not set");
+ throw new MalformedURLException(urlParam + " not set");
+ }
+ }
}
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BrowserHashDataDisplay.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BrowserHashDataDisplay.java
deleted file mode 100644
index c30921da..00000000
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BrowserHashDataDisplay.java
+++ /dev/null
@@ -1,52 +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.online.applet;
-
-import java.net.URL;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import at.gv.egiz.bku.smccstal.SignRequestHandler;
-import at.gv.egiz.stal.signedinfo.ReferenceType;
-import java.applet.AppletContext;
-
-/**
- *
- * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
- */
-public class BrowserHashDataDisplay extends SignRequestHandler {
-
- private static final Log log = LogFactory.getLog(BrowserHashDataDisplay.class);
-
- protected AppletContext ctx;
- protected URL hashDataURL;
-
- public BrowserHashDataDisplay(AppletContext ctx, URL hashDataURL) {
- this.ctx = ctx;
- this.hashDataURL = hashDataURL;
- }
-
- @Override
- public void displayHashDataInputs(List<ReferenceType> signedReferences) throws Exception {
- //TODO pass reference Id's to servlet (TODO servlet)
- log.debug("displaying hashdata inputs at " + hashDataURL);
- ctx.showDocument(hashDataURL, "_blank");
- }
-}