summaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/util/client/ersb
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/ersb
downloadegovutils-defceef8afef538555c13d33e344a89a828a3d97.tar.gz
egovutils-defceef8afef538555c13d33e344a89a828a3d97.tar.bz2
egovutils-defceef8afef538555c13d33e344a89a828a3d97.zip
inital
Diffstat (limited to 'src/main/java/at/gv/util/client/ersb')
-rw-r--r--src/main/java/at/gv/util/client/ersb/ERsBClient.java103
-rw-r--r--src/main/java/at/gv/util/client/ersb/ERsBClientException.java23
2 files changed, 126 insertions, 0 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
new file mode 100644
index 0000000..82198b3
--- /dev/null
+++ b/src/main/java/at/gv/util/client/ersb/ERsBClient.java
@@ -0,0 +1,103 @@
+package at.gv.util.client.ersb;
+
+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.MiscUtil;
+import at.gv.util.client.szr.SZRSOAPHandler;
+import at.gv.util.config.EgovUtilConfiguration;
+import at.gv.util.ex.EgovUtilException;
+import at.gv.util.wsdl.ersb.ErsbService;
+import at.gv.util.wsdl.ersb.ErsbServiceService;
+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
+ WebServiceContext wsContext;
+
+ private EgovUtilConfiguration config = null;
+ Logger log = LoggerFactory.getLogger(ERsBClient.class);
+
+ public ERsBClient() {}
+
+ public ERsBClient(EgovUtilConfiguration config) {
+ if (config == null) {
+ throw new NullPointerException("Parameter config must not be null.");
+ }
+ this.config = config;
+
+
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public ErsbResponse sendERsBRequest(ErsbRequest mir, String ersbServiceURL) throws EgovUtilException {
+ MiscUtil.assertNotNull(mir, "mir");
+ MiscUtil.assertNotNull(ersbServiceURL, "ersbServiceURL");
+
+ URL url = ERsBClient.class.getResource("/schema/ERsB/1.1/ErsbService.wsdl");
+ ErsbServiceService service = new ErsbServiceService(url, new QName("http://statistik.at/namespace/ersb/1#", "ErsbServiceService"));
+ ErsbService port = service.getErsbServiceSoap11();
+
+ log.debug("MISSTORK connection URL: " + ersbServiceURL);
+ BindingProvider bindingProvider = (BindingProvider) port;
+ Map<String, Object> requestContext = bindingProvider.getRequestContext();
+ requestContext.put(
+ BindingProvider.ENDPOINT_ADDRESS_PROPERTY, ersbServiceURL);
+
+ 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);
+
+ log.trace("Adding WS-Security Header handler.");
+ PvpTokenType pvpToken = config.getERsBPVPToken();
+ SZRSOAPHandler szrSOAPHandler = new SZRSOAPHandler();
+ szrSOAPHandler.configure(pvpToken);
+ handlerList.add(szrSOAPHandler);
+ bindingProvider.getBinding().setHandlerChain(handlerList);
+
+ // check for ssl
+ if (ersbServiceURL.toLowerCase().startsWith("https")) {
+ log.trace("Using ssl for MISSTORK client request.");
+ SSLContext sslContext = config.getERsBsslConfiguration().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.getERsBsslConfiguration().useLaxHostNameVerifier()) {
+ log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use.");
+ requestContext.put(JAXWSProperties.HOSTNAME_VERIFIER, new LaxHostNameVerifier());
+ }
+ }
+
+ return port.ersb(mir);
+ }
+
+}
diff --git a/src/main/java/at/gv/util/client/ersb/ERsBClientException.java b/src/main/java/at/gv/util/client/ersb/ERsBClientException.java
new file mode 100644
index 0000000..a51d1a6
--- /dev/null
+++ b/src/main/java/at/gv/util/client/ersb/ERsBClientException.java
@@ -0,0 +1,23 @@
+package at.gv.util.client.ersb;
+
+public class ERsBClientException extends Exception {
+
+ private static final long serialVersionUID = 5173056345209288701L;
+
+ public ERsBClientException() {
+ super();
+ }
+
+ public ERsBClientException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ERsBClientException(String message) {
+ super(message);
+ }
+
+ public ERsBClientException(Throwable cause) {
+ super(cause);
+ }
+
+}