summaryrefslogtreecommitdiff
path: root/BKUApplet/src/main/java/at/gv/egiz/bku
diff options
context:
space:
mode:
authorclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-01-20 14:24:43 +0000
committerclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-01-20 14:24:43 +0000
commit9676c9eb710bf10ecb4812043fedacd2f6e6278c (patch)
tree489866f61c44d8f4805f9317703bcfec670d7f30 /BKUApplet/src/main/java/at/gv/egiz/bku
parent66a8425c4cd1f2284f6f81e71ba302846cea6703 (diff)
downloadmocca-9676c9eb710bf10ecb4812043fedacd2f6e6278c.tar.gz
mocca-9676c9eb710bf10ecb4812043fedacd2f6e6278c.tar.bz2
mocca-9676c9eb710bf10ecb4812043fedacd2f6e6278c.zip
prepare for stal service extension
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@269 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'BKUApplet/src/main/java/at/gv/egiz/bku')
-rw-r--r--BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletBKUWorker.java67
1 files changed, 33 insertions, 34 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 9fc21df8..3903bf10 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
@@ -35,6 +35,7 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
+import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
/**
@@ -47,9 +48,10 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
protected AppletParameterProvider params;
protected String sessionId;
protected STALPortType stalPort;
+ private ObjectFactory stalObjFactory = new ObjectFactory();
public AppletBKUWorker(BKUGUIFacade gui, AppletContext ctx,
- AppletParameterProvider paramProvider) {
+ AppletParameterProvider paramProvider) {
super(gui);
if (ctx == null) {
throw new NullPointerException("Applet context not provided");
@@ -77,7 +79,7 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
actionCommandList.clear();
actionCommandList.add("ok");
gui.showErrorDialog(BKUGUIFacade.ERR_SERVICE_UNREACHABLE,
- new Object[] { e.getMessage() });
+ new Object[]{e.getMessage()});
try {
waitForAction();
} catch (InterruptedException e1) {
@@ -89,14 +91,17 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
try {
registerSignRequestHandler();
- ObjectFactory of = new ObjectFactory();
-
GetNextRequestResponseType nextRequestResp = stalPort.connect(sessionId);
do {
- List<RequestType> requests = nextRequestResp
- .getInfoboxReadRequestOrSignRequestOrQuitRequest();
- List<STALRequest> stalRequests = STALTranslator
- .translateRequests(requests);
+ List<JAXBElement<? extends RequestType>> requests = nextRequestResp.getInfoboxReadRequestOrSignRequestOrQuitRequest();
+
+ // (rather use validator)
+ if (requests.size() == 0) {
+ log.error("Received empty NextRequestResponse: no STAL requests to handle. (STAL-X requests might not have gotten unmarshalled)");
+ throw new Exception("No STAL requests to handle.");
+ }
+
+ List<STALRequest> stalRequests = STALTranslator.translateRequests(requests);
if (log.isInfoEnabled()) {
StringBuilder sb = new StringBuilder("Received ");
@@ -117,13 +122,13 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
String domainId = r.getDomainIdentifier();
if ("IdentityLink".equals(infoboxId) && domainId == null) {
if (!InternalSSLSocketFactory.getInstance().isEgovAgency()) {
- handle = false;
+ handle = false;
}
}
}
}
- List<ResponseType> responses;
+ List<JAXBElement<? extends ResponseType>> responses;
if (handle) {
List<STALResponse> stalResponses = handleRequest(stalRequests);
if (log.isInfoEnabled()) {
@@ -137,28 +142,26 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
}
responses = STALTranslator.fromSTAL(stalResponses);
} else {
- responses = new ArrayList<ResponseType>(1);
- ErrorResponseType err = of.createErrorResponseType();
+ log.error("Insufficient rights to execute command InfoboxReadRequest for Infobox IdentityLink, return Error 6002");
+ responses = new ArrayList<JAXBElement<? extends ResponseType>>(1);
+ ErrorResponseType err = stalObjFactory.createErrorResponseType();
err.setErrorCode(6002);
// err.setErrorMessage();
- responses.add(err);
+ responses.add(stalObjFactory.createGetNextRequestTypeErrorResponse(err));
}
if (!finished) {
- log.info("Not finished yet (BKUWorker: " + this
- + "), sending responses");
- GetNextRequestType nextRequest = of.createGetNextRequestType();
+ log.info("Not finished yet (BKUWorker: " + this + "), sending responses");
+ GetNextRequestType nextRequest = stalObjFactory.createGetNextRequestType();
nextRequest.setSessionId(sessionId);
- nextRequest.getInfoboxReadResponseOrSignResponseOrErrorResponse()
- .addAll(responses);
+ nextRequest.getInfoboxReadResponseOrSignResponseOrErrorResponse().addAll(responses);
nextRequestResp = stalPort.getNextRequest(nextRequest);
}
} while (!finished);
log.info("Done " + Thread.currentThread().getName());
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
- gui.showErrorDialog(BKUGUIFacade.ERR_UNKNOWN, new Object[] { ex
- .getMessage() });
+ gui.showErrorDialog(BKUGUIFacade.ERR_UNKNOWN, new Object[]{ex.getMessage()});
try {
waitForAction();
} catch (InterruptedException e) {
@@ -174,20 +177,18 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
protected void sendRedirect() {
try {
URL redirectURL = params.getURLParameter(BKUApplet.REDIRECT_URL,
- sessionId);
- String redirectTarget = params
- .getAppletParameter(BKUApplet.REDIRECT_TARGET);
+ sessionId);
+ String redirectTarget = params.getAppletParameter(BKUApplet.REDIRECT_TARGET);
if (redirectTarget == null) {
log.info("Done. Redirecting to " + redirectURL + " ...");
ctx.showDocument(redirectURL);
} else {
- log.info("Done. Redirecting to " + redirectURL + " (target="
- + redirectTarget + ") ...");
+ log.info("Done. Redirecting to " + redirectURL + " (target=" + redirectTarget + ") ...");
ctx.showDocument(redirectURL, redirectTarget);
}
} catch (MalformedURLException ex) {
log.warn("Failed to redirect: " + ex.getMessage(), ex);
- // gui.showErrorDialog(errorMsg, okListener, actionCommand)
+ // gui.showErrorDialog(errorMsg, okListener, actionCommand)
}
}
@@ -195,26 +196,24 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable {
URL wsdlURL = params.getURLParameter(BKUApplet.WSDL_URL);
log.debug("STAL WSDL at " + wsdlURL);
QName endpointName = new QName(BKUApplet.STAL_WSDL_NS,
- BKUApplet.STAL_SERVICE);
+ BKUApplet.STAL_SERVICE);
STALService stal = new STALService(wsdlURL, endpointName);
return stal.getSTALPort();
}
private void registerSignRequestHandler() throws MalformedURLException {
- String hashDataDisplayStyle = params
- .getAppletParameter(BKUApplet.HASHDATA_DISPLAY);
+ String hashDataDisplayStyle = params.getAppletParameter(BKUApplet.HASHDATA_DISPLAY);
if (BKUApplet.HASHDATA_DISPLAY_BROWSER.equals(hashDataDisplayStyle)) {
URL hashDataURL = params.getURLParameter(BKUApplet.HASHDATA_URL,
- sessionId);
+ sessionId);
log.debug("register SignRequestHandler for HashDataURL " + hashDataURL);
addRequestHandler(SignRequest.class, new BrowserHashDataDisplay(ctx,
- hashDataURL));
+ hashDataURL));
} else {
// BKUApplet.HASHDATA_DISPLAY_FRAME
- log.debug("register SignRequestHandler for STAL port "
- + BKUApplet.WSDL_URL);
+ log.debug("register SignRequestHandler for STAL port " + BKUApplet.WSDL_URL);
AppletHashDataDisplay handler = new AppletHashDataDisplay(stalPort,
- sessionId);
+ sessionId);
addRequestHandler(SignRequest.class, handler);
}
}