org.jboss.seam.social
Class OAuthServiceBase

java.lang.Object
  extended by org.jboss.seam.social.OAuthServiceBase
All Implemented Interfaces:
Serializable, HasStatus, OAuthService, RestService
Direct Known Subclasses:
OAuthServiceJackson

public abstract class OAuthServiceBase
extends Object
implements OAuthService, HasStatus

This Abstract implementation of OAuthService uses an OAuthProvider to deal with remote OAuth Services

Author:
Antoine Sabot-Durand
See Also:
Serialized Form

Field Summary
protected  InjectionPoint ip
           
protected  UserProfile myProfile
           
protected  OAuthSessionSettings sessionSettings
           
protected  SeamSocialExtension socialConfig
           
 
Constructor Summary
OAuthServiceBase()
           
 
Method Summary
 boolean equals(Object obj)
           
 OAuthToken getAccessToken()
           
 String getAuthorizationUrl()
          Returns the url to the OAuth service to ask an authorization to access the service.
 UserProfile getMyProfile()
           
 String getName()
           
 Annotation getQualifier()
          Returns the Qualifier used for this social network
protected  OAuthToken getRequestToken()
           
 OAuthSessionSettings getSession()
           
 OAuthServiceSettings getSettings()
           
 String getStatus()
           
 String getType()
          Returns the name/type of the Social Network we're connected to
 String getVerifier()
          Access to OAuth verifier
 String getVerifierParamName()
           
 int hashCode()
           
protected  void init()
          This method tries to find a configuration for the current service.
 void initAccessToken()
          Initialize the OAuth access token after the service gave an authorization with the Verifier
protected abstract  void initMyProfile()
           
 boolean isConnected()
          Returns the status of this ServiceHndler
protected  void requireAuthorization()
           
 void resetConnection()
          Close connexion if needed
protected  RestResponse sendSignedRequest(OAuthRequest request)
           
 RestResponse sendSignedRequest(RestVerb verb, String uri)
          Send an OAuth request signed without any parameter
 RestResponse sendSignedRequest(RestVerb verb, String uri, Map<String,Object> params)
          Send an OAuth request signed with a list a parameter
 RestResponse sendSignedRequest(RestVerb verb, String uri, String key, Object value)
          Send an OAuth request signed with a single parameter
 RestResponse sendSignedXmlRequest(RestVerb verb, String uri, String payload)
          Send an OAuth request signed with an XML Paylad as content
 void setAccessToken(OAuthToken token)
          Set the Access Token with for an OAuth access
 void setAccessToken(String token, String secret)
          Initialize and set an OAuth access token from its public and private keys
 void setSession(OAuthSessionSettings session)
          Set the Session settings of the given service
 void setSettings(OAuthServiceSettings settings)
          Initialize OAuth settings
 void setStatus(String status)
          Set the status to update
 void setVerifier(String verifierStr)
          Used to initialize verifier code returned by OAuth service
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.seam.social.rest.RestService
getServiceLogo
 
Methods inherited from interface org.jboss.seam.social.HasStatus
updateStatus, updateStatus
 

Field Detail

sessionSettings

@Inject
protected OAuthSessionSettings sessionSettings

ip

@Inject
protected InjectionPoint ip

socialConfig

@Inject
protected SeamSocialExtension socialConfig

myProfile

protected UserProfile myProfile
Constructor Detail

OAuthServiceBase

public OAuthServiceBase()
Method Detail

init

protected void init()
This method tries to find a configuration for the current service. It does it in this order :
  1. looks for an OAuthConfiguration annotation to get value in it and build an OAuthServiceSettings from these
  2. looks for a OAuthServiceSettings bean with the same service qualifier (having the ServiceRelated meta annotation)


getType

public String getType()
Description copied from interface: RestService
Returns the name/type of the Social Network we're connected to

Specified by:
getType in interface RestService
Returns:
name of the service

getSession

public OAuthSessionSettings getSession()
Specified by:
getSession in interface OAuthService
Returns:
the session settings of the given service

setSession

public void setSession(OAuthSessionSettings session)
Description copied from interface: OAuthService
Set the Session settings of the given service

Specified by:
setSession in interface OAuthService

getStatus

public String getStatus()
Specified by:
getStatus in interface HasStatus
Returns:
the status update

setStatus

public void setStatus(String status)
Description copied from interface: HasStatus
Set the status to update

Specified by:
setStatus in interface HasStatus

getName

public String getName()
Specified by:
getName in interface RestService
Returns:
the name of the service with this session

getSettings

public OAuthServiceSettings getSettings()
Specified by:
getSettings in interface OAuthService
Returns:
the settings of the service

setSettings

public void setSettings(OAuthServiceSettings settings)
Description copied from interface: OAuthService
Initialize OAuth settings

Specified by:
setSettings in interface OAuthService

getAuthorizationUrl

public String getAuthorizationUrl()
Description copied from interface: OAuthService
Returns the url to the OAuth service to ask an authorization to access the service.

Specified by:
getAuthorizationUrl in interface OAuthService
Returns:
the REST URL to use request access

getRequestToken

protected OAuthToken getRequestToken()

initAccessToken

public void initAccessToken()
Description copied from interface: OAuthService
Initialize the OAuth access token after the service gave an authorization with the Verifier

Specified by:
initAccessToken in interface OAuthService

initMyProfile

protected abstract void initMyProfile()

resetConnection

public void resetConnection()
Description copied from interface: RestService
Close connexion if needed

Specified by:
resetConnection in interface RestService

sendSignedRequest

protected RestResponse sendSignedRequest(OAuthRequest request)

sendSignedRequest

public RestResponse sendSignedRequest(RestVerb verb,
                                      String uri)
Description copied from interface: OAuthService
Send an OAuth request signed without any parameter

Specified by:
sendSignedRequest in interface OAuthService
Parameters:
verb - a REST verb
uri - the REST address of the request
Returns:
an HttpResponse containing the response. It could be in various format (json, xml, string)

sendSignedRequest

public RestResponse sendSignedRequest(RestVerb verb,
                                      String uri,
                                      String key,
                                      Object value)
Description copied from interface: OAuthService
Send an OAuth request signed with a single parameter

Specified by:
sendSignedRequest in interface OAuthService
Parameters:
verb - a REST verb
uri - the REST address of the request
key - name of the parameter
value - value of the parameter
Returns:
an HttpResponse containing the response. It could be in various format (json, xml, string)

sendSignedXmlRequest

public RestResponse sendSignedXmlRequest(RestVerb verb,
                                         String uri,
                                         String payload)
Description copied from interface: OAuthService
Send an OAuth request signed with an XML Paylad as content

Specified by:
sendSignedXmlRequest in interface OAuthService
Parameters:
verb - the REST verb of the request
uri - the url of the remote request
payload - the content of the XML payload to send to the service
Returns:
an HttpResponse containing the response. It could be in various format (json, xml, string)

sendSignedRequest

public RestResponse sendSignedRequest(RestVerb verb,
                                      String uri,
                                      Map<String,Object> params)
Description copied from interface: OAuthService
Send an OAuth request signed with a list a parameter

Specified by:
sendSignedRequest in interface OAuthService
Parameters:
verb - a REST verb
uri - the REST address of the request
params - a Map of key value parameters to send in the header of the request
Returns:
an HttpResponse containing the response. It could be in various format (json, xml, string)

setVerifier

public void setVerifier(String verifierStr)
Description copied from interface: OAuthService
Used to initialize verifier code returned by OAuth service

Specified by:
setVerifier in interface OAuthService

getVerifier

public String getVerifier()
Description copied from interface: OAuthService
Access to OAuth verifier

Specified by:
getVerifier in interface OAuthService
Returns:
the OAUth verifier

getAccessToken

public OAuthToken getAccessToken()
Specified by:
getAccessToken in interface OAuthService
Returns:
the access token for the OAuth service

isConnected

public boolean isConnected()
Description copied from interface: RestService
Returns the status of this ServiceHndler

Specified by:
isConnected in interface RestService
Returns:
true if the connection process is over and successful

requireAuthorization

protected void requireAuthorization()

setAccessToken

public void setAccessToken(String token,
                           String secret)
Description copied from interface: OAuthService
Initialize and set an OAuth access token from its public and private keys

Specified by:
setAccessToken in interface OAuthService
Parameters:
token - public key
secret - secret keys

setAccessToken

public void setAccessToken(OAuthToken token)
Description copied from interface: OAuthService
Set the Access Token with for an OAuth access

Specified by:
setAccessToken in interface OAuthService
Parameters:
token - the token to set

toString

public String toString()
Overrides:
toString in class Object

getVerifierParamName

public String getVerifierParamName()
Specified by:
getVerifierParamName in interface OAuthService
Returns:
the name of the URL param name containing verifier code sent bakc by the remote service

getMyProfile

public UserProfile getMyProfile()
Specified by:
getMyProfile in interface RestService
Returns:

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

getQualifier

public Annotation getQualifier()
Description copied from interface: RestService
Returns the Qualifier used for this social network

Specified by:
getQualifier in interface RestService
Returns:
Annotation being a Qualifier


Copyright © 2011 Seam Framework. All Rights Reserved.