summaryrefslogtreecommitdiff
path: root/BKUOnline/src/main/java
diff options
context:
space:
mode:
authorclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-01-20 14:09:21 +0000
committerclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-01-20 14:09:21 +0000
commit23f82c4d63290cb41dc0fc6ebb86d6cae9a560fe (patch)
tree79b317ee10777ece72bb916d95ccc70616f0015a /BKUOnline/src/main/java
parent7c14149f55c8f48ca24786f97f7abed4e55804b1 (diff)
downloadmocca-23f82c4d63290cb41dc0fc6ebb86d6cae9a560fe.tar.gz
mocca-23f82c4d63290cb41dc0fc6ebb86d6cae9a560fe.tar.bz2
mocca-23f82c4d63290cb41dc0fc6ebb86d6cae9a560fe.zip
prepare for stal service extension
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@262 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'BKUOnline/src/main/java')
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java13
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBroker.java5
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java195
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java127
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALXJAXBContextFactory.java61
5 files changed, 193 insertions, 208 deletions
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java
index 781e0832..7930c53a 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java
@@ -67,13 +67,11 @@ public class BKURequestHandler extends SpringBKUServlet {
return new String(os.toByteArray(), encoding);
}
+ @Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, java.io.IOException {
- log.debug("Got new request");
- String acceptLanguage = req.getHeader("Accept-Language");
- Locale locale = AcceptLanguage.getLocale(acceptLanguage);
- log.debug("Accept-Language locale: " + locale);
-
+ log.debug("Received new request");
+
HttpSession session = req.getSession(false);
if (session != null) {
log.warn("Already a session with id: " + session.getId()
@@ -95,6 +93,10 @@ public class BKURequestHandler extends SpringBKUServlet {
log.debug("Using session id: " + session.getId());
}
+ String acceptLanguage = req.getHeader("Accept-Language");
+ Locale locale = AcceptLanguage.getLocale(acceptLanguage);
+ log.debug("Accept-Language locale: " + locale);
+
HTTPBindingProcessor bindingProcessor;
bindingProcessor = (HTTPBindingProcessor) getBindingProcessorManager()
.createBindingProcessor(req.getRequestURL().toString(),
@@ -185,6 +187,7 @@ public class BKURequestHandler extends SpringBKUServlet {
dispatcher.forward(req, resp);
}
+ @Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, java.io.IOException {
doPost(req, resp);
diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBroker.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBroker.java
index d1fe045a..b77f7660 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBroker.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBroker.java
@@ -22,6 +22,7 @@ import at.gv.egiz.stal.STAL;
import at.gv.egiz.stal.service.types.RequestType;
import at.gv.egiz.stal.service.types.ResponseType;
import java.util.List;
+import javax.xml.bind.JAXBElement;
/**
*
@@ -32,9 +33,9 @@ public interface STALRequestBroker extends STAL {
public static final int ERR_4500 = 4500;
public static final long DEFAULT_TIMEOUT_MS = 1000*60*5; //5mn
- public List<RequestType> connect();
+ public List<JAXBElement<? extends RequestType>> connect();
- public List<RequestType> nextRequest(List<ResponseType> response);
+ public List<JAXBElement<? extends RequestType>> nextRequest(List<JAXBElement<? extends ResponseType>> responses);
public List<HashDataInput> getHashDataInput();
}
diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java
index 5e3a1a99..252327d3 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java
@@ -25,6 +25,7 @@ import at.gv.egiz.stal.STALRequest;
import at.gv.egiz.stal.STALResponse;
import at.gv.egiz.stal.SignRequest;
import at.gv.egiz.stal.service.types.InfoboxReadRequestType;
+import at.gv.egiz.stal.service.types.ObjectFactory;
import at.gv.egiz.stal.service.types.QuitRequestType;
import at.gv.egiz.stal.service.types.RequestType;
import at.gv.egiz.stal.service.types.ResponseType;
@@ -34,6 +35,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
+import javax.xml.bind.JAXBElement;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -52,14 +54,12 @@ public class STALRequestBrokerImpl implements STALRequestBroker {
private static final Log log = LogFactory.getLog(STALRequestBrokerImpl.class);
-// private boolean expectingResponse = false;
+ private ObjectFactory stalObjFactory = new ObjectFactory();
+
private boolean interrupted = false;
-// private final RequestsMonitor reqMon = new RequestsMonitor();
-// private final ResponsesMonitor respMon = new ResponsesMonitor();
-
- protected ArrayList<RequestType> requests;
- protected ArrayList<ResponseType> responses;
+ protected final ArrayList<JAXBElement<? extends RequestType>> requests;
+ protected final ArrayList<JAXBElement<? extends ResponseType>> responses;
protected ArrayList<HashDataInput> hashDataInputs;
@@ -69,8 +69,8 @@ public class STALRequestBrokerImpl implements STALRequestBroker {
if (timeoutMillisec <= 0)
timeoutMillisec = DEFAULT_TIMEOUT_MS;
timeout = timeoutMillisec;
- requests = new ArrayList<RequestType>();
- responses = new ArrayList<ResponseType>();
+ requests = new ArrayList<JAXBElement<? extends RequestType>>();
+ responses = new ArrayList<JAXBElement<? extends ResponseType>>();
hashDataInputs = new ArrayList<HashDataInput>();
}
@@ -95,36 +95,39 @@ public class STALRequestBrokerImpl implements STALRequestBroker {
requests.clear();
hashDataInputs.clear();
-// reqMon.produce(requests);
-// reqMon.setHashDataInput(null);
for (STALRequest stalRequest : stalRequests) {
if (stalRequest instanceof SignRequest) {
log.trace("Received SignRequest, keep HashDataInput.");
- SignRequestType req = new SignRequestType();
- req.setKeyIdentifier(((SignRequest) stalRequest).getKeyIdentifier());
- req.setSignedInfo(((SignRequest) stalRequest).getSignedInfo());
+ SignRequestType reqT = stalObjFactory.createSignRequestType();
+ reqT.setKeyIdentifier(((SignRequest) stalRequest).getKeyIdentifier());
+ reqT.setSignedInfo(((SignRequest) stalRequest).getSignedInfo());
+ JAXBElement<SignRequestType> req = stalObjFactory.createGetNextRequestResponseTypeSignRequest(reqT);
requests.add(req);
//DataObjectHashDataInput with reference caching enabled DataObject
hashDataInputs.addAll(((SignRequest) stalRequest).getHashDataInput());
break;
} else if (stalRequest instanceof InfoboxReadRequest) {
log.trace("Received InfoboxReadRequest");
- InfoboxReadRequestType req = new InfoboxReadRequestType();
- req.setInfoboxIdentifier(((InfoboxReadRequest) stalRequest).getInfoboxIdentifier());
- req.setDomainIdentifier(((InfoboxReadRequest) stalRequest).getDomainIdentifier());
+ InfoboxReadRequestType reqT = new InfoboxReadRequestType();
+ reqT.setInfoboxIdentifier(((InfoboxReadRequest) stalRequest).getInfoboxIdentifier());
+ reqT.setDomainIdentifier(((InfoboxReadRequest) stalRequest).getDomainIdentifier());
+ JAXBElement<InfoboxReadRequestType> req = stalObjFactory.createGetNextRequestResponseTypeInfoboxReadRequest(reqT);
requests.add(req);
} else if (stalRequest instanceof QuitRequest) {
log.trace("Received QuitRequest, do not wait for responses.");
- requests.add(new QuitRequestType());
+ QuitRequestType reqT = stalObjFactory.createQuitRequestType();
+ JAXBElement<QuitRequestType> req = stalObjFactory.createGetNextRequestResponseTypeQuitRequest(reqT);
+ requests.add(req);
log.trace("notifying request consumers");
requests.notify();
-// reqMon.notify();
return new ArrayList<STALResponse>();
} else {
log.error("Received unsupported STAL request: " + stalRequest.getClass().getName() + ", send QUIT");
requests.clear();
- requests.add(new QuitRequestType());
+ QuitRequestType reqT = stalObjFactory.createQuitRequestType();
+ JAXBElement<QuitRequestType> req = stalObjFactory.createGetNextRequestResponseTypeQuitRequest(reqT);
+ requests.add(req);
log.trace("notifying request consumers");
requests.notify();
return new ArrayList<STALResponse>();
@@ -132,32 +135,25 @@ public class STALRequestBrokerImpl implements STALRequestBroker {
}
log.trace("notifying request consumers");
requests.notify();
-// reqMon.notify();
}
- synchronized (responses) { //respMon) {
+ synchronized (responses) {
long beforeWait = System.currentTimeMillis();
-// while (respMon.responses == null) {
while (responses.isEmpty()) {
log.trace("waiting to consume response");
-// respMon.wait(timeout);
responses.wait(timeout);
if (System.currentTimeMillis() - beforeWait >= timeout) {
log.warn("timeout while waiting to consume response, cleanup requests");
-// reqMon.consume(); //TODO check deadlock?
-// reqMon.setHashDataInput(null);
- requests.clear(); //TODO sync on requests?
+ requests.clear();
hashDataInputs.clear();
return Collections.singletonList((STALResponse) new ErrorResponse(ERR_4500));
}
}
log.trace("consuming responses");
-// List<STALResponse> responses = respMon.consume();
List<STALResponse> resps = STALTranslator.toSTAL(responses);
responses.clear();
log.trace("notifying response producers");
responses.notify();
-// respMon.notify();
return resps;
}
@@ -169,7 +165,7 @@ public class STALRequestBrokerImpl implements STALRequestBroker {
}
@Override
- public List<RequestType> connect() {
+ public List<JAXBElement<? extends RequestType>> connect() {
if (interrupted) {
return null;
}
@@ -181,15 +177,9 @@ public class STALRequestBrokerImpl implements STALRequestBroker {
requests.wait(timeout);
if (System.currentTimeMillis() - beforeWait >= timeout) {
log.warn("timeout while waiting to consume request");
- return Collections.singletonList((RequestType) new QuitRequestType());
+ return createSingleQuitRequest();
}
}
-
-// log.trace("consume request");
-// List<RequestType> reqs = new ArrayList<RequestType>();
-// reqs.addAll(requests);
-// requests.clear();
-// return reqs;
log.trace("don't consume request now, leave for further connect calls");
return requests;
}
@@ -212,7 +202,7 @@ public class STALRequestBrokerImpl implements STALRequestBroker {
* @return QUIT if expected responses are not provided
*/
@Override
- public List<RequestType> nextRequest(List<ResponseType> resps) {
+ public List<JAXBElement<? extends RequestType>> nextRequest(List<JAXBElement<? extends ResponseType>> resps) {
if (interrupted) {
return null;
}
@@ -227,69 +217,43 @@ public class STALRequestBrokerImpl implements STALRequestBroker {
}
}
- synchronized (responses) { //respMon) {
+ synchronized (responses) {
if (resps != null && resps.size() > 0) {
-// if (!expectingResponse) {
-// log.warn("Received unexpected response in nextRequest(), return QUIT");
-// return Collections.singletonList((RequestType) new QuitRequestType());
-// }
long beforeWait = System.currentTimeMillis();
-// while (respMon.responses != null) {
while (!responses.isEmpty()) {
log.trace("waiting to produce response");
-// respMon.wait(timeout);
responses.wait(timeout);
if (System.currentTimeMillis() - beforeWait >= timeout) {
log.warn("timeout while waiting to produce response");
- return Collections.singletonList((RequestType) new QuitRequestType());
+ return createSingleQuitRequest();
}
}
log.trace("produce response");
-// respMon.produce(resps);
responses.addAll(resps);
//reset HashDataInputCallback iff SignResponse
if (log.isTraceEnabled()) {
- for (ResponseType response : resps) {
- log.trace("Received STAL response: " + response.getClass().getName());
+ for (JAXBElement<? extends ResponseType> response : resps) {
+ log.trace("Received STAL response: " + response.getValue().getClass().getName());
}
}
log.trace("notifying response consumers");
-// respMon.notify();
responses.notify();
} else {
-// if (expectingResponse) {
-// log.warn("Did not receive expected response(s) in nextRequest(), return QUIT");
-// return Collections.singletonList((RequestType) new QuitRequestType());
-// }
-// log.trace("expecting non-null response in next nextRequest(response)");
-// expectingResponse = true;
log.error("Received NextRequest without responses, return QUIT");
- return Collections.singletonList((RequestType) new QuitRequestType());
+ return createSingleQuitRequest();
}
}
- synchronized (requests) { //reqMon) {
+ synchronized (requests) {
long beforeWait = System.currentTimeMillis();
-// while (reqMon.requests == null) {
while (requests.isEmpty()) {
log.trace("waiting to consume request");
-// reqMon.wait(timeout);
requests.wait(timeout);
if (System.currentTimeMillis() - beforeWait >= timeout) {
log.warn("timeout while waiting to consume request");
- return Collections.singletonList((RequestType) new QuitRequestType());
+ return createSingleQuitRequest();
}
}
-// log.trace("consume request");
-// List<RequestType> reqs = new ArrayList<RequestType>(); // reqMon.consume();
-// reqs.addAll(requests);
-//
-//// if (requests.size() > 0 && requests.get(0) instanceof QuitRequestType) {
-//// log.trace("expecting no response in next nextRequest()");
-//// expectingResponse = false;
-//// }
-// requests.clear();
-// return reqs;
log.trace("don't consume request now, but on next response delivery");
return requests;
}
@@ -304,92 +268,19 @@ public class STALRequestBrokerImpl implements STALRequestBroker {
public List<HashDataInput> getHashDataInput() {
synchronized (requests) {
log.trace("return " + hashDataInputs.size() + " current HashDataInput(s) ");
- return hashDataInputs; //reqMon.getHashDataInput();
+ return hashDataInputs;
}
}
@Override
public void setLocale(Locale locale) {
}
-
-// class RequestsMonitor {
-// List<STALRequest> requests;
-// List<HashDataInput> hashDataInput;
-//
-// void produce(List<STALRequest> req) {
-// requests = req;
-// }
-//
-// synchronized List<at.gv.egiz.stal.service.types.STALRequest> consume() {
-// List<at.gv.egiz.stal.service.types.STALRequest> reqs = new ArrayList<at.gv.egiz.stal.service.types.STALRequest>();
-// for (STALRequest request : requests) {
-// if (request instanceof SignRequest) {
-// at.gv.egiz.stal.service.types.SignRequest r = new at.gv.egiz.stal.service.types.SignRequest();
-// r.setKeyIdentifier(((SignRequest) request).getKeyIdentifier());
-// r.setSignedInfo(((SignRequest) request).getSignedInfo());
-// reqs.add(r);
-// } else if (request instanceof InfoboxReadRequest) {
-// at.gv.egiz.stal.service.types.InfoboxReadRequest r = new at.gv.egiz.stal.service.types.InfoboxReadRequest();
-// r.setDomainIdentifier(((InfoboxReadRequest) request).getDomainIdentifier());
-// r.setInfoboxIdentifier(((InfoboxReadRequest) request).getInfoboxIdentifier());
-// reqs.add(r);
-// } else if (request instanceof QuitRequest) {
-// at.gv.egiz.stal.service.types.QuitRequest r = new at.gv.egiz.stal.service.types.QuitRequest();
-// reqs.add(r);
-// } else {
-// log.error("unknown STAL request type: " + request.getClass());
-// requests = null;
-// return Collections.singletonList((at.gv.egiz.stal.service.types.STALRequest) new at.gv.egiz.stal.service.types.QuitRequest());
-// }
-// }
-// requests = null;
-// return reqs;
-// }
-//
-// void setHashDataInput(List<HashDataInput> hdi) {
-// hashDataInput = hdi;
-// }
-//
-// List<HashDataInput> getHashDataInput() {
-// return hashDataInput;
-// }
-// }
-//
-// /** TODO: now, that responses are not nulled, synchronize directly on responses? */
-// class ResponsesMonitor {
-// List<at.gv.egiz.stal.service.types.STALResponse> responses;
-//
-// void produce(List<at.gv.egiz.stal.service.types.STALResponse> resp) {
-// responses = resp;
-// }
-//
-// synchronized List<STALResponse> consume() {
-// List<STALResponse> resps = new ArrayList<STALResponse>();
-//
-// for (at.gv.egiz.stal.service.types.STALResponse response : responses) {
-// if (response instanceof at.gv.egiz.stal.service.types.InfoboxReadResponse) {
-// InfoboxReadResponse r = new InfoboxReadResponse();
-// r.setInfoboxValue(((at.gv.egiz.stal.service.types.InfoboxReadResponse) response).getInfoboxValue());
-// resps.add(r);
-// } else if (response instanceof at.gv.egiz.stal.service.types.SignResponse) {
-// SignResponse r = new SignResponse();
-// r.setSignatureValue(((at.gv.egiz.stal.service.types.SignResponse) response).getSignatureValue());
-// resps.add(r);
-// } else if (response instanceof at.gv.egiz.stal.service.types.ErrorResponse) {
-// ErrorResponse r = new ErrorResponse();
-// r.setErrorCode(((at.gv.egiz.stal.service.types.ErrorResponse) response).getErrorCode());
-// r.setErrorMessage(((at.gv.egiz.stal.service.types.ErrorResponse) response).getErrorMessage());
-// resps.add(r);
-// } else {
-// log.error("unknown STAL response type: " + response.getClass());
-// ErrorResponse r = new ErrorResponse(4000);
-// r.setErrorMessage("unknown STAL response type: " + response.getClass());
-// responses = null;
-// return Collections.singletonList((STALResponse) r);
-// }
-// }
-// responses = null;
-// return resps;
-// }
-// }
+
+ private List<JAXBElement<? extends RequestType>> createSingleQuitRequest() {
+ QuitRequestType quitT = stalObjFactory.createQuitRequestType();
+ JAXBElement<QuitRequestType> quit = stalObjFactory.createGetNextRequestResponseTypeQuitRequest(quitT);
+ ArrayList<JAXBElement<? extends RequestType>> l = new ArrayList<JAXBElement<? extends RequestType>>();
+ l.add(quit);
+ return l;
+ }
}
diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java
index 05a3f5e5..45629869 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java
@@ -14,9 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package at.gv.egiz.stal.service.impl;
+//import at.buergerkarte.namespaces.cardchannel.service.CommandAPDUType;
+//import at.buergerkarte.namespaces.cardchannel.service.ScriptType;
import at.gv.egiz.bku.binding.BindingProcessor;
import at.gv.egiz.bku.binding.BindingProcessorManager;
import at.gv.egiz.bku.binding.Id;
@@ -36,6 +37,7 @@ import at.gv.egiz.stal.service.types.QuitRequestType;
import at.gv.egiz.stal.service.types.RequestType;
import at.gv.egiz.stal.service.types.ResponseType;
import at.gv.egiz.stal.service.types.SignRequestType;
+import com.sun.xml.ws.developer.UsesJAXBContext;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -46,6 +48,7 @@ import java.util.Map;
import javax.annotation.Resource;
import javax.jws.WebService;
import javax.servlet.ServletContext;
+import javax.xml.bind.JAXBElement;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.handler.MessageContext;
import org.apache.commons.logging.Log;
@@ -56,46 +59,45 @@ import org.apache.commons.logging.LogFactory;
* @author clemens
*/
@WebService(endpointInterface = "at.gv.egiz.stal.service.STALPortType")
+@UsesJAXBContext(STALXJAXBContextFactory.class)
public class STALServiceImpl implements STALPortType {
public static final String BINDING_PROCESSOR_MANAGER = "bindingProcessorManager";
public static final Id TEST_SESSION_ID = IdFactory.getInstance().createId("TestSession");
-
protected static final Log log = LogFactory.getLog(STALServiceImpl.class);
-
+
+
static {
-
if (log.isTraceEnabled()) {
log.trace("enabling webservice communication dump");
System.setProperty("com.sun.xml.ws.transport.http.HttpAdapter.dump", "true");
} else {
System.setProperty("com.sun.xml.ws.fault.SOAPFaultBuilder.disableCaptureStackTrace", "false");
}
-
}
-
@Resource
- WebServiceContext wsContext;
+ protected WebServiceContext wsContext;
protected IdFactory idF = IdFactory.getInstance();
+ private at.gv.egiz.stal.service.types.ObjectFactory stalObjFactory = new at.gv.egiz.stal.service.types.ObjectFactory();
+// private at.buergerkarte.namespaces.cardchannel.service.ObjectFactory ccObjFactory = new at.buergerkarte.namespaces.cardchannel.service.ObjectFactory();
-
@Override
public GetNextRequestResponseType connect(String sessId) {
-
+
if (sessId == null) {
throw new NullPointerException("No session id provided");
}
-
+
Id sessionId = idF.createId(sessId);
if (log.isDebugEnabled()) {
log.debug("Received Connect [" + sessionId + "]");
}
-
+
if (TEST_SESSION_ID.equals(sessionId)) {
return getTestSessionNextRequestResponse(null);
}
-
+
GetNextRequestResponseType response = new GetNextRequestResponseType();
response.setSessionId(sessionId.toString());
@@ -103,7 +105,7 @@ public class STALServiceImpl implements STALPortType {
if (stal != null) {
- List<RequestType> requestsOut = ((STALRequestBroker) stal).connect();
+ List<JAXBElement<? extends RequestType>> requestsOut = ((STALRequestBroker) stal).connect();
response.getInfoboxReadRequestOrSignRequestOrQuitRequest().addAll(requestsOut);
if (log.isDebugEnabled()) {
@@ -112,29 +114,32 @@ public class STALServiceImpl implements STALPortType {
sb.append("] containing ");
sb.append(requestsOut.size());
sb.append(" requests: ");
- for (RequestType reqOut : requestsOut) {
- sb.append(reqOut.getClass());
+ for (JAXBElement<? extends RequestType> reqOut : requestsOut) {
+ sb.append(reqOut.getValue().getClass());
sb.append(' ');
}
log.debug(sb.toString());
}
} else {
log.error("Failed to get STAL for session " + sessionId + ", returning QuitRequest");
- response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(new QuitRequestType());
+ QuitRequestType quitT = stalObjFactory.createQuitRequestType();
+ JAXBElement<QuitRequestType> quit = stalObjFactory.createGetNextRequestResponseTypeQuitRequest(quitT);
+ response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(quit);
}
return response;
}
-
+
@Override
public GetNextRequestResponseType getNextRequest(GetNextRequestType request) {
if (request.getSessionId() == null) {
throw new NullPointerException("No session id provided");
}
-
+
Id sessionId = idF.createId(request.getSessionId());
- List<ResponseType> responsesIn = request.getInfoboxReadResponseOrSignResponseOrErrorResponse();//getResponse();
+ List<JAXBElement<? extends ResponseType>> responsesIn = request.getInfoboxReadResponseOrSignResponseOrErrorResponse();
+// List<ResponseType> responsesIn = request.getInfoboxReadResponseOrSignResponseOrErrorResponse();//getResponse();
if (log.isDebugEnabled()) {
StringBuilder sb = new StringBuilder("Received GetNextRequest [");
@@ -142,25 +147,25 @@ public class STALServiceImpl implements STALPortType {
sb.append("] containing ");
sb.append(responsesIn.size());
sb.append(" responses: ");
- for (ResponseType respIn : responsesIn) {
+ for (Object respIn : responsesIn) {
sb.append(respIn.getClass());
sb.append(' ');
}
log.debug(sb.toString());
}
-
+
if (TEST_SESSION_ID.equals(sessionId)) {
return getTestSessionNextRequestResponse(responsesIn);
}
GetNextRequestResponseType response = new GetNextRequestResponseType();
response.setSessionId(sessionId.toString());
-
+
STALRequestBroker stal = getStal(sessionId);
if (stal != null) {
- List<RequestType> requestsOut = ((STALRequestBroker) stal).nextRequest(responsesIn);
+ List<JAXBElement<? extends RequestType>> requestsOut = ((STALRequestBroker) stal).nextRequest(responsesIn);
response.getInfoboxReadRequestOrSignRequestOrQuitRequest().addAll(requestsOut);
if (log.isDebugEnabled()) {
@@ -169,15 +174,17 @@ public class STALServiceImpl implements STALPortType {
sb.append("] containing ");
sb.append(requestsOut.size());
sb.append(" requests: ");
- for (RequestType reqOut : requestsOut) {
- sb.append(reqOut.getClass());
+ for (JAXBElement<? extends RequestType> reqOut : requestsOut) {
+ sb.append(reqOut.getValue().getClass());
sb.append(' ');
}
log.debug(sb.toString());
}
} else {
log.error("Failed to get STAL for session " + sessionId + ", returning QuitRequest");
- response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(new QuitRequestType());
+ QuitRequestType quitT = stalObjFactory.createQuitRequestType();
+ JAXBElement<QuitRequestType> quit = stalObjFactory.createGetNextRequestResponseTypeQuitRequest(quitT);
+ response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(quit);
}
return response;
}
@@ -188,7 +195,7 @@ public class STALServiceImpl implements STALPortType {
if (request.getSessionId() == null) {
throw new NullPointerException("No session id provided");
}
-
+
Id sessionId = idF.createId(request.getSessionId());
if (log.isDebugEnabled()) {
@@ -197,13 +204,13 @@ public class STALServiceImpl implements STALPortType {
GetHashDataInputResponseType response = new GetHashDataInputResponseType();
response.setSessionId(sessionId.toString());
-
+
if (TEST_SESSION_ID.equals(sessionId)) {
log.debug("Received GetHashDataInput for session " + TEST_SESSION_ID + ", return DummyHashDataInput");
GetHashDataInputResponseType.Reference ref = new GetHashDataInputResponseType.Reference();
ref.setID("signed-data-reference-0-1214921968-27971781-24309"); //Reference-" + TEST_SESSION_ID + "-001");
ref.setMimeType("text/plain");
-
+
Charset charset;
try {
charset = Charset.forName("iso-8859-15");
@@ -316,30 +323,52 @@ public class STALServiceImpl implements STALPortType {
return (bp == null) ? null : (bp.isFinished() ? null : (STALRequestBroker) bp.getSTAL());
}
- private GetNextRequestResponseType getTestSessionNextRequestResponse(List<ResponseType> responsesIn) {
+ private GetNextRequestResponseType getTestSessionNextRequestResponse(List<JAXBElement<? extends ResponseType>> responsesIn) {
GetNextRequestResponseType response = new GetNextRequestResponseType();
response.setSessionId(TEST_SESSION_ID.toString());
-
- if (responsesIn != null && responsesIn.size() > 0 && responsesIn.get(0) instanceof ErrorResponseType) {
- log.info("Received TestSession GetNextRequest(ErrorResponse), returning QuitRequest");
- response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(new QuitRequestType());
+
+ List<JAXBElement<? extends RequestType>> reqs = response.getInfoboxReadRequestOrSignRequestOrQuitRequest();
+
+ if (responsesIn == null) {
+ log.info("[TestSession] received CONNECT, return dummy requests ");
+// ScriptType scriptT = ccObjFactory.createScriptType();
+// CommandAPDUType cmd = ccObjFactory.createCommandAPDUType();
+// cmd.setValue("TestSession CardChannelCMD 1234".getBytes());
+// scriptT.getResetOrCommandAPDUOrVerifyAPDU().add(cmd);
+// reqs.add(ccObjFactory.createScript(scriptT));
+ addDummyRequests(reqs);
+ } else if (responsesIn != null && responsesIn.size() > 0 && responsesIn.get(0).getValue() instanceof ErrorResponseType) {
+ log.info("[TestSession] received ErrorResponse, return QUIT request");
+ QuitRequestType quitT = stalObjFactory.createQuitRequestType();
+ reqs.add(stalObjFactory.createGetNextRequestResponseTypeQuitRequest(quitT));
} else {
- log.info("Received TestSession GetNextRequest, returning SignRequest and 3 InfoboxReadRequests ");
- InfoboxReadRequestType req = new InfoboxReadRequestType();
- req.setInfoboxIdentifier("IdentityLink");
- req.setDomainIdentifier("hansiwurzel");
- response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(req);
- SignRequestType sig = new SignRequestType();
- sig.setKeyIdentifier("SecureSignatureKeypair");
- sig.setSignedInfo("<dsig:SignedInfo xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:xpf=\"http://www.w3.org/2002/06/xmldsig-filter2\"><dsig:CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\" /> <dsig:SignatureMethod Algorithm=\"http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1\" /> <dsig:Reference Id=\"signed-data-reference-0-1214921968-27971781-24309\" URI=\"#signed-data-object-0-1214921968-27971781-13578\"><dsig:Transforms> <dsig:Transform Algorithm=\"http://www.w3.org/2002/06/xmldsig-filter2\"> <xpf:XPath xmlns:xpf=\"http://www.w3.org/2002/06/xmldsig-filter2\" Filter=\"intersect\">id('signed-data-object-0-1214921968-27971781-13578')/node()</xpf:XPath></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /> <dsig:DigestValue>H1IePEEfGQ2SG03H6LTzw1TpCuM=</dsig:DigestValue></dsig:Reference><dsig:Reference Id=\"etsi-data-reference-0-1214921968-27971781-25439\" Type=\"http://uri.etsi.org/01903/v1.1.1#SignedProperties\" URI=\"#xmlns(etsi=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('etsi-data-object-0-1214921968-27971781-3095')/child::etsi:QualifyingProperties/child::etsi:SignedProperties)\"><dsig:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /><dsig:DigestValue>yV6Q+I60buqR4mMaxA7fi+CV35A=</dsig:DigestValue></dsig:Reference></dsig:SignedInfo>".getBytes());
- response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(sig);
- req = new InfoboxReadRequestType();
- req.setInfoboxIdentifier("CertifiedKeypair");
- response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(req);
- req = new InfoboxReadRequestType();
- req.setInfoboxIdentifier("SecureSignatureKeypair");
- response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(req);
+ log.info("[TestSession] received " + responsesIn.size() + " response(s), return dummy requests" );
+ addDummyRequests(reqs);
}
return response;
}
+
+ private void addDummyRequests(List<JAXBElement<? extends RequestType>> reqs) {
+// log.info("[TestSession] add READ request for Infobox IdentityLink");
+// InfoboxReadRequestType ibrT1 = stalObjFactory.createInfoboxReadRequestType();
+// ibrT1.setInfoboxIdentifier("IdentityLink");
+// reqs.add(stalObjFactory.createGetNextRequestResponseTypeInfoboxReadRequest(ibrT1));
+
+ log.info("[TestSession] add READ request for Infobox CertifiedKeypair");
+ InfoboxReadRequestType ibrT2 = stalObjFactory.createInfoboxReadRequestType();
+ ibrT2.setInfoboxIdentifier("CertifiedKeypair");
+ reqs.add(stalObjFactory.createGetNextRequestResponseTypeInfoboxReadRequest(ibrT2));
+
+ log.info("[TestSession] add READ request for Infobox SecureSignatureKeypair");
+ InfoboxReadRequestType ibrT3 = stalObjFactory.createInfoboxReadRequestType();
+ ibrT3.setInfoboxIdentifier("SecureSignatureKeypair");
+ reqs.add(stalObjFactory.createGetNextRequestResponseTypeInfoboxReadRequest(ibrT3));
+
+ log.info("[TestSession] add SIGN request");
+ SignRequestType sigT1 = stalObjFactory.createSignRequestType();
+ sigT1.setKeyIdentifier("SecureSignatureKeypair");
+ sigT1.setSignedInfo("<dsig:SignedInfo xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:xpf=\"http://www.w3.org/2002/06/xmldsig-filter2\"><dsig:CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\" /> <dsig:SignatureMethod Algorithm=\"http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1\" /> <dsig:Reference Id=\"signed-data-reference-0-1214921968-27971781-24309\" URI=\"#signed-data-object-0-1214921968-27971781-13578\"><dsig:Transforms> <dsig:Transform Algorithm=\"http://www.w3.org/2002/06/xmldsig-filter2\"> <xpf:XPath xmlns:xpf=\"http://www.w3.org/2002/06/xmldsig-filter2\" Filter=\"intersect\">id('signed-data-object-0-1214921968-27971781-13578')/node()</xpf:XPath></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /> <dsig:DigestValue>H1IePEEfGQ2SG03H6LTzw1TpCuM=</dsig:DigestValue></dsig:Reference><dsig:Reference Id=\"etsi-data-reference-0-1214921968-27971781-25439\" Type=\"http://uri.etsi.org/01903/v1.1.1#SignedProperties\" URI=\"#xmlns(etsi=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('etsi-data-object-0-1214921968-27971781-3095')/child::etsi:QualifyingProperties/child::etsi:SignedProperties)\"><dsig:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /><dsig:DigestValue>yV6Q+I60buqR4mMaxA7fi+CV35A=</dsig:DigestValue></dsig:Reference></dsig:SignedInfo>".getBytes());
+ reqs.add(stalObjFactory.createGetNextRequestResponseTypeSignRequest(sigT1));
+ }
+
}
diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALXJAXBContextFactory.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALXJAXBContextFactory.java
new file mode 100644
index 00000000..92559254
--- /dev/null
+++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALXJAXBContextFactory.java
@@ -0,0 +1,61 @@
+/*
+ * 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.stal.service.impl;
+
+import com.sun.xml.bind.api.JAXBRIContext;
+import com.sun.xml.bind.api.TypeReference;
+import com.sun.xml.ws.api.model.SEIModel;
+import com.sun.xml.ws.developer.JAXBContextFactory;
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.JAXBException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class STALXJAXBContextFactory implements JAXBContextFactory {
+
+ private static final Log log = LogFactory.getLog(STALXJAXBContextFactory.class);
+
+ @Override
+ public JAXBRIContext createJAXBContext(SEIModel sei, List<Class> classesToBind, List<TypeReference> typeReferences) throws JAXBException {
+ if (log.isTraceEnabled()) {
+ log.trace("JAXBContext seed for SEI " + sei.getTargetNamespace() + ":");
+ for (Class class1 : classesToBind) {
+ log.trace(" " + class1);
+ }
+ for (TypeReference typeReference : typeReferences) {
+ log.trace(" typeRef " + typeReference.tagName + " -> " + typeReference.type);
+ }
+ }
+ List<Class> classes = new ArrayList<Class>();
+ classes.addAll(classesToBind);
+// Class ccOF = at.buergerkarte.namespaces.cardchannel.service.ObjectFactory.class;
+// if (!classes.contains(ccOF)) {
+// log.debug("adding " + ccOF + " to JAXBContext seed");
+// classes.add(ccOF);
+// }
+
+ //TODO add typeReference?
+
+ return JAXBRIContext.newInstance(classes.toArray(new Class[classes.size()]),
+ typeReferences, null, sei.getTargetNamespace(), false, null);
+ }
+}