diff --git a/src/main/java/com/eactive/eai/adapter/http/dynamic/filter/HmacSha256VerifyFilterKjb.java b/src/main/java/com/eactive/eai/adapter/http/dynamic/filter/HmacSha256VerifyFilterKjb.java index 92bed3d..182e48c 100644 --- a/src/main/java/com/eactive/eai/adapter/http/dynamic/filter/HmacSha256VerifyFilterKjb.java +++ b/src/main/java/com/eactive/eai/adapter/http/dynamic/filter/HmacSha256VerifyFilterKjb.java @@ -14,6 +14,7 @@ import javax.servlet.http.HttpServletResponse; //import org.apache.commons.net.util.Base64; import org.springframework.http.HttpStatus; import org.apache.commons.lang3.StringUtils; +import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.JSONValue; @@ -157,18 +158,17 @@ public class HmacSha256VerifyFilterKjb implements HttpAdapterFilter { String outboundBody = (String) resultMessage; try { - - if (outboundBody.startsWith(KJB_ROOTLESS_ARRAY)) { - outboundBody = outboundBody.substring(KJB_ROOTLESS_ARRAY.length()); - - if (outboundBody.endsWith("}")) { - outboundBody = outboundBody.substring(0, outboundBody.length() - 1); - } + + Object root = JSONValue.parse(outboundBody); + + if (root instanceof JSONObject && ((JSONObject) root).containsKey("KJB_ROOTLESS_ARRAY")) { + JSONArray jsonArray = (JSONArray) ((JSONObject) root).get("KJB_ROOTLESS_ARRAY"); + outboundBody = jsonArray.toJSONString(); } - + String clientSecret = assignClientSecret(prop, request); String macBody = calculateHMAC(outboundBody, clientSecret); - + response.addHeader("x-obp-signature-body", macBody); response.addHeader("x-obp-partnercode", request.getHeader("x-obp-partnercode")); response.addHeader("x-obp-txid", prop.getProperty(TransactionContextKeys.TRANSACTION_UUID,""));