com.google.wave.api.oauth.impl
Class OAuthServiceImpl

java.lang.Object
  extended by com.google.wave.api.oauth.impl.OAuthServiceImpl
All Implemented Interfaces:
OAuthService

public class OAuthServiceImpl
extends java.lang.Object
implements OAuthService

Implements the OAuthService interface. OAuthService

Author:
kimwhite@google.com (Kimberly White), elizabethford@google.com (Elizabeth Ford)

Method Summary
 boolean checkAuthorization(Wavelet wavelet, LoginFormHandler loginForm)
          Verifies that the user profile contains a request token (i.e.
 java.lang.String get(java.lang.String url, java.util.Map<java.lang.String,java.lang.String> parameters)
          Performs HTTP GET from the Service provider.
 boolean hasAuthorization()
          Checks if the user is authorized.
static OAuthService newInstance(java.lang.String userRecordKey, java.lang.String consumerKey, java.lang.String consumerSecret, java.lang.String requestTokenUrl, java.lang.String authorizeUrl, java.lang.String callbackUrl, java.lang.String accessTokenUrl)
          Factory method.
 java.lang.String post(java.lang.String url, java.util.Map<java.lang.String,java.lang.String> parameters)
          Performs HTTP POST to the Service provider.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newInstance

public static OAuthService newInstance(java.lang.String userRecordKey,
                                       java.lang.String consumerKey,
                                       java.lang.String consumerSecret,
                                       java.lang.String requestTokenUrl,
                                       java.lang.String authorizeUrl,
                                       java.lang.String callbackUrl,
                                       java.lang.String accessTokenUrl)
Factory method. Initializes OAuthServiceProvider with necessary tokens and urls.

Parameters:
userRecordKey - key consisting of user id and wave id.
consumerKey - service provider OAuth consumer key.
consumerSecret - service provider OAuth consumer secret.
requestTokenUrl - url to get service provider request token.
authorizeUrl - url to service provider authorize page.
callbackUrl - url to callback page.
accessTokenUrl - url to get service provider access token.
Returns:
OAuthService instance.

checkAuthorization

public boolean checkAuthorization(Wavelet wavelet,
                                  LoginFormHandler loginForm)
Description copied from interface: OAuthService
Verifies that the user profile contains a request token (i.e. user has logged in). If user profile does not exist or does not contain a request token, fetches a request token and renders the login form so the request token can be signed. If the user profile contains a request token and "confirmed" is true, exchanges the signed request token with the service provider for an access token.

Specified by:
checkAuthorization in interface OAuthService
Parameters:
wavelet - The wavelet on which the robot resides.
loginForm - the form that handles user authorization in wave.
Returns:
boolean True if user is authorized, false if rendering a login form to authorize the user is required.

hasAuthorization

public boolean hasAuthorization()
Description copied from interface: OAuthService
Checks if the user is authorized.

Specified by:
hasAuthorization in interface OAuthService
Returns:
True if the user has an access token.

post

public java.lang.String post(java.lang.String url,
                             java.util.Map<java.lang.String,java.lang.String> parameters)
                      throws OAuthServiceException
Description copied from interface: OAuthService
Performs HTTP POST to the Service provider.

Specified by:
post in interface OAuthService
Parameters:
url - Service provider url to post data.
parameters - Service provider parameters.
Returns:
String of the response message.
Throws:
OAuthServiceException

get

public java.lang.String get(java.lang.String url,
                            java.util.Map<java.lang.String,java.lang.String> parameters)
                     throws OAuthServiceException
Description copied from interface: OAuthService
Performs HTTP GET from the Service provider.

Specified by:
get in interface OAuthService
Parameters:
url - Service provider url to fetch resources.
parameters - Service provider parameters.
Returns:
String of the response message.
Throws:
OAuthServiceException