Skip to content

Commit 1520298

Browse files
committed
[SDK-3816] Update docs for verification thread-safety
1 parent 298b954 commit 1520298

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

lib/src/main/java/com/auth0/jwt/JWTVerifier.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ static Verification init(Algorithm algorithm) throws IllegalArgumentException {
4646
}
4747

4848
/**
49-
* {@link Verification} implementation that accepts all the expected Claim values for verification.
49+
* {@link Verification} implementation that accepts all the expected Claim values for verification, and
50+
* builds a {@link com.auth0.jwt.interfaces.JWTVerifier} used to verify a JWT's signature and expected claims.
51+
*
52+
* Note that this class is <strong>not</strong> thread-safe. Calling {@link #build()} returns an instance of
53+
* {@link com.auth0.jwt.interfaces.JWTVerifier} which can be reused.
5054
*/
5155
public static class BaseVerification implements Verification {
5256
private final Algorithm algorithm;

lib/src/main/java/com/auth0/jwt/interfaces/JWTVerifier.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@
44

55

66
/**
7-
* Used to verify the JWT for its signature and claims.
7+
* Used to verify the JWT for its signature and claims. Implementations must be thread-safe. Instances are created
8+
* using {@link Verification}.
9+
*
10+
* <pre>
11+
* try {
12+
* JWTVerifier verifier = JWTVerifier.init(Algorithm.RSA256(publicKey, privateKey)
13+
* .withIssuer("auth0")
14+
* .build();
15+
* DecodedJWT jwt = verifier.verify("token");
16+
* } catch (JWTVerificationException e) {
17+
* // invalid signature or claims
18+
* }
19+
* </pre>
820
*/
921
public interface JWTVerifier {
1022

lib/src/main/java/com/auth0/jwt/interfaces/Verification.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
import java.util.function.BiPredicate;
88

99
/**
10-
* Constructs and holds the checks required for a JWT to be considered valid.
10+
* Constructs and holds the checks required for a JWT to be considered valid. Note that implementations are
11+
* <strong>not</strong> thread-safe. Once built by calling {@link #build()}, the resulting
12+
* {@link com.auth0.jwt.interfaces.JWTVerifier} is thread-safe.
1113
*/
1214
public interface Verification {
1315

0 commit comments

Comments
 (0)