org.jboss.resteasy.auth.oauth

## Class OAuthUtils

- java.lang.Object
- - org.jboss.resteasy.auth.oauth.OAuthUtils

-     public class OAuthUtils
      extends Object

- - ### Field Summary

    Fields
    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 Summary

    Constructors
    Constructor and Description
    `OAuthUtils()`

  - ### Method Summary

    Methods
    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

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### AUTHORIZATION_HEADER

          public static final String AUTHORIZATION_HEADER

      HTTP Authorization header
      See Also:
        Constant Field Values

    - #### AUTHENTICATE_HEADER

          public static final String AUTHENTICATE_HEADER

      HTTP WWW-Authenticate header
      See Also:
        Constant Field Values

    - #### OAUTH_VERIFIER_PARAM

          public static final String OAUTH_VERIFIER_PARAM

      OAuth Verifier parameter
      See Also:
        Constant Field Values

    - #### OAUTH_CALLBACK_CONFIRMED_PARAM

          public static final String OAUTH_CALLBACK_CONFIRMED_PARAM

      OAuth Callback Confirmed parameter
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### OAuthUtils

          public OAuthUtils()

  - ### Method Detail

    - #### encodeForOAuth

          public static String encodeForOAuth(String value)

      Encodes the given value for use in an OAuth parameter

    - #### sendValues

          public static void sendValues(javax.servlet.http.HttpServletResponse resp,
                        String... params)
                                 throws IOException

      Sends a list of OAuth parameters in the body of the given Http Servlet Response
      Parameters:
        `params` - a list of parameters
      Throws:
        `IOException`

    - #### readMessage

          public static net.oauth.OAuthMessage readMessage(javax.servlet.http.HttpServletRequest req)

      Reads an OAuthMessage from an HTTP Servlet Request. Uses the Authorization header, GET and POST parameters.

    - #### makeErrorResponse

          public static void makeErrorResponse(javax.servlet.http.HttpServletResponse resp,
                               String message,
                               int httpCode,
                               OAuthProvider provider)
                                        throws IOException

      Sends an error to the OAuth Consumer
      Throws:
        `IOException`

    - #### parseTimestamp

          public static long parseTimestamp(String timestampString)
                                     throws OAuthException

      Parse an OAuth timestamp
      Throws:
        `OAuthException`

    - #### getHttpCode

          public static int getHttpCode(net.oauth.OAuthProblemException x)

      Finds the HTTP status code from the given exception

    - #### getOAuthProvider

          public static OAuthProvider getOAuthProvider(javax.servlet.ServletContext context)
                                                throws javax.servlet.ServletException

      Loads the OAuthProvider as specified in the Servlet Context parameters, and caches it in the Servlet Context attributes for reuse.
      Throws:
        `javax.servlet.ServletException`

    - #### getValidator

          public static OAuthValidator getValidator(javax.servlet.ServletContext context,
                                    OAuthProvider provider)

      Creates an OAuthValidator, and caches it in the Servlet Context attributes for reuse.

    - #### validateRequestWithAccessToken

          public static void validateRequestWithAccessToken(javax.servlet.http.HttpServletRequest request,
                                            net.oauth.OAuthMessage message,
                                            OAuthToken accessToken,
                                            OAuthValidator validator,
                                            OAuthConsumer consumer)
                                                     throws Exception

      Throws:
        `Exception`

    - #### validateRequestWithoutAccessToken

          public static void validateRequestWithoutAccessToken(javax.servlet.http.HttpServletRequest request,
                                               net.oauth.OAuthMessage message,
                                               OAuthValidator validator,
                                               OAuthConsumer consumer)
                                                        throws Exception

      Validates if a given request is a valid 2-leg oAuth request
      Throws:
        `Exception`

    - #### validateUriScopes

          public 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

Copyright © 2014. All Rights Reserved.