All Known Implementing Classes:
BearerJwtTokenGenerator, BearerTokenGenerator

public interface TokenGenerator
  • Method Details

    • init

      void init(Router router) throws Exception
      Throws:
      Exception
    • getTokenType

      String getTokenType()
      Returns:
      the token type used, probably "Bearer".
    • getToken

      String getToken(String username, String clientId, String clientSecret, Map<String,Object> additionalClaims)
      Returns:
      a new token for the specified user and client.
    • getUsername

      String getUsername(String token) throws NoSuchElementException
      Checks the token for validity. Returns the username the token was generated for.
      Parameters:
      token - The token.
      Returns:
      The username.
      Throws:
      NoSuchElementException - if the token is not valid or no username is contained in the token.
    • getAdditionalClaims

      Map<String,Object> getAdditionalClaims(String token) throws NoSuchElementException
      Checks the token for validity. Returns the additional claims the token was generated for.
      Parameters:
      token - The token.
      Returns:
      The additional claims.
      Throws:
      NoSuchElementException - if the token is not valid.
    • getClientId

      String getClientId(String token) throws NoSuchElementException
      Checks the token for validity. Returns the clientId the token was generated for.
      Parameters:
      token - The token.
      Returns:
      The clientId.
      Throws:
      NoSuchElementException - if the token is not valid or no clientId is contained in the token.
    • invalidateToken

      void invalidateToken(String token, String clientId, String clientSecret) throws NoSuchElementException
      Revokes a token.
      Throws:
      NoSuchElementException
    • supportsRevocation

      boolean supportsRevocation()
      Returns:
      whether this token manager supports revocation (also known as "invalidation")
    • getExpiration

      long getExpiration()
      Returns:
      token expiration in seconds, or 0 if there is no expiration
    • getJwkIfAvailable

      String getJwkIfAvailable()
      Returns:
      the JWK representation of the key used to sign the tokens or null, if there is no such key (e.g. because the tokens are randomly generated strings)