Class InvalidJwtException

java.lang.Object
java.lang.Throwable
java.lang.Exception
org.jose4j.jwt.consumer.InvalidJwtException
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
InvalidJwtSignatureException

public class InvalidJwtException extends Exception
An exception thrown when a JWT is considered invalid or otherwise cannot be processed/consumed.
See Also:
  • Constructor Details

  • 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 calling hasErrorCode(ErrorCodes.EXPIRED)
      Returns:
      true if expiration is one of the reasons for the JWT being invalid and false otherwise
    • getErrorDetails

      public List<ErrorCodeValidator.Error> getErrorDetails()
      Returns a list of reasons the JWT was considered invalid.
      Returns:
      the list of error reasons/details
    • getJwtContext

      public JwtContext getJwtContext()
      Returns a JwtContext object including the JwtClaims representing the JWT processed up to the point of this InvalidJwtException 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, the JwtContext may not be complete.
      Returns:
      the JwtContext
    • getMessage

      public String getMessage()
      Overrides:
      getMessage in class Throwable
    • getOriginalMessage

      public String getOriginalMessage()
      Returns the original message of this exception without the details.
      Returns:
      the original message