Package org.jose4j.jwt.consumer
Class InvalidJwtException
java.lang.Object
java.lang.Throwable
java.lang.Exception
org.jose4j.jwt.consumer.InvalidJwtException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
InvalidJwtSignatureException
An exception thrown when a JWT is considered invalid or otherwise cannot be
processed/consumed.
- See Also:
-
Constructor Summary
ConstructorDescriptionInvalidJwtException
(String message, List<ErrorCodeValidator.Error> details, JwtContext jwtContext) InvalidJwtException
(String message, ErrorCodeValidator.Error detail, Throwable cause, JwtContext jwtContext) -
Method Summary
Modifier and TypeMethodDescriptionReturns a list of reasons the JWT was considered invalid.Returns aJwtContext
object including theJwtClaims
representing the JWT processed up to the point of thisInvalidJwtException
being thrown.Returns the original message of this exception without the details.boolean
hasErrorCode
(int code) Provides programmatic access to (some) specific reasons for JWT invalidity by indicating if the given error code was one of the reasons for the JWT being considered invalid.boolean
Indicates if the JWT was invalid because it had expired (i.e.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
InvalidJwtException
public InvalidJwtException(String message, List<ErrorCodeValidator.Error> details, JwtContext jwtContext) -
InvalidJwtException
public InvalidJwtException(String message, ErrorCodeValidator.Error detail, Throwable cause, JwtContext jwtContext)
-
-
Method Details
-
hasErrorCode
public boolean hasErrorCode(int code) Provides programmatic access to (some) specific reasons for JWT invalidity by indicating if the given error code was one of the reasons for the JWT being considered invalid.
Error codes used by this library are defined in
ErrorCodes
.- Parameters:
code
- the given error code- Returns:
- true if the given error code was one of the reasons for the JWT being invalid and false otherwise
-
hasExpired
public boolean hasExpired()Indicates if the JWT was invalid because it had expired (i.e. the expiration time "exp" claim identified a time in the past). This is equivalent to callinghasErrorCode(ErrorCodes.EXPIRED)
- Returns:
- true if expiration is one of the reasons for the JWT being invalid and false otherwise
-
getErrorDetails
Returns a list of reasons the JWT was considered invalid.- Returns:
- the list of error reasons/details
-
getJwtContext
Returns aJwtContext
object including theJwtClaims
representing the JWT processed up to the point of thisInvalidJwtException
being thrown. Some care should be taken when using this because, depending on what kind of error was encountered in processing the JWT and when it was encountered, theJwtContext
may not be complete.- Returns:
- the
JwtContext
-
getMessage
- Overrides:
getMessage
in classThrowable
-
getOriginalMessage
Returns the original message of this exception without the details.- Returns:
- the original message
-