public class

OAuthParameters

extends Object
java.lang.Object
   ↳ com.google.gdata.client.authn.oauth.OAuthParameters
Known Direct Subclasses

Class Overview

Container for OAuth-related parameters. The parameters are divided into two categories: those used to generate the signature base string, and other parameters. For each parameter, there are 4 different types of methods: a getter, a setter, a check if the parameter exists (that returns a boolean) and a check if the parameter exists (that throws an exception). Refer to the getters/setters for each parameter below to learn more about the parameter.

Summary

Nested Classes
enum OAuthParameters.OAuthType Type of OAuth for this parameter set (i.e., two-legged or three-legged OAuth (see https://sites.google.com/a/google.com/oauth/). 
Constants
String OAUTH_CALLBACK_KEY
String OAUTH_CONSUMER_KEY
String OAUTH_CONSUMER_SECRET
String OAUTH_KEY
String OAUTH_NONCE_KEY
String OAUTH_SIGNATURE_KEY
String OAUTH_SIGNATURE_METHOD_KEY
String OAUTH_TIMESTAMP_KEY
String OAUTH_TOKEN_KEY
String OAUTH_TOKEN_SECRET_KEY
String OAUTH_VERIFIER_KEY
String REALM_KEY
String XOAUTH_REQUESTOR_ID_KEY
Fields
protected Map<String, String> baseParameters
protected Map<String, String> extraParameters
private OAuthParameters.OAuthType oauthType
Public Constructors
OAuthParameters()
Creates a new OAuthParameters object.
Public Methods
void addCustomBaseParameter(String key, String value)
Adds a parameter to be used when generating the OAuth signature.
void addExtraParameter(String key, String value)
Sets a parameter related to OAuth (but not used when generating the signature).
void assertOAuthCallbackExists()
Checks to see if the OAuth callback exists.
void assertOAuthConsumerKeyExists()
Checks to see if the OAuth Consumer Key exists.
void assertOAuthConsumerSecretExists()
void assertOAuthNonceExists()
Checks to see if the OAuth nonce exists.
void assertOAuthSignatureExists()
Checks to see if the OAuth signature exists.
void assertOAuthSignatureMethodExists()
Checks to see if the OAuth signature method exists.
void assertOAuthTimestampExists()
Checks to see if the OAuth timestamp exists.
void assertOAuthTokenExists()
Checks to see if the OAuth token exists.
void assertOAuthTokenSecretExists()
Checks to see if the OAuth token secret exists.
void assertOAuthVerifierExists()
Checks to see if the OAuth Verifier exists.
void assertRealmExists()
Checks to see if the realm exists.
boolean checkOAuthCallbackExists()
Checks to see if the OAuth callback exists.
boolean checkOAuthConsumerKeyExists()
Checks to see if the OAuth Consumer Key exists.
boolean checkOAuthConsumerSecretExists()
boolean checkOAuthNonceExists()
Checks to see if the OAuth nonce exists.
boolean checkOAuthSignatureExists()
Checks to see if the OAuth signature exists.
boolean checkOAuthSignatureMethodExists()
Checks to see if the OAuth signature method exists.
boolean checkOAuthTimestampExists()
Checks to see if the OAuth timestamp exists.
boolean checkOAuthTokenExists()
Checks to see if the OAuth token exists.
boolean checkOAuthTokenSecretExists()
Checks to see if the OAuth token secret exists.
boolean checkOAuthVerifierExists()
Checks to see if the OAuth Verifier exists.
boolean checkRealmExists()
Checks to see if the realm exists.
Map<String, String> getBaseParameters()
Return the parameters used to calculate the OAuth signature.
Map<String, String> getExtraParameters()
Returns any other parameters used in the OAuth process, such as the OAuth callback url.
String getOAuthCallback()
Returns the OAuth callback url.
String getOAuthConsumerKey()
Returns the OAuth Consumer Key.
String getOAuthConsumerSecret()
String getOAuthNonce()
Returns the OAuth nonce.
String getOAuthSignature()
Returns the OAuth signature used to sign the current request.
String getOAuthSignatureMethod()
Returns the OAuth Signature Method.
String getOAuthTimestamp()
Returns the OAuth timestamp.
String getOAuthToken()
Returns the OAuth token.
String getOAuthTokenSecret()
Returns the OAuth Token Secret.
OAuthParameters.OAuthType getOAuthType()
Retrieves the OAuth type requested.
String getOAuthVerifier()
Returns the OAuth Verifier.
String getRealm()
Returns the Realm parameter to be used in the authorization header, as defined by
void removeCustomBaseParameter(String key)
Removes a parameter from the OAuth signature.
void reset()
Resets all transient parameters related to a single request, so that these parameters do not interfere with multiple requests.
void setOAuthCallback(String oauthCallback)
Sets the OAuth callback url.
void setOAuthConsumerKey(String consumerKey)
Sets the OAuth Consumer Key.
void setOAuthConsumerSecret(String consumerSecret)
void setOAuthNonce(String oauthNonce)
Sets the OAuth nonce.
void setOAuthSignature(String signature)
Sets the OAuth signature used to sign the current request.
void setOAuthSignatureMethod(String signatureMethod)
Sets the OAuth Signature Method.
void setOAuthTimestamp(String timestamp)
Sets the OAuth timestamp.
void setOAuthToken(String token)
Sets the OAuth token.
void setOAuthTokenSecret(String tokenSecret)
Returns the OAuth Token Secret.
void setOAuthType(OAuthParameters.OAuthType type)
Sets the value of the OAuth type.
void setOAuthVerifier(String verifier)
Returns the OAuth Verifier.
void setRealm(String realm)
Sets the Realm parameter.
Protected Methods
void assertExists(String key, Map<String, String> params)
Checks the given key to see if it exists, and throws an exception if it does not.
boolean checkExists(String key, Map<String, String> params)
Checks the given key to see if it exists.
String get(String key, Map<String, String> params)
Retrieves the value with the given key from the input map.
void put(String key, String value, Map<String, String> params)
Adds the key/value pair to the input map.
void remove(String key, Map<String, String> params)
Removes a key/value pair from the input map.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String OAUTH_CALLBACK_KEY

Constant Value: "oauth_callback"

public static final String OAUTH_CONSUMER_KEY

Constant Value: "oauth_consumer_key"

public static final String OAUTH_CONSUMER_SECRET

Constant Value: "oauth_consumer_secret"

public static final String OAUTH_KEY

Constant Value: "OAuth"

public static final String OAUTH_NONCE_KEY

Constant Value: "oauth_nonce"

public static final String OAUTH_SIGNATURE_KEY

Constant Value: "oauth_signature"

public static final String OAUTH_SIGNATURE_METHOD_KEY

Constant Value: "oauth_signature_method"

public static final String OAUTH_TIMESTAMP_KEY

Constant Value: "oauth_timestamp"

public static final String OAUTH_TOKEN_KEY

Constant Value: "oauth_token"

public static final String OAUTH_TOKEN_SECRET_KEY

Constant Value: "oauth_token_secret"

public static final String OAUTH_VERIFIER_KEY

Constant Value: "oauth_verifier"

public static final String REALM_KEY

Constant Value: "realm"

public static final String XOAUTH_REQUESTOR_ID_KEY

Constant Value: "xoauth_requestor_id"

Fields

protected Map<String, String> baseParameters

protected Map<String, String> extraParameters

private OAuthParameters.OAuthType oauthType

Public Constructors

public OAuthParameters ()

Creates a new OAuthParameters object. Initializes parameters containers.

Public Methods

public void addCustomBaseParameter (String key, String value)

Adds a parameter to be used when generating the OAuth signature.

Parameters
key The key used to reference this parameter. This key will also be used to reference the value in the request url and in the http authorization header.
value The value of the parameter

public void addExtraParameter (String key, String value)

Sets a parameter related to OAuth (but not used when generating the signature).

Parameters
key The key used to reference this parameter
value The value of the parameter

public void assertOAuthCallbackExists ()

Checks to see if the OAuth callback exists. Throws an exception if it does not. See getOAuthCallback() to learn more about this parameter.

Throws
OAuthException if the OAuth callback does not exist

public void assertOAuthConsumerKeyExists ()

Checks to see if the OAuth Consumer Key exists. Throws an exception if it does not. See getOAuthConsumerKey() to learn more about this parameter.

Throws
OAuthException if the OAuth Consumer Key does not exist

public void assertOAuthConsumerSecretExists ()

public void assertOAuthNonceExists ()

Checks to see if the OAuth nonce exists. Throws an exception if it does not. See getOAuthNonce() to learn more about this parameter.

Throws
OAuthException if the OAuth nonce does not exist

public void assertOAuthSignatureExists ()

Checks to see if the OAuth signature exists. Throws an exception if it does not. See getOAuthSignature() to learn more about this parameter.

Throws
OAuthException if the OAuth signature does not exist

public void assertOAuthSignatureMethodExists ()

Checks to see if the OAuth signature method exists. Throws an exception if it does not. See getOAuthSignatureMethod() to learn more about this parameter.

Throws
OAuthException if the OAuth signature method does not exist

public void assertOAuthTimestampExists ()

Checks to see if the OAuth timestamp exists. Throws an exception if it does not. See getOAuthTimestamp() to learn more about this parameter.

Throws
OAuthException if the OAuth timestamp does not exist

public void assertOAuthTokenExists ()

Checks to see if the OAuth token exists. Throws an exception if it does not. See getOAuthToken() to learn more about this parameter.

Throws
OAuthException if the OAuth token does not exist

public void assertOAuthTokenSecretExists ()

Checks to see if the OAuth token secret exists. Throws an exception if it does not. See getOAuthTokenSecret() to learn more about this parameter.

Throws
OAuthException if the OAuth token secret does not exist

public void assertOAuthVerifierExists ()

Checks to see if the OAuth Verifier exists. Throws an exception if it does not. See getOAuthVerifier() to learn more about this parameter.

Throws
OAuthException if the OAuth token secret does not exist

public void assertRealmExists ()

Checks to see if the realm exists. Throws an exception if it does not. See getRealm() to learn more about this parameter.

Throws
OAuthException if the realm does not exist

public boolean checkOAuthCallbackExists ()

Checks to see if the OAuth callback exists. See getOAuthCallback() to learn more about this parameter.

Returns
  • true if the OAuth callback exists, false otherwise

public boolean checkOAuthConsumerKeyExists ()

Checks to see if the OAuth Consumer Key exists. See getOAuthConsumerKey() to learn more about this parameter.

Returns
  • true if the OAuth Consumer Key exists, false otherwise

public boolean checkOAuthConsumerSecretExists ()

public boolean checkOAuthNonceExists ()

Checks to see if the OAuth nonce exists. See getOAuthNonce() to learn more about this parameter.

Returns
  • true if the OAuth nonce exists, false otherwise

public boolean checkOAuthSignatureExists ()

Checks to see if the OAuth signature exists. See getOAuthSignature() to learn more about this parameter.

Returns
  • true if the OAuth signature exists, false otherwise

public boolean checkOAuthSignatureMethodExists ()

Checks to see if the OAuth signature method exists. See getOAuthSignatureMethod() to learn more about this parameter.

Returns
  • true if the OAuth signature method exists, false otherwise

public boolean checkOAuthTimestampExists ()

Checks to see if the OAuth timestamp exists. See getOAuthTimestamp() to learn more about this parameter.

Returns
  • true if the OAuth timestamp exists, false otherwise

public boolean checkOAuthTokenExists ()

Checks to see if the OAuth token exists. See getOAuthToken() to learn more about this parameter.

Returns
  • true if the OAuth token exists, false otherwise

public boolean checkOAuthTokenSecretExists ()

Checks to see if the OAuth token secret exists. See getOAuthTokenSecret() to learn more about this parameter.

Returns
  • true if the OAuth token secret exists, false otherwise

public boolean checkOAuthVerifierExists ()

Checks to see if the OAuth Verifier exists. See getOAuthTokenSecret() to learn more about this parameter.

Returns
  • true if the OAuth Verifier exists, false otherwise

public boolean checkRealmExists ()

Checks to see if the realm exists. See getRealm() to learn more about this parameter.

Returns
  • true if the realm exists, false otherwise

public Map<String, String> getBaseParameters ()

Return the parameters used to calculate the OAuth signature.

Returns
  • a map of key/value pairs to use in the signature base string

public Map<String, String> getExtraParameters ()

Returns any other parameters used in the OAuth process, such as the OAuth callback url.

Returns
  • a map of key/value pairs for the extra parameters

public String getOAuthCallback ()

Returns the OAuth callback url. The OAuth callback url is a url the Consumer provides to the Service Provider in the user authorization url. Once the user has authorized, the Service Provider will redirect the user back to the callback url with the user-authorized request token in the response. This parameter is optional.

public String getOAuthConsumerKey ()

Returns the OAuth Consumer Key. The OAuth Consumer Key is a value used by the Consumer to identify itself to the Service Provider. This parameter is required for all OAuth requests. This parameter is included in the OAuth signature base string.

public String getOAuthConsumerSecret ()

public String getOAuthNonce ()

Returns the OAuth nonce. OAuth defines the nonce as "a random string, uniquely generated for each request. The nonce allows the Service Provider to verify that a request has never been made before and helps prevent replay attacks when requests are made over a non-secure channel (such as HTTP)." This parameter is optional, and it will be supplied by getNonce() if it is not provided. This parameter is included in the OAuth signature base string.

public String getOAuthSignature ()

Returns the OAuth signature used to sign the current request. This parameter is optional, and it will be set by OAuthHelper if it is not provided.

public String getOAuthSignatureMethod ()

Returns the OAuth Signature Method. Valid values are "RSA-SHA1", "HMAC-SHA1" and "PLAINTEXT". This parameter is optional, and will be supplied by OAuthSigner if it is not provided by the user. This parameter is included in the OAuth signature base string.

public String getOAuthTimestamp ()

Returns the OAuth timestamp. OAuth defines the timestamp as "the number of seconds since January 1, 1970 00:00:00 GMT. The timestamp value MUST be a positive integer and MUST be equal or greater than the timestamp used in previous requests." This parameter is optional, and will be supplied by getTimestamp() if it is not provided by the user. This parameter is included in the OAuth signature base string.

public String getOAuthToken ()

Returns the OAuth token. This token may either be the unauthorized request token, the user-authorized request token, or the access token. This parameter is optional, and will be modified by the methods in OAuthHelper. This parameter is included in the OAuth signature base string.

public String getOAuthTokenSecret ()

Returns the OAuth Token Secret. The OAuth Token Secret is a secret used by the Consumer to establish ownership of a given Token. This parameter is optional.

public OAuthParameters.OAuthType getOAuthType ()

Retrieves the OAuth type requested.

public String getOAuthVerifier ()

Returns the OAuth Verifier.

public String getRealm ()

Returns the Realm parameter to be used in the authorization header, as defined by

public void removeCustomBaseParameter (String key)

Removes a parameter from the OAuth signature.

Parameters
key The key used to reference this parameter.

public void reset ()

Resets all transient parameters related to a single request, so that these parameters do not interfere with multiple requests.

public void setOAuthCallback (String oauthCallback)

Sets the OAuth callback url. See getOAuthCallback() to learn more about this parameter.

Parameters
oauthCallback

public void setOAuthConsumerKey (String consumerKey)

Sets the OAuth Consumer Key. See getOAuthConsumerKey() to learn more about this parameter.

Parameters
consumerKey

public void setOAuthConsumerSecret (String consumerSecret)

Parameters
consumerSecret

public void setOAuthNonce (String oauthNonce)

Sets the OAuth nonce. See getOAuthNonce() to learn more about this parameter.

Parameters
oauthNonce

public void setOAuthSignature (String signature)

Sets the OAuth signature used to sign the current request. See getOAuthSignature() to learn more about this parameter.

Parameters
signature

public void setOAuthSignatureMethod (String signatureMethod)

Sets the OAuth Signature Method. See getOAuthSignatureMethod() to learn more about this parameter.

Parameters
signatureMethod

public void setOAuthTimestamp (String timestamp)

Sets the OAuth timestamp. See getOAuthTimestamp() to learn more about this parameter.

Parameters
timestamp

public void setOAuthToken (String token)

Sets the OAuth token. See getOAuthToken() to learn more about this parameter.

Parameters
token

public void setOAuthTokenSecret (String tokenSecret)

Returns the OAuth Token Secret. See getOAuthTokenSecret() to learn more about this parameter.

Parameters
tokenSecret

public void setOAuthType (OAuthParameters.OAuthType type)

Sets the value of the OAuth type.

Parameters
type

public void setOAuthVerifier (String verifier)

Returns the OAuth Verifier. See getOAuthVerifier() to learn more about this parameter.

Parameters
verifier

public void setRealm (String realm)

Sets the Realm parameter. See getRealm() to learn more about this parameter.

Parameters
realm

Protected Methods

protected void assertExists (String key, Map<String, String> params)

Checks the given key to see if it exists, and throws an exception if it does not. See checkExists(String, Map) for more information.

Parameters
key The key to check for existence
params The map to check for the key
Throws
OAuthException if the value for the given key doesn't exist

protected boolean checkExists (String key, Map<String, String> params)

Checks the given key to see if it exists. In order to "exist", the value can't be null, and it can't be an empty string.

Parameters
key The key to check for existence
params The map to check for the key
Returns
  • true if the value is a string that is not empty, false otherwise

protected String get (String key, Map<String, String> params)

Retrieves the value with the given key from the input map. A null value is returned as an empty string.

Parameters
key The key whose value to retrieve
params The map from which to retrieve the value from
Returns
  • the value associated with the given key

protected void put (String key, String value, Map<String, String> params)

Adds the key/value pair to the input map.

Parameters
key The key to add to the map
value The value to add to the map
params The map to add the values to

protected void remove (String key, Map<String, String> params)

Removes a key/value pair from the input map.

Parameters
key The key to remove
params The map to remove the key from