summaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/util/client/mis_v2
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2019-10-01 10:57:01 +0200
committerThomas Lenz <thomas.lenz@egiz.gv.at>2019-10-01 10:57:01 +0200
commitdf2ba23f9479f37c11a7a23b697b5acaa4e97d33 (patch)
treeea042bb74cab85c45f47f84ff864ab808f72342b /src/main/java/at/gv/util/client/mis_v2
parentdcd678d6ac5ededc8b58b5d473cf12acfdbd8598 (diff)
downloadegovutils-df2ba23f9479f37c11a7a23b697b5acaa4e97d33.tar.gz
egovutils-df2ba23f9479f37c11a7a23b697b5acaa4e97d33.tar.bz2
egovutils-df2ba23f9479f37c11a7a23b697b5acaa4e97d33.zip
update MIS v2.0 end-point implementation
add MISV2Client.java for testing
Diffstat (limited to 'src/main/java/at/gv/util/client/mis_v2')
-rw-r--r--src/main/java/at/gv/util/client/mis_v2/MISV2Client.java117
1 files changed, 117 insertions, 0 deletions
diff --git a/src/main/java/at/gv/util/client/mis_v2/MISV2Client.java b/src/main/java/at/gv/util/client/mis_v2/MISV2Client.java
new file mode 100644
index 0000000..ed145f5
--- /dev/null
+++ b/src/main/java/at/gv/util/client/mis_v2/MISV2Client.java
@@ -0,0 +1,117 @@
+package at.gv.util.client.mis_v2;
+
+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.apache.cxf.configuration.jsse.TLSClientParameters;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.transport.http.HTTPConduit;
+import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
+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.client.szr.SZRClient;
+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.mis_v2.GetMandatesError;
+import at.gv.util.wsdl.mis_v2.GetMandatesPortType;
+import at.gv.util.wsdl.mis_v2.GetMandatesService;
+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.mis_v2.GetMandatesRequestType;
+import at.gv.util.xsd.mis_v2.GetMandatesResponseType;
+
+public class MISV2Client {
+
+ @Resource WebServiceContext wsContext;
+
+ private EgovUtilConfiguration config = null;
+ Logger log = LoggerFactory.getLogger(MISV2Client.class);
+
+ private GetMandatesService service;
+
+ public MISV2Client() {}
+
+ public MISV2Client(EgovUtilConfiguration config) {
+ if (config == null) {
+ throw new NullPointerException("Parameter config must not be null.");
+ }
+ this.config = config;
+
+ URL url = MISV2Client.class.getResource("/wsdl/mis/mis_2.0/mis-2.0.0.wsdl");
+ service = new GetMandatesService(url);
+
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public GetMandatesResponseType sendMandateIssueRequest(GetMandatesRequestType getMandatesRequest, String misServiceURL) throws SZRException, EgovUtilException, GetMandatesError {
+ MiscUtil.assertNotNull(getMandatesRequest, "mir");
+ MiscUtil.assertNotNull(misServiceURL, "misServiceURL");
+
+
+ GetMandatesPortType port = service.getGetMandatesPort();
+
+ log.debug("MIS v2.0 connection URL: " + misServiceURL);
+ BindingProvider bindingProvider = (BindingProvider) port;
+ Map<String, Object> requestContext = bindingProvider.getRequestContext();
+ requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, misServiceURL);
+
+ 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 (misServiceURL.toLowerCase().startsWith("https")) {
+ log.trace("Using ssl for MIS client request.");
+ SSLContext sslContext = config.getMMSsslConfiguration().getSSLContext(false);
+ if (sslContext == null) {
+ throw new EgovUtilException("SSL context from configuration is empty. Please configure an SSL context in the configuration first.");
+ }
+ Client client = ClientProxy.getClient(port);
+ HTTPConduit http = (HTTPConduit) client.getConduit();
+ HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
+
+ httpClientPolicy.setConnectionTimeout(36000);
+ httpClientPolicy.setAllowChunking(false);
+ httpClientPolicy.setReceiveTimeout(32000);
+
+ http.setClient(httpClientPolicy);
+
+ TLSClientParameters tlsParams = new TLSClientParameters();
+ tlsParams.setSSLSocketFactory(sslContext.getSocketFactory());
+
+ // check for lax hostname
+ if (this.config.getMISsslConfiguration().useLaxHostNameVerifier()) {
+ log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use.");
+ tlsParams.setHostnameVerifier(new LaxHostNameVerifier());
+ }
+
+ http.setTlsClientParameters(tlsParams );
+ }
+ return port.getMandatesOperation(getMandatesRequest);
+
+ }
+
+}