Class OAuth
java.lang.Object
oauth.signpost.OAuth
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringPass this value as the callback "url" upon retrieving a request token if your application cannot receive callbacks (e.g.private static final PercentEscaperstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringaddQueryParameters(String url, String... kvPairs) Appends a list of key/value pairs to the given URL, e.g.:static StringaddQueryParameters(String url, Map<String, String> params) static StringaddQueryString(String url, String queryString) static voidstatic HttpParametersdecodeForm(InputStream content) static HttpParametersdecodeForm(String form) Parse a form-urlencoded document.formEncode(Collection<T> parameters) Construct a x-www-form-urlencoded document containing the given sequence of name/value pairs.formEncode(Collection<T> parameters, OutputStream into) Construct a x-www-form-urlencoded document containing the given sequence of name/value pairs.static booleanstatic HttpParametersoauthHeaderToParamsMap(String oauthHeader) static Stringstatic Stringstatic StringprepareOAuthHeader(String... kvPairs) Builds an OAuth header from the given list of header fields.static final StringsafeToString(Object from) static StringtoHeaderElement(String name, String value) Helper method to concatenate a parameter and its value to a pair that can be used in an HTTP header.toMap(Collection<T> from) Construct a Map containing a copy of the given parameters.
-
Field Details
-
VERSION_1_0
- See Also:
-
ENCODING
- See Also:
-
FORM_ENCODED
- See Also:
-
HTTP_AUTHORIZATION_HEADER
- See Also:
-
OAUTH_CONSUMER_KEY
- See Also:
-
OAUTH_TOKEN
- See Also:
-
OAUTH_TOKEN_SECRET
- See Also:
-
OAUTH_SIGNATURE_METHOD
- See Also:
-
OAUTH_SIGNATURE
- See Also:
-
OAUTH_TIMESTAMP
- See Also:
-
OAUTH_NONCE
- See Also:
-
OAUTH_VERSION
- See Also:
-
OAUTH_CALLBACK
- See Also:
-
OAUTH_CALLBACK_CONFIRMED
- See Also:
-
OAUTH_VERIFIER
- See Also:
-
OUT_OF_BAND
Pass this value as the callback "url" upon retrieving a request token if your application cannot receive callbacks (e.g. because it's a desktop app). This will tell the service provider that verification happens out-of-band, which basically means that it will generate a PIN code (the OAuth verifier) and display that to your user. You must obtain this code from your user and pass it toin order to complete the token handshake.invalid reference
OAuthProvider#retrieveAccessToken(OAuthConsumer, String)- See Also:
-
percentEncoder
-
-
Constructor Details
-
OAuth
public OAuth()
-
-
Method Details
-
percentEncode
-
percentDecode
-
formEncode
public static <T extends Map.Entry<String,String>> void formEncode(Collection<T> parameters, OutputStream into) throws IOException Construct a x-www-form-urlencoded document containing the given sequence of name/value pairs. Use OAuth percent encoding (not exactly the encoding mandated by x-www-form-urlencoded).- Throws:
IOException
-
formEncode
public static <T extends Map.Entry<String,String>> String formEncode(Collection<T> parameters) throws IOException Construct a x-www-form-urlencoded document containing the given sequence of name/value pairs. Use OAuth percent encoding (not exactly the encoding mandated by x-www-form-urlencoded).- Throws:
IOException
-
decodeForm
Parse a form-urlencoded document. -
decodeForm
- Throws:
IOException
-
toMap
-
safeToString
-
isEmpty
-
addQueryParameters
Appends a list of key/value pairs to the given URL, e.g.:String url = OAuth.addQueryParameters("http://example.com?a=1", b, 2, c, 3);which yields:http://example.com?a=1invalid input: '&b'=2invalid input: '&c'=3
All parameters will be encoded according to OAuth's percent encoding rules.- Parameters:
url- the URLkvPairs- the list of key/value pairs- Returns:
-
addQueryParameters
-
addQueryString
-
prepareOAuthHeader
Builds an OAuth header from the given list of header fields. All parameters starting in 'oauth_*' will be percent encoded.String authHeader = OAuth.prepareOAuthHeader("realm", "http://example.com", "oauth_token", "x%y");which yields:OAuth realm="http://example.com", oauth_token="x%25y"
- Parameters:
kvPairs- the list of key/value pairs- Returns:
- a string eligible to be used as an OAuth HTTP Authorization header.
-
oauthHeaderToParamsMap
-
toHeaderElement
Helper method to concatenate a parameter and its value to a pair that can be used in an HTTP header. This method percent encodes both parts before joining them.- Parameters:
name- the OAuth parameter name, e.g. oauth_tokenvalue- the OAuth parameter value, e.g. 'hello oauth'- Returns:
- a name/value pair, e.g. oauth_token="hello%20oauth"
-
debugOut
-