Package com.auth0

Class SessionUtils

java.lang.Object
com.auth0.SessionUtils

public abstract class SessionUtils extends Object
Helper class to handle easy session key-value storage.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Object
    get​(javax.servlet.http.HttpServletRequest req, String name)
    Get the attribute with the given name from the request session.
    protected static javax.servlet.http.HttpSession
    getSession​(javax.servlet.http.HttpServletRequest req)
    Extracts the HttpSession from the given request.
    static Object
    remove​(javax.servlet.http.HttpServletRequest req, String name)
    Same as get(HttpServletRequest, String) but it also removes the value from the request session.
    static void
    set​(javax.servlet.http.HttpServletRequest req, String name, Object value)
    Set's the attribute value to the request session.

    Methods inherited from class java.lang.Object

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

    • SessionUtils

      public SessionUtils()
  • Method Details

    • getSession

      protected static javax.servlet.http.HttpSession getSession(javax.servlet.http.HttpServletRequest req)
      Extracts the HttpSession from the given request.
      Parameters:
      req - a valid request to get the session from
      Returns:
      the session of the request
    • set

      public static void set(javax.servlet.http.HttpServletRequest req, String name, Object value)
      Set's the attribute value to the request session.
      Parameters:
      req - a valid request to get the session from
      name - the name of the attribute
      value - the value to set
    • get

      public static Object get(javax.servlet.http.HttpServletRequest req, String name)
      Get the attribute with the given name from the request session.
      Parameters:
      req - a valid request to get the session from
      name - the name of the attribute
      Returns:
      the attribute stored in the session or null if it doesn't exists
    • remove

      public static Object remove(javax.servlet.http.HttpServletRequest req, String name)
      Same as get(HttpServletRequest, String) but it also removes the value from the request session.
      Parameters:
      req - a valid request to get the session from
      name - the name of the attribute
      Returns:
      the attribute stored in the session or null if it doesn't exists