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 Details

    • get

      Retrieve a ServiceProviderToken from the store whose token attribute is equal to the token parameter.
      Parameters:
      token - token value of the ServiceProviderToken to retrieve
      Returns:
      Optional of ServiceProviderToken whose value is token, Optional.absent() if there is no ServiceProviderToken instance matching the token parameter
      Throws:
      StoreException - thrown if there is a problem storing the ServiceProviderToken
    • 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

      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 the ServiceProviderToken
    • remove

      void remove(String token)
      Remove a ServiceProviderToken from the store whose token attribute value is equal to the token parameter.
      Parameters:
      token - token value of the ServiceProviderToken to remove
      Throws:
      StoreException - thrown if there is a problem removing the ServiceProviderToken
      Since:
      1.5.0
    • removeExpiredTokens

      void removeExpiredTokens()
      Remove all ServiceProviderTokens from the store that do not have sessions and whose timeToLive has been exceeded. ServiceProviderTokens with session information should be left as-is, to be removed by the removeExpiredSessions() 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 expired ServiceProviderTokens
      Since:
      1.5.0
    • removeExpiredSessions

      void removeExpiredSessions()
      Remove all sessions and ServiceProviderTokens from the store whose session has expired.
      Throws:
      StoreException - thrown if there is a problem removing the ServiceProviderTokens
      Since:
      1.5.0
    • removeByConsumer

      void removeByConsumer(String consumerKey)
      Remove all the ServiceProviderTokens created by the consumer.
      Parameters:
      consumerKey - key of the consumer that created the tokens which are to be removed