Skip to content

Commit 5c5a0bb

Browse files
Nanne Baarsnbaars
authored andcommitted
Update poms and add checks and remove Guava dependency
1 parent 8557efa commit 5c5a0bb

File tree

8 files changed

+114
-36
lines changed

8 files changed

+114
-36
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip
22
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar

commons/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
<version>2.13.2.1</version>
2121
<scope>test</scope>
2222
</dependency>
23+
<dependency>
24+
<groupId>com.fasterxml.jackson.core</groupId>
25+
<artifactId>jackson-annotations</artifactId>
26+
<version>2.13.2</version>
27+
<scope>test</scope>
28+
</dependency>
2329
</dependencies>
2430

2531
<build>
Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,46 @@
11
package org.paseto4j.commons;
22

3-
import com.google.common.io.BaseEncoding;
4-
3+
/**
4+
* Copied from
5+
* http://www.docjar.com/html/api/com/sun/xml/internal/bind/DatatypeConverterImpl.java.html
6+
*/
57
public class HexToBytes {
68

7-
public static byte[] hexToBytes(String hex) {
8-
return BaseEncoding.base16().lowerCase().decode(hex);
9+
public static byte[] hexToBytes(String s) {
10+
final int len = s.length();
11+
12+
// "111" is not a valid hex encoding.
13+
if (len % 2 != 0) throw new IllegalArgumentException("hexBinary needs to be even-length: " + s);
14+
15+
byte[] out = new byte[len / 2];
16+
17+
for (int i = 0; i < len; i += 2) {
18+
int h = hexToBin(s.charAt(i));
19+
int l = hexToBin(s.charAt(i + 1));
20+
if (h == -1 || l == -1)
21+
throw new IllegalArgumentException("contains illegal character for hexBinary: " + s);
22+
23+
out[i / 2] = (byte) (h * 16 + l);
24+
}
25+
26+
return out;
27+
}
28+
29+
private static int hexToBin(char ch) {
30+
if ('0' <= ch && ch <= '9') return ch - '0';
31+
if ('A' <= ch && ch <= 'F') return ch - 'A' + 10;
32+
if ('a' <= ch && ch <= 'f') return ch - 'a' + 10;
33+
return -1;
934
}
1035

11-
public static String hexEncode(byte[] bytes) {
12-
return BaseEncoding.base16().lowerCase().encode(bytes);
36+
private static final char[] hexCode = "0123456789abcdef".toCharArray();
37+
38+
public static String hexEncode(byte[] data) {
39+
StringBuilder r = new StringBuilder(data.length * 2);
40+
for (byte b : data) {
41+
r.append(hexCode[(b >> 4) & 0xF]);
42+
r.append(hexCode[(b & 0xF)]);
43+
}
44+
return r.toString();
1345
}
1446
}

examples/pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,30 @@
2020
<artifactId>paseto4j-version1</artifactId>
2121
<version>${project.version}</version>
2222
</dependency>
23+
<dependency>
24+
<groupId>io.github.nbaars</groupId>
25+
<artifactId>paseto4j-commons</artifactId>
26+
<version>${project.version}</version>
27+
</dependency>
28+
29+
<!-- Start: only for Paseto Version 2 -->
2330
<dependency>
2431
<groupId>io.github.nbaars</groupId>
2532
<artifactId>paseto4j-version2</artifactId>
2633
<version>${project.version}</version>
2734
</dependency>
35+
<dependency>
36+
<groupId>org.apache.tuweni</groupId>
37+
<artifactId>tuweni-crypto</artifactId>
38+
<version>${tuweni.version}</version>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.apache.tuweni</groupId>
42+
<artifactId>tuweni-bytes</artifactId>
43+
<version>${tuweni.version}</version>
44+
</dependency>
45+
<!-- End: only for Paseto Version 2 -->
46+
2847
</dependencies>
2948

3049
</project>

pom.xml

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<maven.compiler.target>11</maven.compiler.target>
3434
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3535

36-
<bouncy.castle.version>1.69</bouncy.castle.version>
36+
<bouncy.castle.version>1.70</bouncy.castle.version>
3737

3838
<sonar.host.url>https://sonarcloud.io/</sonar.host.url>
3939
<sonar.organization>nbaars-github</sonar.organization>
@@ -45,10 +45,8 @@
4545
<sonar.surefire.reportsPath>${project.build.directory}/surefire-reports</sonar.surefire.reportsPath>
4646

4747
<paseto4j.deploy.skip>false</paseto4j.deploy.skip>
48-
<jnr-ffi.version>2.1.8</jnr-ffi.version>
4948
<tuweni.version>2.0.0</tuweni.version>
5049
<junit.version>5.2.0</junit.version>
51-
<guava.version>30.0-jre</guava.version>
5250
</properties>
5351

5452
<profiles>
@@ -62,7 +60,7 @@
6260
<plugin>
6361
<groupId>org.apache.maven.plugins</groupId>
6462
<artifactId>maven-source-plugin</artifactId>
65-
<version>2.2.1</version>
63+
<version>3.2.1</version>
6664
<executions>
6765
<execution>
6866
<id>attach-sources</id>
@@ -75,7 +73,7 @@
7573
<plugin>
7674
<groupId>org.apache.maven.plugins</groupId>
7775
<artifactId>maven-javadoc-plugin</artifactId>
78-
<version>2.9.1</version>
76+
<version>3.4.1</version>
7977
<executions>
8078
<execution>
8179
<id>attach-javadocs</id>
@@ -88,7 +86,7 @@
8886
<plugin>
8987
<groupId>org.apache.maven.plugins</groupId>
9088
<artifactId>maven-gpg-plugin</artifactId>
91-
<version>1.5</version>
89+
<version>3.0.1</version>
9290
<executions>
9391
<execution>
9492
<id>sign-artifacts</id>
@@ -108,7 +106,7 @@
108106
<plugin>
109107
<groupId>org.apache.maven.plugins</groupId>
110108
<artifactId>maven-deploy-plugin</artifactId>
111-
<version>3.0.0-M1</version>
109+
<version>3.0.0</version>
112110
<configuration>
113111
<skip>${paseto4j.deploy.skip}</skip>
114112
</configuration>
@@ -150,22 +148,54 @@
150148
<version>${junit.version}</version>
151149
<scope>test</scope>
152150
</dependency>
153-
<dependency>
154-
<groupId>org.junit.jupiter</groupId>
155-
<artifactId>junit-jupiter-engine</artifactId>
156-
<version>${junit.version}</version>
157-
<scope>test</scope>
158-
</dependency>
159-
<dependency>
160-
<groupId>com.google.guava</groupId>
161-
<artifactId>guava</artifactId>
162-
<version>${guava.version}</version>
163-
<scope>test</scope>
164-
</dependency>
165151
</dependencies>
166152

167153
<build>
168154
<plugins>
155+
<plugin>
156+
<groupId>org.apache.maven.plugins</groupId>
157+
<artifactId>maven-dependency-plugin</artifactId>
158+
<executions>
159+
<execution>
160+
<id>analyze</id>
161+
<goals>
162+
<goal>analyze-only</goal>
163+
</goals>
164+
<configuration>
165+
<ignoreNonCompile>true</ignoreNonCompile>
166+
<failOnWarning>true</failOnWarning>
167+
</configuration>
168+
</execution>
169+
</executions>
170+
<version>3.3.0</version>
171+
</plugin>
172+
<plugin>
173+
<groupId>org.apache.maven.plugins</groupId>
174+
<artifactId>maven-enforcer-plugin</artifactId>
175+
<version>3.1.0</version>
176+
<executions>
177+
<execution>
178+
<id>analyze</id>
179+
<goals>
180+
<goal>enforce</goal>
181+
</goals>
182+
<configuration>
183+
<rules>
184+
<requireReleaseDeps>
185+
<message>No Snapshots Allowed!</message>
186+
<onlyWhenRelease>true</onlyWhenRelease>
187+
</requireReleaseDeps>
188+
<requireMavenVersion>
189+
<version>[3.8.6,)</version>
190+
</requireMavenVersion>
191+
<requireJavaVersion>
192+
<version>[11,)</version>
193+
</requireJavaVersion>
194+
</rules>
195+
</configuration>
196+
</execution>
197+
</executions>
198+
</plugin>
169199
<plugin>
170200
<groupId>org.apache.maven.plugins</groupId>
171201
<artifactId>maven-compiler-plugin</artifactId>

version1/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@
2525
<artifactId>bcprov-jdk15on</artifactId>
2626
<version>${bouncy.castle.version}</version>
2727
</dependency>
28-
<dependency>
29-
<groupId>org.bouncycastle</groupId>
30-
<artifactId>bcpkix-jdk15on</artifactId>
31-
<version>${bouncy.castle.version}</version>
32-
</dependency>
3328

3429
<dependency>
3530
<groupId>io.github.nbaars</groupId>

version2/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@
1818
<artifactId>paseto4j-commons</artifactId>
1919
<version>${project.version}</version>
2020
</dependency>
21-
<dependency>
22-
<groupId>com.github.jnr</groupId>
23-
<artifactId>jnr-ffi</artifactId>
24-
<version>${jnr-ffi.version}</version>
25-
</dependency>
2621
<dependency>
2722
<groupId>org.apache.tuweni</groupId>
2823
<artifactId>tuweni-bytes</artifactId>

version3/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<groupId>org.bouncycastle</groupId>
3030
<artifactId>bcpkix-jdk15on</artifactId>
3131
<version>${bouncy.castle.version}</version>
32+
<scope>test</scope>
3233
</dependency>
3334

3435
<dependency>

0 commit comments

Comments
 (0)