com.sun.jersey.oauth.signature
Class OAuthParameters

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<java.lang.String,java.lang.String>
          extended by com.sun.jersey.oauth.signature.OAuthParameters
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,java.lang.String>

public class OAuthParameters
extends java.util.HashMap<java.lang.String,java.lang.String>

A data structure class that represents OAuth protocol parameters.

Author:
Hubert A. Le Van Gong , Paul C. Bryan
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Field Summary
static java.lang.String AUTHORIZATION_HEADER
          Name of HTTP authorization header.
static java.lang.String CALLBACK
          Name of parameter containing the callback URL.
static java.lang.String CONSUMER_KEY
          Name of parameter containing the consumer key.
static java.lang.String NONCE
          Name of parameter containing the nonce.
static java.lang.String REALM
          Name of parameter containing the protection realm.
static java.lang.String SCHEME
          OAuth scheme in Authorization header.
static java.lang.String SIGNATURE
          Name of parameter containing the signature.
static java.lang.String SIGNATURE_METHOD
          Name of parameter containing the signature method.
static java.lang.String TIMESTAMP
          Name of parameter containing the timestamp.
static java.lang.String TOKEN
          Name of parameter containing the access/request token.
static java.lang.String VERIFIER
          Name of parameter containing the verifier code.
static java.lang.String VERSION
          Name of parameter containing the protocol version.
 
Constructor Summary
OAuthParameters()
           
 
Method Summary
 OAuthParameters callback(java.lang.String callback)
          Builder pattern method to return OAuthParameters after setting callback URL.
 OAuthParameters consumerKey(java.lang.String consumerKey)
          Builder pattern method to return OAuthParameters after setting consumer key.
 java.lang.String getConsumerKey()
          Returns the consumer key.
 java.lang.String getNonce()
          Returns the nonce, a value that should be unique for a given timestamp.
 java.lang.String getRealm()
          Returns the protection realm for the request.
 java.lang.String getSignature()
          Returns the signature for the request.
 java.lang.String getSignatureMethod()
          Returns the signature method used to sign the request.
 java.lang.String getTimestamp()
          Returns the timestamp, a value expected to be a positive integer, typically containing the number of seconds since January 1, 1970 00:00:00 GMT (epoch).
 java.lang.String getToken()
          Returns the request or access token.
 java.lang.String getVersion()
          Returns the protocol version.
 OAuthParameters nonce()
          Builder pattern method to return OAuthParameters after setting nonce to a randomly-generated UUID.
 OAuthParameters nonce(java.lang.String nonce)
          Builder pattern method to return OAuthParameters after setting nonce.
 OAuthParameters readRequest(OAuthRequest request)
          Reads a request for OAuth parameters, and populates this object.
 OAuthParameters realm(java.lang.String realm)
          Builder pattern method to return OAuthParameters after setting protection realm.
 void setConsumerKey(java.lang.String consumerKey)
          Sets the consumer key.
 void setNonce()
          Sets the nonce to contain a randomly-generated UUID.
 void setNonce(java.lang.String nonce)
          Sets the nonce, a value that should be unique for a given timestamp.
 void setRealm(java.lang.String realm)
          Sets the protection realm for the request.
 void setSignature(java.lang.String signature)
          Sets the signature for the request.
 void setSignatureMethod(java.lang.String signatureMethod)
          Sets the signature method used to sign the request.
 void setTimestamp()
          Sets the timestamp to the current time as number of seconds since epoch.
 void setTimestamp(java.lang.String timestamp)
          Sets the timestamp.
 void setToken(java.lang.String token)
          Sets the request or access token.
 void setVersion(java.lang.String version)
          Sets the protocol version.
 OAuthParameters signature(java.lang.String signature)
          Builder pattern method to return OAuthParameters after setting signature.
 OAuthParameters signatureMethod(java.lang.String signatureMethod)
          Builder pattern method to return OAuthParameters after setting signature method.
 OAuthParameters timestamp()
          Builder pattern method to return OAuthParameters after setting timestamp to the current time.
 OAuthParameters timestamp(java.lang.String timestamp)
          Builder pattern method to return OAuthParameters after setting timestamp.
 OAuthParameters token(java.lang.String token)
          Builder pattern method to return OAuthParameters after setting token.
 OAuthParameters verifier(java.lang.String verifier)
          Builder pattern method to return OAuthParameters after setting verifier code.
 OAuthParameters version()
          Builder pattern method to return OAuthParameters after setting version to the default value of 1.0.
 OAuthParameters version(java.lang.String version)
          Builder pattern method to return OAuthParameters after setting version.
 OAuthParameters writeRequest(OAuthRequest request)
          Writes the OAuth parameters to a request, as an Authorization header.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

AUTHORIZATION_HEADER

public static final java.lang.String AUTHORIZATION_HEADER
Name of HTTP authorization header.

See Also:
Constant Field Values

SCHEME

public static final java.lang.String SCHEME
OAuth scheme in Authorization header.

See Also:
Constant Field Values

REALM

public static final java.lang.String REALM
Name of parameter containing the protection realm.

See Also:
Constant Field Values

CONSUMER_KEY

public static final java.lang.String CONSUMER_KEY
Name of parameter containing the consumer key.

See Also:
Constant Field Values

TOKEN

public static final java.lang.String TOKEN
Name of parameter containing the access/request token.

See Also:
Constant Field Values

SIGNATURE_METHOD

public static final java.lang.String SIGNATURE_METHOD
Name of parameter containing the signature method.

See Also:
Constant Field Values

SIGNATURE

public static final java.lang.String SIGNATURE
Name of parameter containing the signature.

See Also:
Constant Field Values

TIMESTAMP

public static final java.lang.String TIMESTAMP
Name of parameter containing the timestamp.

See Also:
Constant Field Values

NONCE

public static final java.lang.String NONCE
Name of parameter containing the nonce.

See Also:
Constant Field Values

VERSION

public static final java.lang.String VERSION
Name of parameter containing the protocol version.

See Also:
Constant Field Values

VERIFIER

public static final java.lang.String VERIFIER
Name of parameter containing the verifier code.

See Also:
Constant Field Values

CALLBACK

public static final java.lang.String CALLBACK
Name of parameter containing the callback URL.

See Also:
Constant Field Values
Constructor Detail

OAuthParameters

public OAuthParameters()
Method Detail

getRealm

public java.lang.String getRealm()
Returns the protection realm for the request.


setRealm

public void setRealm(java.lang.String realm)
Sets the protection realm for the request.


realm

public OAuthParameters realm(java.lang.String realm)
Builder pattern method to return OAuthParameters after setting protection realm.

Parameters:
realm - the protection realm for the request.
Returns:
this parameters object.

getConsumerKey

public java.lang.String getConsumerKey()
Returns the consumer key.


setConsumerKey

public void setConsumerKey(java.lang.String consumerKey)
Sets the consumer key.


consumerKey

public OAuthParameters consumerKey(java.lang.String consumerKey)
Builder pattern method to return OAuthParameters after setting consumer key.

Parameters:
consumerKey - the consumer key.

getToken

public java.lang.String getToken()
Returns the request or access token.


setToken

public void setToken(java.lang.String token)
Sets the request or access token.


token

public OAuthParameters token(java.lang.String token)
Builder pattern method to return OAuthParameters after setting token.

Parameters:
token - the access or request token.
Returns:
this parameters object.

getSignatureMethod

public java.lang.String getSignatureMethod()
Returns the signature method used to sign the request.


setSignatureMethod

public void setSignatureMethod(java.lang.String signatureMethod)
Sets the signature method used to sign the request.


signatureMethod

public OAuthParameters signatureMethod(java.lang.String signatureMethod)
Builder pattern method to return OAuthParameters after setting signature method.

Parameters:
signatureMethod - the signature method used to sign the request.
Returns:
this parameters object.

getSignature

public java.lang.String getSignature()
Returns the signature for the request.


setSignature

public void setSignature(java.lang.String signature)
Sets the signature for the request.


signature

public OAuthParameters signature(java.lang.String signature)
Builder pattern method to return OAuthParameters after setting signature.

Parameters:
signature - the signature for the request.
Returns:
this parameters object.

getTimestamp

public java.lang.String getTimestamp()
Returns the timestamp, a value expected to be a positive integer, typically containing the number of seconds since January 1, 1970 00:00:00 GMT (epoch).


setTimestamp

public void setTimestamp(java.lang.String timestamp)
Sets the timestamp. Its value is not validated, but should be a positive integer, typically containing the number of seconds since January 1, 1970 00:00:00 GMT (epoch).


timestamp

public OAuthParameters timestamp(java.lang.String timestamp)
Builder pattern method to return OAuthParameters after setting timestamp.

Parameters:
timestamp - positive integer, typically number of seconds since epoch.
Returns:
this parameters object.

setTimestamp

public void setTimestamp()
Sets the timestamp to the current time as number of seconds since epoch.


timestamp

public OAuthParameters timestamp()
Builder pattern method to return OAuthParameters after setting timestamp to the current time.

Returns:
this parameters object.

getNonce

public java.lang.String getNonce()
Returns the nonce, a value that should be unique for a given timestamp.


setNonce

public void setNonce(java.lang.String nonce)
Sets the nonce, a value that should be unique for a given timestamp.


nonce

public OAuthParameters nonce(java.lang.String nonce)
Builder pattern method to return OAuthParameters after setting nonce.

Parameters:
nonce - a value that should be unique for a given timestamp.
Returns:
this parameters object.

setNonce

public void setNonce()
Sets the nonce to contain a randomly-generated UUID.


nonce

public OAuthParameters nonce()
Builder pattern method to return OAuthParameters after setting nonce to a randomly-generated UUID.

Returns:
this parameters object.

getVersion

public java.lang.String getVersion()
Returns the protocol version.


setVersion

public void setVersion(java.lang.String version)
Sets the protocol version.


version

public OAuthParameters version(java.lang.String version)
Builder pattern method to return OAuthParameters after setting version.

Parameters:
version - the protocol version.
Returns:
this parameters object.

version

public OAuthParameters version()
Builder pattern method to return OAuthParameters after setting version to the default value of 1.0.

Returns:
this parameters object.

verifier

public OAuthParameters verifier(java.lang.String verifier)
Builder pattern method to return OAuthParameters after setting verifier code.

Parameters:
verifier - the verifier code.
Returns:
this parameters object.

callback

public OAuthParameters callback(java.lang.String callback)
Builder pattern method to return OAuthParameters after setting callback URL.

Parameters:
callback - the callback URL.
Returns:
this parameters object.

readRequest

public OAuthParameters readRequest(OAuthRequest request)
Reads a request for OAuth parameters, and populates this object.

Parameters:
request - the request to read OAuth parameters from.
Returns:
this parameters object.

writeRequest

public OAuthParameters writeRequest(OAuthRequest request)
Writes the OAuth parameters to a request, as an Authorization header.

Parameters:
request - the request to write OAuth parameters to.
Returns:
this parameters object.


Copyright © 2011 Sun Microsystems, Inc. All Rights Reserved.