Skip to content

Commit

Permalink
fix(web-hook) implement what has been discussed during the architectu…
Browse files Browse the repository at this point in the history
…re session 2
  • Loading branch information
mathias-vandaele committed Jul 12, 2024
1 parent 850be29 commit 5c1110a
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

public final class URLAndBodyEncodingStrategy implements HMACEncodingStrategy {

private static String extractSignatureData(final WebhookProcessingPayload payload) {
private String extractSignatureData(final WebhookProcessingPayload payload) {
return prepareForSignature(
payload.rawBody(), HttpWebhookUtil.extractContentType(payload.headers()));
}

private static String prepareForSignature(byte[] rawBody, String contentTypeHeader) {
private String prepareForSignature(byte[] rawBody, String contentTypeHeader) {
if (MediaType.FORM_DATA.toString().equalsIgnoreCase(contentTypeHeader)) {
String bodyAsString =
URLDecoder.decode(new String(rawBody, StandardCharsets.UTF_8), StandardCharsets.UTF_8);
Expand Down Expand Up @@ -58,17 +58,17 @@ private static String prepareForSignature(byte[] rawBody, String contentTypeHead
throw new RuntimeException("Can't extract signature data from body");
}

private static String mapObjectToString(Object o) {
private String mapObjectToString(Object o) {
try {
return ConnectorsObjectMapperSupplier.getCopy().writeValueAsString(o);
return ConnectorsObjectMapperSupplier.DEFAULT_MAPPER.writeValueAsString(o);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}

private static Object mapBytesToObject(byte[] rawBody) {
private Object mapBytesToObject(byte[] rawBody) {
try {
return ConnectorsObjectMapperSupplier.getCopy().readValue(rawBody, Object.class);
return ConnectorsObjectMapperSupplier.DEFAULT_MAPPER.readValue(rawBody, Object.class);
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down

0 comments on commit 5c1110a

Please sign in to comment.