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 classOAuth.ParameterA name/value pair.static classOAuth.ProblemsStrings used for problem reporting.
-
Field Summary
Fields Modifier and Type Field Description static StringENCODINGThe encoding used to represent characters as bytes.static StringFORM_ENCODEDThe MIME type for a sequence of OAuth parameters.static StringHMAC_SHA1static StringOAUTH_CALLBACKstatic StringOAUTH_CALLBACK_CONFIRMEDstatic StringOAUTH_CONSUMER_KEYstatic StringOAUTH_NONCEstatic StringOAUTH_SIGNATUREstatic StringOAUTH_SIGNATURE_METHODstatic StringOAUTH_TIMESTAMPstatic StringOAUTH_TOKENstatic StringOAUTH_TOKEN_SECRETstatic StringOAUTH_VERIFIERstatic StringOAUTH_VERSIONstatic StringRSA_SHA1static StringVERSION_1_0
-
Constructor Summary
Constructors Constructor Description OAuth()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringaddParameters(String url, Iterable<? extends Map.Entry<String,String>> parameters)static StringaddParameters(String url, String... parameters)Construct a URL like the given one, but with the given parameters added to its query string.static StringdecodeCharacters(byte[] from)static List<OAuth.Parameter>decodeForm(String form)Parse a form-urlencoded document.static StringdecodePercent(String s)static byte[]encodeCharacters(String from)static StringformEncode(Iterable<? extends Map.Entry<String,String>> parameters)Construct a form-urlencoded document containing the given sequence of name/value pairs.static voidformEncode(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 booleanisEmpty(String str)static booleanisFormEncoded(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 StringpercentEncode(Iterable<String> values)Construct a &-separated list of the given values, percentEncoded.static StringpercentEncode(String s)static voidsetCharacterEncoding(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)
-
-