Skip to content

Commit 8541a6e

Browse files
authored
First commit (#1)
1 parent dba17f0 commit 8541a6e

22 files changed

+1783
-1
lines changed

.github/dependabot.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "maven" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "weekly"

.github/workflows/ci.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
pull_request:
8+
branches:
9+
- '**'
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Set up JDK 17
18+
uses: actions/setup-java@v2
19+
with:
20+
java-version: '17'
21+
distribution: 'temurin'
22+
- name: Build with Maven
23+
run: ./mvnw --batch-mode clean verify

.gitignore

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### JetBrains template
3+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
4+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
5+
6+
# User-specific stuff:
7+
.idea
8+
9+
# Sensitive or high-churn files:
10+
.idea/dataSources.ids
11+
.idea/dataSources.xml
12+
.idea/dataSources.local.xml
13+
.idea/sqlDataSources.xml
14+
.idea/dynamic.xml
15+
.idea/uiDesigner.xml
16+
17+
# Gradle:
18+
.idea/gradle.xml
19+
.idea/libraries
20+
21+
# Mongo Explorer plugin:
22+
.idea/mongoSettings.xml
23+
24+
## File-based project format:
25+
*.iws
26+
*.iml
27+
28+
## Plugin-specific files:
29+
30+
# IntelliJ
31+
/out/
32+
33+
# mpeltonen/sbt-idea plugin
34+
.idea_modules/
35+
36+
# JIRA plugin
37+
atlassian-ide-plugin.xml
38+
39+
# Crashlytics plugin (for Android Studio and IntelliJ)
40+
com_crashlytics_export_strings.xml
41+
crashlytics.properties
42+
crashlytics-build.properties
43+
fabric.properties
44+
### Maven template
45+
target/
46+
pom.xml.tag
47+
pom.xml.releaseBackup
48+
pom.xml.versionsBackup
49+
pom.xml.next
50+
release.properties
51+
dependency-reduced-pom.xml
52+
buildNumber.properties
53+
.mvn/timing.properties
54+

.mvn/jvm.config

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED

.mvn/wrapper/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
maven-wrapper.jar

.mvn/wrapper/maven-wrapper.properties

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip
18+
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar

README.md

+66-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,67 @@
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+
![Maven Central Version](https://img.shields.io/maven-central/v/com.cosium.standard_webhooks_consumer/standard-webhooks-consumer)
3+
14
# standard-webhooks-consumer
2-
https://www.standardwebhooks.com/ consumer side java library
5+
6+
https://www.standardwebhooks.com/ consumer side java library.
7+
8+
# Maven dependency
9+
10+
```xml
11+
<dependency>
12+
<groupId>com.cosium.standard_webhooks_consumer</groupId>
13+
<artifactId>standard-webhooks-consumer</artifactId>
14+
<version>${standard-webhooks-consumer.version}</version>
15+
</dependency>
16+
```
17+
18+
# Signature verification
19+
20+
```java
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+
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+
}
66+
}
67+
```

0 commit comments

Comments
 (0)