Interface ServiceProviderTokenStore
- All Known Implementing Classes:
PersistentServiceProviderTokenStore
public interface ServiceProviderTokenStore
Provides persistent storage for OAuth tokens. The implementation of this store should only concern itself
with the immediate task that it is being asked to perform. As an example, if the
get(String) method
throws an InvalidTokenException, the store should not remove the token from persistent storage itself. The
caller of the get(String) method is responsible for the removal of the token. It is the sole task of the
store to save objects to a persistent backend and retrieve or remove them when requested.-
Method Summary
Modifier and TypeMethodDescriptionRetrieve aServiceProviderTokenfrom the store whosetokenattribute is equal to thetokenparameter.getAccessTokensForUser(String username) Retrieves all the access tokens the user has approved.put(ServiceProviderToken token) Put the token in the store.voidRemove aServiceProviderTokenfrom the store whosetokenattribute value is equal to thetokenparameter.voidremoveByConsumer(String consumerKey) Remove all theServiceProviderTokens created by the consumer.voidRemove all sessions andServiceProviderTokens from the store whosesessionhas expired.voidRemove allServiceProviderTokens from the store that do not have sessions and whosetimeToLivehas been exceeded.
-
Method Details
-
get
Retrieve aServiceProviderTokenfrom the store whosetokenattribute is equal to thetokenparameter.- Parameters:
token- token value of theServiceProviderTokento retrieve- Returns:
- Optional of
ServiceProviderTokenwhose value istoken,Optional.absent()if there is noServiceProviderTokeninstance matching thetokenparameter - Throws:
StoreException- thrown if there is a problem storing theServiceProviderToken
-
getAccessTokensForUser
Retrieves all the access tokens the user has approved.- Parameters:
username- the user that approved the access tokens to retrieve- Returns:
- all the access tokens the user has approved
-
put
Put the token in the store.- Parameters:
token-ServiceProviderTokento store- Returns:
- the
ServiceProviderTokenthat was stored - Throws:
StoreException- thrown if there is a problem loading theServiceProviderToken
-
remove
Remove aServiceProviderTokenfrom the store whosetokenattribute value is equal to thetokenparameter.- Parameters:
token- token value of theServiceProviderTokento remove- Throws:
StoreException- thrown if there is a problem removing theServiceProviderToken- Since:
- 1.5.0
-
removeExpiredTokens
void removeExpiredTokens()Remove allServiceProviderTokens from the store that do not have sessions and whosetimeToLivehas been exceeded.ServiceProviderTokens with session information should be left as-is, to be removed by theremoveExpiredSessions()method when the session expires.Note: In 1.4.0 support for OAuth sessions was implemented. Rather than create an entirely separate entity, session information is carried along with access tokens. This means that if we remove expired tokens that have sessions, we will also be removing the session information. Consequently, we don't want to remove an expired token until the session has expired and the token cannot be renewed. To remove expired sessions and the tokens associated with them, use
removeExpiredSessions()instead.- Throws:
StoreException- thrown if there is a problem removing the expiredServiceProviderTokens- Since:
- 1.5.0
-
removeExpiredSessions
void removeExpiredSessions()Remove all sessions andServiceProviderTokens from the store whosesessionhas expired.- Throws:
StoreException- thrown if there is a problem removing theServiceProviderTokens- Since:
- 1.5.0
-
removeByConsumer
Remove all theServiceProviderTokens created by the consumer.- Parameters:
consumerKey- key of the consumer that created the tokens which are to be removed
-