1
1
[ ![ 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 )
2
2
![ Maven Central Version] ( https://img.shields.io/maven-central/v/com.cosium.standard_webhooks_consumer/standard-webhooks-consumer )
3
3
4
- # standard-webhooks-consumer
4
+ # Standard Webhooks Consumer
5
5
6
6
https://www.standardwebhooks.com/ consumer side java library.
7
7
@@ -19,49 +19,51 @@ https://www.standardwebhooks.com/ consumer side java library.
19
19
20
20
``` java
21
21
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
- }
39
22
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
+ }
66
67
}
68
+
67
69
```
0 commit comments