From d0879e9058943c6afa1912ccbeae936db2811f26 Mon Sep 17 00:00:00 2001 From: clemenso Date: Tue, 30 Sep 2008 13:54:54 +0000 Subject: backport to JAXWS2.0 STALService initial connect() git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@76 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../egiz/stal/service/impl/STALRequestBroker.java | 8 +- .../stal/service/impl/STALRequestBrokerImpl.java | 324 +++++++++++++++------ .../gv/egiz/stal/service/impl/STALServiceImpl.java | 186 ++++++++---- 3 files changed, 366 insertions(+), 152 deletions(-) (limited to 'BKUOnline/src/main/java/at/gv') 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 560282ac..af886eec 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,8 +22,8 @@ package at.gv.egiz.stal.service.impl; import at.gv.egiz.stal.HashDataInput; import at.gv.egiz.stal.STAL; -import at.gv.egiz.stal.STALRequest; -import at.gv.egiz.stal.STALResponse; +import at.gv.egiz.stal.service.types.RequestType; +import at.gv.egiz.stal.service.types.ResponseType; import java.util.List; /** @@ -35,7 +35,9 @@ public interface STALRequestBroker extends STAL { public static final int ERR_6000 = 6000; public static final long DEFAULT_TIMEOUT_MS = 1000*60*5; //5mn - public List nextRequest(List response); + public List connect(); + + public List nextRequest(List response); public List 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 dc3cc6d3..bfa83dd4 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 @@ -22,10 +22,17 @@ package at.gv.egiz.stal.service.impl; import at.gv.egiz.stal.ErrorResponse; import at.gv.egiz.stal.HashDataInput; +import at.gv.egiz.stal.InfoboxReadRequest; 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.types.InfoboxReadRequestType; +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 at.gv.egiz.stal.util.STALTranslator; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -48,18 +55,26 @@ public class STALRequestBrokerImpl implements STALRequestBroker { private static final Log log = LogFactory.getLog(STALRequestBrokerImpl.class); - private boolean expectingResponse = false; +// private boolean expectingResponse = false; private boolean interrupted = false; - private final RequestsMonitor reqMon = new RequestsMonitor(); - private final ResponsesMonitor respMon = new ResponsesMonitor(); +// private final RequestsMonitor reqMon = new RequestsMonitor(); +// private final ResponsesMonitor respMon = new ResponsesMonitor(); + + protected ArrayList requests; + protected ArrayList responses; + + protected ArrayList hashDataInputs; private long timeout; public STALRequestBrokerImpl(long timeoutMillisec) { if (timeoutMillisec <= 0) timeoutMillisec = DEFAULT_TIMEOUT_MS; - this.timeout = timeoutMillisec; + timeout = timeoutMillisec; + requests = new ArrayList(); + responses = new ArrayList(); + hashDataInputs = new ArrayList(); } /** @@ -73,52 +88,80 @@ public class STALRequestBrokerImpl implements STALRequestBroker { * @pre requests: either single SignRequest, QuitRequest or multiple ReadInfoboxRequests */ @Override - public List handleRequest(List requests) { + public List handleRequest(List stalRequests) { if (interrupted) { return null; } try { - synchronized (reqMon) { + synchronized (requests) { log.trace("produce request"); - reqMon.produce(requests); - reqMon.setHashDataInput(null); - for (STALRequest request : requests) { - if (request instanceof SignRequest) { - log.trace("Received SignRequest, keep HashDataInput."); - reqMon.setHashDataInput(((SignRequest) request).getHashDataInput()); - break; - } else if (request instanceof QuitRequest) { - log.trace("Received QuitRequest, do not wait for responses."); - log.trace("notifying request consumers"); - reqMon.notify(); - return new ArrayList(); - } else if (log.isTraceEnabled()) { - log.trace("Received STAL request: " + request.getClass().getName()); + 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()); + requests.add(req); + 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()); + requests.add(req); + } else if (stalRequest instanceof QuitRequest) { + log.trace("Received QuitRequest, do not wait for responses."); + requests.add(new QuitRequestType()); + log.trace("notifying request consumers"); + requests.notify(); +// reqMon.notify(); + return new ArrayList(); + } else { + log.error("Received unsupported STAL request: " + stalRequest.getClass().getName() + ", send QUIT"); + requests.clear(); + requests.add(new QuitRequestType()); + log.trace("notifying request consumers"); + requests.notify(); + return new ArrayList(); } } log.trace("notifying request consumers"); - reqMon.notify(); + requests.notify(); +// reqMon.notify(); } - synchronized (respMon) { + synchronized (responses) { //respMon) { long beforeWait = System.currentTimeMillis(); - while (respMon.responses == null) { +// while (respMon.responses == null) { + while (responses.isEmpty()) { log.trace("waiting to consume response"); - respMon.wait(timeout); +// 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); +// reqMon.consume(); //TODO check deadlock? +// reqMon.setHashDataInput(null); + requests.clear(); //TODO sync on requests? + hashDataInputs.clear(); return Collections.singletonList((STALResponse) new ErrorResponse(ERR_6000)); } } log.trace("consuming responses"); - List responses = respMon.consume(); +// List responses = respMon.consume(); + List resps = STALTranslator.toSTAL(responses); + responses.clear(); log.trace("notifying response producers"); - respMon.notify(); + responses.notify(); +// respMon.notify(); - return responses; + return resps; } } catch (InterruptedException ex) { log.warn("interrupt in handleRequest(): " + ex.getMessage()); @@ -127,6 +170,36 @@ public class STALRequestBrokerImpl implements STALRequestBroker { } } + @Override + public List connect() { + if (interrupted) { + return null; + } + try { + synchronized (requests) { + long beforeWait = System.currentTimeMillis(); + while (requests.isEmpty()) { + log.trace("waiting to consume request"); + requests.wait(timeout); + if (System.currentTimeMillis() - beforeWait >= timeout) { + log.warn("timeout while waiting to consume request"); + return Collections.singletonList((RequestType) new QuitRequestType()); + } + } + log.trace("consume request"); + List reqs = new ArrayList(); + reqs.addAll(requests); + + requests.clear(); + return reqs; + } + } catch (InterruptedException ex) { + log.warn("interrupt in nextRequest(): " + ex.getMessage()); + interrupted = true; + return null; + } + } + /** * This method is thread-safe, except for * an 'initial' call to nextRequest(null) followed by a @@ -139,63 +212,74 @@ public class STALRequestBrokerImpl implements STALRequestBroker { * @return QUIT if expected responses are not provided */ @Override - public List nextRequest(List responses) { + public List nextRequest(List resps) { if (interrupted) { return null; } try { - synchronized (respMon) { - if (responses != null && responses.size() > 0) { - if (!expectingResponse) { - log.warn("Received unexpected response in nextRequest(), return QUIT"); - return Collections.singletonList((STALRequest) new QuitRequest()); - } + synchronized (responses) { //respMon) { + 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 (respMon.responses != null) { + while (!responses.isEmpty()) { log.trace("waiting to produce response"); - respMon.wait(timeout); +// respMon.wait(timeout); + responses.wait(timeout); if (System.currentTimeMillis() - beforeWait >= timeout) { log.warn("timeout while waiting to produce response"); - return Collections.singletonList((STALRequest) new QuitRequest()); + return Collections.singletonList((RequestType) new QuitRequestType()); } } log.trace("produce response"); - respMon.produce(responses); +// respMon.produce(resps); + responses.addAll(resps); //reset HashDataInputCallback iff SignResponse if (log.isTraceEnabled()) { - for (STALResponse response : responses) { + for (ResponseType response : resps) { log.trace("Received STAL response: " + response.getClass().getName()); } } log.trace("notifying response consumers"); - respMon.notify(); +// respMon.notify(); + responses.notify(); } else { - if (expectingResponse) { - log.warn("Did not receive expected response(s) in nextRequest(), return QUIT"); - return Collections.singletonList((STALRequest) new QuitRequest()); - } - log.trace("expecting non-null response in next nextRequest(response)"); - expectingResponse = true; +// 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()); } } - synchronized (reqMon) { + synchronized (requests) { //reqMon) { long beforeWait = System.currentTimeMillis(); - while (reqMon.requests == null) { +// while (reqMon.requests == null) { + while (requests.isEmpty()) { log.trace("waiting to consume request"); - reqMon.wait(timeout); +// reqMon.wait(timeout); + requests.wait(timeout); if (System.currentTimeMillis() - beforeWait >= timeout) { log.warn("timeout while waiting to consume request"); - return Collections.singletonList((STALRequest) new QuitRequest()); + return Collections.singletonList((RequestType) new QuitRequestType()); } } log.trace("consume request"); - List requests = reqMon.consume(); - if (requests.size() > 0 && requests.get(0) instanceof QuitRequest) { - log.trace("expecting no response in next nextRequest()"); - expectingResponse = false; - } - return requests; + List reqs = new ArrayList(); // 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; } } catch (InterruptedException ex) { log.warn("interrupt in nextRequest(): " + ex.getMessage()); @@ -205,49 +289,95 @@ public class STALRequestBrokerImpl implements STALRequestBroker { } @Override - public synchronized List getHashDataInput() { - log.trace("return " + reqMon.hashDataInput.size() + " current HashDataInput(s) "); - return reqMon.getHashDataInput(); + public List getHashDataInput() { + synchronized (requests) { + log.trace("return " + hashDataInputs.size() + " current HashDataInput(s) "); + return hashDataInputs; //reqMon.getHashDataInput(); + } } @Override public void setLocale(Locale locale) { } - class RequestsMonitor { - List requests; - List hashDataInput; - - void produce(List req) { - requests = req; - } - - synchronized List consume() { - List reqs = requests; - requests = null; - return reqs; - } - - void setHashDataInput(List hdi) { - hashDataInput = hdi; - } - - List getHashDataInput() { - return hashDataInput; - } - } - - class ResponsesMonitor { - List responses; - - void produce(List resp) { - responses = resp; - } - - synchronized List consume() { - List resps = responses; - responses = null; - return resps; - } - } +// class RequestsMonitor { +// List requests; +// List hashDataInput; +// +// void produce(List req) { +// requests = req; +// } +// +// synchronized List consume() { +// List reqs = new ArrayList(); +// 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 hdi) { +// hashDataInput = hdi; +// } +// +// List getHashDataInput() { +// return hashDataInput; +// } +// } +// +// /** TODO: now, that responses are not nulled, synchronize directly on responses? */ +// class ResponsesMonitor { +// List responses; +// +// void produce(List resp) { +// responses = resp; +// } +// +// synchronized List consume() { +// List resps = new ArrayList(); +// +// 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; +// } +// } } 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 d3d6c8db..bcee1e77 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 @@ -22,22 +22,27 @@ package at.gv.egiz.stal.service.impl; import at.gv.egiz.bku.binding.BindingProcessor; import at.gv.egiz.bku.binding.BindingProcessorManager; -import at.gv.egiz.stal.HashDataInput; -import at.gv.egiz.stal.service.*; import at.gv.egiz.bku.binding.Id; import at.gv.egiz.bku.binding.IdFactory; -import at.gv.egiz.stal.ErrorResponse; -import at.gv.egiz.stal.STALRequest; -import at.gv.egiz.stal.STALResponse; -import at.gv.egiz.stal.InfoboxReadRequest; -import at.gv.egiz.stal.QuitRequest; -import at.gv.egiz.stal.SignRequest; - -import java.io.ByteArrayInputStream; + +import at.gv.egiz.stal.HashDataInput; +import at.gv.egiz.stal.service.GetHashDataInputFault; +import at.gv.egiz.stal.service.STALPortType; +import at.gv.egiz.stal.service.types.ErrorResponseType; +import at.gv.egiz.stal.service.types.GetHashDataInputFaultType; +import at.gv.egiz.stal.service.types.GetHashDataInputResponseType; +import at.gv.egiz.stal.service.types.GetHashDataInputType; +import at.gv.egiz.stal.service.types.GetNextRequestResponseType; +import at.gv.egiz.stal.service.types.GetNextRequestType; +import at.gv.egiz.stal.service.types.InfoboxReadRequestType; +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 java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; -import java.util.Collections; +import java.nio.charset.Charset; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -63,57 +68,90 @@ public class STALServiceImpl implements STALPortType { WebServiceContext wsContext; protected IdFactory idF = IdFactory.getInstance(); + @Override - public GetNextRequestResponseType getNextRequest(GetNextRequestType request) { - - Id sessionId = idF.createId(request.getSessionId()); - - List responsesIn = request.getResponse(); - - GetNextRequestResponseType response = new GetNextRequestResponseType(); - response.setSessionId(sessionId.toString()); + 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)) { - if (responsesIn.size() > 0 && responsesIn.get(0) instanceof ErrorResponse) { - log.info("Received TestSession GetNextRequest(ErrorResponse), returning QuitRequest"); - response.getRequest().add(new QuitRequest()); - } else { - log.info("Received TestSession GetNextRequest, returning InfoboxReadRequest "); - SignRequest sig = new SignRequest(); - sig.setKeyIdentifier("SecureSignatureKeypair"); - sig.setSignedInfo(" id('signed-data-object-0-1214921968-27971781-13578')/node() H1IePEEfGQ2SG03H6LTzw1TpCuM=yV6Q+I60buqR4mMaxA7fi+CV35A=".getBytes()); - response.getRequest().add(sig); - InfoboxReadRequest req = new InfoboxReadRequest(); - req.setInfoboxIdentifier("IdentityLink"); - req.setDomainIdentifier("hansiwurzel"); - response.getRequest().add(req); - req = new InfoboxReadRequest(); - req.setInfoboxIdentifier("CertifiedKeypair"); - response.getRequest().add(req); - req = new InfoboxReadRequest(); - req.setInfoboxIdentifier("SecureSignatureKeypair"); - response.getRequest().add(req); - } - return response; + return getTestSessionNextRequestResponse(null); } + + GetNextRequestResponseType response = new GetNextRequestResponseType(); + response.setSessionId(sessionId.toString()); STALRequestBroker stal = getStal(sessionId); if (stal != null) { + + List requestsOut = ((STALRequestBroker) stal).connect(); + response.getInfoboxReadRequestOrSignRequestOrQuitRequest().addAll(requestsOut); + if (log.isDebugEnabled()) { - StringBuilder sb = new StringBuilder("Received GetNextRequest ["); + StringBuilder sb = new StringBuilder("Returning initial GetNextRequestResponse ["); sb.append(sessionId.toString()); sb.append("] containing "); - sb.append(responsesIn.size()); - sb.append(" responses: "); - for (STALResponse respIn : responsesIn) { - sb.append(respIn); + sb.append(requestsOut.size()); + sb.append(" requests: "); + for (RequestType reqOut : requestsOut) { + sb.append(reqOut.getClass()); sb.append(' '); } + log.debug(sb.toString()); } + } else { + log.error("Failed to get STAL for session " + sessionId + ", returning QuitRequest"); + response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(new QuitRequestType()); + } + 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 responsesIn = request.getInfoboxReadResponseOrSignResponseOrErrorResponse();//getResponse(); + + if (log.isDebugEnabled()) { + StringBuilder sb = new StringBuilder("Received GetNextRequest ["); + sb.append(sessionId.toString()); + sb.append("] containing "); + sb.append(responsesIn.size()); + sb.append(" responses: "); + for (ResponseType respIn : responsesIn) { + sb.append(respIn.getClass()); + sb.append(' '); + } + log.debug(sb.toString()); + } + + if (TEST_SESSION_ID.equals(sessionId)) { + return getTestSessionNextRequestResponse(responsesIn); + } - List requestsOut = ((STALRequestBroker) stal).nextRequest(responsesIn); - response.getRequest().addAll(requestsOut); + GetNextRequestResponseType response = new GetNextRequestResponseType(); + response.setSessionId(sessionId.toString()); + + STALRequestBroker stal = getStal(sessionId); + + if (stal != null) { + + List requestsOut = ((STALRequestBroker) stal).nextRequest(responsesIn); + response.getInfoboxReadRequestOrSignRequestOrQuitRequest().addAll(requestsOut); if (log.isDebugEnabled()) { StringBuilder sb = new StringBuilder("Returning GetNextRequestResponse ["); @@ -121,14 +159,15 @@ public class STALServiceImpl implements STALPortType { sb.append("] containing "); sb.append(requestsOut.size()); sb.append(" requests: "); - for (STALRequest reqOut : requestsOut) { - sb.append(reqOut); + for (RequestType reqOut : requestsOut) { + sb.append(reqOut.getClass()); sb.append(' '); } + log.debug(sb.toString()); } } else { log.error("Failed to get STAL for session " + sessionId + ", returning QuitRequest"); - response.getRequest().add(new QuitRequest()); + response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(new QuitRequestType()); } return response; } @@ -136,6 +175,10 @@ public class STALServiceImpl implements STALPortType { @Override public GetHashDataInputResponseType getHashDataInput(GetHashDataInputType request) throws GetHashDataInputFault { + if (request.getSessionId() == null) { + throw new NullPointerException("No session id provided"); + } + Id sessionId = idF.createId(request.getSessionId()); if (log.isDebugEnabled()) { @@ -150,8 +193,17 @@ public class STALServiceImpl implements STALPortType { GetHashDataInputResponseType.Reference ref = new GetHashDataInputResponseType.Reference(); ref.setID("Reference-" + TEST_SESSION_ID + "-001"); ref.setMimeType("text/plain"); - ref.setEncoding("UTF-8"); - ref.setValue("hashdatainput-öäüß@€-00000000001".getBytes()); + + Charset charset; + try { + charset = Charset.forName("iso-8859-15"); + ref.setEncoding("iso-8859-15"); + } catch (Exception ex) { + log.warn(ex.getMessage()); + charset = Charset.defaultCharset(); + ref.setEncoding(charset.toString()); + } + ref.setValue("hashdatainput-öäüß@€-00000000001".getBytes(charset)); response.getReference().add(ref); return response; } else { @@ -244,10 +296,40 @@ public class STALServiceImpl implements STALPortType { } private STALRequestBroker getStal(Id sessionId) { + if (log.isTraceEnabled()) { + log.trace("resolve STAL for session " + sessionId); + } MessageContext mCtx = wsContext.getMessageContext(); ServletContext sCtx = (ServletContext) mCtx.get(MessageContext.SERVLET_CONTEXT); BindingProcessorManager bpMgr = (BindingProcessorManager) sCtx.getAttribute(BINDING_PROCESSOR_MANAGER); BindingProcessor bp = bpMgr.getBindingProcessor(sessionId); return (bp == null) ? null : (bp.isFinished() ? null : (STALRequestBroker) bp.getSTAL()); } + + private GetNextRequestResponseType getTestSessionNextRequestResponse(List 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()); + } else { + log.info("Received TestSession GetNextRequest, returning InfoboxReadRequest "); + SignRequestType sig = new SignRequestType(); + sig.setKeyIdentifier("SecureSignatureKeypair"); + sig.setSignedInfo(" id('signed-data-object-0-1214921968-27971781-13578')/node() H1IePEEfGQ2SG03H6LTzw1TpCuM=yV6Q+I60buqR4mMaxA7fi+CV35A=".getBytes()); + response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(sig); + InfoboxReadRequestType req = new InfoboxReadRequestType(); + req.setInfoboxIdentifier("IdentityLink"); + req.setDomainIdentifier("hansiwurzel"); + response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(req); + req = new InfoboxReadRequestType(); + req.setInfoboxIdentifier("CertifiedKeypair"); + response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(req); + req = new InfoboxReadRequestType(); + req.setInfoboxIdentifier("SecureSignatureKeypair"); + response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(req); + } + return response; + } } -- cgit v1.2.3