Class PersistentServiceProviderTokenStore
- java.lang.Object
-
- com.atlassian.bitbucket.jenkins.internal.applink.oauth.serviceprovider.AbstractPersistentStore<ServiceProviderToken>
-
- com.atlassian.bitbucket.jenkins.internal.applink.oauth.serviceprovider.token.PersistentServiceProviderTokenStore
-
- All Implemented Interfaces:
ServiceProviderTokenStore,Saveable,OnMaster
@Singleton public class PersistentServiceProviderTokenStore extends AbstractPersistentStore<ServiceProviderToken> implements ServiceProviderTokenStore
AServiceProviderTokenStoreimplementation that persists thetokensto an XML fileOnly one instance of this class must be created per Jenkins instance.
-
-
Field Summary
-
Fields inherited from class com.atlassian.bitbucket.jenkins.internal.applink.oauth.serviceprovider.AbstractPersistentStore
entityMap, xStream
-
-
Constructor Summary
Constructors Constructor Description PersistentServiceProviderTokenStore(ServiceProviderConsumerStore consumerStore)
-
Method Summary
All Methods Instance Methods Concrete 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.protected Class<ServiceProviderToken>getEntityClass()protected StringgetStoreEntryName()protected StringgetStoreKeyName()protected StringgetStoreValueName()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.-
Methods inherited from class com.atlassian.bitbucket.jenkins.internal.applink.oauth.serviceprovider.AbstractPersistentStore
decrypt, encrypt, getConfigFile, load, save
-
-
-
-
Constructor Detail
-
PersistentServiceProviderTokenStore
@Inject public PersistentServiceProviderTokenStore(ServiceProviderConsumerStore consumerStore)
-
-
Method Detail
-
get
public Optional<ServiceProviderToken> get(String token)
Description copied from interface:ServiceProviderTokenStoreRetrieve aServiceProviderTokenfrom the store whosetokenattribute is equal to thetokenparameter.- Specified by:
getin interfaceServiceProviderTokenStore- Parameters:
token- token value of theServiceProviderTokento retrieve- Returns:
- Optional of
ServiceProviderTokenwhose value istoken,Optional.absent()if there is noServiceProviderTokeninstance matching thetokenparameter
-
getAccessTokensForUser
public Iterable<ServiceProviderToken> getAccessTokensForUser(String username)
Description copied from interface:ServiceProviderTokenStoreRetrieves all the access tokens the user has approved.- Specified by:
getAccessTokensForUserin interfaceServiceProviderTokenStore- Parameters:
username- the user that approved the access tokens to retrieve- Returns:
- all the access tokens the user has approved
-
put
public ServiceProviderToken put(ServiceProviderToken token)
Description copied from interface:ServiceProviderTokenStorePut the token in the store.- Specified by:
putin interfaceServiceProviderTokenStore- Parameters:
token-ServiceProviderTokento store- Returns:
- the
ServiceProviderTokenthat was stored
-
remove
public void remove(String token)
Description copied from interface:ServiceProviderTokenStoreRemove aServiceProviderTokenfrom the store whosetokenattribute value is equal to thetokenparameter.- Specified by:
removein interfaceServiceProviderTokenStore- Parameters:
token- token value of theServiceProviderTokento remove
-
removeExpiredTokens
public void removeExpiredTokens()
Description copied from interface:ServiceProviderTokenStoreRemove 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 theServiceProviderTokenStore.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
ServiceProviderTokenStore.removeExpiredSessions()instead.- Specified by:
removeExpiredTokensin interfaceServiceProviderTokenStore
-
removeExpiredSessions
public void removeExpiredSessions()
Description copied from interface:ServiceProviderTokenStoreRemove all sessions andServiceProviderTokens from the store whosesessionhas expired.- Specified by:
removeExpiredSessionsin interfaceServiceProviderTokenStore
-
removeByConsumer
public void removeByConsumer(String consumerKey)
Description copied from interface:ServiceProviderTokenStoreRemove all theServiceProviderTokens created by the consumer.- Specified by:
removeByConsumerin interfaceServiceProviderTokenStore- Parameters:
consumerKey- key of the consumer that created the tokens which are to be removed
-
getEntityClass
protected Class<ServiceProviderToken> getEntityClass()
- Specified by:
getEntityClassin classAbstractPersistentStore<ServiceProviderToken>
-
getStoreValueName
protected String getStoreValueName()
- Specified by:
getStoreValueNamein classAbstractPersistentStore<ServiceProviderToken>
-
getStoreKeyName
protected String getStoreKeyName()
- Specified by:
getStoreKeyNamein classAbstractPersistentStore<ServiceProviderToken>
-
getStoreEntryName
protected String getStoreEntryName()
- Specified by:
getStoreEntryNamein classAbstractPersistentStore<ServiceProviderToken>
-
-