Package org.apache.shiro.web.servlet
Class SimpleCookie
- java.lang.Object
-
- org.apache.shiro.web.servlet.SimpleCookie
-
- All Implemented Interfaces:
Cookie
public class SimpleCookie extends Object implements Cookie
DefaultCookieimplementation. 'HttpOnly' is supported out of the box, even on Servlet2.4and2.5container implementations, using raw header writing logic and notjavax.servlet.http.Cookieobjects (which only has 'HttpOnly' support in Servlet2.6specifications and above).- Since:
- 1.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.shiro.web.servlet.Cookie
Cookie.SameSiteOptions
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringATTRIBUTE_DELIMITERprotected static StringCOMMENT_ATTRIBUTE_NAMEprotected static StringCOOKIE_DATE_FORMAT_STRINGprotected static StringCOOKIE_HEADER_NAMEprotected static longDAY_MILLISstatic intDEFAULT_MAX_AGE-1, indicating the cookie should expire when the browser closes.static intDEFAULT_VERSION-1indicating that no version property should be set on the cookie.protected static StringDOMAIN_ATTRIBUTE_NAMEprotected static StringEXPIRES_ATTRIBUTE_NAMEprotected static StringGMT_TIME_ZONE_IDprotected static StringHTTP_ONLY_ATTRIBUTE_NAMEprotected static StringMAXAGE_ATTRIBUTE_NAMEprotected static StringNAME_VALUE_DELIMITERprotected static StringPATH_ATTRIBUTE_NAMEprotected static StringSAME_SITE_ATTRIBUTE_NAMEprotected static StringSECURE_ATTRIBUTE_NAMEprotected static StringVERSION_ATTRIBUTE_NAME-
Fields inherited from interface org.apache.shiro.web.servlet.Cookie
DELETED_COOKIE_VALUE, ONE_YEAR, ROOT_PATH
-
-
Constructor Summary
Constructors Constructor Description SimpleCookie()SimpleCookie(String name)SimpleCookie(Cookie cookie)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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)StringgetComment()StringgetDomain()intgetMaxAge()StringgetName()StringgetPath()Cookie.SameSiteOptionsgetSameSite()StringgetValue()intgetVersion()booleanisHttpOnly()booleanisSecure()StringreadValue(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)voidsetDomain(String domain)voidsetHttpOnly(boolean httpOnly)voidsetMaxAge(int maxAge)voidsetName(String name)voidsetPath(String path)voidsetSameSite(Cookie.SameSiteOptions sameSite)voidsetSecure(boolean secure)voidsetValue(String value)voidsetVersion(int version)
-
-
-
Field Detail
-
DEFAULT_MAX_AGE
public static final int DEFAULT_MAX_AGE
-1, indicating the cookie should expire when the browser closes.- See Also:
- Constant Field Values
-
DEFAULT_VERSION
public static final int DEFAULT_VERSION
-1indicating that no version property should be set on the cookie.- See Also:
- Constant Field Values
-
NAME_VALUE_DELIMITER
protected static final String NAME_VALUE_DELIMITER
- See Also:
- Constant Field Values
-
ATTRIBUTE_DELIMITER
protected static final String ATTRIBUTE_DELIMITER
- See Also:
- Constant Field Values
-
DAY_MILLIS
protected static final long DAY_MILLIS
- See Also:
- Constant Field Values
-
GMT_TIME_ZONE_ID
protected static final String GMT_TIME_ZONE_ID
- See Also:
- Constant Field Values
-
COOKIE_DATE_FORMAT_STRING
protected static final String COOKIE_DATE_FORMAT_STRING
- See Also:
- Constant Field Values
-
COOKIE_HEADER_NAME
protected static final String COOKIE_HEADER_NAME
- See Also:
- Constant Field Values
-
PATH_ATTRIBUTE_NAME
protected static final String PATH_ATTRIBUTE_NAME
- See Also:
- Constant Field Values
-
EXPIRES_ATTRIBUTE_NAME
protected static final String EXPIRES_ATTRIBUTE_NAME
- See Also:
- Constant Field Values
-
MAXAGE_ATTRIBUTE_NAME
protected static final String MAXAGE_ATTRIBUTE_NAME
- See Also:
- Constant Field Values
-
DOMAIN_ATTRIBUTE_NAME
protected static final String DOMAIN_ATTRIBUTE_NAME
- See Also:
- Constant Field Values
-
VERSION_ATTRIBUTE_NAME
protected static final String VERSION_ATTRIBUTE_NAME
- See Also:
- Constant Field Values
-
COMMENT_ATTRIBUTE_NAME
protected static final String COMMENT_ATTRIBUTE_NAME
- See Also:
- Constant Field Values
-
SECURE_ATTRIBUTE_NAME
protected static final String SECURE_ATTRIBUTE_NAME
- See Also:
- Constant Field Values
-
HTTP_ONLY_ATTRIBUTE_NAME
protected static final String HTTP_ONLY_ATTRIBUTE_NAME
- See Also:
- Constant Field Values
-
SAME_SITE_ATTRIBUTE_NAME
protected static final String SAME_SITE_ATTRIBUTE_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
getComment
public String getComment()
- Specified by:
getCommentin interfaceCookie
-
setComment
public void setComment(String comment)
- Specified by:
setCommentin interfaceCookie
-
getVersion
public int getVersion()
- Specified by:
getVersionin interfaceCookie
-
setVersion
public void setVersion(int version)
- Specified by:
setVersionin interfaceCookie
-
isHttpOnly
public boolean isHttpOnly()
- Specified by:
isHttpOnlyin interfaceCookie
-
setHttpOnly
public void setHttpOnly(boolean httpOnly)
- Specified by:
setHttpOnlyin interfaceCookie
-
getSameSite
public Cookie.SameSiteOptions getSameSite()
- Specified by:
getSameSitein interfaceCookie
-
setSameSite
public void setSameSite(Cookie.SameSiteOptions sameSite)
- Specified by:
setSameSitein interfaceCookie
-
saveTo
public void saveTo(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
-
buildHeaderValue
protected String buildHeaderValue(String name, String value, String comment, String domain, String path, int maxAge, int version, boolean secure, boolean httpOnly)
-
buildHeaderValue
protected String buildHeaderValue(String name, String value, String comment, String domain, String path, int maxAge, int version, boolean secure, boolean httpOnly, Cookie.SameSiteOptions sameSite)
-
removeFrom
public void removeFrom(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)- Specified by:
removeFromin interfaceCookie
-
-