Class OAuth1Parameters
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<String,String>
-
- org.glassfish.jersey.oauth1.signature.OAuth1Parameters
-
- All Implemented Interfaces:
Serializable,Cloneable,Map<String,String>
public class OAuth1Parameters extends HashMap<String,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
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Field Summary
Fields Modifier and Type Field Description static StringAUTHORIZATION_HEADERName of HTTP authorization header.static StringCALLBACKName of parameter containing the callback URL.static StringCALLBACK_CONFIRMEDName of parameter containing the token secret.static StringCONSUMER_KEYName of parameter containing the consumer key.static StringNO_CALLBACK_URI_VALUEDefault value of the callback URI that should be used during Authorization flow for Request Token request when the client is not capable of handling redirects (e.g. the client is a mobile application).static StringNONCEName of parameter containing the nonce.static StringREALMName of parameter containing the protection realm.static StringSCHEMEOAuth scheme in Authorization header.static StringSIGNATUREName of parameter containing the signature.static StringSIGNATURE_METHODName of parameter containing the signature method.static StringTIMESTAMPName of parameter containing the timestamp.static StringTOKENName of parameter containing the access/request token.static StringTOKEN_SECRETName of parameter containing the token secret.static StringVERIFIERName of parameter containing the verifier code.static StringVERSIONName of parameter containing the protocol version.
-
Constructor Summary
Constructors Constructor Description OAuth1Parameters()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OAuth1Parameterscallback(String callback)Builder pattern method to returnOAuth1Parametersafter setting callback URL.OAuth1Parametersclone()OAuth1ParametersconsumerKey(String consumerKey)Builder pattern method to returnOAuth1Parametersafter setting consumer key.StringgetCallback()Returns the callback URL.StringgetConsumerKey()Returns the consumer key.StringgetNonce()Returns the nonce, a value that should be unique for a given timestamp.StringgetRealm()Returns the protection realm for the request.StringgetSignature()Returns the signature for the request.StringgetSignatureMethod()Returns the signature method used to sign the request.StringgetTimestamp()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).StringgetToken()Returns the request or access token.StringgetVerifier()Returns the verifier code.StringgetVersion()Returns the protocol version.OAuth1Parametersnonce()Builder pattern method to returnOAuth1Parametersafter setting nonce to a randomly-generated UUID.OAuth1Parametersnonce(String nonce)Builder pattern method to returnOAuth1Parametersafter setting nonce.Stringput(String key, String value)OAuth1ParametersreadRequest(OAuth1Request request)Reads a request for OAuth parameters, and populates this object.OAuth1Parametersrealm(String realm)Builder pattern method to returnOAuth1Parametersafter setting protection realm.voidsetCallback(String callback)Sets the callback URL.voidsetConsumerKey(String consumerKey)Sets the consumer key.voidsetNonce()Sets the nonce to contain a randomly-generated UUID.voidsetNonce(String nonce)Sets the nonce, a value that should be unique for a given timestamp.voidsetRealm(String realm)Sets the protection realm for the request.voidsetSignature(String signature)Sets the signature for the request.voidsetSignatureMethod(String signatureMethod)Sets the signature method used to sign the request.voidsetTimestamp()Sets the timestamp to the current time as number of seconds since epoch.voidsetTimestamp(String timestamp)Sets the timestamp.voidsetToken(String token)Sets the request or access token.voidsetVerifier(String verifier)Sets the verifier code.voidsetVersion()Sets the protocol version to the default value of 1.0.voidsetVersion(String version)Sets the protocol version.OAuth1Parameterssignature(String signature)Builder pattern method to returnOAuth1Parametersafter setting signature.OAuth1ParameterssignatureMethod(String signatureMethod)Builder pattern method to returnOAuth1Parametersafter setting signature method.OAuth1Parameterstimestamp()Builder pattern method to returnOAuth1Parametersafter setting timestamp to the current time.OAuth1Parameterstimestamp(String timestamp)Builder pattern method to returnOAuth1Parametersafter setting timestamp.OAuth1Parameterstoken(String token)Builder pattern method to returnOAuth1Parametersafter setting token.OAuth1Parametersverifier(String verifier)Builder pattern method to returnOAuth1Parametersafter setting verifier code.OAuth1Parametersversion()Builder pattern method to returnOAuth1Parametersafter setting version to the default value of 1.0.OAuth1Parametersversion(String version)Builder pattern method to returnOAuth1Parametersafter setting version.OAuth1ParameterswriteRequest(OAuth1Request request)Writes the OAuth parameters to a request, as an Authorization header.-
Methods inherited from class java.util.HashMap
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
-
-
-
Field Detail
-
AUTHORIZATION_HEADER
public static final String AUTHORIZATION_HEADER
Name of HTTP authorization header.- See Also:
- Constant Field Values
-
SCHEME
public static final String SCHEME
OAuth scheme in Authorization header.- See Also:
- Constant Field Values
-
REALM
public static final String REALM
Name of parameter containing the protection realm.- See Also:
- Constant Field Values
-
CONSUMER_KEY
public static final String CONSUMER_KEY
Name of parameter containing the consumer key.- See Also:
- Constant Field Values
-
TOKEN
public static final String TOKEN
Name of parameter containing the access/request token.- See Also:
- Constant Field Values
-
SIGNATURE_METHOD
public static final String SIGNATURE_METHOD
Name of parameter containing the signature method.- See Also:
- Constant Field Values
-
SIGNATURE
public static final String SIGNATURE
Name of parameter containing the signature.- See Also:
- Constant Field Values
-
TIMESTAMP
public static final String TIMESTAMP
Name of parameter containing the timestamp.- See Also:
- Constant Field Values
-
NONCE
public static final String NONCE
Name of parameter containing the nonce.- See Also:
- Constant Field Values
-
VERSION
public static final String VERSION
Name of parameter containing the protocol version.- See Also:
- Constant Field Values
-
VERIFIER
public static final String VERIFIER
Name of parameter containing the verifier code.- See Also:
- Constant Field Values
-
CALLBACK
public static final String CALLBACK
Name of parameter containing the callback URL.- See Also:
- Constant Field Values
-
TOKEN_SECRET
public static final String TOKEN_SECRET
Name of parameter containing the token secret. This parameter is never used in requests. It is part of a response to the request token and access token requests.- See Also:
- Constant Field Values
-
CALLBACK_CONFIRMED
public static final String CALLBACK_CONFIRMED
Name of parameter containing the token secret. This parameter is never used in requests. It is part of a response to the request token requests.- See Also:
- Constant Field Values
-
NO_CALLBACK_URI_VALUE
public static final String NO_CALLBACK_URI_VALUE
Default value of the callback URI that should be used during Authorization flow for Request Token request when the client is not capable of handling redirects (e.g. the client is a mobile application).- See Also:
- Constant Field Values
-
-
Method Detail
-
getRealm
public String getRealm()
Returns the protection realm for the request.
-
setRealm
public void setRealm(String realm)
Sets the protection realm for the request.
-
realm
public OAuth1Parameters realm(String realm)
Builder pattern method to returnOAuth1Parametersafter setting protection realm.- Parameters:
realm- the protection realm for the request.- Returns:
- this parameters object.
-
getConsumerKey
public String getConsumerKey()
Returns the consumer key.
-
setConsumerKey
public void setConsumerKey(String consumerKey)
Sets the consumer key.
-
consumerKey
public OAuth1Parameters consumerKey(String consumerKey)
Builder pattern method to returnOAuth1Parametersafter setting consumer key.- Parameters:
consumerKey- the consumer key.
-
getToken
public String getToken()
Returns the request or access token.
-
setToken
public void setToken(String token)
Sets the request or access token.
-
token
public OAuth1Parameters token(String token)
Builder pattern method to returnOAuth1Parametersafter setting token.- Parameters:
token- the access or request token.- Returns:
- this parameters object.
-
getSignatureMethod
public String getSignatureMethod()
Returns the signature method used to sign the request.
-
setSignatureMethod
public void setSignatureMethod(String signatureMethod)
Sets the signature method used to sign the request.
-
signatureMethod
public OAuth1Parameters signatureMethod(String signatureMethod)
Builder pattern method to returnOAuth1Parametersafter setting signature method.- Parameters:
signatureMethod- the signature method used to sign the request.- Returns:
- this parameters object.
-
getSignature
public String getSignature()
Returns the signature for the request.
-
setSignature
public void setSignature(String signature)
Sets the signature for the request.
-
signature
public OAuth1Parameters signature(String signature)
Builder pattern method to returnOAuth1Parametersafter setting signature.- Parameters:
signature- the signature for the request.- Returns:
- this parameters object.
-
getTimestamp
public 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(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 OAuth1Parameters timestamp(String timestamp)
Builder pattern method to returnOAuth1Parametersafter 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 OAuth1Parameters timestamp()
Builder pattern method to returnOAuth1Parametersafter setting timestamp to the current time.- Returns:
- this parameters object.
-
getNonce
public String getNonce()
Returns the nonce, a value that should be unique for a given timestamp.
-
setNonce
public void setNonce(String nonce)
Sets the nonce, a value that should be unique for a given timestamp.
-
nonce
public OAuth1Parameters nonce(String nonce)
Builder pattern method to returnOAuth1Parametersafter 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 OAuth1Parameters nonce()
Builder pattern method to returnOAuth1Parametersafter setting nonce to a randomly-generated UUID.- Returns:
- this parameters object.
-
getVersion
public String getVersion()
Returns the protocol version.
-
setVersion
public void setVersion(String version)
Sets the protocol version.
-
version
public OAuth1Parameters version(String version)
Builder pattern method to returnOAuth1Parametersafter setting version.- Parameters:
version- the protocol version.- Returns:
- this parameters object.
-
setVersion
public void setVersion()
Sets the protocol version to the default value of 1.0.
-
version
public OAuth1Parameters version()
Builder pattern method to returnOAuth1Parametersafter setting version to the default value of 1.0.- Returns:
- this parameters object.
-
getVerifier
public String getVerifier()
Returns the verifier code.
-
setVerifier
public void setVerifier(String verifier)
Sets the verifier code.
-
verifier
public OAuth1Parameters verifier(String verifier)
Builder pattern method to returnOAuth1Parametersafter setting verifier code.- Parameters:
verifier- the verifier code.- Returns:
- this parameters object.
-
getCallback
public String getCallback()
Returns the callback URL.
-
setCallback
public void setCallback(String callback)
Sets the callback URL.
-
callback
public OAuth1Parameters callback(String callback)
Builder pattern method to returnOAuth1Parametersafter setting callback URL.- Parameters:
callback- the callback URL.- Returns:
- this parameters object.
-
readRequest
public OAuth1Parameters readRequest(OAuth1Request 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 OAuth1Parameters writeRequest(OAuth1Request 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.
-
clone
public OAuth1Parameters clone()
-
-