public class JwtTokenStore extends Object implements TokenStore
TokenStore implementation that just reads data from the tokens themselves. Not really a store since it
never persists anything, and methods like getAccessToken(OAuth2Authentication) always return null. But
nevertheless a useful tool since it translates access tokens to and from authentications. Use this wherever a
TokenStore is needed, but remember to use the same JwtAccessTokenConverter instance (or one with the same
verifier) as was used when the tokens were minted.| Constructor and Description |
|---|
JwtTokenStore(JwtAccessTokenConverter jwtTokenEnhancer)
Create a JwtTokenStore with this token enhancer (should be shared with the DefaultTokenServices if used).
|
| Modifier and Type | Method and Description |
|---|---|
Collection<OAuth2AccessToken> |
findTokensByClientId(String clientId) |
Collection<OAuth2AccessToken> |
findTokensByClientIdAndUserName(String clientId,
String userName) |
OAuth2AccessToken |
getAccessToken(OAuth2Authentication authentication)
Retrieve an access token stored against the provided authentication key, if it exists.
|
OAuth2AccessToken |
readAccessToken(String tokenValue)
Read an access token from the store.
|
OAuth2Authentication |
readAuthentication(OAuth2AccessToken token)
Read the authentication stored under the specified token value.
|
OAuth2Authentication |
readAuthentication(String token)
Read the authentication stored under the specified token value.
|
OAuth2Authentication |
readAuthenticationForRefreshToken(OAuth2RefreshToken token) |
OAuth2RefreshToken |
readRefreshToken(String tokenValue)
Read a refresh token from the store.
|
void |
removeAccessToken(OAuth2AccessToken token)
Remove an access token from the database.
|
void |
removeAccessTokenUsingRefreshToken(OAuth2RefreshToken refreshToken)
Remove an access token using a refresh token.
|
void |
removeRefreshToken(OAuth2RefreshToken token)
Remove a refresh token from the database.
|
void |
setApprovalStore(ApprovalStore approvalStore)
ApprovalStore to be used to validate and restrict refresh tokens.
|
void |
setTokenEnhancer(JwtAccessTokenConverter tokenEnhancer) |
void |
storeAccessToken(OAuth2AccessToken token,
OAuth2Authentication authentication)
Store an access token.
|
void |
storeRefreshToken(OAuth2RefreshToken refreshToken,
OAuth2Authentication authentication)
Store the specified refresh token in the database.
|
public JwtTokenStore(JwtAccessTokenConverter jwtTokenEnhancer)
jwtTokenEnhancer - public void setApprovalStore(ApprovalStore approvalStore)
approvalStore - the approvalStore to setpublic OAuth2Authentication readAuthentication(OAuth2AccessToken token)
TokenStorereadAuthentication in interface TokenStoretoken - The token value under which the authentication is stored.public OAuth2Authentication readAuthentication(String token)
TokenStorereadAuthentication in interface TokenStoretoken - The token value under which the authentication is stored.public void storeAccessToken(OAuth2AccessToken token, OAuth2Authentication authentication)
TokenStorestoreAccessToken in interface TokenStoretoken - The token to store.authentication - The authentication associated with the token.public OAuth2AccessToken readAccessToken(String tokenValue)
TokenStorereadAccessToken in interface TokenStoretokenValue - The token value.public void removeAccessToken(OAuth2AccessToken token)
TokenStoreremoveAccessToken in interface TokenStoretoken - The token to remove from the database.public void storeRefreshToken(OAuth2RefreshToken refreshToken, OAuth2Authentication authentication)
TokenStorestoreRefreshToken in interface TokenStorerefreshToken - The refresh token to store.authentication - The authentication associated with the refresh token.public OAuth2RefreshToken readRefreshToken(String tokenValue)
TokenStorereadRefreshToken in interface TokenStoretokenValue - The value of the token to read.public OAuth2Authentication readAuthenticationForRefreshToken(OAuth2RefreshToken token)
readAuthenticationForRefreshToken in interface TokenStoretoken - a refresh tokenpublic void removeRefreshToken(OAuth2RefreshToken token)
TokenStoreremoveRefreshToken in interface TokenStoretoken - The token to remove from the database.public void removeAccessTokenUsingRefreshToken(OAuth2RefreshToken refreshToken)
TokenStoreremoveAccessTokenUsingRefreshToken in interface TokenStorerefreshToken - The refresh token.public OAuth2AccessToken getAccessToken(OAuth2Authentication authentication)
TokenStoregetAccessToken in interface TokenStoreauthentication - the authentication key for the access tokenpublic Collection<OAuth2AccessToken> findTokensByClientIdAndUserName(String clientId, String userName)
findTokensByClientIdAndUserName in interface TokenStoreclientId - the client id to searchuserName - the user name to searchpublic Collection<OAuth2AccessToken> findTokensByClientId(String clientId)
findTokensByClientId in interface TokenStoreclientId - the client id to searchpublic void setTokenEnhancer(JwtAccessTokenConverter tokenEnhancer)
Copyright © 2019. All rights reserved.