aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-10-02 14:30:43 +0200
committerChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-10-02 14:30:43 +0200
commitb3060f8ba40280d438e2b4b06b39aed84c587f7a (patch)
tree8f28026793af1a6d3b071ae91d1afe972b1d8fa7
parentdedb4687f46c0ea10539edc38206d440fe0c806e (diff)
downloadmoa-zs-b3060f8ba40280d438e2b4b06b39aed84c587f7a.tar.gz
moa-zs-b3060f8ba40280d438e2b4b06b39aed84c587f7a.tar.bz2
moa-zs-b3060f8ba40280d438e2b4b06b39aed84c587f7a.zip
For {TNVZ, MSG}: Switch to Soap 1.2
- But: Leave MZS Interface at Soap 1.1 - Add ClientFactory.createSOAP11 to ensure that we can talk back to the app.
-rw-r--r--src/main/java/at/gv/egiz/moazs/backend/ForwardResponseToServiceSink.java2
-rw-r--r--src/main/java/at/gv/egiz/moazs/client/ClientFactory.java21
-rw-r--r--src/main/java/at/gv/egiz/moazs/scheme/SOAPUtils.java12
-rw-r--r--src/test/java/at/gv/egiz/moazs/ITEndToEndTest.java2
-rw-r--r--src/test/java/at/gv/egiz/moazs/SOAPUtilsTest.java14
-rw-r--r--src/test/resources/at/gv/egiz/moazs/ITEndToEndTest/msg-delivery-notification.xml2
-rw-r--r--src/test/resources/at/gv/egiz/moazs/ITEndToEndTest/msg-delivery-request-status.xml2
-rw-r--r--src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/valid-signed-shuffled-soaped-notification.xml2
-rw-r--r--src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/valid-signed-soaped-notification.xml2
9 files changed, 37 insertions, 22 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/backend/ForwardResponseToServiceSink.java b/src/main/java/at/gv/egiz/moazs/backend/ForwardResponseToServiceSink.java
index d870aa8..8e1566e 100644
--- a/src/main/java/at/gv/egiz/moazs/backend/ForwardResponseToServiceSink.java
+++ b/src/main/java/at/gv/egiz/moazs/backend/ForwardResponseToServiceSink.java
@@ -33,7 +33,7 @@ public class ForwardResponseToServiceSink {
log.info("Forward msg:{} with AppDeliveryID={} to service at {}.",
msgResponse.getRootElementLocalPart(), msgResponse.getAppDeliveryID(), params.getURL());
var binaryResponse = repository.retrieveBinaryResponse(msgResponse.getResponseID());
- Mzs2AppPortType client = factory.create(params, Mzs2AppPortType.class);
+ Mzs2AppPortType client = factory.createSoap11(params, Mzs2AppPortType.class);
return msgResponse.sendToAppClient(converter, binaryResponse, client);
}
}
diff --git a/src/main/java/at/gv/egiz/moazs/client/ClientFactory.java b/src/main/java/at/gv/egiz/moazs/client/ClientFactory.java
index 44da83a..8b2054b 100644
--- a/src/main/java/at/gv/egiz/moazs/client/ClientFactory.java
+++ b/src/main/java/at/gv/egiz/moazs/client/ClientFactory.java
@@ -55,16 +55,27 @@ public class ClientFactory {
}
/**
- * Creates a client that communicates with a soap service.
+ * Creates a client that communicates with a soap 1.2 service.
*
* @param params for the client, such as service url and ssl parameters.
* @return the client
*/
public <T> T create(ClientType params, Class<T> clazz) {
- return JAXBClassNotFoundFix.runInTheadWithClassClassLoader(() -> createClient(params, clazz));
+ return JAXBClassNotFoundFix.runInTheadWithClassClassLoader(() -> create(params, clazz, true));
}
- private <T> T createClient(ClientType params, Class<T> clazz) {
+ /**
+ * Creates a client that communicates with a soap 1.1 service.
+ *
+ * @param params for the client, such as service url and ssl parameters.
+ * @return the client
+ */
+ public <T> T createSoap11(ClientType params, Class<T> clazz) {
+ return JAXBClassNotFoundFix.runInTheadWithClassClassLoader(() -> create(params, clazz, false));
+ }
+
+
+ private <T> T create(ClientType params, Class<T> clazz, boolean isSoap12) {
log.info("Create client for service {}", params.getURL());
@@ -72,6 +83,10 @@ public class ClientFactory {
factory.setServiceClass(clazz);
factory.setAddress(params.getURL());
factory.getInInterceptors().add(storeResponseInterceptor);
+
+ if (isSoap12) {
+ factory.setBindingId(SOAPBinding.SOAP12HTTP_MTOM_BINDING);
+ }
setupLoggingInterceptors(factory);
var proxy = new JaxWsProxyFactoryBean(factory).create();
diff --git a/src/main/java/at/gv/egiz/moazs/scheme/SOAPUtils.java b/src/main/java/at/gv/egiz/moazs/scheme/SOAPUtils.java
index f44fb3d..6ec120f 100644
--- a/src/main/java/at/gv/egiz/moazs/scheme/SOAPUtils.java
+++ b/src/main/java/at/gv/egiz/moazs/scheme/SOAPUtils.java
@@ -2,7 +2,7 @@ package at.gv.egiz.moazs.scheme;
import at.gv.egiz.eaaf.core.impl.utils.DOMUtils;
import at.gv.egiz.moazs.MoaZSException;
-import org.apache.cxf.binding.soap.Soap11;
+import org.apache.cxf.binding.soap.Soap12;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -26,8 +26,8 @@ import static at.gv.egiz.moazs.MoaZSException.moaZSException;
public class SOAPUtils {
private static final Logger log = LoggerFactory.getLogger(SOAPUtils.class);
- private static final String SOAP_BODY_MISSING_ERROR_MSG = "<soap11:Body> is missing.";
- private static final String SOAP_BODY_CHILDREN_MISSING_ERROR_MSG = "<soap11:Body> has no child elements.";
+ private static final String SOAP_BODY_MISSING_ERROR_MSG = "<soap12:Body> is missing.";
+ private static final String SOAP_BODY_CHILDREN_MISSING_ERROR_MSG = "<soap12:Body> has no child elements.";
private static final String APP_DELIVERY_ID_FULL_TAG_NAME = "<msg:" + NameSpace.MSG_APP_DELIVERY_ID + ">";
private static final String MULTIPLE_MSG = "Found multiple {} elements. Will choose first element.";
private static final String APP_DELIVERY_ID_MISSING_ERROR_MSG = APP_DELIVERY_ID_FULL_TAG_NAME + " is missing.";
@@ -40,16 +40,16 @@ public class SOAPUtils {
public Node getChildElementOfSoapBody(Element document) throws MoaZSException {
- var bodyList = document.getElementsByTagNameNS(Soap11.SOAP_NAMESPACE, "Body");
+ var bodyList = document.getElementsByTagNameNS(Soap12.SOAP_NAMESPACE, "Body");
if (bodyList.getLength() == 0) throw moaZSException(SOAP_BODY_MISSING_ERROR_MSG);
- if (bodyList.getLength() > 1) log.warn(MULTIPLE_MSG, "<soap11:Body>");
+ if (bodyList.getLength() > 1) log.warn(MULTIPLE_MSG, "<soap12:Body>");
var body = bodyList.item(0);
var children = body.getChildNodes();
var candidates = filterNodeByType(children, Node.ELEMENT_NODE);
if (candidates.isEmpty()) throw moaZSException(SOAP_BODY_CHILDREN_MISSING_ERROR_MSG);
- if (candidates.size() > 1) log.warn(MULTIPLE_MSG, "<soap11:Body> child");
+ if (candidates.size() > 1) log.warn(MULTIPLE_MSG, "<soap12:Body> child");
return candidates.get(0);
}
diff --git a/src/test/java/at/gv/egiz/moazs/ITEndToEndTest.java b/src/test/java/at/gv/egiz/moazs/ITEndToEndTest.java
index 29b7b53..95c7140 100644
--- a/src/test/java/at/gv/egiz/moazs/ITEndToEndTest.java
+++ b/src/test/java/at/gv/egiz/moazs/ITEndToEndTest.java
@@ -92,7 +92,7 @@ public class ITEndToEndTest {
APP = mockApp();
when(factory.create(any(), same(TNVZServicePort.class))).thenReturn(tnvz);
when(factory.create(any(), same(App2ZusePort.class))).thenReturn(msg);
- when(factory.create(any(), same(Mzs2AppPortType.class))).thenReturn(APP);
+ when(factory.createSoap11(any(), same(Mzs2AppPortType.class))).thenReturn(APP);
return factory;
}
diff --git a/src/test/java/at/gv/egiz/moazs/SOAPUtilsTest.java b/src/test/java/at/gv/egiz/moazs/SOAPUtilsTest.java
index ff0060e..bf74ac0 100644
--- a/src/test/java/at/gv/egiz/moazs/SOAPUtilsTest.java
+++ b/src/test/java/at/gv/egiz/moazs/SOAPUtilsTest.java
@@ -15,7 +15,7 @@ public class SOAPUtilsTest {
SOAPUtils utils;
private static final String SOAP_MESSAGE =
- "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body>" +
+ "<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\"><soap:Body>" +
"<DeliveryResponse xmlns=\"http://reference.e-government.gv.at/namespace/zustellung/msg/phas" +
"e2/20181206#\" xmlns:ns2=\"http://reference.e-government.gv.at/namespace/persondata/phase2/" +
"20181206#\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\"><PartialSuccess><DeliverySyste" +
@@ -26,7 +26,7 @@ public class SOAPUtilsTest {
public static final String FORMATTED_MESSAGE =
"<soapenv:Envelope\n" +
- " xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n" +
+ " xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\"\n" +
" xmlns:msg=\"http://reference.e-government.gv.at/namespace/zustellung/msg/phase2/20181206#\">\n" +
" <soapenv:Body>\n" +
" <msg:DeliveryNotification>\n" +
@@ -38,7 +38,7 @@ public class SOAPUtilsTest {
public static final String CLUTTERED_MESSAGE =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<soapenv:Envelope " +
- " xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n " +
+ " xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\"\n " +
" xmlns:msg=\"http://reference.e-government.gv.at/namespace/zustellung/msg/phase2/20181206#\">\n" +
" <soapenv:Body unexpected-attribute=\"unexpectedvalue\"> \n" +
" <msg:DeliveryNotification>\n" +
@@ -48,14 +48,14 @@ public class SOAPUtilsTest {
"</soapenv:Envelope>\n";
private static final String MISSING_BODY_MESSAGE =
- "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><NotABodyTag></NotABodyTag></soap:Envelope>";
+ "<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\"><NotABodyTag></NotABodyTag></soap:Envelope>";
private static final String EMPTY_BODY_MESSAGE =
- "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body> </soap:Body></soap:Envelope>";
+ "<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\"><soap:Body> </soap:Body></soap:Envelope>";
public static final String EMPTY_APP_DELIVERY_ID_MESSAGE =
"<soapenv:Envelope\n" +
- " xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n" +
+ " xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\"\n" +
" xmlns:msg=\"http://reference.e-government.gv.at/namespace/zustellung/msg/phase2/20181206#\">\n" +
" <soapenv:Body>\n" +
" <msg:DeliveryNotification>\n" +
@@ -66,7 +66,7 @@ public class SOAPUtilsTest {
public static final String BLANK_APP_DELIVERY_ID_MESSAGE =
"<soapenv:Envelope\n" +
- " xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n" +
+ " xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\"\n" +
" xmlns:msg=\"http://reference.e-government.gv.at/namespace/zustellung/msg/phase2/20181206#\">\n" +
" <soapenv:Body>\n" +
" <msg:DeliveryNotification>\n" +
diff --git a/src/test/resources/at/gv/egiz/moazs/ITEndToEndTest/msg-delivery-notification.xml b/src/test/resources/at/gv/egiz/moazs/ITEndToEndTest/msg-delivery-notification.xml
index 3a90d36..2f99af5 100644
--- a/src/test/resources/at/gv/egiz/moazs/ITEndToEndTest/msg-delivery-notification.xml
+++ b/src/test/resources/at/gv/egiz/moazs/ITEndToEndTest/msg-delivery-notification.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
- xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"
xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"
xmlns:p="http://reference.e-government.gv.at/namespace/persondata/phase2/20181206#"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
diff --git a/src/test/resources/at/gv/egiz/moazs/ITEndToEndTest/msg-delivery-request-status.xml b/src/test/resources/at/gv/egiz/moazs/ITEndToEndTest/msg-delivery-request-status.xml
index bbeded8..f81a554 100644
--- a/src/test/resources/at/gv/egiz/moazs/ITEndToEndTest/msg-delivery-request-status.xml
+++ b/src/test/resources/at/gv/egiz/moazs/ITEndToEndTest/msg-delivery-request-status.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
- xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"
xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"
xmlns:msg="http://reference.e-government.gv.at/namespace/zustellung/msg/phase2/20181206#">
<soapenv:Body>
diff --git a/src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/valid-signed-shuffled-soaped-notification.xml b/src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/valid-signed-shuffled-soaped-notification.xml
index 1262c3e..f40a6f0 100644
--- a/src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/valid-signed-shuffled-soaped-notification.xml
+++ b/src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/valid-signed-shuffled-soaped-notification.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
+<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body><DeliveryNotification xmlns="http://reference.e-government.gv.at/namespace/zustellung/msg" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:p="http://reference.e-government.gv.at/namespace/persondata/20020228#" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion">
<Success>
<DeliveryService>https://localhost/example-delivery-system</DeliveryService>
diff --git a/src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/valid-signed-soaped-notification.xml b/src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/valid-signed-soaped-notification.xml
index 54e9918..535b2ad 100644
--- a/src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/valid-signed-soaped-notification.xml
+++ b/src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/valid-signed-soaped-notification.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
+<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body><DeliveryNotification xmlns="http://reference.e-government.gv.at/namespace/zustellung/msg" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:p="http://reference.e-government.gv.at/namespace/persondata/20020228#" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion">
<Success>
<DeliveryService>https://localhost/example-delivery-system</DeliveryService>