From 38a5316a1eafe4752ea6a72168a7dcf21d865146 Mon Sep 17 00:00:00 2001 From: BuddhimaN Date: Tue, 21 Sep 2021 11:20:08 +0530 Subject: [PATCH 1/2] Added fix for issue #143 --- .../oxalis/as4/inbound/As4InboundHandler.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/network/oxalis/as4/inbound/As4InboundHandler.java b/src/main/java/network/oxalis/as4/inbound/As4InboundHandler.java index efd956c..e03c327 100644 --- a/src/main/java/network/oxalis/as4/inbound/As4InboundHandler.java +++ b/src/main/java/network/oxalis/as4/inbound/As4InboundHandler.java @@ -83,6 +83,7 @@ public SOAPMessage handle(SOAPMessage request, MessageContext messageContext) th // Organize input data UserMessage userMessage = SOAPHeaderParser.getUserMessage(soapHeader); + validateUserMessage(userMessage); As4EnvelopeHeader envelopeHeader = parseAs4EnvelopeHeader(userMessage); messageContext.put(AS4MessageContextKey.ENVELOPE_HEADER, envelopeHeader); @@ -166,6 +167,20 @@ public SOAPMessage handle(SOAPMessage request, MessageContext messageContext) th return response; } + private void validateUserMessage(UserMessage userMessage) throws OxalisAs4Exception { + if (userMessage.getMessageInfo() == null){ + throw new OxalisAs4Exception("Error processing User Message. Message information not found"); + }else if (userMessage.getCollaborationInfo() == null){ + throw new OxalisAs4Exception("Error processing User Message. Collaboration information not found"); + }else if (userMessage.getPartyInfo() == null){ + throw new OxalisAs4Exception("Error processing User Message. Party information not found"); + }else if (userMessage.getMessageProperties() == null){ + throw new OxalisAs4Exception("Error processing User Message. Message properties not found"); + }else if (userMessage.getPayloadInfo() == null){ + throw new OxalisAs4Exception("Error processing User Message. Payload information not found"); + } + } + private X509Certificate getSenderCertificate(SOAPHeader soapHeader) { try { return SOAPHeaderParser.getSenderCertificate(soapHeader); From 122d505debc1156603e59d1b17064cfdc093993c Mon Sep 17 00:00:00 2001 From: BuddhimaN Date: Wed, 6 Oct 2021 06:05:24 +0530 Subject: [PATCH 2/2] Refactored fix for issue #143 --- .../oxalis/as4/inbound/As4InboundHandler.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/network/oxalis/as4/inbound/As4InboundHandler.java b/src/main/java/network/oxalis/as4/inbound/As4InboundHandler.java index e03c327..ad1e31c 100644 --- a/src/main/java/network/oxalis/as4/inbound/As4InboundHandler.java +++ b/src/main/java/network/oxalis/as4/inbound/As4InboundHandler.java @@ -168,16 +168,16 @@ public SOAPMessage handle(SOAPMessage request, MessageContext messageContext) th } private void validateUserMessage(UserMessage userMessage) throws OxalisAs4Exception { - if (userMessage.getMessageInfo() == null){ - throw new OxalisAs4Exception("Error processing User Message. Message information not found"); - }else if (userMessage.getCollaborationInfo() == null){ - throw new OxalisAs4Exception("Error processing User Message. Collaboration information not found"); - }else if (userMessage.getPartyInfo() == null){ - throw new OxalisAs4Exception("Error processing User Message. Party information not found"); - }else if (userMessage.getMessageProperties() == null){ - throw new OxalisAs4Exception("Error processing User Message. Message properties not found"); - }else if (userMessage.getPayloadInfo() == null){ - throw new OxalisAs4Exception("Error processing User Message. Payload information not found"); + + boolean isNull = Stream.of(userMessage.getMessageInfo(), + userMessage.getCollaborationInfo(), + userMessage.getPartyInfo(), + userMessage.getMessageProperties(), + userMessage.getPayloadInfo()). + anyMatch(Objects::isNull); + + if(isNull){ + throw new OxalisAs4Exception("Error processing User Message. Incomplete Data."); } }