org.apache.shindig.gadgets.oauth
Class BasicOAuthStore

java.lang.Object
  extended by org.apache.shindig.gadgets.oauth.BasicOAuthStore
All Implemented Interfaces:
OAuthStore

public class BasicOAuthStore
extends Object
implements OAuthStore

Simple implementation of the OAuthStore interface. We use a in-memory hash map. If initialized with a private key, then the store will return an OAuthAccessor in getOAuthAccessor that uses that private key if no consumer key and secret could be found.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.shindig.gadgets.oauth.OAuthStore
OAuthStore.ConsumerInfo, OAuthStore.TokenInfo
 
Constructor Summary
BasicOAuthStore()
           
 
Method Summary
static String convertFromOpenSsl(String privateKey)
           
 int getAccessTokenAddCount()
           
 int getAccessTokenLookupCount()
           
 int getAccessTokenRemoveCount()
           
 OAuthStore.ConsumerInfo getConsumerKeyAndSecret(SecurityToken securityToken, String serviceName, net.oauth.OAuthServiceProvider provider)
          Retrieve OAuth consumer to use for requests.
 int getConsumerKeyLookupCount()
           
 OAuthStore.TokenInfo getTokenInfo(SecurityToken securityToken, OAuthStore.ConsumerInfo consumerInfo, String serviceName, String tokenName)
          Retrieve OAuth access token to use for the request.
 void initFromConfigString(String oauthConfigStr)
           
 void removeToken(SecurityToken securityToken, OAuthStore.ConsumerInfo consumerInfo, String serviceName, String tokenName)
          Remove the access token for the given user/gadget/service/token
 void setConsumerKeyAndSecret(BasicOAuthStoreConsumerIndex providerKey, BasicOAuthStoreConsumerKeyAndSecret keyAndSecret)
           
 void setDefaultCallbackUrl(String defaultCallbackUrl)
           
 void setDefaultKey(BasicOAuthStoreConsumerKeyAndSecret defaultKey)
           
 void setTokenInfo(SecurityToken securityToken, OAuthStore.ConsumerInfo consumerInfo, String serviceName, String tokenName, OAuthStore.TokenInfo tokenInfo)
          Set the access token for the given user/gadget/service/token
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicOAuthStore

public BasicOAuthStore()
Method Detail

initFromConfigString

public void initFromConfigString(String oauthConfigStr)
                          throws GadgetException
Throws:
GadgetException

convertFromOpenSsl

public static String convertFromOpenSsl(String privateKey)

setDefaultKey

public void setDefaultKey(BasicOAuthStoreConsumerKeyAndSecret defaultKey)

setDefaultCallbackUrl

public void setDefaultCallbackUrl(String defaultCallbackUrl)

setConsumerKeyAndSecret

public void setConsumerKeyAndSecret(BasicOAuthStoreConsumerIndex providerKey,
                                    BasicOAuthStoreConsumerKeyAndSecret keyAndSecret)

getConsumerKeyAndSecret

public OAuthStore.ConsumerInfo getConsumerKeyAndSecret(SecurityToken securityToken,
                                                       String serviceName,
                                                       net.oauth.OAuthServiceProvider provider)
                                                throws GadgetException
Description copied from interface: OAuthStore
Retrieve OAuth consumer to use for requests. The returned consumer is ready to use for signed fetch requests.

Specified by:
getConsumerKeyAndSecret in interface OAuthStore
Parameters:
securityToken - token for user/gadget making request.
serviceName - gadget's nickname for the service being accessed.
provider - OAuth service provider info to be inserted into the returned consumer.
Throws:
GadgetException - if no OAuth consumer can be found (e.g. no consumer key can be used.)

getTokenInfo

public OAuthStore.TokenInfo getTokenInfo(SecurityToken securityToken,
                                         OAuthStore.ConsumerInfo consumerInfo,
                                         String serviceName,
                                         String tokenName)
Description copied from interface: OAuthStore
Retrieve OAuth access token to use for the request.

Specified by:
getTokenInfo in interface OAuthStore
Parameters:
securityToken - token for user/gadget making request.
consumerInfo - OAuth consumer that will be used for the request.
serviceName - gadget's nickname for the service being accessed.
tokenName - gadget's nickname for the token to use.
Returns:
the token and secret, or null if none exist

setTokenInfo

public void setTokenInfo(SecurityToken securityToken,
                         OAuthStore.ConsumerInfo consumerInfo,
                         String serviceName,
                         String tokenName,
                         OAuthStore.TokenInfo tokenInfo)
Description copied from interface: OAuthStore
Set the access token for the given user/gadget/service/token

Specified by:
setTokenInfo in interface OAuthStore

removeToken

public void removeToken(SecurityToken securityToken,
                        OAuthStore.ConsumerInfo consumerInfo,
                        String serviceName,
                        String tokenName)
Description copied from interface: OAuthStore
Remove the access token for the given user/gadget/service/token

Specified by:
removeToken in interface OAuthStore

getConsumerKeyLookupCount

public int getConsumerKeyLookupCount()

getAccessTokenLookupCount

public int getAccessTokenLookupCount()

getAccessTokenAddCount

public int getAccessTokenAddCount()

getAccessTokenRemoveCount

public int getAccessTokenRemoveCount()


Copyright © 2007-2012. All Rights Reserved.