Package org.pac4j.core.context
Class WebContextHelper
java.lang.Object
org.pac4j.core.context.WebContextHelper
- All Implemented Interfaces:
HttpConstants
A helper for the web context.
- Since:
- 1.8.1
- Author:
- Jerome Leleu
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.pac4j.core.context.HttpConstants
HttpConstants.HTTP_METHOD -
Field Summary
Fields inherited from interface org.pac4j.core.context.HttpConstants
ACCEPT_HEADER, ACCESS_CONTROL_ALLOW_CREDENTIALS_HEADER, ACCESS_CONTROL_ALLOW_HEADERS_HEADER, ACCESS_CONTROL_ALLOW_METHODS_HEADER, ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, ACCESS_CONTROL_EXPOSE_HEADERS_HEADER, ACCESS_CONTROL_MAX_AGE_HEADER, AJAX_HEADER_NAME, AJAX_HEADER_VALUE, APPLICATION_FORM_ENCODED_HEADER_VALUE, APPLICATION_JSON, AUTHENTICATE_HEADER, AUTHORIZATION_HEADER, BAD_REQUEST, BASIC_HEADER_PREFIX, BEARER_HEADER_PREFIX, CONTENT_TYPE_HEADER, CREATED, DEFAULT_CONNECT_TIMEOUT, DEFAULT_HTTP_PORT, DEFAULT_HTTPS_PORT, DEFAULT_READ_TIMEOUT, DIGEST_HEADER_PREFIX, FACES_PARTIAL_AJAX_PARAMETER, FORBIDDEN, FOUND, HTML_CONTENT_TYPE, LOCATION_HEADER, NO_CONTENT, OK, SCHEME_HTTP, SCHEME_HTTPS, SEE_OTHER, TEMPORARY_REDIRECT, UNAUTHORIZED -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcreateCookieHeader(Cookie cookie) Custom method for adding cookie because the servlet-api version doesn't support SameSite attributes.static CookiegetCookie(Collection<Cookie> cookies, String name) Get a specific cookie by its name.static CookiegetCookie(WebContext context, String name) Get a specific cookie by its name.static booleanisDelete(WebContext context) Whether it is a DELETE request.static booleanisGet(WebContext context) Whether it is a GET request.static booleanisHttp(WebContext context) Whether the request is HTTP.static booleanisHttps(WebContext context) Whether the request is HTTPS.static booleanisHttpsOrSecure(WebContext context) Whether the request is HTTPS or secure.static booleanisPatch(WebContext context) Whether it is a PATCH request.static booleanisPost(WebContext context) Whether it is a POST request.static booleanisPut(WebContext context) Whether it is a PUT request.
-
Constructor Details
-
WebContextHelper
public WebContextHelper()
-
-
Method Details
-
getCookie
Get a specific cookie by its name.- Parameters:
cookies- provided cookiesname- the name of the cookie- Returns:
- the cookie
-
getCookie
Get a specific cookie by its name.- Parameters:
context- the current web contextname- the name of the cookie- Returns:
- the cookie
-
isGet
Whether it is a GET request.- Parameters:
context- the web context- Returns:
- whether it is a GET request
-
isPost
Whether it is a POST request.- Parameters:
context- the web context- Returns:
- whether it is a POST request
-
isPut
Whether it is a PUT request.- Parameters:
context- the web context- Returns:
- whether it is a PUT request
-
isPatch
Whether it is a PATCH request.- Parameters:
context- the web context- Returns:
- whether it is a PATCH request
-
isDelete
Whether it is a DELETE request.- Parameters:
context- the web context- Returns:
- whether it is a DELETE request
-
isHttpsOrSecure
Whether the request is HTTPS or secure.- Parameters:
context- the current web context- Returns:
- whether the request is HTTPS or secure
-
isHttp
Whether the request is HTTP.- Parameters:
context- the current web context- Returns:
- whether the request is HTTP
-
isHttps
Whether the request is HTTPS.- Parameters:
context- the current web context- Returns:
- whether the request is HTTPS
-
createCookieHeader
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
-