public class BasicOAuth2Store extends Object implements OAuth2Store
OAuth2Store
Default OAuth2Store. Handles a persistence scenario with a separate cache
and persistence layer.
Uses 3 Guice bindings to achieve storage implementation.
1) OAuth2Persister 2) OAuth2Cache 3) OAuth2Encrypter| Constructor and Description |
|---|
BasicOAuth2Store(OAuth2Cache cache,
OAuth2Persister persister,
OAuth2Encrypter encrypter,
String globalRedirectUri,
Authority authority,
String contextRoot,
BlobCrypter stateCrypter) |
| Modifier and Type | Method and Description |
|---|---|
void |
clearAccessorCache()
Clears all currently cached
OAuth2Accessors. |
boolean |
clearCache()
Clears any in-memory caching of OAuth2Accessors or Tokens.
|
void |
clearClientCache()
Clears all currently cache
OAuth2Clients. |
void |
clearTokenCache()
Clears all currently cached
OAuth2Tokens. |
OAuth2Token |
createToken()
Creates, but does not store, an
OAuth2Token. |
OAuth2Client |
getClient(String gadgetUri,
String serviceName) |
protected String |
getGadgetUri(String gadgetUri,
String serviceName) |
OAuth2Accessor |
getOAuth2Accessor(OAuth2CallbackState state)
Given an OAuth2CallbackState, see
OAuth2Store.getOAuth2CallbackState, the store will
return the OAuth2Accessor if it exists in storage but will not create a new one. |
OAuth2Accessor |
getOAuth2Accessor(String gadgetUri,
String serviceName,
String user,
String scope)
Will look for an accessor with the supplied mapping and return it.
|
BlobCrypter |
getStateCrypter()
Gets the OAuth2 state encrypter/decrypter
|
OAuth2Token |
getToken(String gadgetUri,
String serviceName,
String user,
String scope,
OAuth2Token.Type type)
Gets a token, if it exists, from the store.
|
boolean |
init()
Cues the store to clear it's current state and reload from persistence.
|
protected OAuth2Token |
internalCreateToken() |
OAuth2Client |
invalidateClient(OAuth2Client client)
Invalidate a cached client and force it to be reloaded from persistence.
|
OAuth2Token |
invalidateToken(OAuth2Token token)
Invalidate a cached token and force it to be reloaded from persistence.
|
OAuth2Accessor |
removeOAuth2Accessor(OAuth2Accessor accessor)
Removes an
OAuth2Accessor from the store. |
OAuth2Token |
removeToken(OAuth2Token token)
Removes an
OAuth2Token from the store. |
static boolean |
runImport(OAuth2Persister source,
OAuth2Persister target,
boolean clean) |
void |
setToken(OAuth2Token token)
Either inserts updates an
OAuth2Token in the store. |
void |
storeOAuth2Accessor(OAuth2Accessor accessor)
Either inserts updates an
OAuth2Accessor in the store. |
@Inject public BasicOAuth2Store(OAuth2Cache cache, OAuth2Persister persister, OAuth2Encrypter encrypter, String globalRedirectUri, Authority authority, String contextRoot, BlobCrypter stateCrypter)
public boolean clearCache()
throws GadgetException
OAuth2StoreclearCache in interface OAuth2Storetrue if the clear succeededGadgetException - if the clear could not happenpublic OAuth2Token createToken()
OAuth2StoreOAuth2Token. The token can then be initialized and
stored.createToken in interface OAuth2StoreOAuth2Tokenpublic OAuth2Client getClient(String gadgetUri, String serviceName) throws GadgetException
GadgetExceptionpublic OAuth2Accessor getOAuth2Accessor(OAuth2CallbackState state)
OAuth2StoreOAuth2Store.getOAuth2CallbackState, the store will
return the OAuth2Accessor if it exists in storage but will not create a new one.getOAuth2Accessor in interface OAuth2Storestate - OAuth2CallbackState index of the accessor to getOAuth2Accessor or null if it cannot be locatedpublic OAuth2Accessor getOAuth2Accessor(String gadgetUri, String serviceName, String user, String scope) throws GadgetException
OAuth2StoregetOAuth2Accessor in interface OAuth2StoregadgetUri - String URI of the gadget issuing the requestserviceName - String name of the OAuth2 service from the gadget specuser - user userid of the page viewerscope - String optional scope of the request. Supplied by the request or the gadget
specOAuth2Accessor , never nullGadgetException - if a lookup or creation error occurspublic OAuth2Token getToken(String gadgetUri, String serviceName, String user, String scope, OAuth2Token.Type type) throws GadgetException
OAuth2StoregetToken in interface OAuth2StoregadgetUri - String URI of the gadget issuing the requestserviceName - String name of the OAuth2 service from the gadget specuser - user userid of the page viewerscope - String optional scope of the request. Supplied by the request or the gadget
spectype - Type if the token, ACCESS or REFRESHOAuth2Token for the supplied mapping, null if it isn't storedGadgetException - if something goes wrongpublic boolean init()
throws GadgetException
OAuth2Storeinit in interface OAuth2StoreGadgetExceptionpublic OAuth2Accessor removeOAuth2Accessor(OAuth2Accessor accessor)
OAuth2StoreOAuth2Accessor from the store.removeOAuth2Accessor in interface OAuth2Storeaccessor - to removenull if the accessor was already removedpublic OAuth2Token removeToken(OAuth2Token token) throws GadgetException
OAuth2StoreOAuth2Token from the store.removeToken in interface OAuth2Storetoken - to removenull if the token was already removed\GadgetException - if something goes wrongpublic static boolean runImport(OAuth2Persister source, OAuth2Persister target, boolean clean)
public void setToken(OAuth2Token token) throws GadgetException
OAuth2StoreOAuth2Token in the store.setToken in interface OAuth2Storetoken - to storeGadgetException - if something goes wrongpublic void storeOAuth2Accessor(OAuth2Accessor accessor)
OAuth2StoreOAuth2Accessor in the store.storeOAuth2Accessor in interface OAuth2Storeaccessor - to storeprotected String getGadgetUri(String gadgetUri, String serviceName) throws GadgetException
GadgetExceptionprotected OAuth2Token internalCreateToken()
public BlobCrypter getStateCrypter()
OAuth2StoregetStateCrypter in interface OAuth2Storepublic OAuth2Client invalidateClient(OAuth2Client client)
OAuth2StoreinvalidateClient in interface OAuth2Storeclient - to be invalidatednull> if client could not be foundpublic OAuth2Token invalidateToken(OAuth2Token token)
OAuth2StoreinvalidateToken in interface OAuth2Storetoken - to be invalidatednull if token could not be foundpublic void clearAccessorCache()
throws GadgetException
OAuth2StoreOAuth2Accessors.clearAccessorCache in interface OAuth2StoreGadgetExceptionpublic void clearTokenCache()
throws GadgetException
OAuth2StoreOAuth2Tokens. Does not remove them from persistence.clearTokenCache in interface OAuth2StoreGadgetExceptionpublic void clearClientCache()
throws GadgetException
OAuth2StoreOAuth2Clients. Does not remove the from persistence.clearClientCache in interface OAuth2StoreGadgetExceptionCopyright © 2007-2014 The Apache Software Foundation. All Rights Reserved.