Skip to content

Commit 2cc532f

Browse files
committed
change TokenExpiredException to extend JWTVerificationException
1 parent 36f58e5 commit 2cc532f

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ private boolean assertValidInstantClaim(String claimName, Claim claim, long leew
343343
if (shouldBeFuture) {
344344
isValid = assertInstantIsFuture(claimVal, leeway, now);
345345
if (!isValid) {
346-
throw new TokenExpiredException(String.format("The Token has expired on %s.", claimVal), claimVal);
346+
throw new TokenExpiredException(String.format("The Token has expired on %s.", claimVal), claim);
347347
}
348348
} else {
349349
isValid = assertInstantIsLessThanOrEqualToNow(claimVal, leeway, now);

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

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
package com.auth0.jwt.exceptions;
22

3+
import com.auth0.jwt.RegisteredClaims;
4+
import com.auth0.jwt.interfaces.Claim;
5+
36
import java.time.Instant;
47

58
/**
69
* The exception that is thrown if the token is expired.
710
*/
8-
public class TokenExpiredException extends JWTVerificationException {
11+
public class TokenExpiredException extends IncorrectClaimException {
912

1013
private static final long serialVersionUID = -7076928975713577708L;
1114

1215
private final Instant expiredOn;
1316

14-
public TokenExpiredException(String message, Instant expiredOn) {
15-
super(message);
16-
this.expiredOn = expiredOn;
17+
public TokenExpiredException(String message, Claim claim) {
18+
super(message, RegisteredClaims.EXPIRES_AT, claim);
19+
this.expiredOn = claim.asInstant();
1720
}
1821

1922
public Instant getExpiredOn() {

0 commit comments

Comments
 (0)