Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix 4.1.5 #91

Merged
merged 5 commits into from
Feb 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</parent>

<artifactId>oxalis-as4</artifactId>
<version>4.1.4</version>
<version>4.1.5</version>

<packaging>jar</packaging>

Expand Down
49 changes: 25 additions & 24 deletions src/main/java/no/difi/oxalis/as4/outbound/As4MessageSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,32 +49,30 @@ public class As4MessageSender {
public static final QName SERVICE_NAME = new QName("oxalis.difi.no/", "outbound-service");
public static final QName PORT_NAME = new QName("oxalis.difi.no/", "port");

@Inject
private MessagingProvider messagingProvider;

@Inject
private MessageIdGenerator messageIdGenerator;

@Inject
private Settings<KeyStoreConf> settings;

@Inject
private Settings<As4Conf> as4settings;

@Inject
private CompressionUtil compressionUtil;

@Inject
private Settings<HttpConf> httpConfSettings;

@Inject
private TransmissionResponseConverter transmissionResponseConverter;

@Inject
private MerlinProvider merlinProvider;
private final MessagingProvider messagingProvider;
private final MessageIdGenerator messageIdGenerator;
private final Settings<KeyStoreConf> settings;
private final Settings<As4Conf> as4settings;
private final CompressionUtil compressionUtil;
private final Settings<HttpConf> httpConfSettings;
private final TransmissionResponseConverter transmissionResponseConverter;
private final MerlinProvider merlinProvider;
private final PolicyService policyService;
private final String browserType;

@Inject
private PolicyService policyService;
public As4MessageSender(MessagingProvider messagingProvider, MessageIdGenerator messageIdGenerator, Settings<KeyStoreConf> settings, Settings<As4Conf> as4settings, CompressionUtil compressionUtil, Settings<HttpConf> httpConfSettings, TransmissionResponseConverter transmissionResponseConverter, MerlinProvider merlinProvider, PolicyService policyService, BrowserTypeProvider browserTypeProvider) {
this.messagingProvider = messagingProvider;
this.messageIdGenerator = messageIdGenerator;
this.settings = settings;
this.as4settings = as4settings;
this.compressionUtil = compressionUtil;
this.httpConfSettings = httpConfSettings;
this.transmissionResponseConverter = transmissionResponseConverter;
this.merlinProvider = merlinProvider;
this.policyService = policyService;
this.browserType = browserTypeProvider.getBrowserType();
}

public TransmissionResponse send(TransmissionRequest request) throws OxalisAs4TransmissionException {
try (DispatchImpl<SOAPMessage> dispatch = createDispatch(request)) {
Expand Down Expand Up @@ -162,6 +160,9 @@ private DispatchImpl<SOAPMessage> createDispatch(TransmissionRequest request) th
final HTTPClientPolicy httpClientPolicy = httpConduit.getClient();
httpClientPolicy.setConnectionTimeout(httpConfSettings.getInt(HttpConf.TIMEOUT_CONNECT));
httpClientPolicy.setReceiveTimeout(httpConfSettings.getInt(HttpConf.TIMEOUT_READ));
httpClientPolicy.setAllowChunking(true);
httpClientPolicy.setChunkLength(8192);
httpClientPolicy.setBrowserType(browserType);

return dispatch;
}
Expand Down
45 changes: 45 additions & 0 deletions src/main/java/no/difi/oxalis/as4/outbound/BrowserTypeProvider.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package no.difi.oxalis.as4.outbound;

import com.google.inject.Inject;
import com.google.inject.Singleton;
import lombok.extern.slf4j.Slf4j;
import no.difi.oxalis.as4.inbound.OxalisAS4Version;
import no.difi.oxalis.commons.util.OxalisVersion;
import org.bouncycastle.asn1.x500.RDN;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x500.style.BCStyle;
import org.bouncycastle.asn1.x500.style.IETFUtils;
import org.bouncycastle.cert.jcajce.JcaX509CertificateHolder;

import java.security.cert.CertificateEncodingException;
import java.security.cert.X509Certificate;

@Slf4j
@Singleton
public class BrowserTypeProvider {

private final X509Certificate certificate;

@Inject
public BrowserTypeProvider(X509Certificate certificate) {
this.certificate = certificate;
}

public String getBrowserType() {
return String.format("Oxalis %s / AS4 %s / %s",
OxalisVersion.getVersion(),
OxalisAS4Version.getVersion(),
getCN());
}

private String getCN() {
try {
X500Name x500name = new JcaX509CertificateHolder(certificate).getSubject();
RDN cn = x500name.getRDNs(BCStyle.CN)[0];
return IETFUtils.valueToString(cn.getFirst().getValue());
} catch (CertificateEncodingException e) {
log.warn("Could not extract CN from certificate", e);
return "Unknown";
}
}
}
3 changes: 2 additions & 1 deletion src/main/java/no/difi/oxalis/as4/util/SOAPHeaderParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public static X509Certificate getSenderCertificate(SOAPHeader header) throws Oxa
if (bstNodes != null) {
for (int i = 0; i < bstNodes.getLength(); i++) {
Element bstElem = (Element) bstNodes.item(i);
if (bstElem.getAttribute("wsu:Id").equals(refUri)) {

if (bstElem.getAttributeNS("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd", "Id").equals(refUri)) {
try {
String pem = bstElem.getTextContent().replaceAll("[\r\n]+", "");
byte[] buf = Base64.getDecoder().decode(pem);
Expand Down