Class RequestAnnotations

java.lang.Object
com.atlassian.oauth.util.RequestAnnotations

public class RequestAnnotations extends Object
Managed annotations on the request to mark certain information to downstream parties
Since:
1.2
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    getOAuthConsumerKey(jakarta.servlet.http.HttpServletRequest req)
    Gets the consumer key that the given OAuth request has been authenticated on.
    static boolean
    isOAuthRequest(jakarta.servlet.http.HttpServletRequest req)
     
    static void
    markAsOAuthRequest(jakarta.servlet.http.HttpServletRequest req)
    Annotates the servlet request as one having been authenticated via OAuth.
    static void
    setOAuthConsumerKey(jakarta.servlet.http.HttpServletRequest req, String consumerKey)
    Annotates the servlet request as one having been authenticated via OAuth using the consumerKey given.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RequestAnnotations

      public RequestAnnotations()
  • Method Details

    • isOAuthRequest

      public static boolean isOAuthRequest(jakarta.servlet.http.HttpServletRequest req) throws NullPointerException
      Parameters:
      req - The servlet request to test, cannot be null;
      Returns:
      If the request was authenticated via OAuth
      Throws:
      NullPointerException - If the req variable is null
    • markAsOAuthRequest

      public static void markAsOAuthRequest(jakarta.servlet.http.HttpServletRequest req) throws NullPointerException
      Annotates the servlet request as one having been authenticated via OAuth. Subsequent calls on the same request will have the same result.
      Parameters:
      req - The servlet request to annotate
      Throws:
      NullPointerException - If the req variable is null
    • getOAuthConsumerKey

      public static String getOAuthConsumerKey(jakarta.servlet.http.HttpServletRequest req)
      Gets the consumer key that the given OAuth request has been authenticated on. Calling this method on a non-OAuth request will result in IllegalStateException. If unsure, simply call isOAuthRequest(jakarta.servlet.http.HttpServletRequest) beforehand.
      Parameters:
      req - the servlet request
      Returns:
      consumer key
      Since:
      1.6
    • setOAuthConsumerKey

      public static void setOAuthConsumerKey(jakarta.servlet.http.HttpServletRequest req, String consumerKey)
      Annotates the servlet request as one having been authenticated via OAuth using the consumerKey given.
      Parameters:
      req - the servlet request
      consumerKey - consumer key that the request has been authenticated on
      Since:
      1.6