Class OAuthRequest
java.lang.Object
org.eclipse.lyo.server.oauth.core.OAuthRequest
Validates that a request is authorized. The request must contain a valid
access token and pass
OAuthValidator
tests. To change the validator
used, call OAuthConfiguration.setValidator(OAuthValidator)
.
Usage:
try { OAuthRequest request = new OAuthRequest(httpRequest); request.validate(); } catch (OAuthException e) { // Request failed validation. Send an unauthorized response. OAuthServlet.handleException(httpResponse, e, OAuthConfiguration.getInstance().getRealm()); }
- Author:
- Samuel Padgett
-
Constructor Summary
ConstructorDescriptionOAuthRequest
(jakarta.servlet.http.HttpServletRequest request) OAuthRequest
(jakarta.servlet.http.HttpServletRequest request, String requestUrl) -
Method Summary
Modifier and TypeMethodDescriptionnet.oauth.OAuthAccessor
jakarta.servlet.http.HttpServletRequest
net.oauth.OAuthMessage
void
setHttpRequest
(jakarta.servlet.http.HttpServletRequest httpRequest) void
validate()
Validates that the request is authorized and throws an OAuth exception if not.
-
Constructor Details
-
OAuthRequest
public OAuthRequest(jakarta.servlet.http.HttpServletRequest request, String requestUrl) throws net.oauth.OAuthException, IOException - Parameters:
requestUrl
- the official URL of the request; that is the URL a legitimate client would use to compute the digital signature. If this parameter is null, this method will try to reconstruct the URL from the HTTP request; which may be wrong in some cases.- Throws:
net.oauth.OAuthException
IOException
-
OAuthRequest
public OAuthRequest(jakarta.servlet.http.HttpServletRequest request) throws net.oauth.OAuthException, IOException - Throws:
net.oauth.OAuthException
IOException
-
-
Method Details
-
getHttpRequest
public jakarta.servlet.http.HttpServletRequest getHttpRequest() -
setHttpRequest
public void setHttpRequest(jakarta.servlet.http.HttpServletRequest httpRequest) -
getMessage
public net.oauth.OAuthMessage getMessage() -
getAccessor
public net.oauth.OAuthAccessor getAccessor() -
getConsumer
-
validate
public void validate() throws net.oauth.OAuthException, IOException, jakarta.servlet.ServletExceptionValidates that the request is authorized and throws an OAuth exception if not. The request must contain a valid access token and passOAuthValidator.validateMessage(OAuthMessage, OAuthAccessor)
checks using the validator set in theOAuthConfiguration
.If the request fails validation, you can use
OAuthServlet.handleException(jakarta.servlet.http.HttpServletResponse, Exception, String)
to send an unauthorized response.- Throws:
net.oauth.OAuthException
- if the request fails validationIOException
jakarta.servlet.ServletException
-