diff --git a/api/pom.xml b/api/pom.xml index fac58aa6e..27fa55273 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -50,4 +50,4 @@ - \ No newline at end of file + diff --git a/api/src/main/java9/module-info.java b/api/src/main/java9/module-info.java new file mode 100644 index 000000000..266df2845 --- /dev/null +++ b/api/src/main/java9/module-info.java @@ -0,0 +1,6 @@ +module io.jsonwebtoken.jjwt.api { + exports io.jsonwebtoken; + exports io.jsonwebtoken.io; + exports io.jsonwebtoken.lang; + exports io.jsonwebtoken.security; +} diff --git a/extensions/gson/pom.xml b/extensions/gson/pom.xml index 35e458e27..2d06c99ea 100644 --- a/extensions/gson/pom.xml +++ b/extensions/gson/pom.xml @@ -53,4 +53,4 @@ - \ No newline at end of file + diff --git a/extensions/gson/src/main/java9/module-info.java b/extensions/gson/src/main/java9/module-info.java new file mode 100644 index 000000000..158678acb --- /dev/null +++ b/extensions/gson/src/main/java9/module-info.java @@ -0,0 +1,11 @@ +module io.jsonwebtoken.jjwt.ext.gson { + requires transitive com.google.gson; + requires io.jsonwebtoken.jjwt.api; + + exports io.jsonwebtoken.gson.io; + + provides io.jsonwebtoken.io.Deserializer with + io.jsonwebtoken.gson.io.GsonDeserializer; + provides io.jsonwebtoken.io.Serializer with + io.jsonwebtoken.gson.io.GsonSerializer; +} diff --git a/extensions/jackson/pom.xml b/extensions/jackson/pom.xml index 469789f61..6f00d32c2 100644 --- a/extensions/jackson/pom.xml +++ b/extensions/jackson/pom.xml @@ -69,4 +69,5 @@ - \ No newline at end of file + + diff --git a/extensions/jackson/src/main/java9/module-info.java b/extensions/jackson/src/main/java9/module-info.java new file mode 100644 index 000000000..ae4b8870e --- /dev/null +++ b/extensions/jackson/src/main/java9/module-info.java @@ -0,0 +1,13 @@ +module io.jsonwebtoken.jjwt.ext.jackson { + requires transitive com.fasterxml.jackson.core; + requires transitive com.fasterxml.jackson.databind; + requires io.jsonwebtoken.jjwt.api; + + exports io.jsonwebtoken.jackson.io; + + provides io.jsonwebtoken.io.Deserializer with + io.jsonwebtoken.jackson.io.JacksonDeserializer; + provides io.jsonwebtoken.io.Serializer with + io.jsonwebtoken.jackson.io.JacksonSerializer; + +} diff --git a/extensions/orgjson/pom.xml b/extensions/orgjson/pom.xml index 5d9da307f..acd666844 100644 --- a/extensions/orgjson/pom.xml +++ b/extensions/orgjson/pom.xml @@ -69,4 +69,5 @@ - \ No newline at end of file + + diff --git a/extensions/orgjson/src/main/java9/module-info.java b/extensions/orgjson/src/main/java9/module-info.java new file mode 100644 index 000000000..7f38196bb --- /dev/null +++ b/extensions/orgjson/src/main/java9/module-info.java @@ -0,0 +1,9 @@ +module io.jsonwebtoken.jjwt.ext.orgjson { + requires transitive org.json; + requires io.jsonwebtoken.jjwt.api; + + exports io.jsonwebtoken.orgjson.io; + + provides io.jsonwebtoken.io.Deserializer with io.jsonwebtoken.orgjson.io.OrgJsonDeserializer; + provides io.jsonwebtoken.io.Serializer with io.jsonwebtoken.orgjson.io.OrgJsonSerializer; +} diff --git a/impl/pom.xml b/impl/pom.xml index 4d10f5581..24f50b3dc 100644 --- a/impl/pom.xml +++ b/impl/pom.xml @@ -68,4 +68,4 @@ - \ No newline at end of file + diff --git a/impl/src/main/java9/module-info.java b/impl/src/main/java9/module-info.java new file mode 100644 index 000000000..7d0e57c26 --- /dev/null +++ b/impl/src/main/java9/module-info.java @@ -0,0 +1,15 @@ +module io.jsonwebtoken.jjwt.impl { + requires io.jsonwebtoken.jjwt.api; + + exports io.jsonwebtoken.impl; + exports io.jsonwebtoken.impl.compression; + exports io.jsonwebtoken.impl.lang; + + provides io.jsonwebtoken.CompressionCodec with + io.jsonwebtoken.impl.compression.DeflateCompressionAlgorithm, + io.jsonwebtoken.impl.compression.GzipCompressionAlgorithm; + + uses io.jsonwebtoken.CompressionCodec; + uses io.jsonwebtoken.io.Deserializer; + uses io.jsonwebtoken.io.Serializer; +} diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml new file mode 100644 index 000000000..b98a01f9e --- /dev/null +++ b/integration-tests/pom.xml @@ -0,0 +1,25 @@ + + + 4.0.0 + + + io.jsonwebtoken + jjwt-root + 0.12.7-SNAPSHOT + + + jjwt-integration-tests + JJWT :: Integration-Tests + pom + + + true + + + + unsigned-jackson + + + diff --git a/integration-tests/unsigned-jackson/pom.xml b/integration-tests/unsigned-jackson/pom.xml new file mode 100644 index 000000000..52d398d85 --- /dev/null +++ b/integration-tests/unsigned-jackson/pom.xml @@ -0,0 +1,72 @@ + + + 4.0.0 + + + io.jsonwebtoken + jjwt-integration-tests + 0.12.7-SNAPSHOT + + + jjwt-integration-tests-unsigned-jackson + JJWT :: Integration-Tests :: unsigned-jackson + Create and parse an unsigned JWT using Jackson and JPMS. + jar + + + 9 + true + + + + + io.jsonwebtoken + jjwt-api + ${project.version} + + + io.jsonwebtoken + jjwt-impl + ${project.version} + runtime + + + io.jsonwebtoken + jjwt-jackson + ${project.version} + runtime + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + true + false + + + + + org.apache.felix + maven-bundle-plugin + + + bundle-manifest + none + + + + + + + diff --git a/integration-tests/unsigned-jackson/src/main/java/io/jsonwebtoken/it/unsigned/UnsignedJwtCreator.java b/integration-tests/unsigned-jackson/src/main/java/io/jsonwebtoken/it/unsigned/UnsignedJwtCreator.java new file mode 100644 index 000000000..85baa25f5 --- /dev/null +++ b/integration-tests/unsigned-jackson/src/main/java/io/jsonwebtoken/it/unsigned/UnsignedJwtCreator.java @@ -0,0 +1,33 @@ +package io.jsonwebtoken.it.unsigned; + +import io.jsonwebtoken.*; + +import java.time.Instant; +import java.util.Date; +import java.util.List; + +public class UnsignedJwtCreator { + + public UnsignedJwtCreator() { + // explicit + } + + public String create() { + return Jwts.builder() + .claim("roles", List.of("admin")) + .subject("jjwt") + .id("jjwt-0") + .issuedAt(Date.from(Instant.now())) + .notBefore(Date.from(Instant.now())) + .compact(); + } + + public Jwt read(String jwt) { + final JwtParser jwtParser = Jwts.parser() + .unsecured() + .requireSubject("jjwt") + .build(); + + return jwtParser.parseUnsecuredClaims(jwt); + } +} diff --git a/integration-tests/unsigned-jackson/src/main/java/module-info.java b/integration-tests/unsigned-jackson/src/main/java/module-info.java new file mode 100644 index 000000000..71d5b72a0 --- /dev/null +++ b/integration-tests/unsigned-jackson/src/main/java/module-info.java @@ -0,0 +1,4 @@ +module io.jsonwebtoken.jjwt.it.unsigned { + requires io.jsonwebtoken.jjwt.api; + +} diff --git a/integration-tests/unsigned-jackson/src/main/resources/META-INF/MANIFEST.MF b/integration-tests/unsigned-jackson/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/unsigned-jackson/src/test/java/io/jsonwebtoken/it/unsigned/UnsignedJwtCreatorTest.java b/integration-tests/unsigned-jackson/src/test/java/io/jsonwebtoken/it/unsigned/UnsignedJwtCreatorTest.java new file mode 100644 index 000000000..4f56cec39 --- /dev/null +++ b/integration-tests/unsigned-jackson/src/test/java/io/jsonwebtoken/it/unsigned/UnsignedJwtCreatorTest.java @@ -0,0 +1,32 @@ +package io.jsonwebtoken.it.unsigned; +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.Header; +import io.jsonwebtoken.Jws; +import io.jsonwebtoken.Jwt; +import org.junit.Test; + +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + + +public class UnsignedJwtCreatorTest { + + @Test + public void testUnsignedJwt() { + // given: + final UnsignedJwtCreator jwtCreator = new UnsignedJwtCreator(); + final String jwtString = jwtCreator.create(); + + // when + final Jwt readBackJws = jwtCreator.read(jwtString); + + // then + final Claims jwtBody = readBackJws.getPayload(); + assertEquals("jjwt-0", jwtBody.getId()); + assertEquals("jjwt", jwtBody.getSubject()); + assertTrue(jwtBody.get("roles", List.class).contains("admin")); + } + +} diff --git a/pom.xml b/pom.xml index 9827e61e6..74f37aa07 100644 --- a/pom.xml +++ b/pom.xml @@ -555,8 +555,6 @@ maven-compiler-plugin ${maven.compiler.version} - ${jdk.version} - ${jdk.version} ${project.build.sourceEncoding} @@ -689,6 +687,8 @@ [1.8,) + ${jdk.version} + ${jdk.version} 3.0.2 3.0.19 4.2 @@ -733,7 +733,32 @@ false -html5 ${test.addOpens}, --illegal-access=debug + ${jdk.version} + + integration-tests + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + compile-module-info + compile + + compile + + + 9 + ${project.basedir}/src/main/java9 + + + + + + jdk17AndLater