Interface TokenGenerator
- All Known Implementing Classes:
BearerJwtTokenGenerator,BearerTokenGenerator
public interface TokenGenerator
-
Method Summary
Modifier and TypeMethodDescriptiongetAdditionalClaims(String token) Checks the token for validity.getClientId(String token) Checks the token for validity.longgetToken(String username, String clientId, String clientSecret, Map<String, Object> additionalClaims) getUsername(String token) Checks the token for validity.voidvoidinvalidateToken(String token, String clientId, String clientSecret) Revokes a token.boolean
-
Method Details
-
init
- 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
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
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
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)
-