Package org.apache.catalina.core
Class SessionCookieConfigImpl
- java.lang.Object
-
- org.apache.catalina.core.SessionCookieConfigImpl
-
- All Implemented Interfaces:
jakarta.servlet.SessionCookieConfig
- Direct Known Subclasses:
WebSessionCookieConfig
public class SessionCookieConfigImpl extends Object implements jakarta.servlet.SessionCookieConfig
Class that may be used to configure various properties of cookies used for session tracking purposes.
-
-
Constructor Summary
Constructors Constructor Description SessionCookieConfigImpl(StandardContext ctx)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description StringgetAttribute(String name)Get the value for a given session cookie attribute.Map<String,String>getAttributes()Get all the session cookie attributes in case insensitive orderStringgetComment()Deprecated.StringgetDomain()intgetMaxAge()StringgetName()StringgetPath()booleanisHttpOnly()booleanisSecure()voidsetAttribute(String name, String value)Sets the value for the given session cookie attribute.voidsetComment(String comment)Deprecated.voidsetDomain(String domain)voidsetHttpOnly(boolean httpOnly)voidsetMaxAge(int maxAge)voidsetName(String name)voidsetPath(String path)voidsetSecure(boolean secure)
-
-
-
Constructor Detail
-
SessionCookieConfigImpl
public SessionCookieConfigImpl(StandardContext ctx)
Constructor
-
-
Method Detail
-
setName
public void setName(String name)
- Specified by:
setNamein interfacejakarta.servlet.SessionCookieConfig- Parameters:
name- the cookie name to use- Throws:
IllegalStateException- if theServletContextfrom which thisSessionCookieConfigwas acquired has already been initialized
-
getName
public String getName()
- Specified by:
getNamein interfacejakarta.servlet.SessionCookieConfig- Returns:
- the cookie name set via
setName(java.lang.String), orJSESSIONIDifsetName(java.lang.String)was never called
-
setDomain
public void setDomain(String domain)
- Specified by:
setDomainin interfacejakarta.servlet.SessionCookieConfig- Parameters:
domain- the cookie domain to use- Throws:
IllegalStateException- if theServletContextfrom which thisSessionCookieConfigwas acquired has already been initialized
-
getDomain
public String getDomain()
- Specified by:
getDomainin interfacejakarta.servlet.SessionCookieConfig- Returns:
- the cookie domain set via
setDomain(java.lang.String), ornullifsetDomain(java.lang.String)was never called
-
setPath
public void setPath(String path)
- Specified by:
setPathin interfacejakarta.servlet.SessionCookieConfig- Parameters:
path- the cookie path to use- Throws:
IllegalStateException- if theServletContextfrom which thisSessionCookieConfigwas acquired has already been initialized
-
getPath
public String getPath()
- Specified by:
getPathin interfacejakarta.servlet.SessionCookieConfig- Returns:
- the cookie path set via
setPath(java.lang.String), or the context path of theServletContextfrom which thisSessionCookieConfigwas acquired ifsetPath(java.lang.String)was never called
-
setComment
@Deprecated public void setComment(String comment)
Deprecated.- Specified by:
setCommentin interfacejakarta.servlet.SessionCookieConfig- Parameters:
comment- the cookie comment to use- Throws:
IllegalStateException- if theServletContextfrom which thisSessionCookieConfigwas acquired has already been initialized
-
getComment
@Deprecated public String getComment()
Deprecated.- Specified by:
getCommentin interfacejakarta.servlet.SessionCookieConfig- Returns:
- the cookie comment set via
setComment(java.lang.String), ornullifsetComment(java.lang.String)was never called
-
setHttpOnly
public void setHttpOnly(boolean httpOnly)
- Specified by:
setHttpOnlyin interfacejakarta.servlet.SessionCookieConfig- Parameters:
httpOnly- true if the session tracking cookies created on behalf of theServletContextfrom which thisSessionCookieConfigwas acquired shall be marked as HttpOnly, false otherwise- Throws:
IllegalStateException- if theServletContextfrom which thisSessionCookieConfigwas acquired has already been initialized
-
isHttpOnly
public boolean isHttpOnly()
- Specified by:
isHttpOnlyin interfacejakarta.servlet.SessionCookieConfig- Returns:
- true if the session tracking cookies created on behalf of the
ServletContextfrom which thisSessionCookieConfigwas acquired will be marked as HttpOnly, false otherwise
-
setSecure
public void setSecure(boolean secure)
- Specified by:
setSecurein interfacejakarta.servlet.SessionCookieConfig- Parameters:
secure- true if the session tracking cookies created on behalf of theServletContextfrom which thisSessionCookieConfigwas acquired shall be marked as secure even if the request that initiated the corresponding session is using plain HTTP instead of HTTPS, and false if they shall be marked as secure only if the request that initiated the corresponding session was also secure- Throws:
IllegalStateException- if theServletContextfrom which thisSessionCookieConfigwas acquired has already been initialized
-
isSecure
public boolean isSecure()
- Specified by:
isSecurein interfacejakarta.servlet.SessionCookieConfig- Returns:
- true if the session tracking cookies created on behalf of the
ServletContextfrom which thisSessionCookieConfigwas acquired will be marked as secure even if the request that initiated the corresponding session is using plain HTTP instead of HTTPS, and false if they will be marked as secure only if the request that initiated the corresponding session was also secure
-
setMaxAge
public void setMaxAge(int maxAge)
- Specified by:
setMaxAgein interfacejakarta.servlet.SessionCookieConfig
-
getMaxAge
public int getMaxAge()
- Specified by:
getMaxAgein interfacejakarta.servlet.SessionCookieConfig
-
setAttribute
public void setAttribute(String name, String value)
Sets the value for the given session cookie attribute.- Specified by:
setAttributein interfacejakarta.servlet.SessionCookieConfig- Parameters:
name- Name of attribute to set, case insensitivevalue- Value of attribute- Throws:
IllegalStateException- if the associated ServletContext has already been initializedIllegalArgumentException- If the attribute name is null or contains any characters not permitted for use in Cookie names.NumberFormatException- If the attribute is known to be numerical but the provided value cannot be parsed to a number.
-
getAttribute
public String getAttribute(String name)
Get the value for a given session cookie attribute.- Specified by:
getAttributein interfacejakarta.servlet.SessionCookieConfig- Parameters:
name- Name of attribute- Returns:
- Value of specified attribute
-
-