org.brickred.socialauth.provider
Class GenericOAuth1Provider

java.lang.Object
  extended by org.brickred.socialauth.AbstractProvider
      extended by org.brickred.socialauth.provider.GenericOAuth1Provider
All Implemented Interfaces:
Serializable, AuthProvider

public class GenericOAuth1Provider
extends AbstractProvider

Generic OAuth1 provider implementation. By just adding configuration it can be used for any provider which supports OAuth1 protocol. Following configuration required for using this provider:
socialauth.myoauth1 = org.brickred.socialauth.provider.GenericOAuth1Provider
myoauth1.consumer_key=XXX myoauth1.consumer_secret=XXX myoauth1.request_token_url=provider Request_Token_URL myoauth1.authentication_url=provider Authenticate_URL myoauth1.access_token_url=provider Access_Token_URL
Here myoauth1 will be the provider id.

Author:
tarun.nagpal
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.brickred.socialauth.AuthProvider
COUNTRY, DOB, EMAIL, EXT_NAMESPACE, FIRST_NAME, FULL_NAME, GENDER, LANGUAGE, LAST_NAME, NICK_NAME, POSTCODE
 
Constructor Summary
GenericOAuth1Provider(OAuthConfig providerConfig)
          Stores configuration for the provider
 
Method Summary
 Response api(String url, String methodType, Map<String,String> params, Map<String,String> headerParams, String body)
          Makes OAuth signed HTTP request to a given URL.
 AccessGrant getAccessGrant()
          Retrieves the AccessGrant object.
 List<Contact> getContactList()
          This method is not implemented for GenericOAuth1 provider.
 String getLoginRedirectURL(String successUrl)
          This is the most important action.
protected  OAuthStrategyBase getOauthStrategy()
          Returns the OAuthStrategyBase of a provider.
protected  List<String> getPluginsList()
          Returns the list of plugins of a provider.
 String getProviderId()
          Retrieves the provider id
 Profile getUserProfile()
          This method is not implemented for GenericOAuth1 provider.
 void logout()
          Logout
 void setAccessGrant(AccessGrant accessGrant)
          Stores access grant for the provider
 void setPermission(Permission p)
           
 void updateStatus(String msg)
          This method is not implemented for GenericOAuth1 provider.
 Response uploadImage(String message, String fileName, InputStream inputStream)
          This method is not implemented for GenericOAuth1 provider.
 Profile verifyResponse(Map<String,String> requestParams)
          Verifies the user when the external provider redirects back to our application.
 
Methods inherited from class org.brickred.socialauth.AbstractProvider
getPlugin, getPluginsScope, isSupportedPlugin, registerPlugins
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericOAuth1Provider

public GenericOAuth1Provider(OAuthConfig providerConfig)
                      throws Exception
Stores configuration for the provider

Parameters:
providerConfig - It contains the configuration of application like consumer key and consumer secret
Throws:
Exception
Method Detail

setAccessGrant

public void setAccessGrant(AccessGrant accessGrant)
                    throws Exception
Stores access grant for the provider

Parameters:
accessGrant - It contains the access token and other information
Throws:
Exception

getLoginRedirectURL

public String getLoginRedirectURL(String successUrl)
                           throws Exception
This is the most important action. It redirects the browser to an appropriate URL which will be used for authentication with the provider that has been set using setId()

Throws:
Exception

verifyResponse

public Profile verifyResponse(Map<String,String> requestParams)
                       throws Exception
Verifies the user when the external provider redirects back to our application.

Parameters:
requestParams - request parameters, received from the provider
Returns:
Profile object containing the profile information. But in Generic Provider, it will be null.
Throws:
Exception

logout

public void logout()
Logout


setPermission

public void setPermission(Permission p)
Parameters:
p - Permission object which can be Permission.AUHTHENTICATE_ONLY, Permission.ALL, Permission.DEFAULT

api

public Response api(String url,
                    String methodType,
                    Map<String,String> params,
                    Map<String,String> headerParams,
                    String body)
             throws Exception
Makes OAuth signed HTTP request to a given URL. It attaches Authorization header with HTTP request.

Parameters:
url - URL to make HTTP request.
methodType - Method type can be GET, POST or PUT
params - Any additional parameters whose signature need to compute. Only used in case of "POST" and "PUT" method type.
headerParams - Any additional parameters need to pass as Header Parameters
body - Request Body
Returns:
Response object
Throws:
Exception

getAccessGrant

public AccessGrant getAccessGrant()
Description copied from interface: AuthProvider
Retrieves the AccessGrant object.

Returns:
AccessGrant object.

getProviderId

public String getProviderId()
Description copied from interface: AuthProvider
Retrieves the provider id

Returns:
provider id.

updateStatus

public void updateStatus(String msg)
                  throws Exception
This method is not implemented for GenericOAuth1 provider. Use api() method instead to update user status.

Parameters:
msg - Message to be shown as user's status
Throws:
Exception

getContactList

public List<Contact> getContactList()
                             throws Exception
This method is not implemented for GenericOAuth1 provider. Use api() method instead to get user contacts.

Returns:
List of profile objects representing Contacts. Only name and email will be available
Throws:
Exception

getUserProfile

public Profile getUserProfile()
                       throws Exception
This method is not implemented for GenericOAuth1 provider. Use api() method instead to get user profile.

Returns:
Profile object containing the profile information.
Throws:
Exception

uploadImage

public Response uploadImage(String message,
                            String fileName,
                            InputStream inputStream)
                     throws Exception
This method is not implemented for GenericOAuth1 provider.

Parameters:
message - Status Message
fileName - Image file name
inputStream - Input Stream of image
Returns:
Response object
Throws:
Exception

getPluginsList

protected List<String> getPluginsList()
Description copied from class: AbstractProvider
Returns the list of plugins of a provider.

Specified by:
getPluginsList in class AbstractProvider
Returns:
List of plugins of a provider

getOauthStrategy

protected OAuthStrategyBase getOauthStrategy()
Description copied from class: AbstractProvider
Returns the OAuthStrategyBase of a provider.

Specified by:
getOauthStrategy in class AbstractProvider
Returns:
OAuthStrategyBase of a provider.


Copyright © 2013. All Rights Reserved.