summaryrefslogtreecommitdiff
path: root/BKUOnline/src/main/java/at/gv/egiz/stal/service
diff options
context:
space:
mode:
authormcentner <mcentner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2010-05-05 15:29:01 +0000
committermcentner <mcentner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2010-05-05 15:29:01 +0000
commitb1c8641a63a67e3c64d948f9e8dce5c01e11e2dd (patch)
tree0883f08a408f89f758e9a1be629232e3dd055c3a /BKUOnline/src/main/java/at/gv/egiz/stal/service
parent83a9b613836910f7edc370c2fe60fa2268dc4461 (diff)
downloadmocca-b1c8641a63a67e3c64d948f9e8dce5c01e11e2dd.tar.gz
mocca-b1c8641a63a67e3c64d948f9e8dce5c01e11e2dd.tar.bz2
mocca-b1c8641a63a67e3c64d948f9e8dce5c01e11e2dd.zip
Merged feature branch mocca-1.2.13-id@r724 back to trunk.
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@725 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'BKUOnline/src/main/java/at/gv/egiz/stal/service')
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/RequestBrokerSTALFactory.java49
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java24
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java385
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALXJAXBContextFactory.java7
-rw-r--r--BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/TestSignatureData.java7
5 files changed, 256 insertions, 216 deletions
diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/RequestBrokerSTALFactory.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/RequestBrokerSTALFactory.java
index 305d8c1c..5940f505 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/RequestBrokerSTALFactory.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/RequestBrokerSTALFactory.java
@@ -19,27 +19,50 @@ package at.gv.egiz.stal.service.impl;
import java.util.Locale;
+import org.apache.commons.configuration.Configuration;
+
+import at.gv.egiz.bku.conf.MoccaConfigurationFacade;
+import at.gv.egiz.bku.jmx.ComponentMXBean;
+import at.gv.egiz.bku.jmx.ComponentState;
import at.gv.egiz.stal.STAL;
import at.gv.egiz.stal.STALFactory;
/**
*
- * @author clemens
+ * @author clemens, mcentner
*/
-public class RequestBrokerSTALFactory implements STALFactory {
-
- private static long timeout = -1;
+public class RequestBrokerSTALFactory implements STALFactory, ComponentMXBean {
- @Override
- public STAL createSTAL() {
- return new STALRequestBrokerImpl(timeout);
- }
+ public final ConfigurationFacade configurationFacade = new ConfigurationFacade();
+
+ public class ConfigurationFacade implements MoccaConfigurationFacade {
+
+ private Configuration configuration;
+
+ public static final String APPLET_TIMEOUT = "AppletTimeout";
- @Override
- public void setLocale(Locale locale) {
+ public int getAppletTimeout() {
+ return configuration.getInteger(APPLET_TIMEOUT, -1);
}
+
+ }
+
+ public void setConfiguration(Configuration configuration) {
+ configurationFacade.configuration = configuration;
+ }
+
+ @Override
+ public STAL createSTAL() {
+ return new STALRequestBrokerImpl(configurationFacade.getAppletTimeout());
+ }
+
+ @Override
+ public void setLocale(Locale locale) {
+ }
+
+ @Override
+ public ComponentState checkComponentState() {
+ return new ComponentState(true);
+ }
- public static void setTimeout(long millisec) {
- timeout = millisec;
- }
}
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 a2447ab7..5705a9f7 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
@@ -34,8 +34,8 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.xml.bind.JAXBElement;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* An instance of STALRequestBroker is shared between a producer thread (SLCommand)
@@ -50,7 +50,7 @@ import org.apache.commons.logging.LogFactory;
*/
public class STALRequestBrokerImpl implements STALRequestBroker {
- private static final Log log = LogFactory.getLog(STALRequestBrokerImpl.class);
+ private final Logger log = LoggerFactory.getLogger(STALRequestBrokerImpl.class);
private ObjectFactory of = new ObjectFactory();
private STALTranslator translator = new STALTranslator();
@@ -173,7 +173,7 @@ public class STALRequestBrokerImpl implements STALRequestBroker {
log.trace("waiting to consume response");
responses.wait(timeout);
if (System.currentTimeMillis() - beforeWait >= timeout) {
- log.warn("timeout while waiting to consume response, cleanup requests");
+ log.warn("Timeout while waiting to consume response, cleanup requests.");
requests.clear();
hashDataInputs.clear();
return Collections.singletonList((STALResponse) new ErrorResponse(ERR_4500));
@@ -218,7 +218,7 @@ public class STALRequestBrokerImpl implements STALRequestBroker {
log.trace("waiting to consume request");
requests.wait(timeout);
if (System.currentTimeMillis() - beforeWait >= timeout) {
- log.warn("timeout while waiting to consume request");
+ log.warn("Timeout while waiting to consume request.");
return createSingleQuitRequest();
}
}
@@ -250,11 +250,11 @@ public class STALRequestBrokerImpl implements STALRequestBroker {
}
try {
synchronized (requests) {
- log.trace("received responses, now consume request");
+ log.trace("Received responses, now consume request.");
if (requests.size() != 0) {
requests.clear();
} else {
- log.warn("requests queue is empty, response might have already been produced previously ");
+ log.warn("Requests queue is empty, response might have already been produced previously.");
// return QUIT?
}
}
@@ -266,7 +266,7 @@ public class STALRequestBrokerImpl implements STALRequestBroker {
log.trace("waiting to produce response");
responses.wait(timeout);
if (System.currentTimeMillis() - beforeWait >= timeout) {
- log.warn("timeout while waiting to produce response");
+ log.warn("Timeout while waiting to produce response.");
return createSingleQuitRequest();
}
}
@@ -281,7 +281,7 @@ public class STALRequestBrokerImpl implements STALRequestBroker {
log.trace("notifying response consumers");
responses.notify();
} else {
- log.error("Received NextRequest without responses, return QUIT");
+ log.error("Received NextRequest without responses, return QUIT.");
return createSingleQuitRequest();
}
}
@@ -292,11 +292,11 @@ public class STALRequestBrokerImpl implements STALRequestBroker {
log.trace("waiting to consume request");
requests.wait(timeout);
if (System.currentTimeMillis() - beforeWait >= timeout) {
- log.warn("timeout while waiting to consume request");
+ log.warn("Timeout while waiting to consume request.");
return createSingleQuitRequest();
}
}
- log.trace("don't consume request now, but on next response delivery");
+ log.trace("Don't consume request now, but on next response delivery.");
return requests;
}
} catch (InterruptedException ex) {
@@ -309,7 +309,7 @@ public class STALRequestBrokerImpl implements STALRequestBroker {
@Override
public List<HashDataInput> getHashDataInput() {
synchronized (requests) {
- log.trace("return " + hashDataInputs.size() + " current HashDataInput(s) ");
+ log.trace("Return {} current HashDataInput(s).", hashDataInputs.size());
return hashDataInputs;
}
}
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 c8ab280f..e32dad8f 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
@@ -16,13 +16,30 @@
*/
package at.gv.egiz.stal.service.impl;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.List;
+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.slf4j.MDC;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
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;
import at.gv.egiz.bku.binding.IdFactory;
-
import at.gv.egiz.stal.HashDataInput;
import at.gv.egiz.stal.service.GetHashDataInputFault;
import at.gv.egiz.stal.service.STALPortType;
@@ -38,25 +55,8 @@ 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.service.types.GetHashDataInputType.Reference;
-//import at.gv.egiz.stal.service.types.GetHashDataInputResponseType.Reference;
import com.sun.xml.ws.developer.UsesJAXBContext;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.Charset;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-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;
-import org.apache.commons.logging.LogFactory;
/**
*
@@ -68,10 +68,10 @@ 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);
-
+ private final Logger log = LoggerFactory.getLogger(STALServiceImpl.class);
static {
+ Logger log = LoggerFactory.getLogger(STALServiceImpl.class);
if (log.isTraceEnabled()) {
log.trace("enabling webservice communication dump");
System.setProperty("com.sun.xml.ws.transport.http.HttpAdapter.dump", "true");
@@ -91,227 +91,242 @@ public class STALServiceImpl implements STALPortType {
public GetNextRequestResponseType connect(String sessId) {
if (sessId == null) {
- throw new NullPointerException("No session id provided");
+ throw new NullPointerException("No session id provided.");
}
Id sessionId = idF.createId(sessId);
+ MDC.put("id", sessionId.toString());
- 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());
-
- STALRequestBroker stal = getStal(sessionId);
-
- if (stal != null) {
-
- List<JAXBElement<? extends RequestType>> requestsOut = ((STALRequestBroker) stal).connect();
- response.getInfoboxReadRequestOrSignRequestOrQuitRequest().addAll(requestsOut);
-
- if (log.isDebugEnabled()) {
- StringBuilder sb = new StringBuilder("Returning initial GetNextRequestResponse [");
- sb.append(sessionId.toString());
- sb.append("] containing ");
- sb.append(requestsOut.size());
- sb.append(" requests: ");
- for (JAXBElement<? extends RequestType> reqOut : requestsOut) {
- sb.append(reqOut.getValue().getClass());
- sb.append(' ');
+ try {
+ log.debug("Received Connect.");
+
+ if (TEST_SESSION_ID.equals(sessionId)) {
+ return getTestSessionNextRequestResponse(null);
+ }
+
+ GetNextRequestResponseType response = new GetNextRequestResponseType();
+ response.setSessionId(sessionId.toString());
+
+ STALRequestBroker stal = getStal(sessionId);
+
+ if (stal != null) {
+
+ List<JAXBElement<? extends RequestType>> requestsOut = ((STALRequestBroker) stal).connect();
+ response.getInfoboxReadRequestOrSignRequestOrQuitRequest().addAll(requestsOut);
+
+ if (log.isDebugEnabled()) {
+ StringBuilder sb = new StringBuilder("Returning initial GetNextRequestResponse containing ");
+ sb.append(requestsOut.size());
+ sb.append(" requests: ");
+ for (JAXBElement<? extends RequestType> reqOut : requestsOut) {
+ sb.append(reqOut.getValue().getClass());
+ sb.append(' ');
+ }
+ log.debug(sb.toString());
}
- log.debug(sb.toString());
+ } else {
+ log.error("Failed to get STAL, returning QuitRequest.");
+ QuitRequestType quitT = stalObjFactory.createQuitRequestType();
+ JAXBElement<QuitRequestType> quit = stalObjFactory.createGetNextRequestResponseTypeQuitRequest(quitT);
+ response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(quit);
}
- } else {
- log.error("Failed to get STAL for session " + sessionId + ", returning QuitRequest");
- QuitRequestType quitT = stalObjFactory.createQuitRequestType();
- JAXBElement<QuitRequestType> quit = stalObjFactory.createGetNextRequestResponseTypeQuitRequest(quitT);
- response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(quit);
+ return response;
+
+ } finally {
+ MDC.remove("id");
}
- return response;
}
@Override
public GetNextRequestResponseType getNextRequest(GetNextRequestType request) {
if (request.getSessionId() == null) {
- throw new NullPointerException("No session id provided");
+ throw new NullPointerException("No session id provided.");
}
Id sessionId = idF.createId(request.getSessionId());
+ MDC.put("id", sessionId.toString());
- List<JAXBElement<? extends ResponseType>> responsesIn = request.getInfoboxReadResponseOrSignResponseOrErrorResponse();
-// List<ResponseType> responsesIn = request.getInfoboxReadResponseOrSignResponseOrErrorResponse();//getResponse();
+ try {
- if (log.isDebugEnabled()) {
- StringBuilder sb = new StringBuilder("Received GetNextRequest [");
- sb.append(sessionId.toString());
- sb.append("] containing ");
- sb.append(responsesIn.size());
- sb.append(" responses: ");
- for (JAXBElement<? extends ResponseType> respIn : responsesIn) {
- sb.append(respIn.getValue().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<JAXBElement<? extends RequestType>> requestsOut = ((STALRequestBroker) stal).nextRequest(responsesIn);
- response.getInfoboxReadRequestOrSignRequestOrQuitRequest().addAll(requestsOut);
+ List<JAXBElement<? extends ResponseType>> responsesIn = request.getInfoboxReadResponseOrSignResponseOrErrorResponse();
if (log.isDebugEnabled()) {
- StringBuilder sb = new StringBuilder("Returning GetNextRequestResponse [");
- sb.append(sessionId.toString());
- sb.append("] containing ");
- sb.append(requestsOut.size());
- sb.append(" requests: ");
- for (JAXBElement<? extends RequestType> reqOut : requestsOut) {
- sb.append(reqOut.getValue().getClass());
+ StringBuilder sb = new StringBuilder("Received GetNextRequest containing ");
+ sb.append(responsesIn.size());
+ sb.append(" responses: ");
+ for (JAXBElement<? extends ResponseType> respIn : responsesIn) {
+ sb.append(respIn.getValue().getClass());
sb.append(' ');
}
log.debug(sb.toString());
}
- } else {
- log.error("Failed to get STAL for session " + sessionId + ", returning QuitRequest");
- QuitRequestType quitT = stalObjFactory.createQuitRequestType();
- JAXBElement<QuitRequestType> quit = stalObjFactory.createGetNextRequestResponseTypeQuitRequest(quitT);
- response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(quit);
+
+ 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<JAXBElement<? extends RequestType>> requestsOut = ((STALRequestBroker) stal).nextRequest(responsesIn);
+ response.getInfoboxReadRequestOrSignRequestOrQuitRequest().addAll(requestsOut);
+
+ if (log.isDebugEnabled()) {
+ StringBuilder sb = new StringBuilder("Returning GetNextRequestResponse containing ");
+ sb.append(requestsOut.size());
+ sb.append(" requests: ");
+ for (JAXBElement<? extends RequestType> reqOut : requestsOut) {
+ sb.append(reqOut.getValue().getClass());
+ sb.append(' ');
+ }
+ log.debug(sb.toString());
+ }
+ } else {
+ log.error("Failed to get STAL, returning QuitRequest.");
+ QuitRequestType quitT = stalObjFactory.createQuitRequestType();
+ JAXBElement<QuitRequestType> quit = stalObjFactory.createGetNextRequestResponseTypeQuitRequest(quitT);
+ response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(quit);
+ }
+ return response;
+
+ } finally {
+ MDC.remove("id");
}
- return response;
}
@Override
public GetHashDataInputResponseType getHashDataInput(GetHashDataInputType request) throws GetHashDataInputFault {
if (request.getSessionId() == null) {
- throw new NullPointerException("No session id provided");
+ throw new NullPointerException("No session id provided.");
}
Id sessionId = idF.createId(request.getSessionId());
+ MDC.put("id", sessionId.toString());
- if (log.isDebugEnabled()) {
- log.debug("Received GetHashDataInputRequest for session " + sessionId + " containing " + request.getReference().size() + " reference(s)");
- }
-
- if (TEST_SESSION_ID.equals(sessionId)) {
- return getTestSessionHashDataInputResponse(request.getReference());
- }
-
- GetHashDataInputResponseType response = new GetHashDataInputResponseType();
- response.setSessionId(sessionId.toString());
-
- STALRequestBroker stal = getStal(sessionId);
-
- if (stal != null) {
- List<HashDataInput> hashDataInputs = stal.getHashDataInput();
-
- if (hashDataInputs != null) {
-
- Map<String, HashDataInput> hashDataIdMap = new HashMap<String, HashDataInput>();
- for (HashDataInput hdi : hashDataInputs) {
- if (log.isTraceEnabled()) {
- log.trace("Provided HashDataInput for reference " + hdi.getReferenceId());
- }
- hashDataIdMap.put(hdi.getReferenceId(), hdi);
- }
-
- List<GetHashDataInputType.Reference> reqRefs = request.getReference();
- for (GetHashDataInputType.Reference reqRef : reqRefs) {
- String reqRefId = reqRef.getID();
- HashDataInput reqHdi = hashDataIdMap.get(reqRefId);
- if (reqHdi == null) {
- String msg = "Failed to resolve HashDataInput for reference " + reqRefId;
- log.error(msg);
- GetHashDataInputFaultType faultInfo = new GetHashDataInputFaultType();
- faultInfo.setErrorCode(1);
- faultInfo.setErrorMessage(msg);
- throw new GetHashDataInputFault(msg, faultInfo);
- }
-
- InputStream hashDataIS = reqHdi.getHashDataInput();
- if (hashDataIS == null) {
- //HashDataInput not cached?
- String msg = "Failed to obtain HashDataInput for reference " + reqRefId + ", reference not cached";
- log.error(msg);
- GetHashDataInputFaultType faultInfo = new GetHashDataInputFaultType();
- faultInfo.setErrorCode(1);
- faultInfo.setErrorMessage(msg);
- throw new GetHashDataInputFault(msg, faultInfo);
+ try {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Received GetHashDataInputRequest containing {} reference(s).", request.getReference().size());
+ }
+
+ if (TEST_SESSION_ID.equals(sessionId)) {
+ return getTestSessionHashDataInputResponse(request.getReference());
+ }
+
+ GetHashDataInputResponseType response = new GetHashDataInputResponseType();
+ response.setSessionId(sessionId.toString());
+
+ STALRequestBroker stal = getStal(sessionId);
+
+ if (stal != null) {
+ List<HashDataInput> hashDataInputs = stal.getHashDataInput();
+
+ if (hashDataInputs != null) {
+
+ Map<String, HashDataInput> hashDataIdMap = new HashMap<String, HashDataInput>();
+ for (HashDataInput hdi : hashDataInputs) {
+ if (log.isTraceEnabled()) {
+ log.trace("Provided HashDataInput for reference {}.", hdi.getReferenceId());
+ }
+ hashDataIdMap.put(hdi.getReferenceId(), hdi);
}
- ByteArrayOutputStream baos = null;
- try {
- if (log.isDebugEnabled()) {
- log.debug("Resolved HashDataInput " + reqRefId + " (" + reqHdi.getMimeType() + ";charset=" + reqHdi.getEncoding() + ")");
+
+ List<GetHashDataInputType.Reference> reqRefs = request.getReference();
+ for (GetHashDataInputType.Reference reqRef : reqRefs) {
+ String reqRefId = reqRef.getID();
+ HashDataInput reqHdi = hashDataIdMap.get(reqRefId);
+ if (reqHdi == null) {
+ String msg = "Failed to resolve HashDataInput for reference " + reqRefId;
+ log.error(msg);
+ GetHashDataInputFaultType faultInfo = new GetHashDataInputFaultType();
+ faultInfo.setErrorCode(1);
+ faultInfo.setErrorMessage(msg);
+ throw new GetHashDataInputFault(msg, faultInfo);
}
- baos = new ByteArrayOutputStream(hashDataIS.available());
- int c;
- while ((c = hashDataIS.read()) != -1) {
- baos.write(c);
+
+ InputStream hashDataIS = reqHdi.getHashDataInput();
+ if (hashDataIS == null) {
+ //HashDataInput not cached?
+ String msg = "Failed to obtain HashDataInput for reference " + reqRefId + ", reference not cached";
+ log.error(msg);
+ GetHashDataInputFaultType faultInfo = new GetHashDataInputFaultType();
+ faultInfo.setErrorCode(1);
+ faultInfo.setErrorMessage(msg);
+ throw new GetHashDataInputFault(msg, faultInfo);
}
- GetHashDataInputResponseType.Reference ref = new GetHashDataInputResponseType.Reference();
- ref.setID(reqRefId);
- ref.setMimeType(reqHdi.getMimeType());
- ref.setEncoding(reqHdi.getEncoding());
- ref.setFilename(reqHdi.getFilename());
- ref.setValue(baos.toByteArray());
- response.getReference().add(ref);
- } catch (IOException ex) {
- String msg = "Failed to get HashDataInput for reference " + reqRefId;
- log.error(msg, ex);
- GetHashDataInputFaultType faultInfo = new GetHashDataInputFaultType();
- faultInfo.setErrorCode(1);
- faultInfo.setErrorMessage(msg);
- throw new GetHashDataInputFault(msg, faultInfo, ex);
- } finally {
+ ByteArrayOutputStream baos = null;
try {
- baos.close();
+ if (log.isDebugEnabled()) {
+ Object[] args = {reqRefId, reqHdi.getMimeType(), reqHdi.getEncoding()};
+ log.debug("Resolved HashDataInput {} ({};charset={}).", args);
+ }
+ baos = new ByteArrayOutputStream(hashDataIS.available());
+ int c;
+ while ((c = hashDataIS.read()) != -1) {
+ baos.write(c);
+ }
+ GetHashDataInputResponseType.Reference ref = new GetHashDataInputResponseType.Reference();
+ ref.setID(reqRefId);
+ ref.setMimeType(reqHdi.getMimeType());
+ ref.setEncoding(reqHdi.getEncoding());
+ ref.setFilename(reqHdi.getFilename());
+ ref.setValue(baos.toByteArray());
+ response.getReference().add(ref);
} catch (IOException ex) {
+ String msg = "Failed to get HashDataInput for reference " + reqRefId;
+ log.error(msg, ex);
+ GetHashDataInputFaultType faultInfo = new GetHashDataInputFaultType();
+ faultInfo.setErrorCode(1);
+ faultInfo.setErrorMessage(msg);
+ throw new GetHashDataInputFault(msg, faultInfo, ex);
+ } finally {
+ try {
+ baos.close();
+ } catch (IOException ex) {
+ }
}
}
+ return response;
+ } else {
+ String msg = "Failed to resolve any HashDataInputs.";
+ log.error(msg);
+ GetHashDataInputFaultType faultInfo = new GetHashDataInputFaultType();
+ faultInfo.setErrorCode(1);
+ faultInfo.setErrorMessage(msg);
+ throw new GetHashDataInputFault(msg, faultInfo);
}
- return response;
} else {
- String msg = "Failed to resolve any HashDataInputs for session " + sessionId;
+ String msg = "Session timeout."; //Failed to get STAL for session " + sessionId;
log.error(msg);
GetHashDataInputFaultType faultInfo = new GetHashDataInputFaultType();
faultInfo.setErrorCode(1);
faultInfo.setErrorMessage(msg);
throw new GetHashDataInputFault(msg, faultInfo);
}
- } else {
- String msg = "Session timeout"; //Failed to get STAL for session " + sessionId;
- log.error(msg + " " + sessionId);
- GetHashDataInputFaultType faultInfo = new GetHashDataInputFaultType();
- faultInfo.setErrorCode(1);
- faultInfo.setErrorMessage(msg);
- throw new GetHashDataInputFault(msg, faultInfo);
+
+ } finally {
+ MDC.remove("id");
}
}
private STALRequestBroker getStal(Id sessionId) {
- if (log.isTraceEnabled()) {
- log.trace("resolve STAL for session " + sessionId);
- }
+ 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());
+ BindingProcessor bindingProcessor = bpMgr.getBindingProcessor(sessionId);
+ if (bindingProcessor != null) {
+ if (bindingProcessor.getSTAL() instanceof STALRequestBroker) {
+ return (STALRequestBroker) bindingProcessor.getSTAL();
+ }
+ }
+ return null;
}
private GetNextRequestResponseType getTestSessionNextRequestResponse(List<JAXBElement<? extends ResponseType>> responsesIn) {
@@ -359,6 +374,7 @@ public class STALServiceImpl implements STALPortType {
return response;
}
+ @SuppressWarnings("unused")
private void addTestCardChannelRequest(List<JAXBElement<? extends RequestType>> requestList) {
log.info("[TestSession] add CARDCHANNEL request");
ScriptType scriptT = ccObjFactory.createScriptType();
@@ -368,6 +384,7 @@ public class STALServiceImpl implements STALPortType {
requestList.add(ccObjFactory.createScript(scriptT));
}
+ @SuppressWarnings("unused")
private void addTestInfoboxReadRequest(String infoboxIdentifier, List<JAXBElement<? extends RequestType>> requestList) {
log.info("[TestSession] add READ "+ infoboxIdentifier + " request");
InfoboxReadRequestType ibrT = stalObjFactory.createInfoboxReadRequestType();
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
index 9caf950f..300f01d0 100644
--- 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
@@ -23,8 +23,8 @@ 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;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -32,8 +32,9 @@ import org.apache.commons.logging.LogFactory;
*/
public class STALXJAXBContextFactory implements JAXBContextFactory {
- private static final Log log = LogFactory.getLog(STALXJAXBContextFactory.class);
+ private final Logger log = LoggerFactory.getLogger(STALXJAXBContextFactory.class);
+ @SuppressWarnings("unchecked")
@Override
public JAXBRIContext createJAXBContext(SEIModel sei, List<Class> classesToBind, List<TypeReference> typeReferences) throws JAXBException {
if (log.isTraceEnabled()) {
diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/TestSignatureData.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/TestSignatureData.java
index 2f58bb3d..45efc890 100644
--- a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/TestSignatureData.java
+++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/TestSignatureData.java
@@ -6,13 +6,11 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public final class TestSignatureData {
- protected final static Log log = LogFactory.getLog(TestSignatureData.class);
-
public static final String[] ID = new String[] {"signed-data-reference-0-1214921968-27971781-24309", "signed-data-reference-1"};
public static final String ENCODING = "UTF-8";
@@ -22,6 +20,7 @@ public final class TestSignatureData {
HASHDATA_INPUT.put(ID[0], "Ich bin ein einfacher Text. lläöü߀".getBytes(ENCODING));
HASHDATA_INPUT.put(ID[1], "2te referenz".getBytes(ENCODING));
} catch (UnsupportedEncodingException ex) {
+ Logger log = LoggerFactory.getLogger(TestSignatureData.class);
log.error("failed to init signature test data", ex);
}
}