facebook4j.auth
Class OAuthAuthorization

java.lang.Object
  extended by facebook4j.auth.OAuthAuthorization
All Implemented Interfaces:
Authorization, OAuthSupport, java.io.Serializable

public class OAuthAuthorization
extends java.lang.Object
implements Authorization, java.io.Serializable, OAuthSupport

Author:
Ryuji Yamashita - roundrop at gmail.com
See Also:
OAuth Core 1.0a, Serialized Form

Field Summary
private  java.lang.String appId
           
private  java.lang.String appSecret
           
private  java.lang.String callbackURL
           
private  Configuration conf
           
private static HttpClientWrapper http
           
private  AccessToken oauthToken
           
private  java.lang.String permissions
           
private static long serialVersionUID
           
 
Constructor Summary
OAuthAuthorization(Configuration conf)
           
 
Method Summary
private  void ensureTokenIsAvailable()
           
 boolean equals(java.lang.Object obj)
           
private  java.lang.String getAppAccessTokenURL()
           
protected  java.lang.String getExchangeAccessTokenURL(java.lang.String oauthCode)
           
 AccessToken getOAuthAccessToken()
          Returns an access token associated with this instance.
 AccessToken getOAuthAccessToken(java.lang.String oauthCode)
          Exchange the code for a User Access Token.
 AccessToken getOAuthAppAccessToken()
          Returns an App Access Token.
 java.lang.String getOAuthAuthorizationURL(java.lang.String callbackURL)
           
 java.lang.String getOAuthAuthorizationURL(java.lang.String callbackURL, java.lang.String state)
           
 int hashCode()
           
 boolean isEnabled()
          #{inheritDoc}
 void setOAuthAccessToken(AccessToken accessToken)
          Sets the access token
 void setOAuthAppId(java.lang.String appId, java.lang.String appSecret)
          sets the OAuth AppID and App secret
 void setOAuthPermissions(java.lang.String permissions)
          sets the permissions
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

conf

private final Configuration conf

http

private static transient HttpClientWrapper http

appId

private java.lang.String appId

appSecret

private java.lang.String appSecret

oauthToken

private AccessToken oauthToken

permissions

private java.lang.String permissions

callbackURL

private java.lang.String callbackURL
Constructor Detail

OAuthAuthorization

public OAuthAuthorization(Configuration conf)
Parameters:
conf - Configuration
Method Detail

ensureTokenIsAvailable

private void ensureTokenIsAvailable()

isEnabled

public boolean isEnabled()
#{inheritDoc}

Specified by:
isEnabled in interface Authorization
Returns:
true if authorization credentials are set

getOAuthAuthorizationURL

public java.lang.String getOAuthAuthorizationURL(java.lang.String callbackURL)
Specified by:
getOAuthAuthorizationURL in interface OAuthSupport

getOAuthAuthorizationURL

public java.lang.String getOAuthAuthorizationURL(java.lang.String callbackURL,
                                                 java.lang.String state)
Specified by:
getOAuthAuthorizationURL in interface OAuthSupport

getOAuthAccessToken

public AccessToken getOAuthAccessToken(java.lang.String oauthCode)
                                throws FacebookException
Description copied from interface: OAuthSupport
Exchange the code for a User Access Token.

Specified by:
getOAuthAccessToken in interface OAuthSupport
Parameters:
oauthCode - OAuth code.
Returns:
User Access Token
Throws:
FacebookException - when Facebook service or network is unavailable, or the user has not authorized
See Also:
Server-Side Authentication

getExchangeAccessTokenURL

protected java.lang.String getExchangeAccessTokenURL(java.lang.String oauthCode)

getOAuthAccessToken

public AccessToken getOAuthAccessToken()
Description copied from interface: OAuthSupport
Returns an access token associated with this instance.

Specified by:
getOAuthAccessToken in interface OAuthSupport
Returns:
access token
See Also:
Server-Side Authentication

getOAuthAppAccessToken

public AccessToken getOAuthAppAccessToken()
                                   throws FacebookException
Description copied from interface: OAuthSupport
Returns an App Access Token.

Specified by:
getOAuthAppAccessToken in interface OAuthSupport
Returns:
App Access Token
Throws:
FacebookException - when Facebook service or network is unavailable, or the user has not authorized
See Also:
Server-Side Authentication

getAppAccessTokenURL

private java.lang.String getAppAccessTokenURL()

setOAuthAccessToken

public void setOAuthAccessToken(AccessToken accessToken)
Description copied from interface: OAuthSupport
Sets the access token

Specified by:
setOAuthAccessToken in interface OAuthSupport
Parameters:
accessToken - accessToken

setOAuthAppId

public void setOAuthAppId(java.lang.String appId,
                          java.lang.String appSecret)
Description copied from interface: OAuthSupport
sets the OAuth AppID and App secret

Specified by:
setOAuthAppId in interface OAuthSupport
Parameters:
appId - OAuth AppID
appSecret - OAuth App secret

setOAuthPermissions

public void setOAuthPermissions(java.lang.String permissions)
Description copied from interface: OAuthSupport
sets the permissions

Specified by:
setOAuthPermissions in interface OAuthSupport
Parameters:
permissions - comma-separated permission names
See Also:
Permissions Reference

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object