diff --git a/connectors/webhook/src/main/java/io/camunda/connector/inbound/signature/strategy/URLAndBodyEncodingStrategy.java b/connectors/webhook/src/main/java/io/camunda/connector/inbound/signature/strategy/URLAndBodyEncodingStrategy.java index 777af12f2d..01cc246726 100644 --- a/connectors/webhook/src/main/java/io/camunda/connector/inbound/signature/strategy/URLAndBodyEncodingStrategy.java +++ b/connectors/webhook/src/main/java/io/camunda/connector/inbound/signature/strategy/URLAndBodyEncodingStrategy.java @@ -34,22 +34,13 @@ private String prepareForSignature(byte[] rawBody, String contentTypeHeader) { .map(param -> param.split("=")) .collect( Collectors.toMap(param -> param[0], param -> param.length == 1 ? "" : param[1])); - return strMap.keySet().stream() - .sorted() - .map(key -> key.concat(strMap.get(key))) - .reduce(String::concat) - .orElse(""); + return extractSignatureFromMap(strMap); } Object o = mapBytesToObject(rawBody); if (o instanceof Map map) { for (Map.Entry entry : map.entrySet()) { - if (entry.getKey() instanceof String) { - Map strMap = (Map) map; - return strMap.keySet().stream() - .sorted() - .map(key -> key.concat(strMap.get(key))) - .reduce(String::concat) - .orElse(""); + if (entry.getKey() instanceof String && entry.getValue() instanceof String) { + return extractSignatureFromMap((Map) map); } } } else { @@ -58,6 +49,14 @@ private String prepareForSignature(byte[] rawBody, String contentTypeHeader) { throw new RuntimeException("Can't extract signature data from body"); } + private String extractSignatureFromMap(Map map) { + return map.keySet().stream() + .sorted() + .map(key -> key.concat(map.get(key))) + .reduce(String::concat) + .orElse(""); + } + private String mapObjectToString(Object o) { try { return ConnectorsObjectMapperSupplier.DEFAULT_MAPPER.writeValueAsString(o);