Skip to content

Commit

Permalink
change TokenExpiredException to extend JWTVerificationException
Browse files Browse the repository at this point in the history
  • Loading branch information
Blaubeeree committed Jan 16, 2025
1 parent 0195ecf commit 69e70f5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/src/main/java/com/auth0/jwt/JWTVerifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ private boolean assertValidInstantClaim(String claimName, Claim claim, long leew
if (shouldBeFuture) {
isValid = assertInstantIsFuture(claimVal, leeway, now);
if (!isValid) {
throw new TokenExpiredException(String.format("The Token has expired on %s.", claimVal), claimVal);
throw new TokenExpiredException(String.format("The Token has expired on %s.", claimVal), claim);
}
} else {
isValid = assertInstantIsLessThanOrEqualToNow(claimVal, leeway, now);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
package com.auth0.jwt.exceptions;

import com.auth0.jwt.RegisteredClaims;
import com.auth0.jwt.interfaces.Claim;

import java.time.Instant;

/**
* The exception that is thrown if the token is expired.
*/
public class TokenExpiredException extends JWTVerificationException {
public class TokenExpiredException extends IncorrectClaimException {

private static final long serialVersionUID = -7076928975713577708L;

private final Instant expiredOn;

public TokenExpiredException(String message, Instant expiredOn) {
super(message);
this.expiredOn = expiredOn;
public TokenExpiredException(String message, Claim claim) {
super(message, RegisteredClaims.EXPIRES_AT, claim);
this.expiredOn = claim.asInstant();
}

public Instant getExpiredOn() {
Expand Down

0 comments on commit 69e70f5

Please # to comment.