org.apache.shindig.social.opensocial.oauth
Interface OAuthDataStore

All Known Implementing Classes:
SampleOAuthDataStore

public interface OAuthDataStore

A class that manages the OAuth data for Shindig, including storing the map of consumer key/secrets, storing request and access tokens, and providing a way to upgrade tokens to authorized values.


Method Summary
 void authorizeToken(OAuthEntry entry, String userId)
          Authorize the request token for the given user id.
 OAuthEntry convertToAccessToken(OAuthEntry entry)
          Called when converting a request token to an access token.
 void disableToken(OAuthEntry entry)
          Mark a token DISABLED and store it.
 OAuthEntry generateRequestToken(String consumerKey, String oauthVersion, String signedCallbackUrl, String virtualOrganization)
          Generate a valid requestToken for the given consumerKey.
 net.oauth.OAuthConsumer getConsumer(String consumerKey)
          Lookup consumers.
 OAuthEntry getEntry(String oauthToken)
          Get the OAuthEntry that corresponds to the oauthToken.
 SecurityToken getSecurityTokenForConsumerRequest(String consumerKey, String userId, net.oauth.OAuthConsumer authConsumer)
          Return the proper security token for a 2 legged oauth request that has been validated for the given consumerKey.
 void removeToken(OAuthEntry entry)
          Remove a token
 

Method Detail

getEntry

OAuthEntry getEntry(String oauthToken)
Get the OAuthEntry that corresponds to the oauthToken.

Parameters:
oauthToken - a non-null oauthToken
Returns:
a valid OAuthEntry or null if no match

getSecurityTokenForConsumerRequest

SecurityToken getSecurityTokenForConsumerRequest(String consumerKey,
                                                 String userId,
                                                 net.oauth.OAuthConsumer authConsumer)
                                                 throws net.oauth.OAuthProblemException
Return the proper security token for a 2 legged oauth request that has been validated for the given consumerKey. App specific checks like making sure the requested user has the app installed should take place in this method. Returning null may allow for other authentication schemes to be used. Throwing an OAuthProblemException will allows errors to be returned to the caller.

Parameters:
consumerKey - A consumer key
userId - The userId to validate.
authConsumer - The OAuthConsumer
Returns:
A valid Security Token
Throws:
net.oauth.OAuthProblemException - when there are errors

getConsumer

net.oauth.OAuthConsumer getConsumer(String consumerKey)
                                    throws net.oauth.OAuthProblemException
Lookup consumers. Generally this corresponds to an opensocial Application but could be abstracted in other ways. If you have multiple containers you may want to include the container as part of the identifier. Your consumer object should have the key and secret, a link to your provider plus you should consider setting properties that correspond to the metadata in the opensocial app like icon, description, etc. Returning null will inform the client that the consumer key does not exist. If you want to control the error response throw an OAuthProblemException

Parameters:
consumerKey - A valid, non-null ConsumerKey
Returns:
the consumer object corresponding to the specified key.
Throws:
net.oauth.OAuthProblemException - when the implementing class wants to signal errors

generateRequestToken

OAuthEntry generateRequestToken(String consumerKey,
                                String oauthVersion,
                                String signedCallbackUrl,
                                String virtualOrganization)
                                throws net.oauth.OAuthProblemException
Generate a valid requestToken for the given consumerKey.

Parameters:
consumerKey - A valid consumer key
oauthVersion - The version (1 or 1a)
signedCallbackUrl - Callback URL sent from consumer, may be null. If callbackUrl is not null then the returned entry should have signedCallbackUrl set to true.
virtualOrganization - the virtualOrganization context (if any)
Returns:
An OAuthEntry containing a valid request token.
Throws:
net.oauth.OAuthProblemException - when the implementing class wants to control the error response

convertToAccessToken

OAuthEntry convertToAccessToken(OAuthEntry entry)
                                throws net.oauth.OAuthProblemException
Called when converting a request token to an access token. This is called in the final phase of 3-legged OAuth after the user authorizes the app.

Parameters:
entry - The Entry to convert
Returns:
a new entry with type Type.ACCESS
Throws:
net.oauth.OAuthProblemException - when the implementing class wants to control the error response

authorizeToken

void authorizeToken(OAuthEntry entry,
                    String userId)
                    throws net.oauth.OAuthProblemException
Authorize the request token for the given user id.

Parameters:
entry - A valid OAuthEntry
userId - A user id
Throws:
net.oauth.OAuthProblemException - when the implementing class wants to control the error response

disableToken

void disableToken(OAuthEntry entry)
Mark a token DISABLED and store it.

Parameters:
entry - A valid OAuthEntry

removeToken

void removeToken(OAuthEntry entry)
Remove a token

Parameters:
entry - A valid OAuthEntry


Copyright © 2007-2012. All Rights Reserved.