|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.google.gdata.client.GoogleAuthTokenFactory
public class GoogleAuthTokenFactory
A factory for creating Google authentication tokens (ClientLogin and AuthSub).
| Nested Class Summary | |
|---|---|
static class |
GoogleAuthTokenFactory.AuthSubToken
Encapsulates the token used by web applications to login on behalf of a user. |
static class |
GoogleAuthTokenFactory.OAuthToken
Encapsulates the OAuth information used by applications to login on behalf of a user. |
static class |
GoogleAuthTokenFactory.UserToken
The UserToken encapsulates the token retrieved as a result of authenticating to Google using a user's credentials. |
| Nested classes/interfaces inherited from interface com.google.gdata.client.AuthTokenFactory |
|---|
AuthTokenFactory.AuthToken, AuthTokenFactory.TokenListener |
| Field Summary | |
|---|---|
static java.lang.String |
GOOGLE_ACCOUNTS_PATH
The path name of the Google accounts management handler. |
static java.lang.String |
GOOGLE_LOGIN_PATH
The path name of the Google login handler. |
| Constructor Summary | |
|---|---|
GoogleAuthTokenFactory(java.lang.String serviceName,
java.lang.String applicationName,
AuthTokenFactory.TokenListener tokenListener)
Constructs a factory for creating authentication tokens for connecting to a Google service with name serviceName for an application
with the name applicationName. |
|
GoogleAuthTokenFactory(java.lang.String serviceName,
java.lang.String applicationName,
java.lang.String protocol,
java.lang.String domainName,
AuthTokenFactory.TokenListener tokenListener)
Constructs a factory for creating authentication tokens for connecting to a Google service with name serviceName for an application
with the name applicationName. |
|
| Method Summary | |
|---|---|
HttpAuthToken |
getAuthToken()
Get an authentication token. |
java.lang.String |
getAuthToken(java.lang.String username,
java.lang.String password,
java.lang.String captchaToken,
java.lang.String captchaAnswer,
java.lang.String serviceName,
java.lang.String applicationName)
Retrieves the authentication token for the provided set of credentials for either a Google or a hosted domain. |
java.lang.String |
getAuthToken(java.lang.String username,
java.lang.String password,
java.lang.String captchaToken,
java.lang.String captchaAnswer,
java.lang.String serviceName,
java.lang.String applicationName,
ClientLoginAccountType accountType)
Retrieves the authentication token for the provided set of credentials. |
void |
handleSessionExpiredException(GoogleService.SessionExpiredException sessionExpired)
Handles a session expired exception. |
static java.lang.String |
makePostRequest(java.net.URL url,
java.util.Map<java.lang.String,java.lang.String> parameters)
Makes a HTTP POST request to the provided url given the
provided parameters. |
void |
setAuthSubToken(java.lang.String token)
Sets the AuthSub token to be used to authenticate a user. |
void |
setAuthSubToken(java.lang.String token,
java.security.PrivateKey key)
Sets the AuthSub token to be used to authenticate a user. |
void |
setAuthToken(HttpAuthToken authToken)
Set the authentication token. |
void |
setOAuthCredentials(OAuthParameters parameters,
OAuthSigner signer)
Sets the OAuth credentials used to generate the authorization header. |
void |
setUserCredentials(java.lang.String username,
java.lang.String password)
Sets the credentials of the user to authenticate requests to the server. |
void |
setUserCredentials(java.lang.String username,
java.lang.String password,
ClientLoginAccountType accountType)
Sets the credentials of the user to authenticate requests to the server. |
void |
setUserCredentials(java.lang.String username,
java.lang.String password,
java.lang.String captchaToken,
java.lang.String captchaAnswer)
Sets the credentials of the user to authenticate requests to the server. |
void |
setUserCredentials(java.lang.String username,
java.lang.String password,
java.lang.String captchaToken,
java.lang.String captchaAnswer,
ClientLoginAccountType accountType)
Sets the credentials of the user to authenticate requests to the server. |
void |
setUserToken(java.lang.String token)
Sets the AuthToken that should be used to authenticate requests to the server. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String GOOGLE_ACCOUNTS_PATH
public static final java.lang.String GOOGLE_LOGIN_PATH
| Constructor Detail |
|---|
public GoogleAuthTokenFactory(java.lang.String serviceName,
java.lang.String applicationName,
AuthTokenFactory.TokenListener tokenListener)
serviceName for an application
with the name applicationName. The default domain
(www.google.com) will be used to authenticate.
serviceName - the name of the Google service to which we are
connecting. Sample names of services might include
"cl" (Calendar), "mail" (GMail), or
"blogger" (Blogger)applicationName - the name of the client application accessing the
service. Application names should preferably have
the format [company-id]-[app-name]-[app-version].
The name will be used by the Google servers to
monitor the source of authentication.tokenListener - listener for token changes
public GoogleAuthTokenFactory(java.lang.String serviceName,
java.lang.String applicationName,
java.lang.String protocol,
java.lang.String domainName,
AuthTokenFactory.TokenListener tokenListener)
serviceName for an application
with the name applicationName. The service will authenticate
at the provided domainName.
serviceName - the name of the Google service to which we are
connecting. Sample names of services might include
"cl" (Calendar), "mail" (GMail), or
"blogger" (Blogger)applicationName - the name of the client application accessing the
service. Application names should preferably have
the format [company-id]-[app-name]-[app-version].
The name will be used by the Google servers to
monitor the source of authentication.protocol - name of protocol to use for authentication
("http"/"https")domainName - the name of the domain hosting the login handlertokenListener - listener for token changes| Method Detail |
|---|
public void setUserCredentials(java.lang.String username,
java.lang.String password)
throws AuthenticationException
username - the name of the user (an email address)password - the password of the user
AuthenticationException - if authentication failed.
public void setUserCredentials(java.lang.String username,
java.lang.String password,
ClientLoginAccountType accountType)
throws AuthenticationException
username - the name of the user (an email address)password - the password of the useraccountType - the account type: HOSTED, GOOGLE, or HOSTED_OR_GOOGLE
AuthenticationException - if authentication failed.
public void setUserCredentials(java.lang.String username,
java.lang.String password,
java.lang.String captchaToken,
java.lang.String captchaAnswer)
throws AuthenticationException
username - the name of the user (an email id)password - the password of the usercaptchaToken - the CAPTCHA token issued by the servercaptchaAnswer - the answer to the respective CAPTCHA token
AuthenticationException - if authentication failed
public void setUserCredentials(java.lang.String username,
java.lang.String password,
java.lang.String captchaToken,
java.lang.String captchaAnswer,
ClientLoginAccountType accountType)
throws AuthenticationException
username - the name of the user (an email id)password - the password of the usercaptchaToken - the CAPTCHA token issued by the servercaptchaAnswer - the answer to the respective CAPTCHA tokenaccountType - the account type: HOSTED, GOOGLE, or HOSTED_OR_GOOGLE
AuthenticationException - if authentication failedpublic void setUserToken(java.lang.String token)
token - the AuthToken in ascii formpublic void setAuthSubToken(java.lang.String token)
token - the AuthSub token retrieved from Google
public void setAuthSubToken(java.lang.String token,
java.security.PrivateKey key)
token - the AuthSub token retrieved from Googlekey - the private key to be used to sign all requests
public void setOAuthCredentials(OAuthParameters parameters,
OAuthSigner signer)
throws OAuthException
parameters - the OAuth parameters to use to generated the headersigner - the signing method to use for signing the header
OAuthExceptionpublic void setAuthToken(HttpAuthToken authToken)
authToken - authentication tokenpublic HttpAuthToken getAuthToken()
AuthTokenFactory
getAuthToken in interface AuthTokenFactory
public java.lang.String getAuthToken(java.lang.String username,
java.lang.String password,
java.lang.String captchaToken,
java.lang.String captchaAnswer,
java.lang.String serviceName,
java.lang.String applicationName)
throws AuthenticationException
username - the name of the user (an email address)password - the password of the usercaptchaToken - the CAPTCHA token if CAPTCHA is required (Optional)captchaAnswer - the respective answer of the CAPTCHA token (Optional)serviceName - the name of the service to which a token is requiredapplicationName - the application requesting the token
AuthenticationException - if authentication failed
public java.lang.String getAuthToken(java.lang.String username,
java.lang.String password,
java.lang.String captchaToken,
java.lang.String captchaAnswer,
java.lang.String serviceName,
java.lang.String applicationName,
ClientLoginAccountType accountType)
throws AuthenticationException
username - the name of the user (an email address)password - the password of the usercaptchaToken - the CAPTCHA token if CAPTCHA is required (Optional)captchaAnswer - the respective answer of the CAPTCHA token (Optional)serviceName - the name of the service to which a token is requiredapplicationName - the application requesting the tokenaccountType - the account type: HOSTED, GOOGLE, or HOSTED_OR_GOOGLE
AuthenticationException - if authentication failed
public static java.lang.String makePostRequest(java.net.URL url,
java.util.Map<java.lang.String,java.lang.String> parameters)
throws java.io.IOException
url given the
provided parameters. It returns the output from the POST
handler as a String object.
url - the URL to post the requestparameters - the parameters to post to the handler
java.io.IOException - if an I/O exception occurs while creating, writing,
or reading the request
public void handleSessionExpiredException(GoogleService.SessionExpiredException sessionExpired)
throws GoogleService.SessionExpiredException,
AuthenticationException
AuthTokenFactory
handleSessionExpiredException in interface AuthTokenFactoryGoogleService.SessionExpiredException
AuthenticationException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||