类 MyDefaultTokenServices
- java.lang.Object
-
- cn.bbwres.biscuit.security.oauth2.MyDefaultTokenServices
-
- 所有已实现的接口:
org.springframework.beans.factory.InitializingBean,org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices,org.springframework.security.oauth2.provider.token.ConsumerTokenServices,org.springframework.security.oauth2.provider.token.ResourceServerTokenServices
public class MyDefaultTokenServices extends Object implements org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices, org.springframework.security.oauth2.provider.token.ResourceServerTokenServices, org.springframework.security.oauth2.provider.token.ConsumerTokenServices, org.springframework.beans.factory.InitializingBean
实现了可以单端登陆功能的服务- 作者:
- zhanglinfeng
-
-
构造器概要
构造器 构造器 说明 MyDefaultTokenServices()
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidafterPropertiesSet()Initialize these token services.org.springframework.security.oauth2.common.OAuth2AccessTokencreateAccessToken(org.springframework.security.oauth2.provider.OAuth2Authentication authentication)org.springframework.security.oauth2.common.OAuth2AccessTokengetAccessToken(org.springframework.security.oauth2.provider.OAuth2Authentication authentication)protected intgetAccessTokenValiditySeconds(org.springframework.security.oauth2.provider.OAuth2Request clientAuth)The access token validity period in secondsStringgetClientId(String tokenValue)protected intgetRefreshTokenValiditySeconds(org.springframework.security.oauth2.provider.OAuth2Request clientAuth)The refresh token validity period in secondsprotected booleanisExpired(org.springframework.security.oauth2.common.OAuth2RefreshToken refreshToken)protected booleanisSupportRefreshToken(org.springframework.security.oauth2.provider.OAuth2Request clientAuth)Is a refresh token supported for this client (or the global setting ifclientDetailsServiceis not set.org.springframework.security.oauth2.provider.OAuth2AuthenticationloadAuthentication(String accessTokenValue)org.springframework.security.oauth2.common.OAuth2AccessTokenreadAccessToken(String accessToken)org.springframework.security.oauth2.common.OAuth2AccessTokenrefreshAccessToken(String refreshTokenValue, org.springframework.security.oauth2.provider.TokenRequest tokenRequest)booleanrevokeToken(String tokenValue)voidsetAccessTokenValiditySeconds(int accessTokenValiditySeconds)The default validity (in seconds) of the access token.voidsetAuthenticationManager(org.springframework.security.authentication.AuthenticationManager authenticationManager)An authentication manager that will be used (if provided) to check the user authentication when a token is refreshed.voidsetClientDetailsService(org.springframework.security.oauth2.provider.ClientDetailsService clientDetailsService)The client details service to use for looking up clients (if necessary).voidsetRefreshTokenValiditySeconds(int refreshTokenValiditySeconds)The validity (in seconds) of the refresh token.voidsetReuseRefreshToken(boolean reuseRefreshToken)Whether to reuse refresh tokens (until expired).voidsetSingleClientToken(boolean singleClientToken)voidsetSupportRefreshToken(boolean supportRefreshToken)Whether to support the refresh token.voidsetTokenEnhancer(org.springframework.security.oauth2.provider.token.TokenEnhancer accessTokenEnhancer)An access token enhancer that will be applied to a new token before it is saved in the token store.voidsetTokenStore(org.springframework.security.oauth2.provider.token.TokenStore tokenStore)The persistence strategy for token storage.
-
-
-
方法详细资料
-
afterPropertiesSet
public void afterPropertiesSet() throws ExceptionInitialize these token services. If no random generator is set, one will be created.- 指定者:
afterPropertiesSet在接口中org.springframework.beans.factory.InitializingBean- 抛出:
Exception
-
createAccessToken
@Transactional public org.springframework.security.oauth2.common.OAuth2AccessToken createAccessToken(org.springframework.security.oauth2.provider.OAuth2Authentication authentication) throws org.springframework.security.core.AuthenticationException- 指定者:
createAccessToken在接口中org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices- 抛出:
org.springframework.security.core.AuthenticationException
-
refreshAccessToken
@Transactional(noRollbackFor={org.springframework.security.oauth2.common.exceptions.InvalidTokenException.class,org.springframework.security.oauth2.common.exceptions.InvalidGrantException.class}) public org.springframework.security.oauth2.common.OAuth2AccessToken refreshAccessToken(String refreshTokenValue, org.springframework.security.oauth2.provider.TokenRequest tokenRequest) throws org.springframework.security.core.AuthenticationException- 指定者:
refreshAccessToken在接口中org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices- 抛出:
org.springframework.security.core.AuthenticationException
-
getAccessToken
public org.springframework.security.oauth2.common.OAuth2AccessToken getAccessToken(org.springframework.security.oauth2.provider.OAuth2Authentication authentication)
- 指定者:
getAccessToken在接口中org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices
-
isExpired
protected boolean isExpired(org.springframework.security.oauth2.common.OAuth2RefreshToken refreshToken)
-
readAccessToken
public org.springframework.security.oauth2.common.OAuth2AccessToken readAccessToken(String accessToken)
- 指定者:
readAccessToken在接口中org.springframework.security.oauth2.provider.token.ResourceServerTokenServices
-
loadAuthentication
public org.springframework.security.oauth2.provider.OAuth2Authentication loadAuthentication(String accessTokenValue) throws org.springframework.security.core.AuthenticationException, org.springframework.security.oauth2.common.exceptions.InvalidTokenException
- 指定者:
loadAuthentication在接口中org.springframework.security.oauth2.provider.token.ResourceServerTokenServices- 抛出:
org.springframework.security.core.AuthenticationExceptionorg.springframework.security.oauth2.common.exceptions.InvalidTokenException
-
revokeToken
public boolean revokeToken(String tokenValue)
- 指定者:
revokeToken在接口中org.springframework.security.oauth2.provider.token.ConsumerTokenServices
-
getAccessTokenValiditySeconds
protected int getAccessTokenValiditySeconds(org.springframework.security.oauth2.provider.OAuth2Request clientAuth)
The access token validity period in seconds- 参数:
clientAuth- the current authorization request- 返回:
- the access token validity period in seconds
-
getRefreshTokenValiditySeconds
protected int getRefreshTokenValiditySeconds(org.springframework.security.oauth2.provider.OAuth2Request clientAuth)
The refresh token validity period in seconds- 参数:
clientAuth- the current authorization request- 返回:
- the refresh token validity period in seconds
-
isSupportRefreshToken
protected boolean isSupportRefreshToken(org.springframework.security.oauth2.provider.OAuth2Request clientAuth)
Is a refresh token supported for this client (or the global setting ifclientDetailsServiceis not set.- 参数:
clientAuth- the current authorization request- 返回:
- boolean to indicate if refresh token is supported
-
setTokenEnhancer
public void setTokenEnhancer(org.springframework.security.oauth2.provider.token.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. If less than or equal to zero then the tokens will be non-expiring.- 参数:
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 the 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(org.springframework.security.oauth2.provider.token.TokenStore tokenStore)
The persistence strategy for token storage.- 参数:
tokenStore- the store for access and refresh tokens.
-
setAuthenticationManager
public void setAuthenticationManager(org.springframework.security.authentication.AuthenticationManager authenticationManager)
An authentication manager that will be used (if provided) to check the user authentication when a token is refreshed.- 参数:
authenticationManager- the authenticationManager to set
-
setClientDetailsService
public void setClientDetailsService(org.springframework.security.oauth2.provider.ClientDetailsService clientDetailsService)
The client details service to use for looking up clients (if necessary). Optional if the access token expiry is set globally viasetAccessTokenValiditySeconds(int).- 参数:
clientDetailsService- the client details service
-
setSingleClientToken
public void setSingleClientToken(boolean singleClientToken)
-
-