diff options
author | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2014-10-16 13:42:04 +0200 |
---|---|---|
committer | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2014-10-16 13:42:04 +0200 |
commit | e2150f22562b4bc06307f4ac7b842687390e4856 (patch) | |
tree | 768250437cca30ab4fda039d924269e37fd99414 /src/main/java/at/gv/util/client | |
parent | 2f3b7f180511a5e0af674e3a25ddbaabaa38d36c (diff) | |
download | egovutils-e2150f22562b4bc06307f4ac7b842687390e4856.tar.gz egovutils-e2150f22562b4bc06307f4ac7b842687390e4856.tar.bz2 egovutils-e2150f22562b4bc06307f4ac7b842687390e4856.zip |
change webservice implementation to Apache CXF
Diffstat (limited to 'src/main/java/at/gv/util/client')
12 files changed, 328 insertions, 129 deletions
diff --git a/src/main/java/at/gv/util/client/ersb/ERsBClient.java b/src/main/java/at/gv/util/client/ersb/ERsBClient.java index 5f68ea5..e15c844 100644 --- a/src/main/java/at/gv/util/client/ersb/ERsBClient.java +++ b/src/main/java/at/gv/util/client/ersb/ERsBClient.java @@ -12,6 +12,11 @@ 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; @@ -27,8 +32,6 @@ import at.gv.util.xsd.ersb.ErsbRequest; import at.gv.util.xsd.ersb.ErsbResponse; import at.gv.util.xsd.szr.pvp.PvpTokenType; -import com.sun.xml.ws.developer.JAXWSProperties; - public class ERsBClient { @Resource @@ -88,13 +91,26 @@ public class ERsBClient { 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()); + 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.getERsBsslConfiguration().useLaxHostNameVerifier()) { log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); - requestContext.put(JAXWSProperties.HOSTNAME_VERIFIER, new LaxHostNameVerifier()); + tlsParams.setHostnameVerifier(new LaxHostNameVerifier()); } + + http.setTlsClientParameters(tlsParams ); } return port.ersb(mir); diff --git a/src/main/java/at/gv/util/client/mis/MISClient.java b/src/main/java/at/gv/util/client/mis/MISClient.java index 88afc8b..722db42 100644 --- a/src/main/java/at/gv/util/client/mis/MISClient.java +++ b/src/main/java/at/gv/util/client/mis/MISClient.java @@ -12,6 +12,11 @@ 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; @@ -27,8 +32,6 @@ import at.gv.util.wsdl.szr.SZRException; import at.gv.util.xsd.mis.MandateIssueRequestType; import at.gv.util.xsd.mis.MandateIssueResponseType; -import com.sun.xml.ws.developer.JAXWSProperties; - public class MISClient { @Resource @@ -79,13 +82,26 @@ public class MISClient { 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()); - } + 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.mandateIssueOperation(mir); } diff --git a/src/main/java/at/gv/util/client/mis/usp/USPClient.java b/src/main/java/at/gv/util/client/mis/usp/USPClient.java index ac8315a..fb88e05 100644 --- a/src/main/java/at/gv/util/client/mis/usp/USPClient.java +++ b/src/main/java/at/gv/util/client/mis/usp/USPClient.java @@ -15,6 +15,11 @@ import javax.xml.ws.WebServiceContext; import javax.xml.ws.handler.Handler; import org.apache.commons.lang.RandomStringUtils; +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; @@ -32,8 +37,6 @@ import at.gv.util.xsd.mis.usp.GetMandatesResponse; import at.gv.util.xsd.mis.usp.IdentificationType; import at.gv.util.xsd.szr.pvp.PvpTokenType; -import com.sun.xml.ws.developer.JAXWSProperties; - public class USPClient { @Resource @@ -122,10 +125,16 @@ public class USPClient { handlerList.add(szrSOAPHandler); bindingProvider.getBinding().setHandlerChain(handlerList); - + Client client = ClientProxy.getClient(uspSuche); + HTTPConduit http = (HTTPConduit) client.getConduit(); + HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); + //set HTTP Client Timeout (Default Timeout 60sec) - requestContext.put(JAXWSProperties.CONNECT_TIMEOUT, this.config.getHTTPRequestTimeout()); - + httpClientPolicy.setConnectionTimeout(this.config.getHTTPRequestTimeout()); + httpClientPolicy.setAllowChunking(false); + httpClientPolicy.setReceiveTimeout(32000); + http.setClient(httpClientPolicy); + // check for ssl if (uspURL.toLowerCase().startsWith("https")) { log.trace("Using ssl for SZR client request."); @@ -133,13 +142,15 @@ public class USPClient { 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.getURsslConfiguration().useLaxHostNameVerifier()) { - log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); - requestContext.put(JAXWSProperties.HOSTNAME_VERIFIER, new LaxHostNameVerifier()); - } + TLSClientParameters tlsParams = new TLSClientParameters(); + tlsParams.setSSLSocketFactory(sslContext.getSocketFactory()); + + // check for lax hostname + if (this.config.getUSPsslConfiguration().useLaxHostNameVerifier()) { + log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); + tlsParams.setHostnameVerifier(new LaxHostNameVerifier()); + } + http.setTlsClientParameters(tlsParams ); } } diff --git a/src/main/java/at/gv/util/client/misstork/MISSTORKClient.java b/src/main/java/at/gv/util/client/misstork/MISSTORKClient.java index 2411f54..14eee06 100644 --- a/src/main/java/at/gv/util/client/misstork/MISSTORKClient.java +++ b/src/main/java/at/gv/util/client/misstork/MISSTORKClient.java @@ -12,28 +12,25 @@ 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.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 @@ -84,13 +81,26 @@ public class MISSTORKClient { 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()); - } + 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.misstorkOperation(mir); } diff --git a/src/main/java/at/gv/util/client/mms/MMSClient.java b/src/main/java/at/gv/util/client/mms/MMSClient.java index 1195d3d..45654d3 100644 --- a/src/main/java/at/gv/util/client/mms/MMSClient.java +++ b/src/main/java/at/gv/util/client/mms/MMSClient.java @@ -12,6 +12,11 @@ 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; @@ -27,8 +32,6 @@ import at.gv.util.wsdl.szr.SZRException; import at.gv.util.xsd.mms.GetMandatesRequest; import at.gv.util.xsd.mms.GetMandatesResponse; -import com.sun.xml.ws.developer.JAXWSProperties; - public class MMSClient { @Resource @@ -79,14 +82,27 @@ public class MMSClient { 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.getMMSsslConfiguration().useLaxHostNameVerifier()) { - log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); - requestContext.put(JAXWSProperties.HOSTNAME_VERIFIER, new LaxHostNameVerifier()); + 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.getMMSsslConfiguration().useLaxHostNameVerifier()) { + log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); + tlsParams.setHostnameVerifier(new LaxHostNameVerifier()); + } + + http.setTlsClientParameters(tlsParams ); } - } return port.getMandatesOperation(request); } diff --git a/src/main/java/at/gv/util/client/moaid/MOAIDClient.java b/src/main/java/at/gv/util/client/moaid/MOAIDClient.java index 09f8a57..d755792 100644 --- a/src/main/java/at/gv/util/client/moaid/MOAIDClient.java +++ b/src/main/java/at/gv/util/client/moaid/MOAIDClient.java @@ -16,6 +16,11 @@ import javax.xml.ws.WebServiceContext; import javax.xml.ws.handler.Handler; import org.apache.commons.lang.RandomStringUtils; +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; @@ -30,8 +35,6 @@ import at.gv.util.wsdl.MOAFault; import at.gv.util.xsd.saml.protocol.RequestType; import at.gv.util.xsd.saml.protocol.ResponseType; -import com.sun.xml.ws.developer.JAXWSProperties; - public class MOAIDClient { @Resource @@ -94,13 +97,26 @@ public class MOAIDClient { if (sslContext == null) { throw new MOAIDClientException("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.getMOAIDsslConfiguration().useLaxHostNameVerifier()) { - log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); - requestContext.put(JAXWSProperties.HOSTNAME_VERIFIER, new LaxHostNameVerifier()); - } + 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.getMOAIDsslConfiguration().useLaxHostNameVerifier()) { + log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); + tlsParams.setHostnameVerifier(new LaxHostNameVerifier()); + } + + http.setTlsClientParameters(tlsParams ); } // make simple moa-id request diff --git a/src/main/java/at/gv/util/client/moaspss/MOASPSSClient.java b/src/main/java/at/gv/util/client/moaspss/MOASPSSClient.java index 947b558..9430f97 100644 --- a/src/main/java/at/gv/util/client/moaspss/MOASPSSClient.java +++ b/src/main/java/at/gv/util/client/moaspss/MOASPSSClient.java @@ -39,6 +39,11 @@ import javax.xml.ws.Service; import javax.xml.ws.handler.Handler; import javax.xml.ws.soap.SOAPBinding; +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.apache.xpath.XPathAPI; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -60,8 +65,6 @@ import at.gv.util.xsd.moaspss.VerifyCMSSignatureResponseType; import at.gv.util.xsd.moaspss.VerifyXMLSignatureRequestType; import at.gv.util.xsd.moaspss.VerifyXMLSignatureResponseType; -import com.sun.xml.ws.developer.JAXWSProperties; - /** * MOA-SS client. * @@ -146,15 +149,26 @@ public class MOASPSSClient { throw new MOASPSSClientException( "SSL context from configuration is empty. Please configure an SSL context in the configuration first."); } - requestContext.put(JAXWSProperties.SSL_SOCKET_FACTORY, - sslContext.getSocketFactory()); - + Client client = ClientProxy.getClient(dispatch); + 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.getMOASPSSsslConfiguration().useLaxHostNameVerifier()) { log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); - requestContext.put(JAXWSProperties.HOSTNAME_VERIFIER, - new LaxHostNameVerifier()); + tlsParams.setHostnameVerifier(new LaxHostNameVerifier()); } + + http.setTlsClientParameters(tlsParams ); } log.trace("Invoking MOA-SS signature creation service."); @@ -279,6 +293,7 @@ public class MOASPSSClient { QName qname = new QName( "http://localhost:8080/moa-spss/services/SignatureVerification", "VerifyXMLSignatureRequest"); + service.addPort(qname, SOAPBinding.SOAP11HTTP_BINDING, serviceURL); ByteArrayOutputStream bos = new ByteArrayOutputStream(); @@ -315,15 +330,26 @@ public class MOASPSSClient { throw new MOASPSSClientException( "SSL context from configuration is empty. Please configure an SSL context in the configuration first."); } - requestContext.put(JAXWSProperties.SSL_SOCKET_FACTORY, - sslContext.getSocketFactory()); - + Client client = ClientProxy.getClient(dispatch); + 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.getMOASPSSsslConfiguration().useLaxHostNameVerifier()) { log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); - requestContext.put(JAXWSProperties.HOSTNAME_VERIFIER, - new LaxHostNameVerifier()); + tlsParams.setHostnameVerifier(new LaxHostNameVerifier()); } + + http.setTlsClientParameters(tlsParams ); } log.trace("Invoking MOA-SP signature verification service."); diff --git a/src/main/java/at/gv/util/client/mzs/MOAZSClient.java b/src/main/java/at/gv/util/client/mzs/MOAZSClient.java index dc66a2b..f696b6d 100644 --- a/src/main/java/at/gv/util/client/mzs/MOAZSClient.java +++ b/src/main/java/at/gv/util/client/mzs/MOAZSClient.java @@ -12,6 +12,11 @@ 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; @@ -24,8 +29,6 @@ import at.gv.util.wsdl.mzs.App2MzsPortType; import at.gv.util.xsd.mzs.DeliveryRequestType; import at.gv.util.xsd.mzs.DeliveryResponseType; -import com.sun.xml.ws.developer.JAXWSProperties; - public class MOAZSClient { @Resource @@ -85,13 +88,26 @@ public class MOAZSClient { if (sslContext == null) { throw new MOAZSClientException("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.getMOAIDsslConfiguration().useLaxHostNameVerifier()) { - log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); - requestContext.put(JAXWSProperties.HOSTNAME_VERIFIER, new LaxHostNameVerifier()); - } + 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.getMOAIDsslConfiguration().useLaxHostNameVerifier()) { + log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); + tlsParams.setHostnameVerifier(new LaxHostNameVerifier()); + } + + http.setTlsClientParameters(tlsParams ); } // make simple moa-id request diff --git a/src/main/java/at/gv/util/client/szr/SZRClient.java b/src/main/java/at/gv/util/client/szr/SZRClient.java index 97e3d12..956cebc 100644 --- a/src/main/java/at/gv/util/client/szr/SZRClient.java +++ b/src/main/java/at/gv/util/client/szr/SZRClient.java @@ -13,6 +13,11 @@ import javax.xml.ws.Holder; 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; @@ -31,8 +36,6 @@ import at.gv.util.xsd.szr.PersonInfoType; import at.gv.util.xsd.szr.pvp.PvpTokenType; import at.gv.util.xsd.szr.xmldsig.KeyValueType; -import com.sun.xml.ws.developer.JAXWSProperties; - public class SZRClient { @Resource @@ -158,14 +161,28 @@ public class SZRClient { SSLContext sslContext = this.config.getSZRsslConfiguration().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.getSZRsslConfiguration().useLaxHostNameVerifier()) { - log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); - requestContext.put(JAXWSProperties.HOSTNAME_VERIFIER, new LaxHostNameVerifier()); - } + + } + + Client client = ClientProxy.getClient(szr); + HTTPConduit http = (HTTPConduit) client.getConduit(); + HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); + + httpClientPolicy.setConnectionTimeout(36000); + httpClientPolicy.setReceiveTimeout(32000); + + http.setClient(httpClientPolicy); + + TLSClientParameters tlsParams = new TLSClientParameters(); + tlsParams.setSSLSocketFactory(sslContext.getSocketFactory()); + + // check for lax hostname + if (this.config.getSZRsslConfiguration().useLaxHostNameVerifier()) { + log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); + tlsParams.setHostnameVerifier(new LaxHostNameVerifier()); + } + + http.setTlsClientParameters(tlsParams ); } } diff --git a/src/main/java/at/gv/util/client/ur_V2/URClient.java b/src/main/java/at/gv/util/client/ur_V2/URClient.java index edf68c8..134f7f5 100644 --- a/src/main/java/at/gv/util/client/ur_V2/URClient.java +++ b/src/main/java/at/gv/util/client/ur_V2/URClient.java @@ -18,9 +18,15 @@ import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; import javax.xml.ws.BindingProvider; import javax.xml.ws.WebServiceContext; +import javax.xml.ws.WebServiceException; import javax.xml.ws.handler.Handler; import org.apache.commons.lang.RandomStringUtils; +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; @@ -52,8 +58,6 @@ import at.gv.util.xsd.ur_V2.search.SucheUnternehmenRequest; import at.gv.util.xsd.ur_V2.search.SucheUnternehmensdaten; import at.gv.util.xsd.ur_V2.simpletypes.EvbStatusTyp; -import com.sun.xml.ws.developer.JAXWSProperties; - public class URClient { @Resource @@ -335,7 +339,7 @@ public class URClient { switchTOSecondarySystem(e); srt = this.urSuche.searchByExample(body); - } catch (com.sun.xml.ws.client.ClientTransportException e) { + } catch (WebServiceException e) { //request secondary service switchTOSecondarySystem(e); srt = this.urSuche.searchByExample(body); @@ -383,8 +387,15 @@ public class URClient { requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, urURL); //set HTTP Client Timeout (Default Timeout 60sec) - //requestContext.put(JAXWSProperties.CONNECT_TIMEOUT, this.config.getHTTPRequestTimeout()); - requestContext.put(JAXWSProperties.CONNECT_TIMEOUT, 15000); + Client client = ClientProxy.getClient(urSuche); + HTTPConduit http = (HTTPConduit) client.getConduit(); + HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); + + //set HTTP Client Timeout (Default Timeout 60sec) + httpClientPolicy.setConnectionTimeout(15000); + httpClientPolicy.setAllowChunking(false); + httpClientPolicy.setReceiveTimeout(32000); + http.setClient(httpClientPolicy); //check for ssl if (urURL.toLowerCase().startsWith("https")) { @@ -393,13 +404,15 @@ public class URClient { 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.getURsslConfiguration().useLaxHostNameVerifier()) { - log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); - requestContext.put(JAXWSProperties.HOSTNAME_VERIFIER, new LaxHostNameVerifier()); - } + TLSClientParameters tlsParams = new TLSClientParameters(); + tlsParams.setSSLSocketFactory(sslContext.getSocketFactory()); + + // check for lax hostname + if (this.config.getURsslConfiguration().useLaxHostNameVerifier()) { + log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); + tlsParams.setHostnameVerifier(new LaxHostNameVerifier()); + } + http.setTlsClientParameters(tlsParams ); } } diff --git a/src/main/java/at/gv/util/client/ur_V5/URClient.java b/src/main/java/at/gv/util/client/ur_V5/URClient.java index 537ed25..d54e771 100644 --- a/src/main/java/at/gv/util/client/ur_V5/URClient.java +++ b/src/main/java/at/gv/util/client/ur_V5/URClient.java @@ -18,9 +18,15 @@ import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; import javax.xml.ws.BindingProvider; import javax.xml.ws.WebServiceContext; +import javax.xml.ws.WebServiceException; import javax.xml.ws.handler.Handler; import org.apache.commons.lang.RandomStringUtils; +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; @@ -54,8 +60,6 @@ import at.gv.util.xsd.ur_V5.search.SucheUnternehmenRequest; import at.gv.util.xsd.ur_V5.search.SucheUnternehmensdaten; import at.gv.util.xsd.ur_V5.simpletypes.EvbStatusTyp; -import com.sun.xml.ws.developer.JAXWSProperties; - public class URClient { @Resource @@ -363,7 +367,7 @@ public class URClient { } } - } catch (com.sun.xml.ws.client.ClientTransportException e) { + } catch (WebServiceException e) { //request secondary service switchTOSecondarySystem(e); @@ -432,8 +436,15 @@ public class URClient { requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, urURL); //set HTTP Client Timeout (Default Timeout 60sec) - //requestContext.put(JAXWSProperties.CONNECT_TIMEOUT, this.config.getHTTPRequestTimeout()); - requestContext.put(JAXWSProperties.CONNECT_TIMEOUT, 15000); + Client client = ClientProxy.getClient(urSuche); + HTTPConduit http = (HTTPConduit) client.getConduit(); + HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); + + //set HTTP Client Timeout (Default Timeout 60sec) + httpClientPolicy.setConnectionTimeout(15000); + httpClientPolicy.setAllowChunking(false); + httpClientPolicy.setReceiveTimeout(32000); + http.setClient(httpClientPolicy); //check for ssl if (urURL.toLowerCase().startsWith("https")) { @@ -442,13 +453,15 @@ public class URClient { 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.getURsslConfiguration().useLaxHostNameVerifier()) { - log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); - requestContext.put(JAXWSProperties.HOSTNAME_VERIFIER, new LaxHostNameVerifier()); - } + TLSClientParameters tlsParams = new TLSClientParameters(); + tlsParams.setSSLSocketFactory(sslContext.getSocketFactory()); + + // check for lax hostname + if (this.config.getURsslConfiguration().useLaxHostNameVerifier()) { + log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); + tlsParams.setHostnameVerifier(new LaxHostNameVerifier()); + } + http.setTlsClientParameters(tlsParams ); } } diff --git a/src/main/java/at/gv/util/client/zuserech/ZuseRechClient.java b/src/main/java/at/gv/util/client/zuserech/ZuseRechClient.java index 74ed951..536986a 100644 --- a/src/main/java/at/gv/util/client/zuserech/ZuseRechClient.java +++ b/src/main/java/at/gv/util/client/zuserech/ZuseRechClient.java @@ -12,6 +12,11 @@ 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; @@ -31,8 +36,6 @@ import at.gv.util.xsd.zuserech.ClearingResponseType; import at.gv.util.xsd.zuserech.ValidateTokenRequest; import at.gv.util.xsd.zuserech.ValidateTokenResponse; -import com.sun.xml.ws.developer.JAXWSProperties; - public class ZuseRechClient { @Resource @@ -83,13 +86,26 @@ public class ZuseRechClient { 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.getClearingsslConfiguration().useLaxHostNameVerifier()) { - log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); - requestContext.put(JAXWSProperties.HOSTNAME_VERIFIER, new LaxHostNameVerifier()); - } + 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.getClearingsslConfiguration().useLaxHostNameVerifier()) { + log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); + tlsParams.setHostnameVerifier(new LaxHostNameVerifier()); + } + + http.setTlsClientParameters(tlsParams ); } return port.clearingOperation(csr); } @@ -125,13 +141,26 @@ public class ZuseRechClient { 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.getClearingsslConfiguration().useLaxHostNameVerifier()) { - log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); - requestContext.put(JAXWSProperties.HOSTNAME_VERIFIER, new LaxHostNameVerifier()); - } + 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.getClearingsslConfiguration().useLaxHostNameVerifier()) { + log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); + tlsParams.setHostnameVerifier(new LaxHostNameVerifier()); + } + + http.setTlsClientParameters(tlsParams ); } return port.validateTokenOperation(vtr); } |