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
DefaultCookie
implementation. 'HttpOnly' is supported out of the box, even on Servlet2.4
and2.5
container implementations, using raw header writing logic and notjavax.servlet.http.Cookie
objects (which only has 'HttpOnly' support in Servlet2.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
Fields Modifier and Type Field Description protected static String
ATTRIBUTE_DELIMITER
protected static String
COMMENT_ATTRIBUTE_NAME
protected static String
COOKIE_DATE_FORMAT_STRING
protected static String
COOKIE_HEADER_NAME
protected static long
DAY_MILLIS
static int
DEFAULT_MAX_AGE
-1
, indicating the cookie should expire when the browser closes.static int
DEFAULT_VERSION
-1
indicating that no version property should be set on the cookie.protected static String
DOMAIN_ATTRIBUTE_NAME
protected static String
EXPIRES_ATTRIBUTE_NAME
protected static String
GMT_TIME_ZONE_ID
protected static String
HTTP_ONLY_ATTRIBUTE_NAME
protected static String
MAXAGE_ATTRIBUTE_NAME
protected static String
NAME_VALUE_DELIMITER
protected static String
PATH_ATTRIBUTE_NAME
protected static String
SAME_SITE_ATTRIBUTE_NAME
protected static String
SECURE_ATTRIBUTE_NAME
protected static String
VERSION_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 String
buildHeaderValue(String name, String value, String comment, String domain, String path, int maxAge, int version, boolean secure, boolean httpOnly)
protected String
buildHeaderValue(String name, String value, String comment, String domain, String path, int maxAge, int version, boolean secure, boolean httpOnly, Cookie.SameSiteOptions sameSite)
String
getComment()
String
getDomain()
int
getMaxAge()
String
getName()
String
getPath()
Cookie.SameSiteOptions
getSameSite()
String
getValue()
int
getVersion()
boolean
isHttpOnly()
boolean
isSecure()
String
readValue(HttpServletRequest request, HttpServletResponse ignored)
void
removeFrom(HttpServletRequest request, HttpServletResponse response)
void
saveTo(HttpServletRequest request, HttpServletResponse response)
void
setComment(String comment)
void
setDomain(String domain)
void
setHttpOnly(boolean httpOnly)
void
setMaxAge(int maxAge)
void
setName(String name)
void
setPath(String path)
void
setSameSite(Cookie.SameSiteOptions sameSite)
void
setSecure(boolean secure)
void
setValue(String value)
void
setVersion(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
-1
indicating 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
-
-
Constructor Detail
-
SimpleCookie
public SimpleCookie()
-
SimpleCookie
public SimpleCookie(String name)
-
SimpleCookie
public SimpleCookie(Cookie cookie)
-
-
Method Detail
-
getComment
public String getComment()
- Specified by:
getComment
in interfaceCookie
-
setComment
public void setComment(String comment)
- Specified by:
setComment
in interfaceCookie
-
getVersion
public int getVersion()
- Specified by:
getVersion
in interfaceCookie
-
setVersion
public void setVersion(int version)
- Specified by:
setVersion
in interfaceCookie
-
isHttpOnly
public boolean isHttpOnly()
- Specified by:
isHttpOnly
in interfaceCookie
-
setHttpOnly
public void setHttpOnly(boolean httpOnly)
- Specified by:
setHttpOnly
in interfaceCookie
-
getSameSite
public Cookie.SameSiteOptions getSameSite()
- Specified by:
getSameSite
in interfaceCookie
-
setSameSite
public void setSameSite(Cookie.SameSiteOptions sameSite)
- Specified by:
setSameSite
in interfaceCookie
-
saveTo
public void saveTo(HttpServletRequest request, 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(HttpServletRequest request, HttpServletResponse response)
- Specified by:
removeFrom
in interfaceCookie
-
readValue
public String readValue(HttpServletRequest request, HttpServletResponse ignored)
-
-