Package com.auth0.jwt

Class JWT


  • public class JWT
    extends java.lang.Object
    Exposes all the JWT functionalities.
    • Constructor Summary

      Constructors 
      Constructor Description
      JWT()
      Constructs a new instance of the JWT library.
    • Constructor Detail

      • JWT

        public JWT()
        Constructs a new instance of the JWT library. Use this if you need to decode many JWT tokens on the fly and do not wish to instantiate a new parser for each invocation.
    • Method Detail

      • decodeJwt

        public DecodedJWT decodeJwt​(java.lang.String token)
                             throws JWTDecodeException
        Decode a given Json Web Token.

        Note that this method doesn't verify the token's signature! Use it only if you trust the token or if you have already verified it.

        Parameters:
        token - with jwt format as string.
        Returns:
        a decoded JWT.
        Throws:
        JWTDecodeException - if any part of the token contained an invalid jwt or JSON format of each of the jwt parts.
      • decode

        public static DecodedJWT decode​(java.lang.String token)
                                 throws JWTDecodeException
        Decode a given Json Web Token.

        Note that this method doesn't verify the token's signature! Use it only if you trust the token or if you have already verified it.

        Parameters:
        token - with jwt format as string.
        Returns:
        a decoded JWT.
        Throws:
        JWTDecodeException - if any part of the token contained an invalid jwt or JSON format of each of the jwt parts.
      • require

        public static Verification require​(Algorithm algorithm)
        Returns a Verification builder with the algorithm to be used to validate token signature.
        Parameters:
        algorithm - that will be used to verify the token's signature.
        Returns:
        Verification builder
        Throws:
        java.lang.IllegalArgumentException - if the provided algorithm is null.
      • create

        public static JWTCreator.Builder create()
        Returns a Json Web Token builder used to create and sign tokens.
        Returns:
        a token builder.