All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.auth0.jwt.JWT Maven / Gradle / Ivy

There is a newer version: 4.4.0
Show newest version
package com.auth0.jwt;

import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.exceptions.JWTDecodeException;
import com.auth0.jwt.interfaces.Claim;
import com.auth0.jwt.interfaces.DecodedJWT;

import java.util.Date;
import java.util.List;

@SuppressWarnings("WeakerAccess")
public abstract class JWT implements DecodedJWT {

    /**
     * Decode a given JWT token.
     *
     * Note that this method doesn't verify the token's signature! Use it only if you trust the token or you already verified it.
     *
     * @param token with jwt format as string.
     * @return a decoded token.
     * @throws JWTDecodeException if any part of the token contained an invalid jwt or JSON format of each of the jwt parts.
     */
    public static JWT decode(String token) throws JWTDecodeException {
        return new JWTDecoder(token);
    }

    /**
     * Returns a {@link JWTVerifier} builder with the algorithm to be used to validate token signature.
     *
     * @param algorithm that will be used to verify the token's signature.
     * @return {@link JWTVerifier} builder
     * @throws IllegalArgumentException if the provided algorithm is null.
     */
    public static JWTVerifier.Verification require(Algorithm algorithm) {
        return JWTVerifier.init(algorithm);
    }

    /**
     * Returns a JWT builder used to create and sign jwt tokens
     *
     * @return a jwt token builder.
     */
    public static JWTCreator.Builder create() {
        return JWTCreator.init();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy