org.brickred.socialauth.provider
Class FacebookImpl

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

public class FacebookImpl
extends AbstractProvider
implements AuthProvider, Serializable

Provider implementation for Facebook

Author:
Abhinav Maheshwari
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
FacebookImpl(Properties props)
          Reads properties provided in the configuration file
 
Method Summary
 Response api(String url, String methodType, Map<String,String> params, Map<String,String> headerParams, String body)
          Makes HTTP request to a given URL.It attaches access token in URL.
 List<Contact> getContactList()
          Gets the list of contacts of the user.
 String getLoginRedirectURL(String redirectUri)
          This is the most important action.
 Profile getUserProfile()
          Retrieves the user profile.
 void logout()
          Logout
 void setPermission(Permission p)
           
 void updateStatus(String msg)
          Updates the status on the chosen provider if available.
 Profile verifyResponse(javax.servlet.http.HttpServletRequest httpReq)
          Verifies the user when the external provider redirects back to our application.
 
Methods inherited from class org.brickred.socialauth.AbstractProvider
isProviderState, setProviderState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FacebookImpl

public FacebookImpl(Properties props)
             throws Exception
Reads properties provided in the configuration file

Parameters:
props - Properties for consumer key
scope - scope is a permission setting. It can be AuthProvider.AUTHENTICATION_ONLY or AuthProvider.ALL_PERMISSIONS
Throws:
Exception
Method Detail

getLoginRedirectURL

public String getLoginRedirectURL(String redirectUri)
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()

Specified by:
getLoginRedirectURL in interface AuthProvider

verifyResponse

public Profile verifyResponse(javax.servlet.http.HttpServletRequest httpReq)
                       throws Exception
Verifies the user when the external provider redirects back to our application.

Specified by:
verifyResponse in interface AuthProvider
Parameters:
request - Request object the request is received from the provider
Returns:
Profile object containing the profile information
Throws:
Exception

updateStatus

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

Specified by:
updateStatus in interface AuthProvider
Parameters:
msg - Message to be shown as user's status
Throws:
Exception

getContactList

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

Specified by:
getContactList in interface AuthProvider
Returns:
List of contact objects representing Contacts. Only name will be available
Throws:
Exception

logout

public void logout()
Logout

Specified by:
logout in interface AuthProvider

setPermission

public void setPermission(Permission p)
Specified by:
setPermission in interface AuthProvider
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 HTTP request to a given URL.It attaches access token in URL.

Specified by:
api in interface AuthProvider
Parameters:
url - URL to make HTTP request.
methodType - Method type can be GET, POST or PUT
params - Not using this parameter in Google API function
headerParams - Parameters need to pass as Header Parameters
body - Request Body
Returns:
Response object
Throws:
Exception

getUserProfile

public Profile getUserProfile()
Retrieves the user profile.

Specified by:
getUserProfile in interface AuthProvider
Returns:
Profile object containing the profile information.


Copyright © 2011. All Rights Reserved.