org.brickred.socialauth
Interface AuthProvider

All Known Implementing Classes:
AbstractProvider, FacebookImpl, FlickerImpl, FourSquareImpl, GenericOAuth1Provider, GenericOAuth2Provider, GitHubImpl, GoogleImpl, GooglePlusImpl, HotmailImpl, InstagramImpl, LinkedInImpl, LinkedInOAuth2Impl, MendeleyImpl, MySpaceImpl, NimbleImpl, OpenIdImpl, RunkeeperImpl, SalesForceImpl, TwitterImpl, YahooImpl, YammerImpl

public interface AuthProvider

This is the main interface representing an authentication provider. First we call the getLoginRedirectURL method to get the URL where the user needs to be redirected. It is the responsibility of the caller to redirect the user to that URL. Once the external provider like Facebook redirects the user back to our application, we call the verifyResponse method and pass along the HttpRequest object that is called upon redirection. If the verifyResponse method returns a non null profile object, we can start calling the other methods to obtain user information, update status or import contacts

Author:
Abhinav Maheshwari

Field Summary
static String COUNTRY
           
static String DOB
           
static String EMAIL
           
static String EXT_NAMESPACE
           
static String FIRST_NAME
           
static String FULL_NAME
           
static String GENDER
           
static String LANGUAGE
           
static String LAST_NAME
           
static String NICK_NAME
           
static String POSTCODE
           
 
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 for making any provider specific calls.
 AccessGrant getAccessGrant()
          Retrieves the AccessGrant object.
 List<Contact> getContactList()
          Gets the list of contacts of the user and their email.
 String getLoginRedirectURL(String successUrl)
          This is the most important action.
<T> T
getPlugin(Class<T> clazz)
          Returns the required plugin if provider support that.
 String getProviderId()
          Retrieves the provider id
 Profile getUserProfile()
          Retrieves the user profile.
 boolean isSupportedPlugin(Class<? extends Plugin> clazz)
          Returns True if provider support given plugin otherwise returns False
 void logout()
          Logout
 void refreshToken(AccessGrant accessGrant)
          Makes a call for a provider to get RefreshToken and returns object of that provider
 void registerPlugins()
          Registers plugin for a provider those are configured in configuration properties or mentioned in provider implementation.
 void setAccessGrant(AccessGrant accessGrant)
          Stores access grant for the provider *
 void setPermission(Permission p)
           
 Response updateStatus(String msg)
          Updates the status on the chosen provider if available.
 Response uploadImage(String message, String fileName, InputStream inputStream)
          Updates the image and message on the chosen provider if available.
 Profile verifyResponse(Map<String,String> requestParams)
          Verifies the user when the external provider redirects back to our application.
 

Field Detail

EXT_NAMESPACE

static final String EXT_NAMESPACE
See Also:
Constant Field Values

EMAIL

static final String EMAIL
See Also:
Constant Field Values

COUNTRY

static final String COUNTRY
See Also:
Constant Field Values

LANGUAGE

static final String LANGUAGE
See Also:
Constant Field Values

FULL_NAME

static final String FULL_NAME
See Also:
Constant Field Values

NICK_NAME

static final String NICK_NAME
See Also:
Constant Field Values

DOB

static final String DOB
See Also:
Constant Field Values

GENDER

static final String GENDER
See Also:
Constant Field Values

POSTCODE

static final String POSTCODE
See Also:
Constant Field Values

FIRST_NAME

static final String FIRST_NAME
See Also:
Constant Field Values

LAST_NAME

static final String LAST_NAME
See Also:
Constant Field Values
Method Detail

getLoginRedirectURL

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

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:
AuthProvider object
Throws:
Exception

updateStatus

Response updateStatus(String msg)
                      throws Exception
Updates the status on the chosen provider if available. This may not be implemented for all providers.

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

getContactList

List<Contact> getContactList()
                             throws Exception
Gets the list of contacts of the user and their email. this may not be available for all providers.

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

getUserProfile

Profile getUserProfile()
                       throws Exception
Retrieves the user profile.

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

logout

void logout()
Logout


setPermission

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

api

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 for making any provider specific calls. For more information, read the comments of this function in different provider.

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

AccessGrant getAccessGrant()
Retrieves the AccessGrant object.

Returns:
AccessGrant object.

getProviderId

String getProviderId()
Retrieves the provider id

Returns:
provider id.

setAccessGrant

void setAccessGrant(AccessGrant accessGrant)
                    throws AccessTokenExpireException,
                           SocialAuthException
Stores access grant for the provider *

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

uploadImage

Response uploadImage(String message,
                     String fileName,
                     InputStream inputStream)
                     throws Exception
Updates the image and message on the chosen provider if available. This is implemented only for Facebook and Twitter.

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

isSupportedPlugin

boolean isSupportedPlugin(Class<? extends Plugin> clazz)
Returns True if provider support given plugin otherwise returns False

Parameters:
clazz - Fully qualified plugin class name e.g org.brickred.socialauth.plugin.FeedPlugin.class
Returns:
true if provider supports plugin otherwise false

getPlugin

<T> T getPlugin(Class<T> clazz)
            throws Exception
Returns the required plugin if provider support that.

Parameters:
clazz - Fully qualified plugin class name e.g org.brickred.socialauth.plugin.FeedPlugin.class
Returns:
the required plugin object
Throws:
Exception

registerPlugins

void registerPlugins()
                     throws Exception
Registers plugin for a provider those are configured in configuration properties or mentioned in provider implementation.

Throws:
Exception

refreshToken

void refreshToken(AccessGrant accessGrant)
                  throws SocialAuthException
Makes a call for a provider to get RefreshToken and returns object of that provider

Parameters:
accessGrant - AccessGrant which contains AccessToken
Throws:
SocialAuthException


Copyright © 2014. All rights reserved.