|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.security.oauth.provider.token.RandomValueProviderTokenServices
public abstract class RandomValueProviderTokenServices
Base implementation for token services that uses random values to generate tokens. Only the persistence mechanism
is left unimplemented.
This base implementation creates tokens that have an expiration. For request tokens, the default validity is
10 minutes. For access tokens, the default validity is 12 hours.
| Constructor Summary | |
|---|---|
RandomValueProviderTokenServices()
|
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public RandomValueProviderTokenServices()
| Method Detail |
|---|
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 org.springframework.beans.factory.InitializingBeanException
public OAuthProviderToken getToken(String token)
throws org.springframework.security.core.AuthenticationException
OAuthProviderTokenServices
getToken in interface OAuthProviderTokenServicestoken - 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 OAuthProviderTokenServicesconsumerKey - 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 OAuthProviderTokenServicesrequestToken - 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 OAuthProviderTokenServicesrequestToken - 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 OAuthTokenLifecycleRegistrylifecycleListeners - The listeners.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||