Skip to content

Commit fbeb7ad

Browse files
committed
[#519] Add src/main/java9/module-info.java files and a simple IT.
1 parent 5812f63 commit fbeb7ad

File tree

17 files changed

+252
-5
lines changed

17 files changed

+252
-5
lines changed

api/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@
5050
</plugins>
5151
</build>
5252

53-
</project>
53+
</project>

api/src/main/java9/module-info.java

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module io.jsonwebtoken.jjwt.api {
2+
exports io.jsonwebtoken;
3+
exports io.jsonwebtoken.io;
4+
exports io.jsonwebtoken.lang;
5+
exports io.jsonwebtoken.security;
6+
}

extensions/gson/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@
5353
</plugins>
5454
</build>
5555

56-
</project>
56+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module io.jsonwebtoken.jjwt.ext.gson {
2+
requires transitive com.google.gson;
3+
requires io.jsonwebtoken.jjwt.api;
4+
5+
exports io.jsonwebtoken.gson.io;
6+
7+
provides io.jsonwebtoken.io.Deserializer with
8+
io.jsonwebtoken.gson.io.GsonDeserializer;
9+
provides io.jsonwebtoken.io.Serializer with
10+
io.jsonwebtoken.gson.io.GsonSerializer;
11+
}

extensions/jackson/pom.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,5 @@
6969
</plugin>
7070
</plugins>
7171
</build>
72-
</project>
72+
73+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module io.jsonwebtoken.jjwt.ext.jackson {
2+
requires transitive com.fasterxml.jackson.core;
3+
requires transitive com.fasterxml.jackson.databind;
4+
requires io.jsonwebtoken.jjwt.api;
5+
6+
exports io.jsonwebtoken.jackson.io;
7+
8+
provides io.jsonwebtoken.io.Deserializer with
9+
io.jsonwebtoken.jackson.io.JacksonDeserializer;
10+
provides io.jsonwebtoken.io.Serializer with
11+
io.jsonwebtoken.jackson.io.JacksonSerializer;
12+
13+
}

extensions/orgjson/pom.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,5 @@
6969
</plugin>
7070
</plugins>
7171
</build>
72-
</project>
72+
73+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module io.jsonwebtoken.jjwt.ext.orgjson {
2+
requires transitive org.json;
3+
requires io.jsonwebtoken.jjwt.api;
4+
5+
exports io.jsonwebtoken.orgjson.io;
6+
7+
provides io.jsonwebtoken.io.Deserializer with io.jsonwebtoken.orgjson.io.OrgJsonDeserializer;
8+
provides io.jsonwebtoken.io.Serializer with io.jsonwebtoken.orgjson.io.OrgJsonSerializer;
9+
}

impl/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,4 @@
6868
</dependency>
6969
</dependencies>
7070

71-
</project>
71+
</project>

impl/src/main/java9/module-info.java

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module io.jsonwebtoken.jjwt.impl {
2+
requires io.jsonwebtoken.jjwt.api;
3+
4+
exports io.jsonwebtoken.impl;
5+
exports io.jsonwebtoken.impl.compression;
6+
exports io.jsonwebtoken.impl.lang;
7+
8+
provides io.jsonwebtoken.CompressionCodec with
9+
io.jsonwebtoken.impl.compression.DeflateCompressionAlgorithm,
10+
io.jsonwebtoken.impl.compression.GzipCompressionAlgorithm;
11+
12+
uses io.jsonwebtoken.CompressionCodec;
13+
uses io.jsonwebtoken.io.Deserializer;
14+
uses io.jsonwebtoken.io.Serializer;
15+
}

integration-tests/pom.xml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>io.jsonwebtoken</groupId>
9+
<artifactId>jjwt-root</artifactId>
10+
<version>0.12.7-SNAPSHOT</version>
11+
</parent>
12+
13+
<artifactId>jjwt-integration-tests</artifactId>
14+
<name>JJWT :: Integration-Tests</name>
15+
<packaging>pom</packaging>
16+
17+
<properties>
18+
<maven.deploy.skip>true</maven.deploy.skip>
19+
</properties>
20+
21+
<modules>
22+
<module>unsigned-jackson</module>
23+
</modules>
24+
25+
</project>
+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>io.jsonwebtoken</groupId>
9+
<artifactId>jjwt-integration-tests</artifactId>
10+
<version>0.12.7-SNAPSHOT</version>
11+
</parent>
12+
13+
<artifactId>jjwt-integration-tests-unsigned-jackson</artifactId>
14+
<name>JJWT :: Integration-Tests :: unsigned-jackson</name>
15+
<description>Create and parse an unsigned JWT using Jackson and JPMS.</description>
16+
<packaging>jar</packaging>
17+
18+
<properties>
19+
<maven.compiler.release>9</maven.compiler.release>
20+
<maven.deploy.skip>true</maven.deploy.skip>
21+
</properties>
22+
23+
<dependencies>
24+
<dependency>
25+
<groupId>io.jsonwebtoken</groupId>
26+
<artifactId>jjwt-api</artifactId>
27+
<version>${project.version}</version>
28+
</dependency>
29+
<dependency>
30+
<groupId>io.jsonwebtoken</groupId>
31+
<artifactId>jjwt-impl</artifactId>
32+
<version>${project.version}</version>
33+
<scope>runtime</scope>
34+
</dependency>
35+
<dependency>
36+
<groupId>io.jsonwebtoken</groupId>
37+
<artifactId>jjwt-jackson</artifactId>
38+
<version>${project.version}</version>
39+
<scope>runtime</scope>
40+
</dependency>
41+
</dependencies>
42+
43+
<build>
44+
<plugins>
45+
<plugin>
46+
<groupId>org.apache.maven.plugins</groupId>
47+
<artifactId>maven-javadoc-plugin</artifactId>
48+
<configuration>
49+
<skip>true</skip>
50+
<detectJavaApiLink>false</detectJavaApiLink>
51+
</configuration>
52+
</plugin>
53+
<!--
54+
this plugin needs to be disabled as long as we are stuck with plugin version 3.3.0, as it cannot
55+
handle Java 9 module-info.class files.
56+
This will also use an empty MANIFEST.MF file, since there is no way in maven to unsetting
57+
an entry (like archive/manifestFile for the jar plugin).
58+
-->
59+
<plugin>
60+
<groupId>org.apache.felix</groupId>
61+
<artifactId>maven-bundle-plugin</artifactId>
62+
<executions>
63+
<execution>
64+
<id>bundle-manifest</id>
65+
<phase>none</phase>
66+
</execution>
67+
</executions>
68+
</plugin>
69+
</plugins>
70+
</build>
71+
72+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package io.jsonwebtoken.it.unsigned;
2+
3+
import io.jsonwebtoken.*;
4+
5+
import java.time.Instant;
6+
import java.util.Date;
7+
import java.util.List;
8+
9+
public class UnsignedJwtCreator {
10+
11+
public UnsignedJwtCreator() {
12+
// explicit
13+
}
14+
15+
public String create() {
16+
return Jwts.builder()
17+
.claim("roles", List.of("admin"))
18+
.subject("jjwt")
19+
.id("jjwt-0")
20+
.issuedAt(Date.from(Instant.now()))
21+
.notBefore(Date.from(Instant.now()))
22+
.compact();
23+
}
24+
25+
public Jwt<Header, Claims> read(String jwt) {
26+
final JwtParser jwtParser = Jwts.parser()
27+
.unsecured()
28+
.requireSubject("jjwt")
29+
.build();
30+
31+
return jwtParser.parseUnsecuredClaims(jwt);
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module io.jsonwebtoken.jjwt.it.unsigned {
2+
requires io.jsonwebtoken.jjwt.api;
3+
4+
}

integration-tests/unsigned-jackson/src/main/resources/META-INF/MANIFEST.MF

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package io.jsonwebtoken.it.unsigned;
2+
import io.jsonwebtoken.Claims;
3+
import io.jsonwebtoken.Header;
4+
import io.jsonwebtoken.Jws;
5+
import io.jsonwebtoken.Jwt;
6+
import org.junit.Test;
7+
8+
import java.util.List;
9+
10+
import static org.junit.Assert.assertEquals;
11+
import static org.junit.Assert.assertTrue;
12+
13+
14+
public class UnsignedJwtCreatorTest {
15+
16+
@Test
17+
public void testUnsignedJwt() {
18+
// given:
19+
final UnsignedJwtCreator jwtCreator = new UnsignedJwtCreator();
20+
final String jwtString = jwtCreator.create();
21+
22+
// when
23+
final Jwt<Header, Claims> readBackJws = jwtCreator.read(jwtString);
24+
25+
// then
26+
final Claims jwtBody = readBackJws.getPayload();
27+
assertEquals("jjwt-0", jwtBody.getId());
28+
assertEquals("jjwt", jwtBody.getSubject());
29+
assertTrue(jwtBody.get("roles", List.class).contains("admin"));
30+
}
31+
32+
}

pom.xml

+25
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,32 @@
733733
<surefire.useModulePath>false</surefire.useModulePath>
734734
<maven.javadoc.additionalOptions>-html5</maven.javadoc.additionalOptions>
735735
<surefire.argLine>${test.addOpens}, --illegal-access=debug</surefire.argLine>
736+
<maven.compiler.release>${jdk.version}</maven.compiler.release>
736737
</properties>
738+
<modules>
739+
<module>integration-tests</module>
740+
</modules>
741+
<build>
742+
<plugins>
743+
<plugin>
744+
<groupId>org.apache.maven.plugins</groupId>
745+
<artifactId>maven-compiler-plugin</artifactId>
746+
<executions>
747+
<execution>
748+
<id>compile-module-info</id>
749+
<phase>compile</phase>
750+
<goals>
751+
<goal>compile</goal>
752+
</goals>
753+
<configuration>
754+
<release>9</release>
755+
<compileSourceRoots>${project.basedir}/src/main/java9</compileSourceRoots>
756+
</configuration>
757+
</execution>
758+
</executions>
759+
</plugin>
760+
</plugins>
761+
</build>
737762
</profile>
738763
<profile>
739764
<id>jdk17AndLater</id>

0 commit comments

Comments
 (0)