Class BearerJwtTokenGenerator
java.lang.Object
com.predic8.membrane.core.interceptor.oauth2.tokengenerators.BearerJwtTokenGenerator
- All Implemented Interfaces:
TokenGenerator
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAdditionalClaims(String token) Checks the token for validity.getClientId(String token) Checks the token for validity.longgetJwk()getToken(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.booleanvoidsetExpiration(long expiration) voidvoidsetWarningGeneratedKey(boolean warningGeneratedKey) booleanorg.jose4j.jwt.JwtClaims
-
Constructor Details
-
BearerJwtTokenGenerator
public BearerJwtTokenGenerator()
-
-
Method Details
-
init
- Specified by:
initin interfaceTokenGenerator- Throws:
Exception
-
getTokenType
- Specified by:
getTokenTypein interfaceTokenGenerator- Returns:
- the token type used, probably "Bearer".
-
getToken
public String getToken(String username, String clientId, String clientSecret, Map<String, Object> additionalClaims) - Specified by:
getTokenin interfaceTokenGenerator- Returns:
- a new token for the specified user and client.
-
verify
public org.jose4j.jwt.JwtClaims verify(String token) throws org.jose4j.jwt.consumer.InvalidJwtException - Throws:
org.jose4j.jwt.consumer.InvalidJwtException
-
getUsername
Description copied from interface:TokenGeneratorChecks the token for validity. Returns the username the token was generated for.- Specified by:
getUsernamein interfaceTokenGenerator- Parameters:
token- The token.- Returns:
- The username.
- Throws:
NoSuchElementException- if the token is not valid or no username is contained in the token.
-
getAdditionalClaims
Description copied from interface:TokenGeneratorChecks the token for validity. Returns the additional claims the token was generated for.- Specified by:
getAdditionalClaimsin interfaceTokenGenerator- Parameters:
token- The token.- Returns:
- The additional claims.
- Throws:
NoSuchElementException- if the token is not valid.
-
getClientId
Description copied from interface:TokenGeneratorChecks the token for validity. Returns the clientId the token was generated for.- Specified by:
getClientIdin interfaceTokenGenerator- Parameters:
token- The token.- Returns:
- The clientId.
- Throws:
NoSuchElementException- if the token is not valid or no clientId is contained in the token.
-
invalidateToken
public void invalidateToken(String token, String clientId, String clientSecret) throws NoSuchElementException Description copied from interface:TokenGeneratorRevokes a token.- Specified by:
invalidateTokenin interfaceTokenGenerator- Throws:
NoSuchElementException
-
supportsRevocation
public boolean supportsRevocation()- Specified by:
supportsRevocationin interfaceTokenGenerator- Returns:
- whether this token manager supports revocation (also known as "invalidation")
-
getExpiration
public long getExpiration()- Specified by:
getExpirationin interfaceTokenGenerator- Returns:
- token expiration in seconds, or 0 if there is no expiration
-
setExpiration
public void setExpiration(long expiration) - Default
- 0
- Description
- Token expiration in seconds (or 0 to use no token expiration).
-
getJwk
-
setJwk
-
isWarningGeneratedKey
public boolean isWarningGeneratedKey() -
setWarningGeneratedKey
public void setWarningGeneratedKey(boolean warningGeneratedKey) -
getJwkIfAvailable
- Specified by:
getJwkIfAvailablein interfaceTokenGenerator- 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)
-