|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.amber.oauth2.common.utils.OAuthUtils
public final class OAuthUtils
Common OAuth Utils class.
Some methods based on the Utils class from OAuth V1.0a library available at: http://oauth.googlecode.com/svn/code/java/core/
Field Summary | |
---|---|
static String |
AUTH_SCHEME
|
static String |
MULTIPART
|
Constructor Summary | |
---|---|
OAuthUtils()
|
Method Summary | ||
---|---|---|
static Map<String,Object> |
decodeForm(String form)
Parse a form-urlencoded document. |
|
static Map<String,String> |
decodeOAuthHeader(String header)
|
|
static String |
decodePercent(String s)
|
|
static Set<String> |
decodeScopes(String s)
|
|
static String |
encodeAuthorizationBearerHeader(Map<String,Object> entries)
Construct an Authorization Bearer header |
|
static String |
encodeOAuthHeader(Map<String,Object> entries)
Construct a WWW-Authenticate header |
|
static String |
encodeScopes(Set<String> s)
|
|
static String |
format(Collection<? extends Map.Entry<String,Object>> parameters,
String encoding)
Translates parameters into application/x-www-form-urlencoded String |
|
static String |
getAuthHeaderField(String authHeader)
|
|
static String |
getAuthzMethod(String header)
|
|
static OAuthProblemException |
handleBadContentTypeException(String expectedContentType)
|
|
static OAuthProblemException |
handleMissingParameters(Set<String> missingParams)
Creates OAuthProblemException that contains set of missing oauth parameters |
|
static OAuthProblemException |
handleNotAllowedParametersOAuthException(List<String> notAllowedParams)
|
|
static OAuthProblemException |
handleOAuthProblemException(String message)
Creates invalid_request exception with given message |
|
static boolean |
hasContentType(String requestContentType,
String requiredContentType)
|
|
static boolean |
hasEmptyValues(String[] array)
|
|
static
|
instantiateClass(Class<T> clazz)
|
|
static Object |
instantiateClassWithParameters(Class clazz,
Class[] paramsTypes,
Object[] paramValues)
|
|
static boolean |
isEmpty(String value)
|
|
static boolean |
isFormEncoded(String contentType)
Return true if the given Content-Type header means FORM_ENCODED. |
|
static boolean |
isMultipart(javax.servlet.http.HttpServletRequest request)
|
|
static String |
percentEncode(Iterable values)
Construct a &-separated list of the given values, percentEncoded. |
|
static String |
percentEncode(String s)
|
|
static String |
saveStreamAsString(InputStream is)
Read data from Input Stream and save it as a String. |
|
static String |
toString(InputStream is,
String defaultCharset)
Get the entity content as a String, using the provided default character set if none is found in the entity. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String AUTH_SCHEME
public static final String MULTIPART
Constructor Detail |
---|
public OAuthUtils()
Method Detail |
---|
public static String format(Collection<? extends Map.Entry<String,Object>> parameters, String encoding)
application/x-www-form-urlencoded
String
parameters
- parameters to encodeencoding
- The name of a supported
character
encoding.
public static String saveStreamAsString(InputStream is) throws IOException
is
- InputStream to be read
IOException
public static String toString(InputStream is, String defaultCharset) throws IOException
is
- input stream to be saved as stringdefaultCharset
- character set to be applied if none found in the entity
IllegalArgumentException
- if entity is null or if content length > Integer.MAX_VALUE
IOException
- if an error occurs reading the input streampublic static OAuthProblemException handleOAuthProblemException(String message)
message
- error message
public static OAuthProblemException handleMissingParameters(Set<String> missingParams)
missingParams
- missing oauth parameters
public static OAuthProblemException handleBadContentTypeException(String expectedContentType)
public static OAuthProblemException handleNotAllowedParametersOAuthException(List<String> notAllowedParams)
public static Map<String,Object> decodeForm(String form)
public static boolean isFormEncoded(String contentType)
public static String decodePercent(String s)
public static String percentEncode(Iterable values)
public static String percentEncode(String s)
public static <T> T instantiateClass(Class<T> clazz) throws OAuthSystemException
OAuthSystemException
public static Object instantiateClassWithParameters(Class clazz, Class[] paramsTypes, Object[] paramValues) throws OAuthSystemException
OAuthSystemException
public static String getAuthHeaderField(String authHeader)
public static Map<String,String> decodeOAuthHeader(String header)
public static String encodeOAuthHeader(Map<String,Object> entries)
public static String encodeAuthorizationBearerHeader(Map<String,Object> entries)
public static boolean isEmpty(String value)
public static boolean hasEmptyValues(String[] array)
public static String getAuthzMethod(String header)
public static Set<String> decodeScopes(String s)
public static String encodeScopes(Set<String> s)
public static boolean isMultipart(javax.servlet.http.HttpServletRequest request)
public static boolean hasContentType(String requestContentType, String requiredContentType)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |