aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/client
diff options
context:
space:
mode:
authorThomas Lenz <tlenz@iaik.tugraz.at>2014-01-27 16:27:02 +0100
committerThomas Lenz <tlenz@iaik.tugraz.at>2014-01-27 16:27:02 +0100
commitcea2f395ec773b386ec628d60120752cf320f6b6 (patch)
tree2145dbbe25f0b4f99c89e60834176ea8fa1d435c /id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/client
parent653fd79254188db598c0b980640fab912c9e39f7 (diff)
downloadmoa-id-spss-cea2f395ec773b386ec628d60120752cf320f6b6.tar.gz
moa-id-spss-cea2f395ec773b386ec628d60120752cf320f6b6.tar.bz2
moa-id-spss-cea2f395ec773b386ec628d60120752cf320f6b6.zip
add PVP2 Demo Application
change SZRGWClient to JAXWs
Diffstat (limited to 'id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/client')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/client/LaxHostNameVerifier.java16
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/client/SZRGWClient.java81
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/client/SZRGWClientException.java17
3 files changed, 114 insertions, 0 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/client/LaxHostNameVerifier.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/client/LaxHostNameVerifier.java
new file mode 100644
index 000000000..a4fe4ab7b
--- /dev/null
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/client/LaxHostNameVerifier.java
@@ -0,0 +1,16 @@
+package at.gv.egovernment.moa.id.client;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.SSLSession;
+
+public class LaxHostNameVerifier implements HostnameVerifier {
+
+ /*
+ * (non-Javadoc)
+ * @see javax.net.ssl.HostnameVerifier#verify(java.lang.String, javax.net.ssl.SSLSession)
+ */
+ public boolean verify(String arg0, SSLSession arg1) {
+ return true;
+ }
+
+}
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/client/SZRGWClient.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/client/SZRGWClient.java
new file mode 100644
index 000000000..37c2ebae0
--- /dev/null
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/client/SZRGWClient.java
@@ -0,0 +1,81 @@
+package at.gv.egovernment.moa.id.client;
+
+import java.net.URL;
+import java.util.Map;
+
+import javax.net.ssl.SSLSocketFactory;
+import javax.xml.namespace.QName;
+
+import at.gv.egovernment.moa.id.config.ConnectionParameter;
+import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider;
+import at.gv.egovernment.moa.id.util.SSLUtils;
+import at.gv.egovernment.moa.logging.Logger;
+import at.gv.egovernment.moa.util.MiscUtil;
+import at.gv.util.wsdl.szrgw.SZRGWService;
+import at.gv.util.wsdl.szrgw.SZRGWType;
+import at.gv.util.xsd.srzgw.CreateIdentityLinkRequest;
+import at.gv.util.xsd.srzgw.CreateIdentityLinkResponse;
+
+import com.sun.xml.ws.developer.JAXWSProperties;
+import javax.xml.ws.BindingProvider;
+
+public class SZRGWClient {
+
+ private SSLSocketFactory sslContext = null;
+
+ public SZRGWClient(ConnectionParameter szrgwconnection) throws SZRGWClientException {
+ initial(szrgwconnection);
+ }
+
+ public CreateIdentityLinkResponse sentCreateIDLRequest(CreateIdentityLinkRequest request, String serviceUrl) throws SZRGWClientException {
+ MiscUtil.assertNotNull(request, "createIDLRequest");
+ MiscUtil.assertNotNull(serviceUrl, "serviceURL");
+
+ URL url = SZRGWClient.class.getResource("/resources/wsdl/szrgw/szrgw.wsdl");
+ SZRGWService service = new SZRGWService(url, new QName("http://reference.e-government.gv.at/namespace/szrgw/20070807/wsdl", "SZRGWService"));
+ SZRGWType port = service.getSZRGWPort();
+
+
+
+
+ BindingProvider bindingProvider = (BindingProvider) port;
+ Map<String, Object> requestContext = bindingProvider.getRequestContext();
+ requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, serviceUrl);
+
+
+ // check for ssl
+ if (serviceUrl.toLowerCase().startsWith("https")) {
+ Logger.trace("Using ssl for SZRGW client request.");
+ if (sslContext == null) {
+ throw new SZRGWClientException("SSL context from configuration is empty. Please configure an SSL context in the configuration first.", null);
+ }
+
+ requestContext.put(JAXWSProperties.SSL_SOCKET_FACTORY, sslContext);
+
+ // check for lax hostname
+ if (true) {
+ Logger.trace("LaxHostnameVerifier enabled. This setting is not recommended to use.");
+ requestContext.put(JAXWSProperties.HOSTNAME_VERIFIER, new LaxHostNameVerifier());
+ }
+ }
+
+
+ return port.szrgwOperation(request);
+
+ }
+
+
+ private void initial(ConnectionParameter szrgwconnection) throws at.gv.egovernment.moa.id.client.SZRGWClientException{
+ try {
+ sslContext = SSLUtils.getSSLSocketFactory(
+ AuthConfigurationProvider.getInstance(),
+ szrgwconnection);
+
+ } catch (Exception e) {
+ Logger.warn("SZRGW Client initialization FAILED.", e);
+ throw new SZRGWClientException("SZRGW Client initialization FAILED.", null);
+
+ }
+
+ }
+}
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/client/SZRGWClientException.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/client/SZRGWClientException.java
new file mode 100644
index 000000000..4eb268ce9
--- /dev/null
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/client/SZRGWClientException.java
@@ -0,0 +1,17 @@
+package at.gv.egovernment.moa.id.client;
+
+import at.gv.egovernment.moa.id.auth.exception.MOAIDException;
+
+public class SZRGWClientException extends MOAIDException{
+
+ private static final long serialVersionUID = 1L;
+
+ public SZRGWClientException(String messageId, Object[] parameters) {
+ super(messageId, parameters);
+ }
+
+ public SZRGWClientException(SZRGWClientException e1) {
+ super("", null, e1);
+ }
+
+}