public class OAuthUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
AUTHENTICATE_HEADER
HTTP WWW-Authenticate header
|
static String |
AUTHORIZATION_HEADER
HTTP Authorization header
|
static String |
OAUTH_CALLBACK_CONFIRMED_PARAM
OAuth Callback Confirmed parameter
|
static String |
OAUTH_VERIFIER_PARAM
OAuth Verifier parameter
|
Constructor and Description |
---|
OAuthUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
encodeForOAuth(String value)
Encodes the given value for use in an OAuth parameter.
|
static int |
getHttpCode(net.oauth.OAuthProblemException x)
Finds the HTTP status code from the given exception.
|
static OAuthProvider |
getOAuthProvider(javax.servlet.ServletContext context)
Loads the OAuthProvider as specified in the Servlet Context parameters, and caches it in the Servlet Context attributes for reuse.
|
static OAuthValidator |
getValidator(javax.servlet.ServletContext context,
OAuthProvider provider)
Creates an OAuthValidator, and caches it in the Servlet Context attributes for reuse.
|
static void |
makeErrorResponse(javax.servlet.http.HttpServletResponse resp,
String message,
int httpCode,
OAuthProvider provider)
Sends an error to the OAuth Consumer.
|
static long |
parseTimestamp(String timestampString)
Parse an OAuth timestamp.
|
static net.oauth.OAuthMessage |
readMessage(javax.servlet.http.HttpServletRequest req)
Reads an OAuthMessage from an HTTP Servlet Request.
|
static void |
sendValues(javax.servlet.http.HttpServletResponse resp,
String... params)
Sends a list of OAuth parameters in the body of the given Http Servlet Response
|
static void |
validateRequestWithAccessToken(javax.servlet.http.HttpServletRequest request,
net.oauth.OAuthMessage message,
OAuthToken accessToken,
OAuthValidator validator,
OAuthConsumer consumer) |
static void |
validateRequestWithoutAccessToken(javax.servlet.http.HttpServletRequest request,
net.oauth.OAuthMessage message,
OAuthValidator validator,
OAuthConsumer consumer)
Validates if a given request is a valid 2-leg oAuth request.
|
static boolean |
validateUriScopes(String requestURI,
String[] scopes)
Validates if a current request URI matches URI provided by the consumer at the
registration time or during the request token validation request.
|
public static final String AUTHORIZATION_HEADER
public static final String AUTHENTICATE_HEADER
public static final String OAUTH_VERIFIER_PARAM
public static final String OAUTH_CALLBACK_CONFIRMED_PARAM
public static String encodeForOAuth(String value)
value
- string to encodepublic static void sendValues(javax.servlet.http.HttpServletResponse resp, String... params) throws IOException
resp
- http responseparams
- a list of <name, value> parametersIOException
- if I/O error occurredpublic static net.oauth.OAuthMessage readMessage(javax.servlet.http.HttpServletRequest req)
req
- http requestOAuthMessage
public static void makeErrorResponse(javax.servlet.http.HttpServletResponse resp, String message, int httpCode, OAuthProvider provider) throws IOException
resp
- http responsemessage
- response messagehttpCode
- response status codeprovider
- OAuthProvider
IOException
- if I/O error occurredpublic static long parseTimestamp(String timestampString) throws OAuthException
timestampString
- timestampOAuthException
- if error occurredpublic static int getHttpCode(net.oauth.OAuthProblemException x)
x
- exceptionpublic static OAuthProvider getOAuthProvider(javax.servlet.ServletContext context) throws javax.servlet.ServletException
context
- servlet contextOAuthProvider
javax.servlet.ServletException
- servlet exceptionpublic static OAuthValidator getValidator(javax.servlet.ServletContext context, OAuthProvider provider)
context
- servlet contextprovider
- OAuthProvider
public static void validateRequestWithAccessToken(javax.servlet.http.HttpServletRequest request, net.oauth.OAuthMessage message, OAuthToken accessToken, OAuthValidator validator, OAuthConsumer consumer) throws Exception
Exception
public static void validateRequestWithoutAccessToken(javax.servlet.http.HttpServletRequest request, net.oauth.OAuthMessage message, OAuthValidator validator, OAuthConsumer consumer) throws Exception
request
- http requestmessage
- messagevalidator
- validatorconsumer
- consumerException
- if error occurredpublic static boolean validateUriScopes(String requestURI, String[] scopes)
requestURI
- request uriscopes
- array of scopesCopyright © 2019 JBoss by Red Hat. All rights reserved.