public final class CookieManager extends AbstractInitializableComponent
This bean centralizes settings related to cookie creation and access, and is parametrized by name so that multiple cookies may be managed with common properties.
Constructor and Description |
---|
CookieManager()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addCookie(String name,
String value)
Add a cookie with the specified name and value.
|
protected void |
doInitialize()
Performs the initialization of the component.
|
void |
setCookieDomain(String domain)
Set the cookie domain to use for session tracking.
|
void |
setCookiePath(String path)
Set the cookie path to use for session tracking.
|
void |
setHttpOnly(boolean flag)
Set the HttpOnly flag.
|
void |
setHttpServletRequest(HttpServletRequest request)
Set the servlet request to read from.
|
void |
setHttpServletResponse(HttpServletResponse response)
Set the servlet response to write to.
|
void |
setMaxAge(int age)
Maximum age in seconds, or -1 for per-session.
|
void |
setSecure(boolean flag)
Set the SSL-only flag.
|
void |
unsetCookie(String name)
Unsets a cookie with the specified name.
|
destroy, doDestroy, initialize, isDestroyed, isInitialized
public void setCookiePath(@Nullable String path)
Defaults to the servlet context path.
path
- cookie path to use, or null for the defaultpublic void setCookieDomain(@Nullable String domain)
domain
- the cookie domain to use, or null for the defaultpublic void setHttpServletRequest(@Nonnull HttpServletRequest request)
request
- servlet requestpublic void setHttpServletResponse(@Nonnull HttpServletResponse response)
response
- servlet responsepublic void setSecure(boolean flag)
flag
- flag to setpublic void setHttpOnly(boolean flag)
flag
- flag to setpublic void setMaxAge(int age)
age
- max age to setprotected void doInitialize() throws ComponentInitializationException
doInitialize
in class AbstractInitializableComponent
ComponentInitializationException
- thrown if there is a problem initializing the component@Nullable public void addCookie(@Nonnull @NotEmpty String name, @Nonnull @NotEmpty String value)
name
- name of cookievalue
- value of cookieCopyright © 2016 JBoss by Red Hat. All rights reserved.