summaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/util/client/mzs
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2013-12-20 12:35:28 +0100
committerThomas Lenz <thomas.lenz@egiz.gv.at>2013-12-20 12:35:28 +0100
commitdefceef8afef538555c13d33e344a89a828a3d97 (patch)
tree24b44f970f161d5b139dde501ca0f5d883f9fdea /src/main/java/at/gv/util/client/mzs
downloadegovutils-defceef8afef538555c13d33e344a89a828a3d97.tar.gz
egovutils-defceef8afef538555c13d33e344a89a828a3d97.tar.bz2
egovutils-defceef8afef538555c13d33e344a89a828a3d97.zip
inital
Diffstat (limited to 'src/main/java/at/gv/util/client/mzs')
-rw-r--r--src/main/java/at/gv/util/client/mzs/MOAZSClient.java106
-rw-r--r--src/main/java/at/gv/util/client/mzs/MOAZSClientException.java23
2 files changed, 129 insertions, 0 deletions
diff --git a/src/main/java/at/gv/util/client/mzs/MOAZSClient.java b/src/main/java/at/gv/util/client/mzs/MOAZSClient.java
new file mode 100644
index 0000000..dc66a2b
--- /dev/null
+++ b/src/main/java/at/gv/util/client/mzs/MOAZSClient.java
@@ -0,0 +1,106 @@
+package at.gv.util.client.mzs;
+
+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.config.EgovUtilConfiguration;
+import at.gv.util.ex.EgovUtilException;
+import at.gv.util.wsdl.mzs.App2Mzs;
+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
+ WebServiceContext wsContext;
+
+ private EgovUtilConfiguration config = null;
+ Logger log = LoggerFactory.getLogger(MOAZSClient.class);
+
+ public MOAZSClient() {}
+
+ public MOAZSClient(EgovUtilConfiguration config) {
+ if (config == null) {
+ throw new NullPointerException("Parameter config must not be null.");
+ }
+ this.config = config;
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public DeliveryResponseType sendMOAZSRequest(DeliveryRequestType request, String serviceURL) throws MOAZSClientException {
+
+ // verify that parameters are not null
+ if (request == null) {
+ throw new NullPointerException("Parameter 'request' must not be null.");
+ }
+
+ if (serviceURL == null) {
+ throw new NullPointerException("Parameter 'serviceURL' must not be null.");
+ }
+
+ URL url = MOAZSClient.class.getResource("/wsdl/mzs/app2mzs.wsdl");
+ App2Mzs service = new App2Mzs(url, new QName("http://reference.e-government.gv.at/namespace/app2mzs.wsdl", "app2mzs"));
+ App2MzsPortType port = service.getApp2MzsPort();
+
+ log.trace("MOA-ZS request URL: " + serviceURL);
+ try {
+
+ // set endpoint address
+ BindingProvider bindingProvider = (BindingProvider) port;
+ Map<String, Object> requestContext = bindingProvider.getRequestContext();
+ requestContext.put(
+ BindingProvider.ENDPOINT_ADDRESS_PROPERTY, serviceURL);
+
+ // add trace log
+ 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);
+
+ // initialize ssl
+ if (serviceURL.toLowerCase().startsWith("https")) {
+ log.trace("Using ssl for MOA-ZS get authentication data request.");
+ SSLContext sslContext = config.getMOAZSsslConfiguration().getSSLContext(false);
+ 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());
+ }
+ }
+
+ // make simple moa-id request
+
+ return port.app2Mzs(request);
+
+ } catch (EgovUtilException e) {
+ throw new MOAZSClientException(e);
+ }
+ }
+
+}
diff --git a/src/main/java/at/gv/util/client/mzs/MOAZSClientException.java b/src/main/java/at/gv/util/client/mzs/MOAZSClientException.java
new file mode 100644
index 0000000..cb98f06
--- /dev/null
+++ b/src/main/java/at/gv/util/client/mzs/MOAZSClientException.java
@@ -0,0 +1,23 @@
+package at.gv.util.client.mzs;
+
+public class MOAZSClientException extends Exception {
+
+ private static final long serialVersionUID = 5173056345209288701L;
+
+ public MOAZSClientException() {
+ super();
+ }
+
+ public MOAZSClientException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public MOAZSClientException(String message) {
+ super(message);
+ }
+
+ public MOAZSClientException(Throwable cause) {
+ super(cause);
+ }
+
+}