diff --git a/pom.xml b/pom.xml
index f4235cd..b10be13 100755
--- a/pom.xml
+++ b/pom.xml
@@ -31,7 +31,7 @@
oxalis-as4
- 4.1.0-SNAPSHOT
+ 4.1.0
jar
diff --git a/src/main/java/no/difi/oxalis/as4/inbound/AS4MessageContextKey.java b/src/main/java/no/difi/oxalis/as4/inbound/AS4MessageContextKey.java
index 45bc622..ecc47fa 100644
--- a/src/main/java/no/difi/oxalis/as4/inbound/AS4MessageContextKey.java
+++ b/src/main/java/no/difi/oxalis/as4/inbound/AS4MessageContextKey.java
@@ -8,4 +8,5 @@ public class AS4MessageContextKey {
public static final String FIRST_PAYLOAD_PATH = "no.difi.oxalis.as4.first.payload.path";
public static final String FIRST_PAYLOAD_HEADER = "no.difi.oxalis.as4.first.payload.header";
public static final String ENVELOPE_HEADER = "no.difi.oxalis.as4.envelope.header";
+ public static final String PERSISTED = "no.difi.oxalis.as4.persisted";
}
diff --git a/src/main/java/no/difi/oxalis/as4/inbound/SetPolicyInterceptor.java b/src/main/java/no/difi/oxalis/as4/inbound/AbstractSetPolicyInterceptor.java
similarity index 86%
rename from src/main/java/no/difi/oxalis/as4/inbound/SetPolicyInterceptor.java
rename to src/main/java/no/difi/oxalis/as4/inbound/AbstractSetPolicyInterceptor.java
index 2762f7a..4471c6c 100644
--- a/src/main/java/no/difi/oxalis/as4/inbound/SetPolicyInterceptor.java
+++ b/src/main/java/no/difi/oxalis/as4/inbound/AbstractSetPolicyInterceptor.java
@@ -1,7 +1,5 @@
package no.difi.oxalis.as4.inbound;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
import lombok.extern.slf4j.Slf4j;
import no.difi.oxalis.as4.util.Constants;
import no.difi.oxalis.as4.util.Marshalling;
@@ -11,7 +9,6 @@
import org.apache.cxf.headers.Header;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.message.Message;
-import org.apache.cxf.phase.Phase;
import org.apache.cxf.ws.policy.PolicyConstants;
import org.apache.cxf.ws.policy.PolicyInInterceptor;
import org.apache.neethi.Policy;
@@ -27,17 +24,14 @@
import java.util.stream.Stream;
@Slf4j
-@Singleton
-public class SetPolicyInterceptor extends AbstractSoapInterceptor {
+abstract class AbstractSetPolicyInterceptor extends AbstractSoapInterceptor {
private final JAXBContext jaxbContext = Marshalling.getInstance();
private final PolicyService policyService;
- @Inject
- public SetPolicyInterceptor(PolicyService policyService) {
- super(Phase.SETUP);
+ public AbstractSetPolicyInterceptor(String phase, PolicyService policyService) {
+ super(phase);
this.policyService = policyService;
- addBefore(PolicyInInterceptor.class.getName());
}
@Override
@@ -61,7 +55,7 @@ private Optional getMessaging(Message message) {
SoapMessage soapMessage = (SoapMessage) message;
Header header = soapMessage.getHeader(Constants.MESSAGING_QNAME);
- if(header == null) {
+ if (header == null) {
return Optional.empty();
}
diff --git a/src/main/java/no/difi/oxalis/as4/inbound/As4EndpointsPublisherImpl.java b/src/main/java/no/difi/oxalis/as4/inbound/As4EndpointsPublisherImpl.java
index f83b581..99d23d6 100644
--- a/src/main/java/no/difi/oxalis/as4/inbound/As4EndpointsPublisherImpl.java
+++ b/src/main/java/no/difi/oxalis/as4/inbound/As4EndpointsPublisherImpl.java
@@ -35,13 +35,14 @@ public class As4EndpointsPublisherImpl implements As4EndpointsPublisher {
private As4Interceptor oxalisAs4Interceptor;
@Inject
- private SetPolicyInterceptor setPolicyInterceptor;
+ private SetPolicyOutInterceptor setPolicyInInterceptor;
+
+ @Inject
+ private SetPolicyOutInterceptor setPolicyOutInterceptor;
@Override
public EndpointImpl publish(Bus bus) {
- EndpointImpl endpoint = null;
-
- endpoint = (EndpointImpl) Endpoint.publish("/", as4Provider,
+ EndpointImpl endpoint = (EndpointImpl) Endpoint.publish("/", as4Provider,
new LoggingFeature(),
new WSPolicyFeature());
@@ -51,11 +52,10 @@ public EndpointImpl publish(Bus bus) {
endpoint.getBinding().setHandlerChain(Arrays.asList(as4FaultInHandler, new MessagingHandler()));
endpoint.getInInterceptors().add(oxalisAs4Interceptor);
- endpoint.getInInterceptors().add(setPolicyInterceptor);
- endpoint.getOutInterceptors().add(setPolicyInterceptor);
- endpoint.getInFaultInterceptors().add(setPolicyInterceptor);
- endpoint.getOutFaultInterceptors().add(setPolicyInterceptor);
-// endpoint.getOutFaultInterceptors().add(new SetCodeValueFaultOutInterceptor());
+ endpoint.getInInterceptors().add(setPolicyInInterceptor);
+ endpoint.getOutInterceptors().add(setPolicyOutInterceptor);
+ endpoint.getInFaultInterceptors().add(setPolicyInInterceptor);
+ endpoint.getOutFaultInterceptors().add(setPolicyOutInterceptor);
MultipleEndpointObserver newMO = new MultipleEndpointObserver(bus) {
@Override
diff --git a/src/main/java/no/difi/oxalis/as4/inbound/As4InboundHandler.java b/src/main/java/no/difi/oxalis/as4/inbound/As4InboundHandler.java
index f5df5ae..3b1e57e 100755
--- a/src/main/java/no/difi/oxalis/as4/inbound/As4InboundHandler.java
+++ b/src/main/java/no/difi/oxalis/as4/inbound/As4InboundHandler.java
@@ -140,6 +140,8 @@ public SOAPMessage handle(SOAPMessage request, MessageContext messageContext) th
throw new OxalisAs4Exception("Error persisting AS4 metadata", e, AS4ErrorCode.EBMS_0202);
}
+ messageContext.put(AS4MessageContextKey.PERSISTED, true);
+
// Persist statistics
inboundService.complete(as4InboundMetadata);
}
diff --git a/src/main/java/no/difi/oxalis/as4/inbound/As4InboundMetadata.java b/src/main/java/no/difi/oxalis/as4/inbound/As4InboundMetadata.java
index 7df31d7..8a1182f 100755
--- a/src/main/java/no/difi/oxalis/as4/inbound/As4InboundMetadata.java
+++ b/src/main/java/no/difi/oxalis/as4/inbound/As4InboundMetadata.java
@@ -12,23 +12,14 @@
public class As4InboundMetadata implements InboundMetadata {
private final TransmissionIdentifier transmissionIdentifier;
-
private final String conversationId;
-
private final Header header;
-
private final Date timestamp;
-
private final TransportProfile transportProfile;
-
private final Digest digest;
-
private final Receipt primaryReceipt;
-
private final List receipts;
-
private final X509Certificate certificate;
-
private final As4EnvelopeHeader as4EnvelopeHeader;
diff --git a/src/main/java/no/difi/oxalis/as4/inbound/SetPolicyInInterceptor.java b/src/main/java/no/difi/oxalis/as4/inbound/SetPolicyInInterceptor.java
new file mode 100644
index 0000000..c5fad4a
--- /dev/null
+++ b/src/main/java/no/difi/oxalis/as4/inbound/SetPolicyInInterceptor.java
@@ -0,0 +1,20 @@
+package no.difi.oxalis.as4.inbound;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import lombok.extern.slf4j.Slf4j;
+import no.difi.oxalis.as4.util.PolicyService;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.ws.policy.PolicyInInterceptor;
+import org.apache.cxf.ws.policy.PolicyOutInterceptor;
+
+@Slf4j
+@Singleton
+public class SetPolicyInInterceptor extends AbstractSetPolicyInterceptor {
+
+ @Inject
+ public SetPolicyInInterceptor(PolicyService policyService) {
+ super(Phase.RECEIVE, policyService);
+ addBefore(PolicyInInterceptor.class.getName());
+ }
+}
diff --git a/src/main/java/no/difi/oxalis/as4/inbound/SetPolicyOutInterceptor.java b/src/main/java/no/difi/oxalis/as4/inbound/SetPolicyOutInterceptor.java
new file mode 100644
index 0000000..f8fae4f
--- /dev/null
+++ b/src/main/java/no/difi/oxalis/as4/inbound/SetPolicyOutInterceptor.java
@@ -0,0 +1,39 @@
+package no.difi.oxalis.as4.inbound;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import lombok.extern.slf4j.Slf4j;
+import no.difi.oxalis.as4.util.Constants;
+import no.difi.oxalis.as4.util.Marshalling;
+import no.difi.oxalis.as4.util.PolicyService;
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
+import org.apache.cxf.headers.Header;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.ws.policy.PolicyConstants;
+import org.apache.cxf.ws.policy.PolicyInInterceptor;
+import org.apache.cxf.ws.policy.PolicyOutInterceptor;
+import org.apache.neethi.Policy;
+import org.oasis_open.docs.ebxml_msg.ebms.v3_0.ns.core._200704.Messaging;
+import org.oasis_open.docs.ebxml_msg.ebms.v3_0.ns.core._200704.UserMessage;
+import org.w3c.dom.Node;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import java.util.Collection;
+import java.util.Optional;
+import java.util.stream.Stream;
+
+@Slf4j
+@Singleton
+public class SetPolicyOutInterceptor extends AbstractSetPolicyInterceptor {
+
+ @Inject
+ public SetPolicyOutInterceptor(PolicyService policyService) {
+ super(Phase.SETUP, policyService);
+ addBefore(PolicyOutInterceptor.class.getName());
+ }
+}
diff --git a/src/main/java/no/difi/oxalis/as4/util/Marshalling.java b/src/main/java/no/difi/oxalis/as4/util/Marshalling.java
index 49fc671..4bf4dda 100755
--- a/src/main/java/no/difi/oxalis/as4/util/Marshalling.java
+++ b/src/main/java/no/difi/oxalis/as4/util/Marshalling.java
@@ -1,5 +1,6 @@
package no.difi.oxalis.as4.util;
+import lombok.experimental.UtilityClass;
import no.difi.commons.sbdh.jaxb.StandardBusinessDocument;
import org.oasis_open.docs.ebxml_bp.ebbp_signals_2.NonRepudiationInformation;
import org.oasis_open.docs.ebxml_msg.ebms.v3_0.ns.core._200704.Messaging;
@@ -9,6 +10,7 @@
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
+@UtilityClass
public class Marshalling {
public static JAXBContext getInstance() {
@@ -25,7 +27,7 @@ public static JAXBContext createMarshaller() {
NonRepudiationInformation.class,
Messaging.class
);
- }catch (JAXBException e){
+ } catch (JAXBException e) {
throw new RuntimeException("Unable to create marshaller for AS4 documents", e);
}
}