Class JwtManager

java.lang.Object
org.ctan.site.services.account.JwtManager

public class JwtManager extends Object
The class JwtManager contains static utility methods for dealing with JWTs.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final com.auth0.jwt.interfaces.JWTVerifier
    The field VERIFIER contains the verifier.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    create(@NonNull String account)
    Create a JWT with standard options set.
    static String
    create(@NonNull String account, long ttl)
    Create a JWT with standard options set.
    static String
    verify(String token)
    The method verify provides means to verify a JWT and return the account.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • VERIFIER

      protected static final com.auth0.jwt.interfaces.JWTVerifier VERIFIER
      The field VERIFIER contains the verifier. It is visible outside for testing purpose.
  • Method Details

    • create

      public static String create(@NonNull @NonNull String account)
      Create a JWT with standard options set.
      Parameters:
      account - the user id;
      Returns:
      a new JWT
    • create

      public static String create(@NonNull @NonNull String account, long ttl)
      Create a JWT with standard options set.
      Parameters:
      account - the user id;
      ttl - time to live in ms
      Returns:
      a new JWT
    • verify

      public static String verify(String token)
      The method verify provides means to verify a JWT and return the account.
      Parameters:
      token - the JWT
      Returns:
      the verified user id or null