|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.web.util.CookieGenerator
public class CookieGenerator
Helper class for cookie generation, carrying cookie descriptor settings as bean properties and being able to add and remove cookie to/from a given response.
Can serve as base class for components that generate specific cookies, like CookieLocaleResolcer and CookieThemeResolver.
addCookie(javax.servlet.http.HttpServletResponse, java.lang.String)
,
removeCookie(javax.servlet.http.HttpServletResponse)
,
CookieLocaleResolver
,
CookieThemeResolver
Field Summary | |
---|---|
static int |
DEFAULT_COOKIE_MAX_AGE
Deprecated. in favor of setting no max age value at all in such a case |
static String |
DEFAULT_COOKIE_PATH
Default path that cookies will be visible to: "/", i.e. |
protected Log |
logger
|
Constructor Summary | |
---|---|
CookieGenerator()
|
Method Summary | |
---|---|
void |
addCookie(HttpServletResponse response,
String cookieValue)
Add a cookie with the given value to the response, using the cookie descriptor settings of this generator. |
protected Cookie |
createCookie(String cookieValue)
Create a cookie with the given value, using the cookie descriptor settings of this generator (except for "cookieMaxAge"). |
String |
getCookieDomain()
Return the domain for cookies created by this generator, if any. |
Integer |
getCookieMaxAge()
Return the maximum age for cookies created by this generator. |
String |
getCookieName()
Return the given name for cookies created by this generator. |
String |
getCookiePath()
Return the path for cookies created by this generator. |
boolean |
isCookieHttpOnly()
Return whether the cookie is supposed to be marked with the "HttpOnly" attribute. |
boolean |
isCookieSecure()
Return whether the cookie should only be sent using a secure protocol, such as HTTPS (SSL). |
void |
removeCookie(HttpServletResponse response)
Remove the cookie that this generator describes from the response. |
void |
setCookieDomain(String cookieDomain)
Use the given domain for cookies created by this generator. |
void |
setCookieHttpOnly(boolean cookieHttpOnly)
Set whether the cookie is supposed to be marked with the "HttpOnly" attribute. |
void |
setCookieMaxAge(Integer cookieMaxAge)
Use the given maximum age (in seconds) for cookies created by this generator. |
void |
setCookieName(String cookieName)
Use the given name for cookies created by this generator. |
void |
setCookiePath(String cookiePath)
Use the given path for cookies created by this generator. |
void |
setCookieSecure(boolean cookieSecure)
Set whether the cookie should only be sent using a secure protocol, such as HTTPS (SSL). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULT_COOKIE_PATH
@Deprecated public static final int DEFAULT_COOKIE_MAX_AGE
protected final Log logger
Constructor Detail |
---|
public CookieGenerator()
Method Detail |
---|
public void setCookieName(String cookieName)
Cookie.getName()
public String getCookieName()
public void setCookieDomain(String cookieDomain)
Cookie.setDomain(java.lang.String)
public String getCookieDomain()
public void setCookiePath(String cookiePath)
Cookie.setPath(java.lang.String)
public String getCookiePath()
public void setCookieMaxAge(Integer cookieMaxAge)
Cookie.setMaxAge(int)
public Integer getCookieMaxAge()
public void setCookieSecure(boolean cookieSecure)
Cookie.setSecure(boolean)
public boolean isCookieSecure()
public void setCookieHttpOnly(boolean cookieHttpOnly)
Note that this feature is only available on Servlet 3.0 and higher.
javax.servlet.http.Cookie#setHttpOnly
public boolean isCookieHttpOnly()
public void addCookie(HttpServletResponse response, String cookieValue)
Delegates to createCookie(java.lang.String)
for cookie creation.
response
- the HTTP response to add the cookie tocookieValue
- the value of the cookie to addsetCookieName(java.lang.String)
,
setCookieDomain(java.lang.String)
,
setCookiePath(java.lang.String)
,
setCookieMaxAge(java.lang.Integer)
public void removeCookie(HttpServletResponse response)
Delegates to createCookie(java.lang.String)
for cookie creation.
response
- the HTTP response to remove the cookie fromsetCookieName(java.lang.String)
,
setCookieDomain(java.lang.String)
,
setCookiePath(java.lang.String)
protected Cookie createCookie(String cookieValue)
cookieValue
- the value of the cookie to crate
setCookieName(java.lang.String)
,
setCookieDomain(java.lang.String)
,
setCookiePath(java.lang.String)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |