Class OAuthRequest

java.lang.Object
org.eclipse.lyo.server.oauth.core.OAuthRequest

public class OAuthRequest extends Object
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 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

      public LyoOAuthConsumer getConsumer()
    • validate

      public void validate() throws net.oauth.OAuthException, IOException, jakarta.servlet.ServletException
      Validates that the request is authorized and throws an OAuth exception if not. The request must contain a valid access token and pass OAuthValidator.validateMessage(OAuthMessage, OAuthAccessor) checks using the validator set in the OAuthConfiguration.

      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 validation
      IOException
      jakarta.servlet.ServletException