Skip to content

Commit ae65a6d

Browse files
committed
Make JWTDecodeException extend JWTVerificationException
1 parent e5e7c75 commit ae65a6d

3 files changed

Lines changed: 3 additions & 9 deletions

File tree

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ try {
9393
.withIssuer("auth0")
9494
.build(); //Reusable verifier instance
9595
JWT jwt = verifier.verify(token);
96-
} catch (JWTDecodeException exception){
97-
//Invalid token
9896
} catch (JWTVerificationException exception){
9997
//Invalid signature/claims
10098
}
@@ -110,14 +108,11 @@ try {
110108
.withIssuer("auth0")
111109
.build(); //Reusable verifier instance
112110
JWT jwt = verifier.verify(token);
113-
} catch (JWTDecodeException exception){
114-
//Invalid token
115111
} catch (JWTVerificationException exception){
116112
//Invalid signature/claims
117113
}
118114
```
119115

120-
If the token has an invalid syntax or the header or payload are not JSONs, a `JWTDecodeException` will raise.
121116
If the token has an invalid signature or the Claim requirement is not met, a `JWTVerificationException` will raise.
122117

123118

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public Verification withJWTId(String jwtId) {
162162
/**
163163
* Require a specific Claim value.
164164
*
165-
* @param name the Claim's name
165+
* @param name the Claim's name
166166
* @param value the Claim's value. Must be an instance of Integer, Double, Boolean, Date or String class.
167167
* @return this same Verification instance.
168168
* @throws IllegalArgumentException if the name is null or the value class is not allowed.
@@ -229,10 +229,9 @@ private void requireClaim(String name, Object value) {
229229
*
230230
* @param token the String representation of the JWT.
231231
* @return a verified JWT.
232-
* @throws JWTDecodeException if any part of the Token contained an invalid JWT or JSON format.
233232
* @throws JWTVerificationException if any of the required contents inside the JWT is invalid.
234233
*/
235-
public JWT verify(String token) throws JWTDecodeException, JWTVerificationException {
234+
public JWT verify(String token) throws JWTVerificationException {
236235
JWT jwt = new JWT(JWTDecoder.decode(token));
237236
verifyAlgorithm(jwt, algorithm);
238237
verifySignature(TokenUtils.splitToken(token));

lib/src/main/java/com/auth0/jwt/exceptions/JWTDecodeException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.auth0.jwt.exceptions;
22

3-
public class JWTDecodeException extends RuntimeException {
3+
public class JWTDecodeException extends JWTVerificationException {
44
public JWTDecodeException(String message) {
55
this(message, null);
66
}

0 commit comments

Comments
 (0)