public abstract class RandomValueProviderTokenServices extends Object implements OAuthProviderTokenServices, InitializingBean, OAuthTokenLifecycleRegistry
Constructor and Description |
---|
RandomValueProviderTokenServices() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Initialze these token services.
|
void |
authorizeRequestToken(String requestToken,
String verifier,
org.springframework.security.core.Authentication authentication)
Authorize the specified request token with the specified authentication credentials.
|
OAuthAccessProviderToken |
createAccessToken(String requestToken)
Create an OAuth access token given the specified request token.
|
OAuthProviderToken |
createUnauthorizedRequestToken(String consumerKey,
String callbackUrl)
Create an unauthorized OAuth request token.
|
int |
getAccessTokenValiditySeconds()
The validity (in seconds) of the access token.
|
Collection<OAuthTokenLifecycleListener> |
getLifecycleListeners()
The collection of lifecycle listeners for these services.
|
Random |
getRandom()
The random value generator used to create token secrets.
|
int |
getRequestTokenValiditySeconds()
The validity (in seconds) of the unauthenticated request token.
|
OAuthProviderToken |
getToken(String token)
Read a token by its value.
|
int |
getTokenSecretLengthBytes()
The length of the token secret in bytes, before being base64-encoded.
|
protected boolean |
isExpired(OAuthProviderTokenImpl authToken)
Whether the auth token is expired.
|
protected void |
onTokenCreated(OAuthProviderTokenImpl token)
Logic for handling event firing of a created token.
|
protected void |
onTokenRemoved(OAuthProviderTokenImpl token)
Logic for handling event firing of a removed token.
|
protected abstract OAuthProviderTokenImpl |
readToken(String token)
Read a token from persistence.
|
void |
register(OAuthTokenLifecycleListener... lifecycleListeners)
Register lifecycle listener(s) with these token services.
|
protected abstract OAuthProviderTokenImpl |
removeToken(String tokenValue)
Remove a token from persistence.
|
void |
setAccessTokenValiditySeconds(int accessTokenValiditySeconds)
The validity (in seconds) of the access token.
|
void |
setRandom(Random random)
The random value generator used to create token secrets.
|
void |
setRequestTokenValiditySeconds(int requestTokenValiditySeconds)
The validity (in seconds) of the unauthenticated request token.
|
void |
setTokenSecretLengthBytes(int tokenSecretLengthBytes)
The length of the token secret in bytes, before being base64-encoded.
|
protected abstract void |
storeToken(String tokenValue,
OAuthProviderTokenImpl token)
Store a token from persistence.
|
protected abstract OAuthProviderTokenImpl readToken(String token)
token
- The token to read.protected abstract void storeToken(String tokenValue, OAuthProviderTokenImpl token)
tokenValue
- The token value.token
- The token to store.protected abstract OAuthProviderTokenImpl removeToken(String tokenValue)
tokenValue
- The token to remove.public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface InitializingBean
Exception
public OAuthProviderToken getToken(String token) throws org.springframework.security.core.AuthenticationException
OAuthProviderTokenServices
getToken
in interface OAuthProviderTokenServices
token
- The token value.org.springframework.security.core.AuthenticationException
- If the token is invalid, expired, or disabled.protected boolean isExpired(OAuthProviderTokenImpl authToken)
authToken
- The auth token to check for expiration.public OAuthProviderToken createUnauthorizedRequestToken(String consumerKey, String callbackUrl) throws org.springframework.security.core.AuthenticationException
OAuthProviderTokenServices
createUnauthorizedRequestToken
in interface OAuthProviderTokenServices
consumerKey
- The consumer key for which to create the token.callbackUrl
- The callback URL associated with the consumer key.org.springframework.security.core.AuthenticationException
- If the consumer isn't valid or otherwise isn't allowed to create a new request token.public void authorizeRequestToken(String requestToken, String verifier, org.springframework.security.core.Authentication authentication) throws org.springframework.security.core.AuthenticationException
OAuthProviderTokenServices
authorizeRequestToken
in interface OAuthProviderTokenServices
requestToken
- The request token.verifier
- The verifier to be assigned to the request token.authentication
- The authentication credentials with which to authorize the request token. This is the
authentication of the user who has signed in and is authorizing the consumer to have access to a
protected resource. This same authentication can be pulled from the security context, but it's passed explicitly
here to suggest to the method implementation that it needs to take into account what authorities are being
granted to the consumer by the user.org.springframework.security.core.AuthenticationException
- If the token is expired or otherwise unauthorizable, or if the
authentication credentials are insufficient.public OAuthAccessProviderToken createAccessToken(String requestToken) throws org.springframework.security.core.AuthenticationException
OAuthProviderTokenServices
createAccessToken
in interface OAuthProviderTokenServices
requestToken
- The (presumably authorized) request token used to create the access token.org.springframework.security.core.AuthenticationException
- If the request token is expired or disabled or doesn't reference the necessary authentication
credentials or otherwise isn't authorized.protected void onTokenRemoved(OAuthProviderTokenImpl token)
token
- The token that was removed (possibly null).protected void onTokenCreated(OAuthProviderTokenImpl token)
token
- The token that was created.public int getTokenSecretLengthBytes()
public void setTokenSecretLengthBytes(int tokenSecretLengthBytes)
tokenSecretLengthBytes
- The length of the token secret in bytes, before being base64-encoded.public Random getRandom()
public void setRandom(Random random)
random
- The random value generator used to create token secrets.public int getRequestTokenValiditySeconds()
public void setRequestTokenValiditySeconds(int requestTokenValiditySeconds)
requestTokenValiditySeconds
- The validity (in seconds) of the unauthenticated request token.public int getAccessTokenValiditySeconds()
public void setAccessTokenValiditySeconds(int accessTokenValiditySeconds)
accessTokenValiditySeconds
- The validity (in seconds) of the access token.public Collection<OAuthTokenLifecycleListener> getLifecycleListeners()
getLifecycleListeners
in interface OAuthTokenLifecycleRegistry
@Autowired(required=false) public void register(OAuthTokenLifecycleListener... lifecycleListeners)
register
in interface OAuthTokenLifecycleRegistry
lifecycleListeners
- The listeners.Copyright © 2019. All rights reserved.