Package net.oauth
Class OAuth
- java.lang.Object
-
- net.oauth.OAuth
-
public class OAuth extends Object
Miscellaneous constants, methods and types.- Author:
- John Kristian
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
OAuth.Parameter
A name/value pair.static class
OAuth.Problems
Strings used for problem reporting.
-
Field Summary
Fields Modifier and Type Field Description static String
ENCODING
The encoding used to represent characters as bytes.static String
FORM_ENCODED
The MIME type for a sequence of OAuth parameters.static String
HMAC_SHA1
static String
OAUTH_CALLBACK
static String
OAUTH_CALLBACK_CONFIRMED
static String
OAUTH_CONSUMER_KEY
static String
OAUTH_NONCE
static String
OAUTH_SIGNATURE
static String
OAUTH_SIGNATURE_METHOD
static String
OAUTH_TIMESTAMP
static String
OAUTH_TOKEN
static String
OAUTH_TOKEN_SECRET
static String
OAUTH_VERIFIER
static String
OAUTH_VERSION
static String
RSA_SHA1
static String
VERSION_1_0
-
Constructor Summary
Constructors Constructor Description OAuth()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
addParameters(String url, Iterable<? extends Map.Entry<String,String>> parameters)
static String
addParameters(String url, String... parameters)
Construct a URL like the given one, but with the given parameters added to its query string.static String
decodeCharacters(byte[] from)
static List<OAuth.Parameter>
decodeForm(String form)
Parse a form-urlencoded document.static String
decodePercent(String s)
static byte[]
encodeCharacters(String from)
static String
formEncode(Iterable<? extends Map.Entry<String,String>> parameters)
Construct a form-urlencoded document containing the given sequence of name/value pairs.static void
formEncode(Iterable<? extends Map.Entry<String,String>> parameters, OutputStream into)
Write a form-urlencoded document into the given stream, containing the given sequence of name/value pairs.static boolean
isEmpty(String str)
static boolean
isFormEncoded(String contentType)
Return true if the given Content-Type header means FORM_ENCODED.static List<OAuth.Parameter>
newList(String... parameters)
Construct a list of Parameters from name, value, name, value...static Map<String,String>
newMap(Iterable<? extends Map.Entry<String,String>> from)
Construct a MapService containing a copy of the given parameters.static String
percentEncode(Iterable<String> values)
Construct a &-separated list of the given values, percentEncoded.static String
percentEncode(String s)
static void
setCharacterEncoding(String encoding)
-
-
-
Field Detail
-
ENCODING
public static final String ENCODING
The encoding used to represent characters as bytes.- See Also:
- Constant Field Values
-
FORM_ENCODED
public static final String FORM_ENCODED
The MIME type for a sequence of OAuth parameters.- See Also:
- Constant Field Values
-
HMAC_SHA1
public static final String HMAC_SHA1
- See Also:
- Constant Field Values
-
OAUTH_CALLBACK
public static final String OAUTH_CALLBACK
- See Also:
- Constant Field Values
-
OAUTH_CALLBACK_CONFIRMED
public static final String OAUTH_CALLBACK_CONFIRMED
- See Also:
- Constant Field Values
-
OAUTH_CONSUMER_KEY
public static final String OAUTH_CONSUMER_KEY
- See Also:
- Constant Field Values
-
OAUTH_NONCE
public static final String OAUTH_NONCE
- See Also:
- Constant Field Values
-
OAUTH_SIGNATURE
public static final String OAUTH_SIGNATURE
- See Also:
- Constant Field Values
-
OAUTH_SIGNATURE_METHOD
public static final String OAUTH_SIGNATURE_METHOD
- See Also:
- Constant Field Values
-
OAUTH_TIMESTAMP
public static final String OAUTH_TIMESTAMP
- See Also:
- Constant Field Values
-
OAUTH_TOKEN
public static final String OAUTH_TOKEN
- See Also:
- Constant Field Values
-
OAUTH_TOKEN_SECRET
public static final String OAUTH_TOKEN_SECRET
- See Also:
- Constant Field Values
-
OAUTH_VERIFIER
public static final String OAUTH_VERIFIER
- See Also:
- Constant Field Values
-
OAUTH_VERSION
public static final String OAUTH_VERSION
- See Also:
- Constant Field Values
-
RSA_SHA1
public static final String RSA_SHA1
- See Also:
- Constant Field Values
-
VERSION_1_0
public static final String VERSION_1_0
- See Also:
- Constant Field Values
-
-
Method Detail
-
addParameters
public static String addParameters(String url, Iterable<? extends Map.Entry<String,String>> parameters) throws IOException
- Throws:
IOException
-
addParameters
public static String addParameters(String url, String... parameters) throws IOException
Construct a URL like the given one, but with the given parameters added to its query string.- Throws:
IOException
-
decodeCharacters
public static String decodeCharacters(byte[] from)
-
decodeForm
public static List<OAuth.Parameter> decodeForm(String form)
Parse a form-urlencoded document.
-
encodeCharacters
public static byte[] encodeCharacters(String from)
-
formEncode
public static String formEncode(Iterable<? extends Map.Entry<String,String>> parameters) throws IOException
Construct a form-urlencoded document containing the given sequence of name/value pairs. Use OAuth percent encoding (not exactly the encoding mandated by HTTP).- Throws:
IOException
-
formEncode
public static void formEncode(Iterable<? extends Map.Entry<String,String>> parameters, OutputStream into) throws IOException
Write a form-urlencoded document into the given stream, containing the given sequence of name/value pairs.- Throws:
IOException
-
isEmpty
public static boolean isEmpty(String str)
-
isFormEncoded
public static boolean isFormEncoded(String contentType)
Return true if the given Content-Type header means FORM_ENCODED.
-
newList
public static List<OAuth.Parameter> newList(String... parameters)
Construct a list of Parameters from name, value, name, value...
-
newMap
public static Map<String,String> newMap(Iterable<? extends Map.Entry<String,String>> from)
Construct a MapService containing a copy of the given parameters. If several parameters have the same name, the MapService will contain the first value, only.
-
percentEncode
public static String percentEncode(Iterable<String> values)
Construct a &-separated list of the given values, percentEncoded.
-
setCharacterEncoding
public static void setCharacterEncoding(String encoding)
-
-