diff --git a/.github/actions/setup-build/action.yml b/.github/actions/setup-build/action.yml
new file mode 100644
index 000000000..8ab3f8256
--- /dev/null
+++ b/.github/actions/setup-build/action.yml
@@ -0,0 +1,68 @@
+name: 'Setup Build Environment'
+description: 'Sets up JDK(s), Maven Develocity, and optionally SoftHSM'
+inputs:
+ java-version-tests:
+ description: 'The primary/test Java version'
+ required: false
+ default: '17'
+ distribution:
+ description: 'JDK distribution to use'
+ required: false
+ default: 'zulu'
+ java-version-maven:
+ description: 'The Java version used to execute Maven'
+ required: false
+ default: '17'
+ develocity-access-key:
+ description: 'Develocity access key'
+ required: false
+ setup-softhsm:
+ description: 'Whether to set up SoftHSM'
+ required: false
+ default: 'true'
+
+runs:
+ using: 'composite'
+ steps:
+
+ - name: Set up JDK ${{ inputs.java-version-tests }} (Runs Tests)
+ if: ${{ inputs.java-version != inputs.java-version-maven }}
+ uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
+ with:
+ distribution: ${{ inputs.distribution }}
+ java-version: ${{ inputs.java-version-tests }}
+ cache: 'maven'
+ check-latest: true
+
+ - name: Set up JDK ${{ inputs.java-version-maven }} (Runs Maven)
+ uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
+ with:
+ distribution: ${{ inputs.distribution }}
+ java-version: ${{ inputs.java-version-maven }}
+ cache: 'maven'
+ check-latest: true
+
+ - name: Set up OSS Community Develocity Instance for Maven
+ uses: gradle/develocity-actions/setup-maven@974e8dbcbda40db6828fc35f349c80a7c0e71529 #v2.1
+ with:
+ develocity-access-key: ${{ inputs.develocity-access-key }}
+
+ - name: Install softhsm2
+ if: ${{ inputs.setup-softhsm == 'true' }}
+ run: sudo apt-get install -y softhsm2
+ shell: bash
+
+ - name: Install opensc
+ if: ${{ inputs.setup-softhsm == 'true' }}
+ run: sudo apt-get install -y opensc
+ shell: bash
+
+ - name: Ensure SoftHSM user configuration
+ if: ${{ inputs.setup-softhsm == 'true' }}
+ run: impl/src/test/scripts/softhsm configure
+ shell: bash
+
+ - name: Populate SoftHSM with JJWT test keys
+ if: ${{ inputs.setup-softhsm == 'true' }}
+ run: impl/src/test/scripts/softhsm import
+ shell: bash
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index b607a342f..b144899ce 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1,7 +1,7 @@
name: CI
on:
- workflow_dispatch:
+ workflow_dispatch:
pull_request: # all pull requests
push:
branches:
@@ -11,151 +11,60 @@ env:
MVN_CMD: ./mvnw --no-transfer-progress -B
jobs:
- oracle:
- strategy:
- matrix:
- java: [ '17' ]
+ build:
runs-on: 'ubuntu-latest'
- name: jdk-${{ matrix.java }}-oracle
- steps:
- - uses: actions/checkout@v4
- - name: Set up JDK
- uses: actions/setup-java@v4.7.0
- with:
- distribution: oracle
- java-version: ${{ matrix.java }}
- - name: Set up OSS Community Develocity Instance for Maven
- uses: gradle/develocity-actions/setup-maven@v2.1
- with:
- develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
- - name: Install softhsm2
- run: sudo apt-get install -y softhsm2
- - name: Install opensc
- run: sudo apt-get install -y opensc
- - name: Ensure SoftHSM user configuration
- run: impl/src/test/scripts/softhsm configure
- - name: Populate SoftHSM with JJWT test keys
- run: impl/src/test/scripts/softhsm import
- - name: Build
- # run a full build, just as we would for a release (i.e. the `ossrh` profile), but don't use gpg
- # to sign artifacts, since we don't want to mess with storing signing credentials in CI:
- run: ${{env.MVN_CMD}} verify -Possrh -Dgpg.skip=true
-
- temurin:
strategy:
+ fail-fast: false
matrix:
- java: [ '8', '11', '17', '18' ]
- runs-on: 'ubuntu-latest'
- name: jdk-${{ matrix.java }}-temurin
+ distribution: [ 'oracle', 'temurin', 'zulu', 'corretto', 'semeru' ]
+ java-version: [ 8, 11, 17, 21, 25 ]
+ # Oracle only provides JDK 17+, so exclude earlier versions:
+ exclude:
+ - distribution: 'oracle'
+ java-version: 8
+ - distribution: 'oracle'
+ java-version: 11
+ name: jdk-${{ matrix.java-version }}-${{ matrix.distribution }}
steps:
- - uses: actions/checkout@v4
- - name: Set up JDK
- uses: actions/setup-java@v4
- with:
- java-version: ${{ matrix.java }}
- distribution: 'temurin'
- cache: 'maven'
- check-latest: true
- - name: Set up OSS Community Develocity Instance for Maven
- uses: gradle/develocity-actions/setup-maven@v2.1
+ - name: Checkout
+ uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
+ - name: Setup Build Environment
+ uses: ./.github/actions/setup-build
with:
+ java-version-tests: ${{ matrix.java-version }}
+ distribution: ${{ matrix.distribution }}
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
- - name: Install softhsm2
- run: sudo apt-get install -y softhsm2
- - name: Install opensc
- run: sudo apt-get install -y opensc
- - name: Ensure SoftHSM user configuration
- run: impl/src/test/scripts/softhsm configure
- - name: Populate SoftHSM with JJWT test keys
- run: impl/src/test/scripts/softhsm import
- name: Build
# run a full build, just as we would for a release (i.e. the `ossrh` profile), but don't use gpg
# to sign artifacts, since we don't want to mess with storing signing credentials in CI:
- run: ${{env.MVN_CMD}} verify -Possrh -Dgpg.skip=true
-
- zulu:
- strategy:
- matrix:
- java: [ '7', '8', '9', '11', '12', '13', '14', '15', '16', '17', '18', '21' ]
- runs-on: 'ubuntu-latest'
- env:
- JDK_MAJOR_VERSION: ${{ matrix.java }}
- name: jdk-${{ matrix.java }}-zulu
- steps:
- - uses: actions/checkout@v4
- - name: Set up JDK
- uses: actions/setup-java@v4
- with:
- java-version: ${{ matrix.java }}
- distribution: 'zulu'
- cache: 'maven'
- check-latest: true
- - name: Set up OSS Community Develocity Instance for Maven
- uses: gradle/develocity-actions/setup-maven@v2.1
- with:
- develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
- - name: Install softhsm2
- run: sudo apt-get install -y softhsm2
- - name: Install opensc
- run: sudo apt-get install -y opensc
- - name: Ensure SoftHSM user configuration
- run: impl/src/test/scripts/softhsm configure
- - name: Populate SoftHSM with JJWT test keys
- run: impl/src/test/scripts/softhsm import
- - name: Build
- # run a full build, just as we would for a release (i.e. the `ossrh` profile), but don't use gpg
- # to sign artifacts, since we don't want to mess with storing signing credentials in CI:
- run: |
- if [ "$JDK_MAJOR_VERSION" == "7" ]; then export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=128m"; fi
- ${{env.MVN_CMD}} verify -Possrh -Dgpg.skip=true
+ run: ${{env.MVN_CMD}} verify -Possrh -Dgpg.skip=true -Dtest.jdk.version=${{ matrix.java-version }}
# ensure all of our files have the correct/updated license header
license-check:
runs-on: 'ubuntu-latest'
steps:
- - uses: actions/checkout@v4
+ - name: Checkout
+ uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
- fetch-depth: 0 # avoid license plugin history warnings (plus it needs full history)
- - name: Set up JDK
- uses: actions/setup-java@v4
- with:
- distribution: 'zulu'
- java-version: '8'
- cache: 'maven'
- check-latest: true
- - name: Set up OSS Community Develocity Instance for Maven
- uses: gradle/develocity-actions/setup-maven@v2.1
+ fetch-depth: 0
+ - name: Setup Build Environment
+ uses: ./.github/actions/setup-build
with:
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
+ setup-softhsm: 'false'
- name: License Check
- # This adds about 1 minute to any build, which is why we don't want to do it on every other build:
- run: |
- ${{env.MVN_CMD}} license:check
+ # This adds about 1 minute to any build, which is why we don't want to do it on every build:
+ run: ${{env.MVN_CMD}} license:check
code-coverage:
- needs: [oracle, temurin, zulu]
runs-on: 'ubuntu-latest'
steps:
- - uses: actions/checkout@v4
- - name: Set up JDK
- uses: actions/setup-java@v4
- with:
- distribution: 'zulu'
- java-version: '17'
- cache: 'maven'
- check-latest: true
- - name: Set up OSS Community Develocity Instance for Maven
- uses: gradle/develocity-actions/setup-maven@v2.1
+ - name: Checkout
+ uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
+ - name: Setup Build Environment
+ uses: ./.github/actions/setup-build
with:
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
- - name: Install softhsm2
- run: sudo apt-get install -y softhsm2
- - name: Install opensc
- run: sudo apt-get install -y opensc
- - name: Ensure SoftHSM user configuration
- run: impl/src/test/scripts/softhsm configure
- - name: Populate SoftHSM with JJWT test keys
- run: impl/src/test/scripts/softhsm import
- name: Code Coverage
# run a full build, just as we would for a release (i.e. the `ossrh` profile), but don't use gpg
# to sign artifacts, since we don't want to mess with storing signing credentials in CI:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6503af800..b4ab4aa6c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,22 @@
## Release Notes
+### 0.14.0
+
+The first JJWT release that uses Java 8+ features. This release is not strictly backwards compatible and will also not work with Java 7.
+
+#### Backwards Compatibility Breaking Changes
+
+- The `io.jsonwebtoken.lang.Supplier` interface has been renamed and moved to `io.jsonwebtoken.security.ConfidentialValue` to avoid any potential risk of conflict or accidental use
+ with `java.util.function.Supplier`. If you have explicitly configured a `Gson` instance to work with this type previously, you must update your usage to reference the new interface, for example:
+ ```java
+ new GsonBuilder()
+ .registerTypeHierarchyAdapter(io.jsonwebtoken.security.ConfidentialValue.class, GsonConfidentialValueSerializer.INSTANCE)
+ // ... etc ...
+ .create();
+ ```
+ - The `io.jsonwebtoken.gson.io.GsonSupplierSerializer` class has been renamed to `GsonConfidentialValueSerializer`
+ - The `io.jsonwebtoken.jackson.io.JacksonSupplierSerializer` has been renamed to `JacksonConfidentialValueSerializer`.`
+
### 0.13.0
This is the last minor JJWT release branch that will support Java 7. Any necessary emergency bug fixes will be fixed in subsequent `0.13.x` patch releases, but all new development, including Java 8 compatible changes, will be in the next minor (`0.14.0`) release.
@@ -412,7 +429,7 @@ deprecate some concepts, or in some cases, completely break backwards compatibil
`GsonSupplierSerializer` type adapter, for example:
```java
new GsonBuilder()
- .registerTypeHierarchyAdapter(io.jsonwebtoken.lang.Supplier.class, GsonSupplierSerializer.INSTANCE)
+ .registerTypeHierarchyAdapter(io.jsonwebtoken.security.ConfidentialValue.class, GsonSupplierSerializer.INSTANCE)
.disableHtmlEscaping().create();
```
This is to ensure JWKs have `toString()` and application log safety (do not print secure material), but still
diff --git a/README.adoc b/README.adoc
index 4ed4e1518..4ed62e940 100644
--- a/README.adoc
+++ b/README.adoc
@@ -15,7 +15,6 @@ ifdef::env-github[]
endif::[]
// Macros
-:fn-require-java8-plus: Requires Java 8 or a compatible JCA Provider (like BouncyCastle) in the runtime classpath.
:fn-require-java11-plus: Requires Java 11 or a compatible JCA Provider (like BouncyCastle) in the runtime classpath.
:fn-require-java15-plus: Requires Java 15 or a compatible JCA Provider (like BouncyCastle) in the runtime classpath.
@@ -57,7 +56,7 @@ toc::[]
== Features
-* Fully functional on all Java 7+ JDKs and Android
+* Fully functional on all Java 8+ JDKs and Android
* Automatic security best practices and assertions
* Easy to learn and read API
* Convenient and readable http://en.wikipedia.org/wiki/Fluent_interface[fluent] interfaces, great for IDE
@@ -129,16 +128,15 @@ and conditional branch variant in the entire codebase is tested and required to
| https://www.rfc-editor.org/rfc/rfc7518.html#section-5.2.5[AES_256_CBC_HMAC_SHA_512] authenticated encryption algorithm
| `A128GCM`
-| AES GCM using 128-bit key^*1*^
+| AES GCM using 128-bit key
| `A192GCM`
-| AES GCM using 192-bit key^*1*^
+| AES GCM using 192-bit key
| `A256GCM`
-| AES GCM using 256-bit key^*1*^
+| AES GCM using 256-bit key
|===
+
-^*1*.{sp}{fn-require-java8-plus}^
* All Key Management Algorithms for obtaining JWE encryption and decryption keys:
+
@@ -179,25 +177,24 @@ and conditional branch variant in the entire codebase is tested and required to
| ECDH-ES using Concat KDF and CEK wrapped with "A256KW"
| `A128GCMKW`
-| Key wrapping with AES GCM using 128-bit key^*1*^
+| Key wrapping with AES GCM using 128-bit key
| `A192GCMKW`
-| Key wrapping with AES GCM using 192-bit key^*1*^
+| Key wrapping with AES GCM using 192-bit key
| `A256GCMKW`
-| Key wrapping with AES GCM using 256-bit key^*1*^
+| Key wrapping with AES GCM using 256-bit key
| `PBES2-HS256+A128KW`
-| PBES2 with HMAC SHA-256 and "A128KW" wrapping^*1*^
+| PBES2 with HMAC SHA-256 and "A128KW" wrapping
| `PBES2-HS384+A192KW`
-| PBES2 with HMAC SHA-384 and "A192KW" wrapping^*1*^
+| PBES2 with HMAC SHA-384 and "A192KW" wrapping
| `PBES2‑HS512+A256KW`
-| PBES2 with HMAC SHA-512 and "A256KW" wrapping^*1*^
+| PBES2 with HMAC SHA-512 and "A256KW" wrapping
|===
+
-^*1*.{sp}{fn-require-java8-plus}^
* Creating, parsing and verifying JSON Web Keys (JWKs) in all standard JWA key formats using native Java `Key` types:
+
@@ -2218,19 +2215,17 @@ The JWT specification defines 6 standard Authenticated Encryption algorithms use
| `A128GCM`
| 128
-| AES GCM using 128-bit key^*1*^
+| AES GCM using 128-bit key
| `A192GCM`
| 192
-| AES GCM using 192-bit key^*1*^
+| AES GCM using 192-bit key
| `A256GCM`
| 256
-| AES GCM using 256-bit key^*1*^
+| AES GCM using 256-bit key
|===
-^*1*.{sp}{fn-require-java8-plus}^
-
These are all represented as constants in the `io.jsonwebtoken.Jwts.ENC` registry singleton as
implementations of the `io.jsonwebtoken.security.AeadAlgorithm` interface.
@@ -2358,26 +2353,24 @@ Content Encryption Key (CEK):
| ECDH-ES using Concat KDF and CEK wrapped with "A256KW"
| `A128GCMKW`
-| Key wrapping with AES GCM using 128-bit key^*1*^
+| Key wrapping with AES GCM using 128-bit key
| `A192GCMKW`
-| Key wrapping with AES GCM using 192-bit key^*1*^
+| Key wrapping with AES GCM using 192-bit key
| `A256GCMKW`
-| Key wrapping with AES GCM using 256-bit key^*1*^
+| Key wrapping with AES GCM using 256-bit key
| `PBES2-HS256+A128KW`
-| PBES2 with HMAC SHA-256 and "A128KW" wrapping^*1*^
+| PBES2 with HMAC SHA-256 and "A128KW" wrapping
| `PBES2-HS384+A192KW`
-| PBES2 with HMAC SHA-384 and "A192KW" wrapping^*1*^
+| PBES2 with HMAC SHA-384 and "A192KW" wrapping
| `PBES2‑HS512+A256KW`
-| PBES2 with HMAC SHA-512 and "A256KW" wrapping^*1*^
+| PBES2 with HMAC SHA-512 and "A256KW" wrapping
|===
-^*1*.{sp}{fn-require-java8-plus}^
-
These are all represented as constants in the `io.jsonwebtoken.Jwts.KEY` registry singleton as
implementations of the `io.jsonwebtoken.security.KeyAlgorithm` interface.
@@ -3472,7 +3465,7 @@ If you're curious, JJWT will automatically create an internal default Gson insta
[,java]
----
new GsonBuilder()
- .registerTypeHierarchyAdapter(io.jsonwebtoken.lang.Supplier.class, GsonSupplierSerializer.INSTANCE)
+ .registerTypeHierarchyAdapter(io.jsonwebtoken.security.ConfidentialValue.class, GsonConfidentialValueSerializer.INSTANCE)
.setObjectToNumberStrategy(ToNumberPolicy.LONG_OR_DOUBLE)
.setNumberToNumberStrategy(ToNumberPolicy.LONG_OR_DOUBLE)
.disableHtmlEscaping()
@@ -3515,7 +3508,7 @@ And then you can specify the `GsonSerializer` using your own `Gson` instance on
Gson gson = new GsonBuilder()
// don't forget this line!:
- .registerTypeHierarchyAdapter(io.jsonwebtoken.lang.Supplier.class, GsonSupplierSerializer.INSTANCE)
+ .registerTypeHierarchyAdapter(io.jsonwebtoken.security.ConfidentialValue.class, GsonConfidentialValueSerializer.INSTANCE)
.setObjectToNumberStrategy(ToNumberPolicy.LONG_OR_DOUBLE)
.setNumberToNumberStrategy(ToNumberPolicy.LONG_OR_DOUBLE)
.disableHtmlEscaping().create();
@@ -3544,7 +3537,7 @@ Again, as shown above, it is critical to create your `Gson` instance using the `
[,java]
----
-.registerTypeHierarchyAdapter(io.jsonwebtoken.lang.Supplier.class, GsonSupplierSerializer.INSTANCE)
+.registerTypeHierarchyAdapter(io.jsonwebtoken.security.ConfidentialValue.class, GsonConfidentialValueSerializer.INSTANCE)
----
to ensure JWK serialization works as expected.
diff --git a/api/src/main/java/io/jsonwebtoken/Clock.java b/api/src/main/java/io/jsonwebtoken/Clock.java
index 584dd605f..680251628 100644
--- a/api/src/main/java/io/jsonwebtoken/Clock.java
+++ b/api/src/main/java/io/jsonwebtoken/Clock.java
@@ -22,6 +22,7 @@
*
* @since 0.7.0
*/
+@FunctionalInterface
public interface Clock {
/**
diff --git a/api/src/main/java/io/jsonwebtoken/Identifiable.java b/api/src/main/java/io/jsonwebtoken/Identifiable.java
index 88725715c..a8085220b 100644
--- a/api/src/main/java/io/jsonwebtoken/Identifiable.java
+++ b/api/src/main/java/io/jsonwebtoken/Identifiable.java
@@ -81,6 +81,7 @@
*
* @since 0.12.0
*/
+@FunctionalInterface
public interface Identifiable {
/**
diff --git a/api/src/main/java/io/jsonwebtoken/JwtParser.java b/api/src/main/java/io/jsonwebtoken/JwtParser.java
index df7e173b8..2f132e360 100644
--- a/api/src/main/java/io/jsonwebtoken/JwtParser.java
+++ b/api/src/main/java/io/jsonwebtoken/JwtParser.java
@@ -22,7 +22,6 @@
import java.io.InputStream;
/**
- * A parser for reading JWT strings, used to convert them into a {@link Jwt} object representing the expanded JWT.
* A parser for reading JWT strings, used to convert them into a {@link Jwt} object representing the expanded JWT.
*
* @since 0.1
diff --git a/api/src/main/java/io/jsonwebtoken/Jwts.java b/api/src/main/java/io/jsonwebtoken/Jwts.java
index 3e425bb34..eed9bca1b 100644
--- a/api/src/main/java/io/jsonwebtoken/Jwts.java
+++ b/api/src/main/java/io/jsonwebtoken/Jwts.java
@@ -19,7 +19,6 @@
import io.jsonwebtoken.lang.Builder;
import io.jsonwebtoken.lang.Classes;
import io.jsonwebtoken.lang.Registry;
-import io.jsonwebtoken.lang.Supplier;
import io.jsonwebtoken.security.AeadAlgorithm;
import io.jsonwebtoken.security.KeyAlgorithm;
import io.jsonwebtoken.security.KeyPairBuilderSupplier;
@@ -35,6 +34,7 @@
import java.security.PrivateKey;
import java.security.PublicKey;
import java.util.Map;
+import java.util.function.Supplier;
/**
* Factory class useful for creating instances of JWT interfaces. Using this factory class can be a good
@@ -121,34 +121,22 @@ private ENC() {
/**
* "AES GCM using 128-bit key" as defined by
- * RFC 7518, Section 5.31. This
+ * RFC 7518, Section 5.3. This
* algorithm requires a 128-bit (16 byte) key.
- *
- *
1 Requires Java 8 or a compatible JCA Provider (like BouncyCastle) in the runtime
- * classpath. If on Java 7 or earlier, BouncyCastle will be used automatically if found in the runtime
- * classpath.
*/
public static final AeadAlgorithm A128GCM = get().forKey("A128GCM");
/**
* "AES GCM using 192-bit key" as defined by
- * RFC 7518, Section 5.31. This
+ * RFC 7518, Section 5.3. This
* algorithm requires a 192-bit (24 byte) key.
- *
- *
1 Requires Java 8 or a compatible JCA Provider (like BouncyCastle) in the runtime
- * classpath. If on Java 7 or earlier, BouncyCastle will be used automatically if found in the runtime
- * classpath.
*/
public static final AeadAlgorithm A192GCM = get().forKey("A192GCM");
/**
* "AES GCM using 256-bit key" as defined by
- * RFC 7518, Section 5.31. This
+ * RFC 7518, Section 5.3. This
* algorithm requires a 256-bit (32 byte) key.
- *
- *
1 Requires Java 8 or a compatible JCA Provider (like BouncyCastle) in the runtime
- * classpath. If on Java 7 or earlier, BouncyCastle will be used automatically if found in the runtime
- * classpath.
*/
public static final AeadAlgorithm A256GCM = get().forKey("A256GCM");
}
diff --git a/api/src/main/java/io/jsonwebtoken/Locator.java b/api/src/main/java/io/jsonwebtoken/Locator.java
index 1d22258c1..f0a0073c7 100644
--- a/api/src/main/java/io/jsonwebtoken/Locator.java
+++ b/api/src/main/java/io/jsonwebtoken/Locator.java
@@ -28,6 +28,7 @@
* @param the type of object that may be returned from the {@link #locate(Header)} method
* @since 0.12.0
*/
+@FunctionalInterface
public interface Locator {
/**
diff --git a/api/src/main/java/io/jsonwebtoken/io/Base64Decoder.java b/api/src/main/java/io/jsonwebtoken/io/Base64Decoder.java
index e0cb96333..8a57e8a80 100644
--- a/api/src/main/java/io/jsonwebtoken/io/Base64Decoder.java
+++ b/api/src/main/java/io/jsonwebtoken/io/Base64Decoder.java
@@ -19,7 +19,7 @@
/**
* Very fast Base64 decoder guaranteed to
- * work in all >= Java 7 JDK and Android environments.
+ * work in all Java JDK and Android environments.
*
* @since 0.10.0
*/
diff --git a/api/src/main/java/io/jsonwebtoken/io/Base64Encoder.java b/api/src/main/java/io/jsonwebtoken/io/Base64Encoder.java
index 6e0a6b034..249a4c4e9 100644
--- a/api/src/main/java/io/jsonwebtoken/io/Base64Encoder.java
+++ b/api/src/main/java/io/jsonwebtoken/io/Base64Encoder.java
@@ -19,7 +19,7 @@
/**
* Very fast Base64 encoder guaranteed to
- * work in all >= Java 7 JDK and Android environments.
+ * work in all Java JDK and Android environments.
*
* @since 0.10.0
*/
diff --git a/api/src/main/java/io/jsonwebtoken/io/Base64UrlDecoder.java b/api/src/main/java/io/jsonwebtoken/io/Base64UrlDecoder.java
index fcca4cba5..c8a76f56b 100644
--- a/api/src/main/java/io/jsonwebtoken/io/Base64UrlDecoder.java
+++ b/api/src/main/java/io/jsonwebtoken/io/Base64UrlDecoder.java
@@ -17,7 +17,7 @@
/**
* Very fast Base64Url decoder guaranteed to
- * work in all >= Java 7 JDK and Android environments.
+ * work in all Java JDK and Android environments.
*
* @since 0.10.0
*/
diff --git a/api/src/main/java/io/jsonwebtoken/io/Base64UrlEncoder.java b/api/src/main/java/io/jsonwebtoken/io/Base64UrlEncoder.java
index 1377d31e7..c2a1ca59f 100644
--- a/api/src/main/java/io/jsonwebtoken/io/Base64UrlEncoder.java
+++ b/api/src/main/java/io/jsonwebtoken/io/Base64UrlEncoder.java
@@ -17,7 +17,7 @@
/**
* Very fast Base64Url encoder guaranteed to
- * work in all >= Java 7 JDK and Android environments.
+ * work in all Java JDK and Android environments.
*
* @since 0.10.0
*/
diff --git a/api/src/main/java/io/jsonwebtoken/io/Decoder.java b/api/src/main/java/io/jsonwebtoken/io/Decoder.java
index 2cf4fe896..db391c0aa 100644
--- a/api/src/main/java/io/jsonwebtoken/io/Decoder.java
+++ b/api/src/main/java/io/jsonwebtoken/io/Decoder.java
@@ -22,6 +22,7 @@
* @param decoding output type
* @since 0.10.0
*/
+@FunctionalInterface
public interface Decoder {
/**
diff --git a/api/src/main/java/io/jsonwebtoken/io/Decoders.java b/api/src/main/java/io/jsonwebtoken/io/Decoders.java
index 6b7c7e66a..6c414245c 100644
--- a/api/src/main/java/io/jsonwebtoken/io/Decoders.java
+++ b/api/src/main/java/io/jsonwebtoken/io/Decoders.java
@@ -26,13 +26,13 @@ public final class Decoders {
/**
* Very fast Base64 decoder guaranteed to
- * work in all >= Java 7 JDK and Android environments.
+ * work in all Java JDK and Android environments.
*/
public static final Decoder BASE64 = new ExceptionPropagatingDecoder<>(new Base64Decoder());
/**
* Very fast Base64Url decoder guaranteed to
- * work in all >= Java 7 JDK and Android environments.
+ * work in all Java JDK and Android environments.
*/
public static final Decoder BASE64URL = new ExceptionPropagatingDecoder<>(new Base64UrlDecoder());
diff --git a/api/src/main/java/io/jsonwebtoken/io/Encoder.java b/api/src/main/java/io/jsonwebtoken/io/Encoder.java
index f334ee8c2..f07c9816b 100644
--- a/api/src/main/java/io/jsonwebtoken/io/Encoder.java
+++ b/api/src/main/java/io/jsonwebtoken/io/Encoder.java
@@ -22,6 +22,7 @@
* @param the type of the resulting formatted data
* @since 0.10.0
*/
+@FunctionalInterface
public interface Encoder {
/**
diff --git a/api/src/main/java/io/jsonwebtoken/io/Encoders.java b/api/src/main/java/io/jsonwebtoken/io/Encoders.java
index 17f03f250..f3b5f9913 100644
--- a/api/src/main/java/io/jsonwebtoken/io/Encoders.java
+++ b/api/src/main/java/io/jsonwebtoken/io/Encoders.java
@@ -26,13 +26,13 @@ public final class Encoders {
/**
* Very fast Base64 encoder guaranteed to
- * work in all >= Java 7 JDK and Android environments.
+ * work in all Java JDK and Android environments.
*/
public static final Encoder BASE64 = new ExceptionPropagatingEncoder<>(new Base64Encoder());
/**
* Very fast Base64Url encoder guaranteed to
- * work in all >= Java 7 JDK and Android environments.
+ * work in all Java JDK and Android environments.
*/
public static final Encoder BASE64URL = new ExceptionPropagatingEncoder<>(new Base64UrlEncoder());
diff --git a/api/src/main/java/io/jsonwebtoken/lang/Builder.java b/api/src/main/java/io/jsonwebtoken/lang/Builder.java
index 506c802dc..07499c82a 100644
--- a/api/src/main/java/io/jsonwebtoken/lang/Builder.java
+++ b/api/src/main/java/io/jsonwebtoken/lang/Builder.java
@@ -21,6 +21,7 @@
* @param The type of object that will be created when {@link #build()} is invoked.
* @since 0.12.0
*/
+@FunctionalInterface
public interface Builder {
/**
diff --git a/api/src/main/java/io/jsonwebtoken/lang/Conjunctor.java b/api/src/main/java/io/jsonwebtoken/lang/Conjunctor.java
index c604752fd..b754b7220 100644
--- a/api/src/main/java/io/jsonwebtoken/lang/Conjunctor.java
+++ b/api/src/main/java/io/jsonwebtoken/lang/Conjunctor.java
@@ -22,6 +22,7 @@
* @param the type of joined object to return.
* @since 0.12.0
*/
+@FunctionalInterface
public interface Conjunctor {
/**
diff --git a/api/src/main/java/io/jsonwebtoken/security/AssociatedDataSupplier.java b/api/src/main/java/io/jsonwebtoken/security/AssociatedDataSupplier.java
index 4f5cd3719..564d17ca0 100644
--- a/api/src/main/java/io/jsonwebtoken/security/AssociatedDataSupplier.java
+++ b/api/src/main/java/io/jsonwebtoken/security/AssociatedDataSupplier.java
@@ -24,6 +24,7 @@
* @see #getAssociatedData()
* @since 0.12.0
*/
+@FunctionalInterface
public interface AssociatedDataSupplier {
/**
diff --git a/api/src/main/java/io/jsonwebtoken/lang/Supplier.java b/api/src/main/java/io/jsonwebtoken/security/ConfidentialValue.java
similarity index 51%
rename from api/src/main/java/io/jsonwebtoken/lang/Supplier.java
rename to api/src/main/java/io/jsonwebtoken/security/ConfidentialValue.java
index 7a94e591c..f0db518fc 100644
--- a/api/src/main/java/io/jsonwebtoken/lang/Supplier.java
+++ b/api/src/main/java/io/jsonwebtoken/security/ConfidentialValue.java
@@ -13,25 +13,24 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package io.jsonwebtoken.lang;
+package io.jsonwebtoken.security;
/**
- * Represents a supplier of results.
+ * A wrapper for a value that should be treated as confidential. Calling {@link Object#toString()} on a
+ * {@code ConfidentialValue} instance will return the string literal <redacted>.
*
- *
There is no requirement that a new or distinct result be returned each time the supplier is invoked.
- *
- *
This interface is the equivalent of a JDK 8 {@code java.util.function.Supplier}, backported for JJWT's use in
- * JDK 7 environments.
+ *
There is no requirement that a new or distinct result be returned each time the value is invoked.
*
* @param the type of object returned by this supplier
- * @since 0.12.0
+ * @since 0.14.0, renamed and moved from {@code io.jsonwebtoken.lang.Supplier} introduced in 0.12.0
*/
-public interface Supplier {
+// MAINTAINER NOTE: do not mark this as @FunctionalInterface - it makes it easier to break the toString() contract
+public interface ConfidentialValue {
/**
- * Returns a result.
+ * Returns a confidential value that should be treated with care and not exposed unnecessarily.
*
- * @return a result.
+ * @return a confidential value that should be treated with care and not exposed unnecessarily.
*/
T get();
}
diff --git a/api/src/main/java/io/jsonwebtoken/security/DigestSupplier.java b/api/src/main/java/io/jsonwebtoken/security/DigestSupplier.java
index 4c697d9bf..d4d829e73 100644
--- a/api/src/main/java/io/jsonwebtoken/security/DigestSupplier.java
+++ b/api/src/main/java/io/jsonwebtoken/security/DigestSupplier.java
@@ -21,6 +21,7 @@
*
* @since 0.12.0
*/
+@FunctionalInterface
public interface DigestSupplier {
/**
diff --git a/api/src/main/java/io/jsonwebtoken/security/IvSupplier.java b/api/src/main/java/io/jsonwebtoken/security/IvSupplier.java
index f1cc3d506..bc0c4e952 100644
--- a/api/src/main/java/io/jsonwebtoken/security/IvSupplier.java
+++ b/api/src/main/java/io/jsonwebtoken/security/IvSupplier.java
@@ -23,6 +23,7 @@
*
* @since 0.12.0
*/
+@FunctionalInterface
public interface IvSupplier {
/**
diff --git a/api/src/main/java/io/jsonwebtoken/security/Jwk.java b/api/src/main/java/io/jsonwebtoken/security/Jwk.java
index fef6420aa..cd09f082b 100644
--- a/api/src/main/java/io/jsonwebtoken/security/Jwk.java
+++ b/api/src/main/java/io/jsonwebtoken/security/Jwk.java
@@ -16,7 +16,6 @@
package io.jsonwebtoken.security;
import io.jsonwebtoken.Identifiable;
-import io.jsonwebtoken.lang.Supplier;
import java.security.Key;
import java.util.Map;
@@ -49,8 +48,8 @@
*
*
JWKs often represent secret or private key data which should never be exposed publicly, nor mistakenly printed
* to application logs or {@code System.out.println} calls. As a result, all JJWT JWK
- * private or secret values are 'wrapped' in a {@link io.jsonwebtoken.lang.Supplier Supplier} instance to ensure
- * any attempt to call {@link String#toString() toString()} on the value will print a redacted value instead of an
+ * private or secret values are 'wrapped' in a {@link ConfidentialValue ConfidentialValue} instance to ensure
+ * any attempt to call {@link Object#toString() toString()} on the value will print a redacted value instead of an
* actual private or secret value.
*
*
For example, a {@link SecretJwk} will have an internal "{@code k}" member whose value reflects raw
@@ -70,11 +69,11 @@
* k=<redacted>
*
instead of the actual/raw {@code k} value.
*
- *
Finally, because all private or secret values are wrapped as {@link io.jsonwebtoken.lang.Supplier}
+ *
Finally, because all private or secret values are wrapped as {@link ConfidentialValue}
* instances, if you really wanted the real internal value, you could just call the supplier's
- * {@link Supplier#get() get()} method: