Skip to content

Commit ee36467

Browse files
committedJan 27, 2025·
Cleanup README.md
1 parent f9d448b commit ee36467

File tree

1 file changed

+46
-44
lines changed

1 file changed

+46
-44
lines changed
 

‎README.md

+46-44
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[![Build Status](https://github.com/Cosium/standard-webhooks-consumer/actions/workflows/ci.yml/badge.svg)](https://github.com/Cosium/standard-webhooks-consumer/actions/workflows/ci.yml)
22
![Maven Central Version](https://img.shields.io/maven-central/v/com.cosium.standard_webhooks_consumer/standard-webhooks-consumer)
33

4-
# standard-webhooks-consumer
4+
# Standard Webhooks Consumer
55

66
https://www.standardwebhooks.com/ consumer side java library.
77

@@ -19,49 +19,51 @@ https://www.standardwebhooks.com/ consumer side java library.
1919

2020
```java
2121
public class App {
22-
23-
public void verifySymmetricSignature() throws WebhookSignatureVerificationException {
24-
25-
WebhookSignatureVerifier verifier =
26-
WebhookSignatureVerifier.builder("whsec_b6Ovv5eS7H5seJrGSStBYDivs8v2/KrFjfMaVZYsi7w=")
27-
.build();
28-
HttpHeaders httpHeaders =
29-
createHttpHeaders(
30-
Map.of(
31-
"webhook-id",
32-
"7a2486b3-31cf-4bd3-a460-df8845d16cd5",
33-
"webhook-timestamp",
34-
String.valueOf(1737987215),
35-
"webhook-signature",
36-
"v1,iayM3VaiYCEDP/CxWUFWcxUCJk2YmBDQHtHTsaHzrwo="));
37-
verifier.verify(httpHeaders, "{\"greetings\": \"Hello World\"}");
38-
}
3922

40-
public void verifyAsymmetricSignature() throws WebhookSignatureVerificationException {
41-
42-
WebhookSignatureVerifier verifier =
43-
WebhookSignatureVerifier.builder("whpk_MCowBQYDK2VwAyEAkp3dScDPIzT1CwUFUMdzyPbWOAQaCF9z4ucuKuZD7Io=")
44-
.build();
45-
46-
HttpHeaders httpHeaders =
47-
createHttpHeaders(
48-
Map.of(
49-
"webhook-id",
50-
"7a2486b3-31cf-4bd3-a460-df8845d16cd5",
51-
"webhook-timestamp",
52-
String.valueOf(1737987215),
53-
"webhook-signature",
54-
"v1a,XVbiOe+IzCKsXBuhb52iHLroqxFJofJNMQRL80I2kWO0+kXu2gcqgXAzontxDDgpMDw6SMh4sjzr+67EmUUzDg=="));
55-
56-
verifier.verify(httpHeaders, "{\"greetings\": \"Hello World\"}");
57-
}
58-
59-
private HttpHeaders createHttpHeaders(Map<String, String> headers) {
60-
return HttpHeaders.of(
61-
headers.entrySet().stream()
62-
.map(entry -> Map.entry(entry.getKey(), List.of(entry.getValue())))
63-
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)),
64-
(s, s2) -> true);
65-
}
23+
public void verifySymmetricSignature() throws WebhookSignatureVerificationException {
24+
25+
WebhookSignatureVerifier verifier =
26+
WebhookSignatureVerifier.builder("whsec_b6Ovv5eS7H5seJrGSStBYDivs8v2/KrFjfMaVZYsi7w=")
27+
.build();
28+
HttpHeaders httpHeaders =
29+
createHttpHeaders(
30+
Map.of(
31+
"webhook-id",
32+
"7a2486b3-31cf-4bd3-a460-df8845d16cd5",
33+
"webhook-timestamp",
34+
String.valueOf(1737987215),
35+
"webhook-signature",
36+
"v1,iayM3VaiYCEDP/CxWUFWcxUCJk2YmBDQHtHTsaHzrwo="));
37+
verifier.verify(httpHeaders, "{\"greetings\": \"Hello World\"}");
38+
}
39+
40+
public void verifyAsymmetricSignature() throws WebhookSignatureVerificationException {
41+
42+
WebhookSignatureVerifier verifier =
43+
WebhookSignatureVerifier.builder(
44+
"whpk_MCowBQYDK2VwAyEAkp3dScDPIzT1CwUFUMdzyPbWOAQaCF9z4ucuKuZD7Io=")
45+
.build();
46+
47+
HttpHeaders httpHeaders =
48+
createHttpHeaders(
49+
Map.of(
50+
"webhook-id",
51+
"7a2486b3-31cf-4bd3-a460-df8845d16cd5",
52+
"webhook-timestamp",
53+
String.valueOf(1737987215),
54+
"webhook-signature",
55+
"v1a,XVbiOe+IzCKsXBuhb52iHLroqxFJofJNMQRL80I2kWO0+kXu2gcqgXAzontxDDgpMDw6SMh4sjzr+67EmUUzDg=="));
56+
57+
verifier.verify(httpHeaders, "{\"greetings\": \"Hello World\"}");
58+
}
59+
60+
private HttpHeaders createHttpHeaders(Map<String, String> headers) {
61+
return HttpHeaders.of(
62+
headers.entrySet().stream()
63+
.map(entry -> Map.entry(entry.getKey(), List.of(entry.getValue())))
64+
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)),
65+
(s, s2) -> true);
66+
}
6667
}
68+
6769
```

0 commit comments

Comments
 (0)
Please sign in to comment.