Package com.google.api.client.auth.oauth
Class OAuthParameters
- java.lang.Object
-
- com.google.api.client.auth.oauth.OAuthParameters
-
- All Implemented Interfaces:
com.google.api.client.http.HttpExecuteInterceptor,com.google.api.client.http.HttpRequestInitializer
@Beta public final class OAuthParameters extends Object implements com.google.api.client.http.HttpExecuteInterceptor, com.google.api.client.http.HttpRequestInitializer
Beta
OAuth 1.0a parameter manager.The only required non-computed fields are
signerandconsumerKey. Usetokento specify token or temporary credentials.Sample usage, taking advantage that this class implements
HttpRequestInitializer:public static HttpRequestFactory createRequestFactory(HttpTransport transport) { OAuthParameters parameters = new OAuthParameters(); // ... return transport.createRequestFactory(parameters); }If you have a custom request initializer, take a look at the sample usage for
HttpExecuteInterceptor, which this class also implements.- Since:
- 1.0
- Author:
- Yaniv Inbar
-
-
Field Summary
Fields Modifier and Type Field Description StringcallbackAbsolute URI back to which the server will redirect the resource owner when the Resource Owner Authorization step is completed.StringconsumerKeyRequired identifier portion of the client credentials (equivalent to a username).StringnonceRequired nonce value.StringrealmRealm.StringsignatureSignature.StringsignatureMethodName of the signature method used by the client to sign the request.OAuthSignersignerRequired OAuth signature algorithm.StringtimestampRequired timestamp value.StringtokenToken value used to associate the request with the resource owner ornullif the request is not associated with a resource owner.StringverifierThe verification code received from the server.StringversionMust either be "1.0" ornullto skip.
-
Constructor Summary
Constructors Constructor Description OAuthParameters()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcomputeNonce()Computes a nonce based on the hex string of a random non-negative long, setting the value of thenoncefield.voidcomputeSignature(String requestMethod, com.google.api.client.http.GenericUrl requestUrl)Computes a new signature based on the fields and the given request method and URL, setting the values of thesignatureandsignatureMethodfields.voidcomputeTimestamp()Computes a timestamp based on the current system time, setting the value of thetimestampfield.static Stringescape(String value)Returns the escaped form of the given value using OAuth escaping rules.StringgetAuthorizationHeader()Returns theAuthorizationheader value to use with the OAuth parameter values found in the fields.voidinitialize(com.google.api.client.http.HttpRequest request)voidintercept(com.google.api.client.http.HttpRequest request)
-
-
-
Field Detail
-
signer
public OAuthSigner signer
Required OAuth signature algorithm.
-
callback
public String callback
Absolute URI back to which the server will redirect the resource owner when the Resource Owner Authorization step is completed.
-
consumerKey
public String consumerKey
Required identifier portion of the client credentials (equivalent to a username).
-
nonce
public String nonce
Required nonce value. Should be computed usingcomputeNonce().
-
realm
public String realm
Realm.
-
signature
public String signature
Signature. Required but normally computed usingcomputeSignature(java.lang.String, com.google.api.client.http.GenericUrl).
-
signatureMethod
public String signatureMethod
Name of the signature method used by the client to sign the request. Required, but normally computed usingcomputeSignature(java.lang.String, com.google.api.client.http.GenericUrl).
-
timestamp
public String timestamp
Required timestamp value. Should be computed usingcomputeTimestamp().
-
token
public String token
Token value used to associate the request with the resource owner ornullif the request is not associated with a resource owner.
-
verifier
public String verifier
The verification code received from the server.
-
version
public String version
Must either be "1.0" ornullto skip. Provides the version of the authentication process as defined in this specification.
-
-
Method Detail
-
computeNonce
public void computeNonce()
Computes a nonce based on the hex string of a random non-negative long, setting the value of thenoncefield.
-
computeTimestamp
public void computeTimestamp()
Computes a timestamp based on the current system time, setting the value of thetimestampfield.
-
computeSignature
public void computeSignature(String requestMethod, com.google.api.client.http.GenericUrl requestUrl) throws GeneralSecurityException
Computes a new signature based on the fields and the given request method and URL, setting the values of thesignatureandsignatureMethodfields.- Throws:
GeneralSecurityException- general security exception
-
getAuthorizationHeader
public String getAuthorizationHeader()
Returns theAuthorizationheader value to use with the OAuth parameter values found in the fields.
-
escape
public static String escape(String value)
Returns the escaped form of the given value using OAuth escaping rules.
-
initialize
public void initialize(com.google.api.client.http.HttpRequest request) throws IOException- Specified by:
initializein interfacecom.google.api.client.http.HttpRequestInitializer- Throws:
IOException
-
intercept
public void intercept(com.google.api.client.http.HttpRequest request) throws IOException- Specified by:
interceptin interfacecom.google.api.client.http.HttpExecuteInterceptor- Throws:
IOException
-
-