diff options
author | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2013-12-20 12:35:28 +0100 |
---|---|---|
committer | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2013-12-20 12:35:28 +0100 |
commit | defceef8afef538555c13d33e344a89a828a3d97 (patch) | |
tree | 24b44f970f161d5b139dde501ca0f5d883f9fdea /src/main/java/at/gv/util/client/misstork | |
download | egovutils-defceef8afef538555c13d33e344a89a828a3d97.tar.gz egovutils-defceef8afef538555c13d33e344a89a828a3d97.tar.bz2 egovutils-defceef8afef538555c13d33e344a89a828a3d97.zip |
inital
Diffstat (limited to 'src/main/java/at/gv/util/client/misstork')
-rw-r--r-- | src/main/java/at/gv/util/client/misstork/MISSTORKClient.java | 98 | ||||
-rw-r--r-- | src/main/java/at/gv/util/client/misstork/MISSTORKClientException.java | 23 |
2 files changed, 121 insertions, 0 deletions
diff --git a/src/main/java/at/gv/util/client/misstork/MISSTORKClient.java b/src/main/java/at/gv/util/client/misstork/MISSTORKClient.java new file mode 100644 index 0000000..ca4173d --- /dev/null +++ b/src/main/java/at/gv/util/client/misstork/MISSTORKClient.java @@ -0,0 +1,98 @@ +package at.gv.util.client.misstork; + +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.annotation.Resource; +import javax.net.ssl.SSLContext; +import javax.xml.namespace.QName; +import javax.xml.ws.BindingProvider; +import javax.xml.ws.WebServiceContext; +import javax.xml.ws.handler.Handler; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.gv.util.LaxHostNameVerifier; +import at.gv.util.LoggingHandler; +import at.gv.util.MiscUtil; +import at.gv.util.client.moaid.MOAIDClient; +import at.gv.util.config.EgovUtilConfiguration; +import at.gv.util.ex.EgovUtilException; +import at.gv.util.wsdl.mis.MandateIssuePortType; +import at.gv.util.wsdl.mis.MandateIssueService; +import at.gv.util.wsdl.misstork.MISSTORKService; +import at.gv.util.wsdl.misstork.MISSTORKType; +import at.gv.util.wsdl.misstork.MisStorkError; +import at.gv.util.wsdl.szr.SZRException; +import at.gv.util.xsd.mis.MandateIssueRequestType; +import at.gv.util.xsd.mis.MandateIssueResponseType; +import at.gv.util.xsd.misstork.MisStorkRequest; +import at.gv.util.xsd.misstork.MisStorkResponse; + +import com.sun.xml.ws.developer.JAXWSProperties; + +public class MISSTORKClient { + + @Resource + WebServiceContext wsContext; + + private EgovUtilConfiguration config = null; + Logger log = LoggerFactory.getLogger(MISSTORKClient.class); + + public MISSTORKClient() {} + + public MISSTORKClient(EgovUtilConfiguration config) { + if (config == null) { + throw new NullPointerException("Parameter config must not be null."); + } + this.config = config; + + + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + public MisStorkResponse sendMISSTORKRequest(MisStorkRequest mir, String misSTORKServiceURL) throws MisStorkError, EgovUtilException { + MiscUtil.assertNotNull(mir, "mir"); + MiscUtil.assertNotNull(misSTORKServiceURL, "misServiceURL"); + + URL url = MOAIDClient.class.getResource("/wsdl/misstork/misstork.wsdl"); + MISSTORKService service = new MISSTORKService(url, new QName("http://reference.e-government.gv.at/namespace/misstork/20131126/wsdl", "MISSTORKService")); + MISSTORKType port = service.getMISSTORKPort(); + + log.debug("MISSTORK connection URL: " + misSTORKServiceURL); + BindingProvider bindingProvider = (BindingProvider) port; + Map<String, Object> requestContext = bindingProvider.getRequestContext(); + requestContext.put( + BindingProvider.ENDPOINT_ADDRESS_PROPERTY, misSTORKServiceURL); + + log.trace("Adding JAX-WS request/response trace handler."); + List<Handler> handlerList = bindingProvider.getBinding().getHandlerChain(); + if (handlerList == null) { + handlerList = new ArrayList(); + } + LoggingHandler loggingHandler = new LoggingHandler(); + handlerList.add(loggingHandler); + bindingProvider.getBinding().setHandlerChain(handlerList); + + // check for ssl + if (misSTORKServiceURL.toLowerCase().startsWith("https")) { + log.trace("Using ssl for MISSTORK client request."); + SSLContext sslContext = config.getMISSTORKsslConfiguration().getSSLContext(false); + if (sslContext == null) { + throw new EgovUtilException("SSL context from configuration is empty. Please configure an SSL context in the configuration first."); + } + requestContext.put(JAXWSProperties.SSL_SOCKET_FACTORY, sslContext.getSocketFactory()); + + // check for lax hostname + if (this.config.getMISsslConfiguration().useLaxHostNameVerifier()) { + log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); + requestContext.put(JAXWSProperties.HOSTNAME_VERIFIER, new LaxHostNameVerifier()); + } + } + return port.misstorkOperation(mir); + } + +} diff --git a/src/main/java/at/gv/util/client/misstork/MISSTORKClientException.java b/src/main/java/at/gv/util/client/misstork/MISSTORKClientException.java new file mode 100644 index 0000000..19b4cb2 --- /dev/null +++ b/src/main/java/at/gv/util/client/misstork/MISSTORKClientException.java @@ -0,0 +1,23 @@ +package at.gv.util.client.misstork; + +public class MISSTORKClientException extends Exception { + + private static final long serialVersionUID = 5173056345209288701L; + + public MISSTORKClientException() { + super(); + } + + public MISSTORKClientException(String message, Throwable cause) { + super(message, cause); + } + + public MISSTORKClientException(String message) { + super(message); + } + + public MISSTORKClientException(Throwable cause) { + super(cause); + } + +} |