From 59a13bea5783aa666bcbcec793df19f129965ff3 Mon Sep 17 00:00:00 2001 From: Christof Rabensteiner Date: Tue, 21 May 2019 13:47:34 +0200 Subject: WIP: SSL Client Auth - Refactor MsgClient: Not a Singleton anymore. Use MsgClientFactory to make a client. Make request and config private fields. - Add configuration parameters to application.yaml. - Init SSL client auth testcase, but dont include in testsuite because it aint working yet. --- src/main/java/at/gv/egiz/moazs/msg/MsgClient.java | 54 ++++++++++++++++++++--- 1 file changed, 47 insertions(+), 7 deletions(-) (limited to 'src/main/java/at/gv/egiz/moazs/msg/MsgClient.java') diff --git a/src/main/java/at/gv/egiz/moazs/msg/MsgClient.java b/src/main/java/at/gv/egiz/moazs/msg/MsgClient.java index 47ee8c3..6f0b1d9 100644 --- a/src/main/java/at/gv/egiz/moazs/msg/MsgClient.java +++ b/src/main/java/at/gv/egiz/moazs/msg/MsgClient.java @@ -4,24 +4,64 @@ import at.gv.zustellung.app2mzs.xsd.ConfigType; import at.gv.zustellung.msg.xsd.App2ZusePort; import at.gv.zustellung.msg.xsd.DeliveryRequestStatusType; import at.gv.zustellung.msg.xsd.DeliveryRequestType; +import org.apache.cxf.jaxws.JaxWsClientFactoryBean; import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; -import org.springframework.stereotype.Component; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Component public class MsgClient { - public DeliveryRequestStatusType send(DeliveryRequestType msgRequest, ConfigType config) { - var address = config.getServer().getZUSEUrlID(); - var proxy = connect(address); + private static final Logger log = LoggerFactory.getLogger(MsgClient.class); + + private final DeliveryRequestType msgRequest; + private final ConfigType config; + + MsgClient(DeliveryRequestType msgRequest, ConfigType config) { + this.msgRequest = msgRequest; + this.config = config; + } + + public DeliveryRequestStatusType send() { + + var proxy = connect(config); + return proxy.delivery(msgRequest); } - private App2ZusePort connect(String address) { + private App2ZusePort connect(ConfigType config) { + + new JaxWsClientFactoryBean(); + + var address = config.getServer().getZUSEUrlID(); var factory = new JaxWsProxyFactoryBean(); factory.setServiceClass(App2ZusePort.class); factory.setAddress(address); - return (App2ZusePort) factory.create(); + + var proxy = factory.create(); + +// var client = ClientProxy.getClient(proxy); +// var conduit = (HTTPConduit) client.getConduit(); +// +// if (addressIsHttps(address)) { +// var tlsParams = new TLSClientParameters(); +// tlsParams.setSSLSocketFactory(createSSLContext().getSocketFactory()); +// conduit.setTlsClientParameters(tlsParams); +// } + + return (App2ZusePort) proxy; + } + +// private SSLContext createSSLContext() { +// java.util.Properties props = new Properties(); +// props.entrySet(); +// +// // return SSLUtils.getPropertiesSSLContext(this.props, this.configDir, this.propsPrefix, forceTrustAllManager); +// return null; +// } + + private boolean addressIsHttps(String address) { + return address.startsWith("https://"); } } -- cgit v1.2.3