java.lang.Object
io.john.amiscaray.quak.security.auth.jwt.JwtUtil

public class JwtUtil extends Object
Used to manage and produce JWTs.
  • Constructor Details

  • Method Details

    • generateToken

      public String generateToken(Principal principal)
      Generates a token from the user's Principal.
      Parameters:
      principal - The user's principal.
      Returns:
      The JWT token as a String.
    • validateTokenAndGetDecoded

      public com.auth0.jwt.interfaces.DecodedJWT validateTokenAndGetDecoded(String token)
      Validates and decodes a given JWT.
      Parameters:
      token - The JWT as a String.
      Returns:
      The decoded JWT.
    • extractSubject

      public String extractSubject(String token)
      Extracts the subject of a JWT.
      Parameters:
      token - The JWT.
      Returns:
      The subject (the security ID of the user).
    • isTokenExpired

      public boolean isTokenExpired(String token)
      Checks if a JWT is expired.
      Parameters:
      token - The JWT.
      Returns:
      Whether the token is expired.