Package org.apache.shiro.web.servlet
Class SimpleCookie
java.lang.Object
org.apache.shiro.web.servlet.SimpleCookie
- All Implemented Interfaces:
Cookie
Default
Cookie implementation. 'HttpOnly' is supported out of the box, even on
Servlet 2.4 and 2.5 container implementations, using raw header writing logic and not
javax.servlet.http.Cookie objects (which only has 'HttpOnly' support in Servlet
2.6 specifications and above).- Since:
- 1.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.shiro.web.servlet.Cookie
Cookie.SameSiteOptions -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final longstatic final int-1, indicating the cookie should expire when the browser closes.static final int-1indicating that no version property should be set on the cookie.protected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final StringFields inherited from interface org.apache.shiro.web.servlet.Cookie
DELETED_COOKIE_VALUE, ONE_YEAR, ROOT_PATH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringbuildHeaderValue(String name, String value, String comment, String domain, String path, int maxAge, int version, boolean secure, boolean httpOnly) protected StringbuildHeaderValue(String name, String value, String comment, String domain, String path, int maxAge, int version, boolean secure, boolean httpOnly, Cookie.SameSiteOptions sameSite) intgetName()getPath()getValue()intbooleanbooleanisSecure()readValue(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse ignored) voidremoveFrom(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) voidsaveTo(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) voidsetComment(String comment) voidvoidsetHttpOnly(boolean httpOnly) voidsetMaxAge(int maxAge) voidvoidvoidsetSameSite(Cookie.SameSiteOptions sameSite) voidsetSecure(boolean secure) voidvoidsetVersion(int version)
-
Field Details
-
DEFAULT_MAX_AGE
public static final int DEFAULT_MAX_AGE-1, indicating the cookie should expire when the browser closes.- See Also:
-
DEFAULT_VERSION
public static final int DEFAULT_VERSION-1indicating that no version property should be set on the cookie.- See Also:
-
NAME_VALUE_DELIMITER
- See Also:
-
ATTRIBUTE_DELIMITER
- See Also:
-
DAY_MILLIS
protected static final long DAY_MILLIS- See Also:
-
GMT_TIME_ZONE_ID
- See Also:
-
COOKIE_DATE_FORMAT_STRING
- See Also:
-
COOKIE_HEADER_NAME
- See Also:
-
PATH_ATTRIBUTE_NAME
- See Also:
-
EXPIRES_ATTRIBUTE_NAME
- See Also:
-
MAXAGE_ATTRIBUTE_NAME
- See Also:
-
DOMAIN_ATTRIBUTE_NAME
- See Also:
-
VERSION_ATTRIBUTE_NAME
- See Also:
-
COMMENT_ATTRIBUTE_NAME
- See Also:
-
SECURE_ATTRIBUTE_NAME
- See Also:
-
HTTP_ONLY_ATTRIBUTE_NAME
- See Also:
-
SAME_SITE_ATTRIBUTE_NAME
- See Also:
-
-
Constructor Details
-
SimpleCookie
public SimpleCookie() -
SimpleCookie
-
SimpleCookie
-
-
Method Details
-
getName
-
setName
-
getValue
-
setValue
-
getComment
- Specified by:
getCommentin interfaceCookie
-
setComment
- Specified by:
setCommentin interfaceCookie
-
getDomain
-
setDomain
-
getPath
-
setPath
-
getMaxAge
public int getMaxAge() -
setMaxAge
public void setMaxAge(int maxAge) -
getVersion
public int getVersion()- Specified by:
getVersionin interfaceCookie
-
setVersion
public void setVersion(int version) - Specified by:
setVersionin interfaceCookie
-
isSecure
public boolean isSecure() -
setSecure
public void setSecure(boolean secure) -
isHttpOnly
public boolean isHttpOnly()- Specified by:
isHttpOnlyin interfaceCookie
-
setHttpOnly
public void setHttpOnly(boolean httpOnly) - Specified by:
setHttpOnlyin interfaceCookie
-
getSameSite
- Specified by:
getSameSitein interfaceCookie
-
setSameSite
- Specified by:
setSameSitein interfaceCookie
-
saveTo
public void saveTo(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) -
buildHeaderValue
-
buildHeaderValue
-
removeFrom
public void removeFrom(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) - Specified by:
removeFromin interfaceCookie
-
readValue
public String readValue(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse ignored)
-