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
A
ServiceProviderTokenStore implementation that persists the tokens to an XML
file
Only 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
ConstructorsConstructorDescriptionPersistentServiceProviderTokenStore(ServiceProviderConsumerStore consumerStore) -
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.Methods inherited from class com.atlassian.bitbucket.jenkins.internal.applink.oauth.serviceprovider.AbstractPersistentStore
decrypt, encrypt, getConfigFile, load, save
-
Constructor Details
-
PersistentServiceProviderTokenStore
-
-
Method Details
-
get
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
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
Description copied from interface:ServiceProviderTokenStorePut the token in the store.- Specified by:
putin interfaceServiceProviderTokenStore- Parameters:
token-ServiceProviderTokento store- Returns:
- the
ServiceProviderTokenthat was stored
-
remove
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
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
-