|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.security.oauth2.provider.token.DefaultTokenServices
public class DefaultTokenServices
Base implementation for token services using random UUID values for the access token and refresh token values. The
main extension point for customizations is the TokenEnhancer which will be called after the access and
refresh tokens have been generated but before they are stored.
Persistence is delegated to a TokenStore implementation and customization of the access token to a
TokenEnhancer.
| Constructor Summary | |
|---|---|
DefaultTokenServices()
|
|
| Method Summary | |
|---|---|
void |
afterPropertiesSet()
Initialize these token services. |
OAuth2AccessToken |
createAccessToken(OAuth2Authentication authentication)
Create an access token associated with the specified credentials. |
Collection<OAuth2AccessToken> |
findTokensByClientId(String clientId)
|
Collection<OAuth2AccessToken> |
findTokensByUserName(String userName)
|
OAuth2AccessToken |
getAccessToken(OAuth2Authentication authentication)
Retrieve an access token stored against the provided authentication key, if it exists. |
protected int |
getAccessTokenValiditySeconds(OAuth2Request clientAuth)
The access token validity period in seconds |
String |
getClientId(String tokenValue)
|
protected int |
getRefreshTokenValiditySeconds(OAuth2Request clientAuth)
The refresh token validity period in seconds |
protected boolean |
isExpired(OAuth2RefreshToken refreshToken)
|
protected boolean |
isSupportRefreshToken(OAuth2Request clientAuth)
Is a refresh token supported for this client (or the global setting if clientDetailsService is not set. |
OAuth2Authentication |
loadAuthentication(String accessTokenValue)
Load the credentials for the specified access token. |
OAuth2AccessToken |
readAccessToken(String accessToken)
Retrieve the full access token details from just the value. |
OAuth2AccessToken |
refreshAccessToken(String refreshTokenValue,
TokenRequest tokenRequest)
Refresh an access token. |
boolean |
revokeToken(String tokenValue)
|
void |
setAccessTokenValiditySeconds(int accessTokenValiditySeconds)
The default validity (in seconds) of the access token. |
void |
setClientDetailsService(ClientDetailsService clientDetailsService)
The client details service to use for looking up clients (if necessary). |
void |
setRefreshTokenValiditySeconds(int refreshTokenValiditySeconds)
The validity (in seconds) of the refresh token. |
void |
setReuseRefreshToken(boolean reuseRefreshToken)
Whether to reuse refresh tokens (until expired). |
void |
setSupportRefreshToken(boolean supportRefreshToken)
Whether to support the refresh token. |
void |
setTokenEnhancer(TokenEnhancer accessTokenEnhancer)
An access token enhancer that will be applied to a new token before it is saved in the token store. |
void |
setTokenStore(TokenStore tokenStore)
The persistence strategy for token storage. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DefaultTokenServices()
| Method Detail |
|---|
public void afterPropertiesSet()
throws Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanException
public OAuth2AccessToken createAccessToken(OAuth2Authentication authentication)
throws org.springframework.security.core.AuthenticationException
AuthorizationServerTokenServices
createAccessToken in interface AuthorizationServerTokenServicesauthentication - The credentials associated with the access token.
org.springframework.security.core.AuthenticationException - If the credentials are inadequate.
public OAuth2AccessToken refreshAccessToken(String refreshTokenValue,
TokenRequest tokenRequest)
throws org.springframework.security.core.AuthenticationException
AuthorizationServerTokenServices
refreshAccessToken in interface AuthorizationServerTokenServicesrefreshTokenValue - The details about the refresh token.tokenRequest - The incoming token request.
org.springframework.security.core.AuthenticationException - If the refresh token is invalid or expired.public OAuth2AccessToken getAccessToken(OAuth2Authentication authentication)
AuthorizationServerTokenServices
getAccessToken in interface AuthorizationServerTokenServicesauthentication - the authentication key for the access token
protected boolean isExpired(OAuth2RefreshToken refreshToken)
public OAuth2AccessToken readAccessToken(String accessToken)
ResourceServerTokenServices
readAccessToken in interface ResourceServerTokenServicesaccessToken - the token value
public OAuth2Authentication loadAuthentication(String accessTokenValue)
throws org.springframework.security.core.AuthenticationException
ResourceServerTokenServices
loadAuthentication in interface ResourceServerTokenServicesaccessTokenValue - The access token value.
org.springframework.security.core.AuthenticationException - If the access token is expiredpublic String getClientId(String tokenValue)
public Collection<OAuth2AccessToken> findTokensByUserName(String userName)
public Collection<OAuth2AccessToken> findTokensByClientId(String clientId)
public boolean revokeToken(String tokenValue)
revokeToken in interface ConsumerTokenServicesprotected int getAccessTokenValiditySeconds(OAuth2Request clientAuth)
authorizationRequest - the current authorization request
protected int getRefreshTokenValiditySeconds(OAuth2Request clientAuth)
authorizationRequest - the current authorization request
protected boolean isSupportRefreshToken(OAuth2Request clientAuth)
clientDetailsService is not set.
authorizationRequest - the current authorization request
public void setTokenEnhancer(TokenEnhancer accessTokenEnhancer)
accessTokenEnhancer - the access token enhancer to setpublic void setRefreshTokenValiditySeconds(int refreshTokenValiditySeconds)
refreshTokenValiditySeconds - The validity (in seconds) of the refresh token.public void setAccessTokenValiditySeconds(int accessTokenValiditySeconds)
accessTokenValiditySeconds - The validity (in seconds) of the access token.public void setSupportRefreshToken(boolean supportRefreshToken)
supportRefreshToken - Whether to support the refresh token.public void setReuseRefreshToken(boolean reuseRefreshToken)
reuseRefreshToken - Whether to reuse refresh tokens (until expired).public void setTokenStore(TokenStore tokenStore)
tokenStore - the store for access and refresh tokens.public void setClientDetailsService(ClientDetailsService clientDetailsService)
setAccessTokenValiditySeconds(int).
clientDetailsService - the client details service
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||