aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz/moazs/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/util')
-rw-r--r--src/main/java/at/gv/egiz/moazs/util/ClientFactory.java4
-rw-r--r--src/main/java/at/gv/egiz/moazs/util/EndpointFactory.java41
-rw-r--r--src/main/java/at/gv/egiz/moazs/util/SSLContextCreator.java2
-rw-r--r--src/main/java/at/gv/egiz/moazs/util/StoreSOAPBodyBinaryInRepositoryInterceptor.java38
4 files changed, 71 insertions, 14 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/util/ClientFactory.java b/src/main/java/at/gv/egiz/moazs/util/ClientFactory.java
index e7761fe..d0a445b 100644
--- a/src/main/java/at/gv/egiz/moazs/util/ClientFactory.java
+++ b/src/main/java/at/gv/egiz/moazs/util/ClientFactory.java
@@ -1,5 +1,7 @@
-package at.gv.egiz.moazs.util;
+package at.gv.egiz.moazs.client;
+import at.gv.egiz.moazs.util.FileUtils;
+import at.gv.egiz.moazs.util.StoreSOAPBodyBinaryInRepositoryInterceptor;
import at.gv.zustellung.app2mzs.xsd.ClientType;
import at.gv.zustellung.app2mzs.xsd.KeyStoreType;
import at.gv.zustellung.app2mzs.xsd.SSLType;
diff --git a/src/main/java/at/gv/egiz/moazs/util/EndpointFactory.java b/src/main/java/at/gv/egiz/moazs/util/EndpointFactory.java
new file mode 100644
index 0000000..24321e1
--- /dev/null
+++ b/src/main/java/at/gv/egiz/moazs/util/EndpointFactory.java
@@ -0,0 +1,41 @@
+package at.gv.egiz.moazs.util;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.jaxws.EndpointImpl;
+import org.apache.cxf.message.Message;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import javax.xml.ws.Endpoint;
+
+import javax.xml.ws.Service;
+
+@Component
+public class EndpointFactory {
+
+ private final Bus bus;
+
+ @Autowired
+ public EndpointFactory(Bus bus) {
+ this.bus = bus;
+ }
+
+ public Endpoint create(Object implementor, Service service) {
+ return create(implementor, service, null);
+ }
+
+ public Endpoint create(Object implementor, Service service, Interceptor<Message> interceptor) {
+ EndpointImpl endpoint = new EndpointImpl(bus, implementor);
+ endpoint.setAddress("/");
+ endpoint.setServiceName(service.getServiceName());
+ endpoint.setWsdlLocation(service.getWSDLDocumentLocation().toString());
+ endpoint.publish();
+
+ if (interceptor != null) {
+ endpoint.getInInterceptors().add(interceptor);
+ }
+
+ return endpoint;
+ }
+
+}
diff --git a/src/main/java/at/gv/egiz/moazs/util/SSLContextCreator.java b/src/main/java/at/gv/egiz/moazs/util/SSLContextCreator.java
index 302bbf0..8fb5d80 100644
--- a/src/main/java/at/gv/egiz/moazs/util/SSLContextCreator.java
+++ b/src/main/java/at/gv/egiz/moazs/util/SSLContextCreator.java
@@ -1,4 +1,4 @@
-package at.gv.egiz.moazs.util;
+package at.gv.egiz.moazs.client;
import at.gv.egiz.eaaf.core.impl.utils.KeyStoreUtils;
import at.gv.zustellung.app2mzs.xsd.KeyStoreType;
diff --git a/src/main/java/at/gv/egiz/moazs/util/StoreSOAPBodyBinaryInRepositoryInterceptor.java b/src/main/java/at/gv/egiz/moazs/util/StoreSOAPBodyBinaryInRepositoryInterceptor.java
index 2db81ab..d70c8bd 100644
--- a/src/main/java/at/gv/egiz/moazs/util/StoreSOAPBodyBinaryInRepositoryInterceptor.java
+++ b/src/main/java/at/gv/egiz/moazs/util/StoreSOAPBodyBinaryInRepositoryInterceptor.java
@@ -1,6 +1,6 @@
package at.gv.egiz.moazs.util;
-import at.gv.egiz.moazs.repository.DeliveryRepository;
+import at.gv.egiz.moazs.repository.BinaryRepository;
import at.gv.egiz.moazs.scheme.SOAPUtils;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
@@ -15,6 +15,7 @@ import org.xml.sax.SAXException;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
+import java.util.Map;
import static at.gv.egiz.moazs.MoaZSException.moaZSException;
@@ -25,14 +26,16 @@ public class StoreSOAPBodyBinaryInRepositoryInterceptor extends AbstractPhaseInt
private final CXFMessageUtils messageUtils;
private final SOAPUtils soapUtils;
- private final DeliveryRepository repository;
+ private final Map<String, String> idSuffixes;
+ private final BinaryRepository repository;
@Autowired
public StoreSOAPBodyBinaryInRepositoryInterceptor(CXFMessageUtils extractor, SOAPUtils soapUtils,
- DeliveryRepository repository) {
+ Map<String, String> idSuffixes, BinaryRepository repository) {
super(Phase.RECEIVE);
this.messageUtils = extractor;
this.soapUtils = soapUtils;
+ this.idSuffixes = idSuffixes;
this.repository = repository;
}
@@ -45,17 +48,28 @@ public class StoreSOAPBodyBinaryInRepositoryInterceptor extends AbstractPhaseInt
log.trace("Interceptor received this SOAP message: {}. ", new String(content, StandardCharsets.UTF_8));
}
- if(content.length > 0) {
- Element document = soapUtils.toDOM(content);
- byte[] status = soapUtils.unwrapSoapEnvelope(document);
- String appDeliveryID = soapUtils.getAppDeliveryIDFrom(document);
- repository.addSignedDeliveryRequestStatus(status, appDeliveryID);
+ if (content.length <= 0) {
+ return;
+ }
+
+ Element document = soapUtils.toDOM(content);
+ byte[] response = soapUtils.unwrapSoapEnvelope(document);
+ String appDeliveryID = soapUtils.getAppDeliveryIDFrom(document);
+ String rootTag = document.getTagName();
- if(log.isTraceEnabled()) {
- log.trace("DeliveryRequestStatus with AppDeliveryID={} unwrapped and stored: {}. ",
- appDeliveryID, new String(status, StandardCharsets.UTF_8));
- }
+ if (!idSuffixes.containsKey(rootTag)) {
+ log.trace("Will not add message of type {}. ", rootTag);
+ return;
}
+
+ var id = appDeliveryID + idSuffixes.get(rootTag);
+ repository.add(id, response);
+
+ if(log.isTraceEnabled()) {
+ log.trace("Msg Response with AppDeliveryID={} unwrapped and stored: {}. ",
+ appDeliveryID, new String(response, StandardCharsets.UTF_8));
+ }
+
} catch (ParserConfigurationException | SAXException | IOException | NullPointerException e) {
throw moaZSException("Could not extract signed data from message.", e);
}