Skip to content

Commit

Permalink
Merge pull request #63 from difi/release-4.1.0
Browse files Browse the repository at this point in the history
Release 4.1.0
  • Loading branch information
FrodeBjerkholt authored Jan 28, 2020
2 parents 3548630 + 018653e commit 63b3888
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 30 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</parent>

<artifactId>oxalis-as4</artifactId>
<version>4.1.0-SNAPSHOT</version>
<version>4.1.0</version>

<packaging>jar</packaging>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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
Expand All @@ -61,7 +55,7 @@ private Optional<Messaging> getMessaging(Message message) {
SoapMessage soapMessage = (SoapMessage) message;
Header header = soapMessage.getHeader(Constants.MESSAGING_QNAME);

if(header == null) {
if (header == null) {
return Optional.empty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Receipt> receipts;

private final X509Certificate certificate;

private final As4EnvelopeHeader as4EnvelopeHeader;


Expand Down
Original file line number Diff line number Diff line change
@@ -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());
}
}
Original file line number Diff line number Diff line change
@@ -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());
}
}
4 changes: 3 additions & 1 deletion src/main/java/no/difi/oxalis/as4/util/Marshalling.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -9,6 +10,7 @@
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;

@UtilityClass
public class Marshalling {

public static JAXBContext getInstance() {
Expand All @@ -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);
}
}
Expand Down

0 comments on commit 63b3888

Please sign in to comment.