|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.gdata.client.authn.oauth.OAuthHelper
public class OAuthHelper
Helper methods to support the entire OAuth lifecycle, including generating the user authorization url, exchanging the user authenticated request token for an access token, and generating the Authorization http header.
Constructor Summary | |
---|---|
OAuthHelper(java.lang.String requestTokenUrl,
java.lang.String userAuthorizationUrl,
java.lang.String accessTokenUrl,
OAuthSigner signer)
Deprecated. |
|
OAuthHelper(java.lang.String requestTokenUrl,
java.lang.String userAuthorizationUrl,
java.lang.String accessTokenUrl,
OAuthSigner signer,
OAuthHttpClient httpClient)
Deprecated. |
|
OAuthHelper(java.lang.String requestTokenUrl,
java.lang.String userAuthorizationUrl,
java.lang.String accessTokenUrl,
java.lang.String revokeTokenUrl,
OAuthSigner signer)
Create a new OAuthHelper object. |
|
OAuthHelper(java.lang.String requestTokenUrl,
java.lang.String userAuthorizationUrl,
java.lang.String accessTokenUrl,
java.lang.String revokeTokenUrl,
OAuthSigner signer,
OAuthHttpClient httpClient)
Create a new OAuthHelper object. |
Method Summary | |
---|---|
java.lang.String |
createUserAuthorizationUrl(OAuthParameters oauthParameters)
Generates the url which the user should visit in order to authenticate and authorize with the Service Provider. |
java.lang.String |
getAccessToken(OAuthParameters oauthParameters)
Exchanges the user-authorized request token for an access token. |
java.lang.String |
getAccessToken(java.lang.String queryString,
OAuthParameters oauthParameters)
Exchanges the user-authorized request token for an access token. |
java.lang.String |
getAccessToken(java.net.URL url,
OAuthParameters oauthParameters)
Exchanges the user-authorized request token for an access token. |
java.lang.String |
getAccessTokenUrl()
Get the access token url |
java.lang.String |
getAuthorizationHeader(java.lang.String requestUrl,
java.lang.String httpMethod,
OAuthParameters oauthParameters)
Generates the string to be used as the HTTP authorization header. |
void |
getOAuthParametersFromCallback(java.lang.String queryString,
OAuthParameters oauthParameters)
Helper method which parses a querystring for the OAuth related parameters. |
void |
getOAuthParametersFromCallback(java.net.URL url,
OAuthParameters oauthParameters)
Helper method which parses a url for the OAuth related parameters. |
java.net.URL |
getOAuthUrl(java.lang.String baseUrl,
java.lang.String httpMethod,
OAuthParameters oauthParameters)
Returns a properly formatted and signed OAuth request url, with the appropriate parameters. |
java.lang.String |
getRequestTokenUrl()
Get the request token url |
java.lang.String |
getRevokeTokenUrl()
Get the revoke token url |
void |
getUnauthorizedRequestToken(OAuthParameters oauthParameters)
Retrieves the unauthorized request token and token secret from the remote server and sets the parameters in the OAuthParameters object. |
java.lang.String |
getUserAuthorizationUrl()
Get the user authorization url |
java.lang.String |
getUserAuthorizationUrl(OAuthParameters oauthParameters)
Deprecated. Call a combination of getUnauthorizedRequestToken(com.google.gdata.client.authn.oauth.OAuthParameters) and
createUserAuthorizationUrl(com.google.gdata.client.authn.oauth.OAuthParameters) instead. |
void |
revokeToken(OAuthParameters oauthParameters)
Revokes the user's OAuth token. |
void |
setAccessTokenUrl(java.lang.String url)
Set the access token url |
void |
setRequestTokenUrl(java.lang.String url)
Set the request token url |
void |
setRevokeTokenUrl(java.lang.String url)
Set the revoke token url |
void |
setUserAuthorizationUrl(java.lang.String url)
Set the user authorization url |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
@Deprecated public OAuthHelper(java.lang.String requestTokenUrl, java.lang.String userAuthorizationUrl, java.lang.String accessTokenUrl, OAuthSigner signer)
OAuthHelper
object.
requestTokenUrl
- the url used to obtain an unauthorized request tokenuserAuthorizationUrl
- the url used to obtain user authorization for
consumer accessaccessTokenUrl
- the url used to exchange the user-authorized request
token for an access tokensigner
- the OAuthSigner
to use when signing the request@Deprecated public OAuthHelper(java.lang.String requestTokenUrl, java.lang.String userAuthorizationUrl, java.lang.String accessTokenUrl, OAuthSigner signer, OAuthHttpClient httpClient)
OAuthHelper
object. This version of the constructor
is primarily for testing purposes, where a mocked OAuthHttpClient
and OAuthSigner
can be specified.
requestTokenUrl
- the url used to obtain an unauthorized request tokenuserAuthorizationUrl
- the url used to obtain user authorization for
consumer accessaccessTokenUrl
- the url used to exchange the user-authorized request
token for an access tokensigner
- the OAuthSigner
to use when signing the requesthttpClient
- the OAuthHttpClient
to use when making http
requestspublic OAuthHelper(java.lang.String requestTokenUrl, java.lang.String userAuthorizationUrl, java.lang.String accessTokenUrl, java.lang.String revokeTokenUrl, OAuthSigner signer)
OAuthHelper
object.
requestTokenUrl
- the url used to obtain an unauthorized request tokenuserAuthorizationUrl
- the url used to obtain user authorization for
consumer accessaccessTokenUrl
- the url used to exchange the user-authorized request
token for an access tokenrevokeTokenUrl
- the url used to revoke the OAuth tokensigner
- the OAuthSigner
to use when signing the requestpublic OAuthHelper(java.lang.String requestTokenUrl, java.lang.String userAuthorizationUrl, java.lang.String accessTokenUrl, java.lang.String revokeTokenUrl, OAuthSigner signer, OAuthHttpClient httpClient)
OAuthHelper
object. This version of the constructor
is primarily for testing purposes, where a mocked OAuthHttpClient
and OAuthSigner
can be specified.
requestTokenUrl
- the url used to obtain an unauthorized request tokenuserAuthorizationUrl
- the url used to obtain user authorization for
consumer accessaccessTokenUrl
- the url used to exchange the user-authorized request
token for an access tokenrevokeTokenUrl
- the url used to revoke the OAuth tokensigner
- the OAuthSigner
to use when signing the requesthttpClient
- the OAuthHttpClient
to use when making http
requestsMethod Detail |
---|
public java.lang.String getAccessTokenUrl()
public void setAccessTokenUrl(java.lang.String url)
public java.lang.String getRequestTokenUrl()
public void setRequestTokenUrl(java.lang.String url)
public java.lang.String getUserAuthorizationUrl()
public void setUserAuthorizationUrl(java.lang.String url)
public java.lang.String getRevokeTokenUrl()
public void setRevokeTokenUrl(java.lang.String url)
public void getUnauthorizedRequestToken(OAuthParameters oauthParameters) throws OAuthException
OAuthParameters
object.
The following parameter is required in OAuthParameters
:
If the request is successful, the following parameters will be set in
OAuthParameters
:
oauthParameters
- the OAuth parameters necessary for this request.
OAuthException
- if there is an error with the OAuth request@Deprecated public java.lang.String getUserAuthorizationUrl(OAuthParameters oauthParameters) throws OAuthException
getUnauthorizedRequestToken(com.google.gdata.client.authn.oauth.OAuthParameters)
and
createUserAuthorizationUrl(com.google.gdata.client.authn.oauth.OAuthParameters)
instead.
getUnauthorizedRequestToken(OAuthParameters)
to retrieve the
unauthorized request token, and then calls
createUserAuthorizationUrl(OAuthParameters)
. Users who wish to
add a token secret to the callback url should call
getUnauthorizedRequestToken(OAuthParameters)
first, append the
retrieved token secret to the callback url, and then call
createUserAuthorizationUrl(OAuthParameters)
.
The following parameter is required in OAuthParameters
:
The following parameter is optional:
oauthParameters
- the OAuth parameters necessary for this request
OAuthException
- if there is an error with the OAuth requestpublic java.lang.String createUserAuthorizationUrl(OAuthParameters oauthParameters)
OAuthParameters
object. The url will look something like this:
https://www.google.com/accounts/OAuthAuthorizeToken?oauth_token=[OAUTHTOKENSTRING]&oauth_callback=http%3A%2F%2Fwww.google.com%2F
The following parameter is required in OAuthParameters
:
The following parameter is optional:
oauthParameters
- the OAuth parameters necessary for this request
public void getOAuthParametersFromCallback(java.net.URL url, OAuthParameters oauthParameters)
OAuthParameters
object.
url
- The url containing the OAuth parameters.oauthParameters
- OAuth parameters for this requestpublic void getOAuthParametersFromCallback(java.lang.String queryString, OAuthParameters oauthParameters)
OAuthParameters
object.
queryString
- the query string containing the OAuth parametersoauthParameters
- OAuth parameters for this requestpublic java.lang.String getAccessToken(java.net.URL url, OAuthParameters oauthParameters) throws OAuthException
getAccessToken(String, OAuthParameters)
.
The following parameters are required in OAuthParameters
:
url
- the url to parse the request token fromoauthParameters
- OAuth parameters for this request
OAuthException
- if there is an error with the OAuth requestpublic java.lang.String getAccessToken(java.lang.String queryString, OAuthParameters oauthParameters) throws OAuthException
getAccessToken(OAuthParameters)
(The query string is everything
in the authorization response URL after the question mark).
The following parameters are required in OAuthParameters
:
queryString
- the query string containing the request tokenoauthParameters
- OAuth parameters for this request
OAuthException
- if there is an error with the OAuth requestpublic java.lang.String getAccessToken(OAuthParameters oauthParameters) throws OAuthException
The following parameters are required in OAuthParameters
:
If the request is successful, the following parameters will be set in
OAuthParameters
:
oauthParameters
- OAuth parameters for this request
OAuthException
- if there is an error with the OAuth requestpublic java.lang.String getAuthorizationHeader(java.lang.String requestUrl, java.lang.String httpMethod, OAuthParameters oauthParameters) throws OAuthException
OAuth realm="", oauth_signature="SOME_LONG_STRING", oauth_nonce="123456", oauth_signature_method="RSA-SHA1", oauth_consumer_key="www.example.com", oauth_token="abc123", oauth_timestamp="123456"
The following parameters are required in OAuthParameters
:
requestUrl
- the url of the requesthttpMethod
- the http method of the request (for example GET)oauthParameters
- OAuth parameters for this request
OAuthException
- if there is an error with the OAuth requestpublic void revokeToken(OAuthParameters oauthParameters) throws OAuthException
OAuthParameters
:
oauthParameters
- OAuth parameters for this request.
OAuthException
- if there is an error with the OAuth requestpublic java.net.URL getOAuthUrl(java.lang.String baseUrl, java.lang.String httpMethod, OAuthParameters oauthParameters) throws OAuthException
baseUrl
- the url to make the request tohttpMethod
- the http method of this request (for example, "GET")oauthParameters
- OAuth parameters for this request
OAuthException
- if there is an error with the OAuth request
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |