summaryrefslogtreecommitdiff
path: root/BKUApplet/src/main
diff options
context:
space:
mode:
authorclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2008-10-13 12:53:57 +0000
committerclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2008-10-13 12:53:57 +0000
commit255269ab17404fa1249c257e88815cbbee6e0d0f (patch)
tree04eeeb6b674c26fc1f0ed79b21adc4d2179c81d2 /BKUApplet/src/main
parentb45d01ce32c23539a4446be0cb1501f6be5cb2e8 (diff)
downloadmocca-255269ab17404fa1249c257e88815cbbee6e0d0f.tar.gz
mocca-255269ab17404fa1249c257e88815cbbee6e0d0f.tar.bz2
mocca-255269ab17404fa1249c257e88815cbbee6e0d0f.zip
ExternalDisplaySignRequestHandler
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@105 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'BKUApplet/src/main')
-rw-r--r--BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java1
-rw-r--r--BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java32
-rw-r--r--BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/ExternalDisplaySignRequestHandler.java45
-rw-r--r--BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/SignRequestHandlerFactory.java21
-rw-r--r--BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WebServiceSignRequestHandler.java (renamed from BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/WSSignRequestHandler.java)17
5 files changed, 104 insertions, 12 deletions
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 ab38c163..32c4feaa 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
@@ -46,6 +46,7 @@ public class BKUApplet extends JApplet {
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 HASHDATA_URL = "HashDataURL";
public final static String SESSION_ID = "SessionID";
public static final String BACKGROUND_PARAM = "background";
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 fbf74162..d5ba4e40 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
@@ -46,6 +46,7 @@ import at.gv.egiz.stal.service.types.ErrorResponseType;
import at.gv.egiz.stal.service.types.RequestType;
import at.gv.egiz.stal.service.types.ResponseType;
import at.gv.egiz.stal.util.STALTranslator;
+import java.applet.AppletContext;
public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
ActionListener, SMCCSTALRequestHandler {
@@ -54,6 +55,7 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
protected BKUGUIFacade gui;
protected BKUApplet parent;
private STALPortType stalPort;
+ private URL hashDataURL;
protected List<String> actionCommandList = new ArrayList<String>();
protected Boolean actionPerformed = false;
protected boolean finished = false;
@@ -115,13 +117,30 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
STALService stal = new STALService(wsdlURL, endpointName);
return stal.getSTALPort();
}
+
+ private URL getHashDataURL() throws MalformedURLException {
+ String hashDataParam = parent.getMyAppletParameter(BKUApplet.HASHDATA_URL);
+ URL codebase = parent.getCodeBase();
+ if (hashDataParam != null) {
+ try {
+ return new URL(codebase, hashDataParam);
+// log.debug("Found HashDataInputServlet URL: " + hashDataURL);
+ } catch (MalformedURLException ex) {
+ log.fatal("Paremeter " + BKUApplet.HASHDATA_URL + " is not a vailid URL.", ex);
+ throw new MalformedURLException(ex.getMessage());
+ }
+ } else {
+ log.fatal("Paremeter " + BKUApplet.HASHDATA_URL + " not set");
+ throw new MalformedURLException(BKUApplet.HASHDATA_URL + " not set");
+ }
+ }
@Override
public void run() {
gui.showWelcomeDialog();
try {
stalPort = getSTALPort();
-
+ hashDataURL = getHashDataURL();
} catch (Exception e) {
log.fatal("Failed to call STAL service.", e);
actionCommandList.clear();
@@ -135,14 +154,21 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
}
return;
}
+
+ //TODO factory for SignRequestHandler providing either WebServiceHDISignRequestHandler or ExternalHDIDisplaySignRequestHandler
+ AppletContext ctx = parent.getAppletContext();
+ log.debug("register SignRequestHandler for HashDataURL " + hashDataURL);
+ addRequestHandler(at.gv.egiz.stal.SignRequest.class, new ExternalDisplaySignRequestHandler(ctx, hashDataURL));
+
try {
String sessionId = parent.getMyAppletParameter(BKUApplet.SESSION_ID);
if (sessionId == null) {
// use the testsession for testing
sessionId = "TestSession";
}
- addRequestHandler(at.gv.egiz.stal.SignRequest.class,
- new WSSignRequestHandler(sessionId, stalPort));
+
+// log.debug("register SignRequestHandler for STAL port " + BKUApplet.WSDL_URL);
+// addRequestHandler(at.gv.egiz.stal.SignRequest.class, new WebServiceSignRequestHandler(sessionId, stalPort));
ObjectFactory of = new ObjectFactory();
GetNextRequestResponseType nextRequestResp = stalPort.connect(sessionId);
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/ExternalDisplaySignRequestHandler.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/ExternalDisplaySignRequestHandler.java
new file mode 100644
index 00000000..a9bbc559
--- /dev/null
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/ExternalDisplaySignRequestHandler.java
@@ -0,0 +1,45 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package at.gv.egiz.bku.online.applet;
+
+import at.gv.egiz.bku.smccstal.SMCCSTALRequestHandler;
+import at.gv.egiz.bku.smccstal.SignRequestHandler;
+import at.gv.egiz.stal.signedinfo.ReferenceType;
+import java.applet.AppletContext;
+import java.net.URL;
+import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author clemens
+ */
+public class ExternalDisplaySignRequestHandler extends SignRequestHandler {
+
+ private static final Log log = LogFactory.getLog(ExternalDisplaySignRequestHandler.class);
+
+ AppletContext ctx;
+ URL hashDataURL;
+
+ public ExternalDisplaySignRequestHandler(AppletContext ctx, URL hashDataURL) {
+ this.ctx = ctx;
+ this.hashDataURL = hashDataURL;
+ }
+
+ @Override
+ public SMCCSTALRequestHandler newInstance() {
+ return new ExternalDisplaySignRequestHandler(ctx, 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");
+ }
+
+}
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/SignRequestHandlerFactory.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/SignRequestHandlerFactory.java
new file mode 100644
index 00000000..327ea8aa
--- /dev/null
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/SignRequestHandlerFactory.java
@@ -0,0 +1,21 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package at.gv.egiz.bku.online.applet;
+
+import at.gv.egiz.bku.smccstal.SignRequestHandler;
+
+/**
+ *
+ * @author clemens
+ */
+public class SignRequestHandlerFactory {
+
+ static SignRequestHandler getInstance() {
+ //TODO return ExternalDisplaySignRequestHandler by default, WebServiceSignRequestHandler if requested
+ //TODO get configuration as param
+ return null;
+ }
+}
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/WebServiceSignRequestHandler.java
index 3a36a290..4a87b8b5 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/WebServiceSignRequestHandler.java
@@ -31,21 +31,19 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
-import java.util.Map.Entry;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
- *
* @author clemens
*/
-public class WSSignRequestHandler extends SignRequestHandler {
+public class WebServiceSignRequestHandler extends SignRequestHandler {
- private static final Log log = LogFactory.getLog(WSSignRequestHandler.class);
+ private static final Log log = LogFactory.getLog(WebServiceSignRequestHandler.class);
STALPortType stalPort;
String sessId;
- public WSSignRequestHandler(String sessId, STALPortType stalPort) {
+ public WebServiceSignRequestHandler(String sessId, STALPortType stalPort) {
if (stalPort == null || sessId == null) {
throw new NullPointerException("STAL port must not be null");
}
@@ -54,8 +52,8 @@ public class WSSignRequestHandler extends SignRequestHandler {
}
@Override
- public List<HashDataInput> getCashedHashDataInputs(List<ReferenceType> signedReferences) throws Exception {
-
+ public void displayHashDataInputs(List<ReferenceType> signedReferences) throws Exception {
+
GetHashDataInputType request = new GetHashDataInputType();
request.setSessionId(sessId);
@@ -158,11 +156,12 @@ public class WSSignRequestHandler extends SignRequestHandler {
}
hashDataInputs.add(new ByteArrayHashDataInput(hdi, signedRefId, mimeType, encoding));
}
- return hashDataInputs;
+
+ gui.showHashDataInputDialog(hashDataInputs, this, "ok");
}
@Override
public SMCCSTALRequestHandler newInstance() {
- return new WSSignRequestHandler(this.sessId, this.stalPort);
+ return new WebServiceSignRequestHandler(this.sessId, this.stalPort);
}
}