org.springframework.security.oauth2.provider.token
类 DefaultTokenServices

java.lang.Object
  继承者 org.springframework.security.oauth2.provider.token.DefaultTokenServices
所有已实现的接口:
org.springframework.beans.factory.InitializingBean, AuthorizationServerTokenServices, ConsumerTokenServices, ResourceServerTokenServices

public class DefaultTokenServices
extends Object
implements AuthorizationServerTokenServices, ResourceServerTokenServices, ConsumerTokenServices, org.springframework.beans.factory.InitializingBean

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.

作者:
Ryan Heaton, Luke Taylor, Dave Syer

构造方法摘要
DefaultTokenServices()
           
 
方法摘要
 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.
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

DefaultTokenServices

public DefaultTokenServices()
方法详细信息

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Initialize these token services. If no random generator is set, one will be created.

指定者:
接口 org.springframework.beans.factory.InitializingBean 中的 afterPropertiesSet
抛出:
Exception

createAccessToken

public OAuth2AccessToken createAccessToken(OAuth2Authentication authentication)
                                    throws org.springframework.security.core.AuthenticationException
从接口 AuthorizationServerTokenServices 复制的描述
Create an access token associated with the specified credentials.

指定者:
接口 AuthorizationServerTokenServices 中的 createAccessToken
参数:
authentication - The credentials associated with the access token.
返回:
The access token.
抛出:
org.springframework.security.core.AuthenticationException - If the credentials are inadequate.

refreshAccessToken

public OAuth2AccessToken refreshAccessToken(String refreshTokenValue,
                                            TokenRequest tokenRequest)
                                     throws org.springframework.security.core.AuthenticationException
从接口 AuthorizationServerTokenServices 复制的描述
Refresh an access token. The authorization request should be used for 2 things (at least): to validate that the client id of the original access token is the same as the one requesting the refresh, and to narrow the scopes (if provided).

指定者:
接口 AuthorizationServerTokenServices 中的 refreshAccessToken
参数:
refreshTokenValue - The details about the refresh token.
tokenRequest - The incoming token request.
返回:
The (new) access token.
抛出:
org.springframework.security.core.AuthenticationException - If the refresh token is invalid or expired.

getAccessToken

public OAuth2AccessToken getAccessToken(OAuth2Authentication authentication)
从接口 AuthorizationServerTokenServices 复制的描述
Retrieve an access token stored against the provided authentication key, if it exists.

指定者:
接口 AuthorizationServerTokenServices 中的 getAccessToken
参数:
authentication - the authentication key for the access token
返回:
the access token or null if there was none

isExpired

protected boolean isExpired(OAuth2RefreshToken refreshToken)

readAccessToken

public OAuth2AccessToken readAccessToken(String accessToken)
从接口 ResourceServerTokenServices 复制的描述
Retrieve the full access token details from just the value.

指定者:
接口 ResourceServerTokenServices 中的 readAccessToken
参数:
accessToken - the token value
返回:
the full access token with client id etc.

loadAuthentication

public OAuth2Authentication loadAuthentication(String accessTokenValue)
                                        throws org.springframework.security.core.AuthenticationException
从接口 ResourceServerTokenServices 复制的描述
Load the credentials for the specified access token.

指定者:
接口 ResourceServerTokenServices 中的 loadAuthentication
参数:
accessTokenValue - The access token value.
返回:
The authentication for the access token.
抛出:
org.springframework.security.core.AuthenticationException - If the access token is expired

getClientId

public String getClientId(String tokenValue)
指定者:
接口 ConsumerTokenServices 中的 getClientId

findTokensByUserName

public Collection<OAuth2AccessToken> findTokensByUserName(String userName)
指定者:
接口 ConsumerTokenServices 中的 findTokensByUserName

findTokensByClientId

public Collection<OAuth2AccessToken> findTokensByClientId(String clientId)
指定者:
接口 ConsumerTokenServices 中的 findTokensByClientId

revokeToken

public boolean revokeToken(String tokenValue)
指定者:
接口 ConsumerTokenServices 中的 revokeToken

getAccessTokenValiditySeconds

protected int getAccessTokenValiditySeconds(OAuth2Request clientAuth)
The access token validity period in seconds

参数:
authorizationRequest - the current authorization request
返回:
the access token validity period in seconds

getRefreshTokenValiditySeconds

protected int getRefreshTokenValiditySeconds(OAuth2Request clientAuth)
The refresh token validity period in seconds

参数:
authorizationRequest - the current authorization request
返回:
the refresh token validity period in seconds

isSupportRefreshToken

protected boolean isSupportRefreshToken(OAuth2Request clientAuth)
Is a refresh token supported for this client (or the global setting if clientDetailsService is not set.

参数:
authorizationRequest - the current authorization request
返回:
boolean to indicate if refresh token is supported

setTokenEnhancer

public void setTokenEnhancer(TokenEnhancer accessTokenEnhancer)
An access token enhancer that will be applied to a new token before it is saved in the token store.

参数:
accessTokenEnhancer - the access token enhancer to set

setRefreshTokenValiditySeconds

public void setRefreshTokenValiditySeconds(int refreshTokenValiditySeconds)
The validity (in seconds) of the refresh token.

参数:
refreshTokenValiditySeconds - The validity (in seconds) of the refresh token.

setAccessTokenValiditySeconds

public void setAccessTokenValiditySeconds(int accessTokenValiditySeconds)
The default validity (in seconds) of the access token. Zero or negative for non-expiring tokens. If a client details service is set the validity period will be read from he client, defaulting to this value if not defined by the client.

参数:
accessTokenValiditySeconds - The validity (in seconds) of the access token.

setSupportRefreshToken

public void setSupportRefreshToken(boolean supportRefreshToken)
Whether to support the refresh token.

参数:
supportRefreshToken - Whether to support the refresh token.

setReuseRefreshToken

public void setReuseRefreshToken(boolean reuseRefreshToken)
Whether to reuse refresh tokens (until expired).

参数:
reuseRefreshToken - Whether to reuse refresh tokens (until expired).

setTokenStore

public void setTokenStore(TokenStore tokenStore)
The persistence strategy for token storage.

参数:
tokenStore - the store for access and refresh tokens.

setClientDetailsService

public void setClientDetailsService(ClientDetailsService clientDetailsService)
The client details service to use for looking up clients (if necessary). Optional if the access token expiry is set globally via setAccessTokenValiditySeconds(int).

参数:
clientDetailsService - the client details service


Copyright © 2013. All rights reserved.