Class WebContextHelper

java.lang.Object
org.pac4j.core.context.WebContextHelper
All Implemented Interfaces:
HttpConstants

public final class WebContextHelper extends Object implements HttpConstants
A helper for the web context.
Since:
1.8.1
Author:
Jerome Leleu
  • Constructor Details

    • WebContextHelper

      public WebContextHelper()
  • Method Details

    • getCookie

      public static Cookie getCookie(Collection<Cookie> cookies, String name)
      Get a specific cookie by its name.
      Parameters:
      cookies - provided cookies
      name - the name of the cookie
      Returns:
      the cookie
    • getCookie

      public static Cookie getCookie(WebContext context, String name)
      Get a specific cookie by its name.
      Parameters:
      context - the current web context
      name - the name of the cookie
      Returns:
      the cookie
    • isGet

      public static boolean isGet(WebContext context)
      Whether it is a GET request.
      Parameters:
      context - the web context
      Returns:
      whether it is a GET request
    • isPost

      public static boolean isPost(WebContext context)
      Whether it is a POST request.
      Parameters:
      context - the web context
      Returns:
      whether it is a POST request
    • isPut

      public static boolean isPut(WebContext context)
      Whether it is a PUT request.
      Parameters:
      context - the web context
      Returns:
      whether it is a PUT request
    • isPatch

      public static boolean isPatch(WebContext context)
      Whether it is a PATCH request.
      Parameters:
      context - the web context
      Returns:
      whether it is a PATCH request
    • isDelete

      public static boolean isDelete(WebContext context)
      Whether it is a DELETE request.
      Parameters:
      context - the web context
      Returns:
      whether it is a DELETE request
    • isHttpsOrSecure

      public static boolean isHttpsOrSecure(WebContext context)
      Whether the request is HTTPS or secure.
      Parameters:
      context - the current web context
      Returns:
      whether the request is HTTPS or secure
    • isHttp

      public static boolean isHttp(WebContext context)
      Whether the request is HTTP.
      Parameters:
      context - the current web context
      Returns:
      whether the request is HTTP
    • isHttps

      public static boolean isHttps(WebContext context)
      Whether the request is HTTPS.
      Parameters:
      context - the current web context
      Returns:
      whether the request is HTTPS
    • createCookieHeader

      public static String createCookieHeader(Cookie cookie)
      Custom method for adding cookie because the servlet-api version doesn't support SameSite attributes. Sets the default SameSite policy to lax which is what most browsers do if the cookie doesn't specify a SameSite policy.
      Parameters:
      cookie - pac4j Cookie object