Class JWTCredentials

java.lang.Object
dev.getelements.elements.security.JWTCredentials

public class JWTCredentials extends Object
  • Constructor Details

    • JWTCredentials

      public JWTCredentials(String token)
      Generic JWT Credentials.
      Parameters:
      token - the token to parse.
  • Method Details

    • isJwt

      public static boolean isJwt(String credentials)
      Checks if a set of credentials is a valid JWT.
      Parameters:
      credentials - the credentials
      Returns:
      true if JWT, or false otherwise.
    • getDecoded

      public com.auth0.jwt.interfaces.DecodedJWT getDecoded()
      Gets the DecodedJWT backing this object.
      Returns:
      the decoded JWT
    • findIssuer

      public Optional<String> findIssuer()
      Finds the issuer of the token.
      Returns:
      an Optional<String>
    • findAudience

      public Optional<List<String>> findAudience()
      Finds the audience of the token.
      Returns:
      an Optional<List<String>>
    • findExpirationDate

      public Optional<Date> findExpirationDate()
      Finds the expiration date of the token.
      Returns:
      an Optional<Date>
    • verify

      public boolean verify(com.auth0.jwt.algorithms.Algorithm algorithm)
      Verifies the JWT has the required data, and that the signature matches
      Returns:
      if the JWT token is valid
    • asCustomCredentials

      public CustomJWTCredentials asCustomCredentials()
      Converts this JWTCredentials to CustomJWTCredentials, throwing the appropriate exceptions if the conversion is not appropriate for this instance.
      Returns:
      CustomJWTCredentials, if the supplied credentials are valid