diff --git a/src/main/java/network/oxalis/as4/inbound/As4InboundHandler.java b/src/main/java/network/oxalis/as4/inbound/As4InboundHandler.java index efd956c..ad1e31c 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 { + + 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."); + } + } + private X509Certificate getSenderCertificate(SOAPHeader soapHeader) { try { return SOAPHeaderParser.getSenderCertificate(soapHeader);