From e2150f22562b4bc06307f4ac7b842687390e4856 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Thu, 16 Oct 2014 13:42:04 +0200 Subject: change webservice implementation to Apache CXF --- .../java/at/gv/util/client/moaid/MOAIDClient.java | 34 ++++++++++++++++------ 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'src/main/java/at/gv/util/client/moaid') 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 -- cgit v1.2.3