Class StandardApplicationCookieService
java.lang.Object
org.apache.nifi.web.security.cookie.StandardApplicationCookieService
- All Implemented Interfaces:
ApplicationCookieService
- Direct Known Subclasses:
StandardCookieCsrfTokenRepository.CsrfApplicationCookieService
Standard implementation of Application Cookie Service using Spring Framework utilities
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCookie(URI resourceUri, jakarta.servlet.http.HttpServletResponse response, ApplicationCookieName applicationCookieName, String value) Generate cookie with specified valuevoidaddSessionCookie(URI resourceUri, jakarta.servlet.http.HttpServletResponse response, ApplicationCookieName applicationCookieName, String value) Generate cookie with session-based expiration and specified value as well as SameSite Strict propertyprotected org.springframework.http.ResponseCookie.ResponseCookieBuildergetCookieBuilder(URI resourceUri, ApplicationCookieName applicationCookieName, String value, Duration maxAge) Get Response Cookie Builder with standard propertiesprivate StringgetCookiePath(URI resourceUri) getCookieValue(jakarta.servlet.http.HttpServletRequest request, ApplicationCookieName applicationCookieName) Get cookie value using specified namevoidremoveCookie(URI resourceUri, jakarta.servlet.http.HttpServletResponse response, ApplicationCookieName applicationCookieName) Generate cookie with an empty value instructing the client to remove the cookie with a maximum age of 60 secondsprivate voidsetResponseCookie(jakarta.servlet.http.HttpServletResponse response, org.springframework.http.ResponseCookie responseCookie)
-
Field Details
-
MAX_AGE_SESSION
-
MAX_AGE_REMOVE
-
MAX_AGE_STANDARD
-
DEFAULT_PATH
- See Also:
-
SECURE_ENABLED
private static final boolean SECURE_ENABLED- See Also:
-
HTTP_ONLY_ENABLED
private static final boolean HTTP_ONLY_ENABLED- See Also:
-
logger
private static final org.slf4j.Logger logger
-
-
Constructor Details
-
StandardApplicationCookieService
public StandardApplicationCookieService()
-
-
Method Details
-
addCookie
public void addCookie(URI resourceUri, jakarta.servlet.http.HttpServletResponse response, ApplicationCookieName applicationCookieName, String value) Generate cookie with specified value- Specified by:
addCookiein interfaceApplicationCookieService- Parameters:
resourceUri- Resource URI containing path and domainresponse- HTTP Servlet ResponseapplicationCookieName- Application Cookie Name to be addedvalue- Cookie value to be added
-
addSessionCookie
public void addSessionCookie(URI resourceUri, jakarta.servlet.http.HttpServletResponse response, ApplicationCookieName applicationCookieName, String value) Generate cookie with session-based expiration and specified value as well as SameSite Strict property- Specified by:
addSessionCookiein interfaceApplicationCookieService- Parameters:
resourceUri- Resource URI containing path and domainresponse- HTTP Servlet ResponseapplicationCookieName- Application Cookie Namevalue- Cookie value to be added
-
getCookieValue
public Optional<String> getCookieValue(jakarta.servlet.http.HttpServletRequest request, ApplicationCookieName applicationCookieName) Get cookie value using specified name- Specified by:
getCookieValuein interfaceApplicationCookieService- Parameters:
request- HTTP Servlet ResponseapplicationCookieName- Application Cookie Name to be retrieved- Returns:
- Optional Cookie Value
-
removeCookie
public void removeCookie(URI resourceUri, jakarta.servlet.http.HttpServletResponse response, ApplicationCookieName applicationCookieName) Generate cookie with an empty value instructing the client to remove the cookie with a maximum age of 60 seconds- Specified by:
removeCookiein interfaceApplicationCookieService- Parameters:
resourceUri- Resource URI containing path and domainresponse- HTTP Servlet ResponseapplicationCookieName- Application Cookie Name to be removed
-
getCookieBuilder
protected org.springframework.http.ResponseCookie.ResponseCookieBuilder getCookieBuilder(URI resourceUri, ApplicationCookieName applicationCookieName, String value, Duration maxAge) Get Response Cookie Builder with standard properties- Parameters:
resourceUri- Resource URI containing path and domainapplicationCookieName- Application Cookie Name to be usedvalue- Cookie valuemaxAge- Max Age- Returns:
- Response Cookie Builder
-
setResponseCookie
private void setResponseCookie(jakarta.servlet.http.HttpServletResponse response, org.springframework.http.ResponseCookie responseCookie) -
getCookiePath
-