Interface ServiceProviderTokenStore
-
- All Known Implementing Classes:
PersistentServiceProviderTokenStore
public interface ServiceProviderTokenStoreProvides 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 theget(String)method throws anInvalidTokenException, the store should not remove the token from persistent storage itself. The caller of theget(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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Optional<ServiceProviderToken>get(String token)Retrieve aServiceProviderTokenfrom the store whosetokenattribute is equal to thetokenparameter.Iterable<ServiceProviderToken>getAccessTokensForUser(String username)Retrieves all the access tokens the user has approved.ServiceProviderTokenput(ServiceProviderToken token)Put the token in the store.voidremove(String token)Remove aServiceProviderTokenfrom the store whosetokenattribute value is equal to thetokenparameter.voidremoveByConsumer(String consumerKey)Remove all theServiceProviderTokens created by the consumer.voidremoveExpiredSessions()Remove all sessions andServiceProviderTokens from the store whosesessionhas expired.voidremoveExpiredTokens()Remove allServiceProviderTokens from the store that do not have sessions and whosetimeToLivehas been exceeded.
-
-
-
Method Detail
-
get
Optional<ServiceProviderToken> get(String token)
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
Iterable<ServiceProviderToken> getAccessTokensForUser(String username)
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
ServiceProviderToken put(ServiceProviderToken token)
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
void remove(String token)
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
void removeByConsumer(String consumerKey)
Remove all theServiceProviderTokens created by the consumer.- Parameters:
consumerKey- key of the consumer that created the tokens which are to be removed
-
-