https://github.com/cosium/standard-webhooks-consumer
https://www.standardwebhooks.com/ consumer side java library
https://github.com/cosium/standard-webhooks-consumer
Last synced: over 1 year ago
JSON representation
https://www.standardwebhooks.com/ consumer side java library
- Host: GitHub
- URL: https://github.com/cosium/standard-webhooks-consumer
- Owner: Cosium
- License: mit
- Created: 2025-01-26T16:25:11.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-02-24T13:55:02.000Z (over 1 year ago)
- Last Synced: 2025-03-01T17:41:47.807Z (over 1 year ago)
- Language: Java
- Size: 34.2 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/Cosium/standard-webhooks-consumer/actions/workflows/ci.yml)
[](https://central.sonatype.com/artifact/com.cosium.standard_webhooks_consumer/standard-webhooks-consumer)
# Standard Webhooks Consumer
https://www.standardwebhooks.com/ consumer side java library.
# Maven dependency
```xml
com.cosium.standard_webhooks_consumer
standard-webhooks-consumer
${standard-webhooks-consumer.version}
```
# Signature verification
```java
public class App {
public void verifySymmetricSignature() throws WebhookSignatureVerificationException {
WebhookSignatureVerifier verifier =
WebhookSignatureVerifier.builder("whsec_b6Ovv5eS7H5seJrGSStBYDivs8v2/KrFjfMaVZYsi7w=")
.build();
HttpHeaders httpHeaders =
createHttpHeaders(
Map.of(
"webhook-id",
"7a2486b3-31cf-4bd3-a460-df8845d16cd5",
"webhook-timestamp",
String.valueOf(1737987215),
"webhook-signature",
"v1,iayM3VaiYCEDP/CxWUFWcxUCJk2YmBDQHtHTsaHzrwo="));
verifier.verify(httpHeaders, "{\"greetings\": \"Hello World\"}");
}
public void verifyAsymmetricSignature() throws WebhookSignatureVerificationException {
WebhookSignatureVerifier verifier =
WebhookSignatureVerifier.builder(
"whpk_MCowBQYDK2VwAyEAkp3dScDPIzT1CwUFUMdzyPbWOAQaCF9z4ucuKuZD7Io=")
.build();
HttpHeaders httpHeaders =
createHttpHeaders(
Map.of(
"webhook-id",
"7a2486b3-31cf-4bd3-a460-df8845d16cd5",
"webhook-timestamp",
String.valueOf(1737987215),
"webhook-signature",
"v1a,XVbiOe+IzCKsXBuhb52iHLroqxFJofJNMQRL80I2kWO0+kXu2gcqgXAzontxDDgpMDw6SMh4sjzr+67EmUUzDg=="));
verifier.verify(httpHeaders, "{\"greetings\": \"Hello World\"}");
}
private HttpHeaders createHttpHeaders(Map headers) {
return HttpHeaders.of(
headers.entrySet().stream()
.map(entry -> Map.entry(entry.getKey(), List.of(entry.getValue())))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)),
(s, s2) -> true);
}
}
```