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 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 aServiceProviderToken
from the store whosetoken
attribute is equal to thetoken
parameter.Iterable<ServiceProviderToken>
getAccessTokensForUser(String username)
Retrieves all the access tokens the user has approved.ServiceProviderToken
put(ServiceProviderToken token)
Put the token in the store.void
remove(String token)
Remove aServiceProviderToken
from the store whosetoken
attribute value is equal to thetoken
parameter.void
removeByConsumer(String consumerKey)
Remove all theServiceProviderToken
s created by the consumer.void
removeExpiredSessions()
Remove all sessions andServiceProviderToken
s from the store whosesession
has expired.void
removeExpiredTokens()
Remove allServiceProviderToken
s from the store that do not have sessions and whosetimeToLive
has been exceeded.
-
-
-
Method Detail
-
get
Optional<ServiceProviderToken> get(String token)
Retrieve aServiceProviderToken
from the store whosetoken
attribute is equal to thetoken
parameter.- Parameters:
token
- token value of theServiceProviderToken
to retrieve- Returns:
- Optional of
ServiceProviderToken
whose value istoken
,Optional.absent()
if there is noServiceProviderToken
instance matching thetoken
parameter - 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
-ServiceProviderToken
to store- Returns:
- the
ServiceProviderToken
that was stored - Throws:
StoreException
- thrown if there is a problem loading theServiceProviderToken
-
remove
void remove(String token)
Remove aServiceProviderToken
from the store whosetoken
attribute value is equal to thetoken
parameter.- Parameters:
token
- token value of theServiceProviderToken
to remove- Throws:
StoreException
- thrown if there is a problem removing theServiceProviderToken
- Since:
- 1.5.0
-
removeExpiredTokens
void removeExpiredTokens()
Remove allServiceProviderToken
s from the store that do not have sessions and whosetimeToLive
has been exceeded.ServiceProviderToken
s 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 expiredServiceProviderToken
s- Since:
- 1.5.0
-
removeExpiredSessions
void removeExpiredSessions()
Remove all sessions andServiceProviderToken
s from the store whosesession
has expired.- Throws:
StoreException
- thrown if there is a problem removing theServiceProviderToken
s- Since:
- 1.5.0
-
removeByConsumer
void removeByConsumer(String consumerKey)
Remove all theServiceProviderToken
s created by the consumer.- Parameters:
consumerKey
- key of the consumer that created the tokens which are to be removed
-
-