org.brickred.socialauth.cdi
Class SocialAuth

java.lang.Object
  extended by org.brickred.socialauth.cdi.SocialAuth
All Implemented Interfaces:
Serializable

@Named(value="socialauth")
@SessionScoped
public class SocialAuth
extends Object
implements Serializable

This is a CDI component that allows us to delegate authentication to OpenID / oAuth providers like Facebook, Twitter, Google, Yahoo. Apart from authentication, it also allows us to obtain various details of the user, update status. This can be inject this component into Seam/CDI beans or used directly. Please note that : @Name("socialauth")

See Also:
Serialized Form

Constructor Summary
SocialAuth()
           
 
Method Summary
 void connect()
          Verifies the user when the external provider redirects back to our application
 List<org.brickred.socialauth.Contact> getContactList()
          Gets the list of contacts available from the provider.
 String getId()
           
 org.brickred.socialauth.Profile getProfile()
          Returns the Profile information for the user.
 String getStatus()
          Status of the user to be updated on a provider like Facebook or Twitter.
 org.brickred.socialauth.Profile getUserProfile()
          Retrieves the user profile from the provider.
 String getViewUrl()
          Gets the relative URL of the view to which user will be redirected after authentication
 void init()
           
 void login()
          This is the most important action.
 void logout()
          Reinitializes the bean
 void setId(String id)
          Sets the authentication provider.
 void setStatus(String status)
          Status of the user to be updated on a provider like Facebook or Twitter.
 void setViewUrl(String viewUrl)
          Sets the view URL to which the user will be redirected after authentication
 void updateStatus()
          Updates the status on the given provider.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SocialAuth

public SocialAuth()
Method Detail

init

public void init()

getId

public String getId()

setId

public void setId(String id)
Sets the authentication provider. It is mandatory to do this before calling login

Parameters:
id - Can either have values facebook, foursquare, google, hotmail, linkedin, myspace, twitter, yahoo OR an OpenID URL

setViewUrl

public void setViewUrl(String viewUrl)
Sets the view URL to which the user will be redirected after authentication

Parameters:
viewUrl - Relative URL of the view, for example "/openid.xhtml"

getViewUrl

public String getViewUrl()
Gets the relative URL of the view to which user will be redirected after authentication

Returns:
relative URL of the view

login

public void login()
           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 you set using setId()

Throws:
Exception

connect

public void connect()
             throws Exception
Verifies the user when the external provider redirects back to our application

Throws:
Exception

logout

public void logout()
Reinitializes the bean


getProfile

public org.brickred.socialauth.Profile getProfile()
Returns the Profile information for the user. Should be called only after loginImmediately()

Returns:
Profile of the user

getStatus

public String getStatus()
Status of the user to be updated on a provider like Facebook or Twitter. Remember this will not give us the current status of the user

Returns:
status message to be updated

setStatus

public void setStatus(String status)
Status of the user to be updated on a provider like Facebook or Twitter. To actually update the status, call updateStatus action.

Parameters:
status -

updateStatus

public void updateStatus()
                  throws Exception
Updates the status on the given provider. Exception will be thrown if the provider does not provide this facility

Throws:
Exception

getContactList

public List<org.brickred.socialauth.Contact> getContactList()
                                                     throws Exception
Gets the list of contacts available from the provider. This may be used to import contacts of any user in your web application from your chosen provider like Gmail, Yahoo or Hotmail

Returns:
list of contacts
Throws:
Exception

getUserProfile

public org.brickred.socialauth.Profile getUserProfile()
                                               throws Exception
Retrieves the user profile from the provider.

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


Copyright © 2013. All Rights Reserved.