Skip to content

Commit a858153

Browse files
bdemerslhazlewood
andauthored
Adds new convenience module using the old package name (#629)
* Adds new connivence module, in place of the old io.jsonwebtoken:jjwt module Some folks are unaware of newer JJWT versions because they are still using the old io.jsonwebtoken:jjwt module. This makes automatic version updates tools "just work" for them NOTE: This new module is _basically_ an empty jar, that adds `jjwt-api` (compile scope), `jjwt-impl` (runtime scope), and `jjwt-jackson` (runtime scope) transitive dependencies. * Minor cleanup before changing `all` directory name * Renamed `all` to `tdjar` (transitive dependency jar) Co-authored-by: Les Hazlewood <[email protected]>
1 parent aecf2c1 commit a858153

File tree

10 files changed

+161
-8
lines changed

10 files changed

+161
-8
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
## Release Notes
22

3+
### JJWT_RELEASE_VERSION
4+
5+
* Adds a simplified "starter" jar that automatically pulls in `jjwt-api`, `jjwt-impl` and `jjwt-jackson`, useful when
6+
upgrading from the older `io.jsonwebtoken:jjwt:*` to the project's current flexible module structure.
7+
38
### 0.11.5
49

510
This patch release adds additional security guards against an ECDSA bug in Java SE versions 15-15.0.6, 17-17.0.2, and 18
@@ -15,7 +20,7 @@ their JVM in a timely manner.
1520
However, even with these additional JJWT security guards, the root cause of the issue is the JVM, so it **strongly
1621
recommended** to upgrade your JVM to version
1722
15.0.7, 17.0.3, or 18.0.1 or later to ensure the bug does not surface elsewhere in your application code or any other
18-
third party library in your application that may not contain similar security guards.
23+
third party library in your application that may not contain similar security guards.
1924

2025
Issues included in this patch are listed in the [JJWT 0.11.5 milestone](https://github.com/jwtk/jjwt/milestone/26?closed=1).
2126

api/src/main/java/io/jsonwebtoken/lang/Collections.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@
1515
*/
1616
package io.jsonwebtoken.lang;
1717

18+
import java.util.ArrayList;
1819
import java.util.Arrays;
19-
import java.util.*;
20+
import java.util.Collection;
21+
import java.util.Enumeration;
22+
import java.util.Iterator;
23+
import java.util.List;
24+
import java.util.Map;
25+
import java.util.Properties;
2026

2127
public final class Collections {
2228

api/src/main/java/io/jsonwebtoken/lang/Strings.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,18 @@
1616
package io.jsonwebtoken.lang;
1717

1818
import java.nio.charset.Charset;
19+
import java.util.ArrayList;
1920
import java.util.Arrays;
20-
import java.util.*;
21+
import java.util.Collection;
22+
import java.util.Enumeration;
23+
import java.util.Iterator;
24+
import java.util.LinkedList;
25+
import java.util.List;
26+
import java.util.Locale;
27+
import java.util.Properties;
28+
import java.util.Set;
29+
import java.util.StringTokenizer;
30+
import java.util.TreeSet;
2131

2232
public final class Strings {
2333

impl/src/main/java/io/jsonwebtoken/impl/DefaultJwtBuilder.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,21 @@
1515
*/
1616
package io.jsonwebtoken.impl;
1717

18-
import io.jsonwebtoken.*;
18+
import io.jsonwebtoken.Claims;
19+
import io.jsonwebtoken.CompressionCodec;
20+
import io.jsonwebtoken.Header;
21+
import io.jsonwebtoken.JwsHeader;
22+
import io.jsonwebtoken.JwtBuilder;
23+
import io.jsonwebtoken.JwtParser;
24+
import io.jsonwebtoken.SignatureAlgorithm;
1925
import io.jsonwebtoken.impl.crypto.DefaultJwtSigner;
2026
import io.jsonwebtoken.impl.crypto.JwtSigner;
2127
import io.jsonwebtoken.impl.lang.LegacyServices;
22-
import io.jsonwebtoken.io.*;
28+
import io.jsonwebtoken.io.Decoders;
29+
import io.jsonwebtoken.io.Encoder;
30+
import io.jsonwebtoken.io.Encoders;
31+
import io.jsonwebtoken.io.SerializationException;
32+
import io.jsonwebtoken.io.Serializer;
2333
import io.jsonwebtoken.lang.Assert;
2434
import io.jsonwebtoken.lang.Collections;
2535
import io.jsonwebtoken.lang.Strings;

impl/src/main/java/io/jsonwebtoken/impl/DefaultJwtParser.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,27 @@
1515
*/
1616
package io.jsonwebtoken.impl;
1717

18-
import io.jsonwebtoken.*;
18+
import io.jsonwebtoken.ClaimJwtException;
19+
import io.jsonwebtoken.Claims;
20+
import io.jsonwebtoken.Clock;
21+
import io.jsonwebtoken.CompressionCodec;
22+
import io.jsonwebtoken.CompressionCodecResolver;
23+
import io.jsonwebtoken.ExpiredJwtException;
24+
import io.jsonwebtoken.Header;
25+
import io.jsonwebtoken.IncorrectClaimException;
26+
import io.jsonwebtoken.InvalidClaimException;
27+
import io.jsonwebtoken.Jws;
28+
import io.jsonwebtoken.JwsHeader;
29+
import io.jsonwebtoken.Jwt;
30+
import io.jsonwebtoken.JwtHandler;
31+
import io.jsonwebtoken.JwtHandlerAdapter;
32+
import io.jsonwebtoken.JwtParser;
33+
import io.jsonwebtoken.MalformedJwtException;
34+
import io.jsonwebtoken.MissingClaimException;
35+
import io.jsonwebtoken.PrematureJwtException;
36+
import io.jsonwebtoken.SignatureAlgorithm;
37+
import io.jsonwebtoken.SigningKeyResolver;
38+
import io.jsonwebtoken.UnsupportedJwtException;
1939
import io.jsonwebtoken.impl.compression.DefaultCompressionCodecResolver;
2040
import io.jsonwebtoken.impl.crypto.DefaultJwtSignatureValidator;
2141
import io.jsonwebtoken.impl.crypto.JwtSignatureValidator;

impl/src/main/java/io/jsonwebtoken/impl/JwtMap.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@
1919
import io.jsonwebtoken.lang.DateFormats;
2020

2121
import java.text.ParseException;
22-
import java.util.*;
22+
import java.util.Calendar;
23+
import java.util.Collection;
24+
import java.util.Date;
25+
import java.util.LinkedHashMap;
26+
import java.util.Map;
27+
import java.util.Set;
2328

2429
public class JwtMap implements Map<String, Object> {
2530

impl/src/main/java/io/jsonwebtoken/impl/compression/DefaultCompressionCodecResolver.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
*/
1616
package io.jsonwebtoken.impl.compression;
1717

18+
import io.jsonwebtoken.CompressionCodec;
19+
import io.jsonwebtoken.CompressionCodecResolver;
1820
import io.jsonwebtoken.CompressionCodecs;
19-
import io.jsonwebtoken.*;
21+
import io.jsonwebtoken.CompressionException;
22+
import io.jsonwebtoken.Header;
2023
import io.jsonwebtoken.impl.lang.Services;
2124
import io.jsonwebtoken.lang.Assert;
2225
import io.jsonwebtoken.lang.Strings;

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@
152152
<module>api</module>
153153
<module>impl</module>
154154
<module>extensions</module>
155+
<module>tdjar</module>
155156
</modules>
156157

157158
<dependencyManagement>
@@ -161,6 +162,11 @@
161162
<artifactId>jjwt-api</artifactId>
162163
<version>${project.version}</version>
163164
</dependency>
165+
<dependency>
166+
<groupId>io.jsonwebtoken</groupId>
167+
<artifactId>jjwt-impl</artifactId>
168+
<version>${project.version}</version>
169+
</dependency>
164170
<dependency>
165171
<groupId>io.jsonwebtoken</groupId>
166172
<artifactId>jjwt-jackson</artifactId>

tdjar/pom.xml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright 2020 JWTK
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
18+
19+
<modelVersion>4.0.0</modelVersion>
20+
21+
<parent>
22+
<groupId>io.jsonwebtoken</groupId>
23+
<artifactId>jjwt-root</artifactId>
24+
<version>0.11.6-SNAPSHOT</version>
25+
<relativePath>../pom.xml</relativePath>
26+
</parent>
27+
28+
<artifactId>jjwt</artifactId>
29+
<name>JJWT :: Legacy Transitive Dependency Jar</name>
30+
<description>Legacy dependency. Please update your dependencies as documented here: https://github.com/jwtk/jjwt#installation</description>
31+
<packaging>jar</packaging>
32+
33+
<properties>
34+
<jjwt.root>${basedir}/..</jjwt.root>
35+
</properties>
36+
37+
<dependencies>
38+
<dependency>
39+
<groupId>io.jsonwebtoken</groupId>
40+
<artifactId>jjwt-api</artifactId>
41+
</dependency>
42+
<dependency>
43+
<groupId>io.jsonwebtoken</groupId>
44+
<artifactId>jjwt-impl</artifactId>
45+
<scope>runtime</scope>
46+
</dependency>
47+
<dependency>
48+
<groupId>io.jsonwebtoken</groupId>
49+
<artifactId>jjwt-jackson</artifactId>
50+
<scope>runtime</scope>
51+
</dependency>
52+
</dependencies>
53+
</project>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package io.jsonwebtoken.all
2+
3+
import io.jsonwebtoken.*
4+
import io.jsonwebtoken.security.Keys
5+
import org.junit.Test
6+
7+
import static org.hamcrest.CoreMatchers.equalTo
8+
import static org.hamcrest.CoreMatchers.notNullValue
9+
import static org.hamcrest.MatcherAssert.assertThat
10+
11+
/**
12+
* This test ensures that the included dependency are all that is needed to use JJWT.
13+
*/
14+
class BasicTest {
15+
16+
@Test
17+
void basicUsageTest() {
18+
def key = Keys.secretKeyFor(SignatureAlgorithm.HS256)
19+
20+
String token = Jwts.builder()
21+
.setSubject("test-user")
22+
.claim("test", "basicUsageTest")
23+
.signWith(key, SignatureAlgorithm.HS256)
24+
.compact()
25+
26+
JwtParser parser = Jwts.parserBuilder()
27+
.setSigningKey(key)
28+
.build()
29+
30+
Jwt<Header, Claims> result = parser.parseClaimsJws(token)
31+
assertThat result, notNullValue()
32+
assertThat result.getBody().getSubject(), equalTo("test-user")
33+
assertThat result.getBody().get("test", String), equalTo("basicUsageTest")
34+
}
35+
}

0 commit comments

Comments
 (0)