Package org.apache.catalina.core
Class ApplicationSessionCookieConfig
- java.lang.Object
-
- org.apache.catalina.core.ApplicationSessionCookieConfig
-
- All Implemented Interfaces:
SessionCookieConfig
public class ApplicationSessionCookieConfig extends Object implements SessionCookieConfig
-
-
Constructor Summary
Constructors Constructor Description ApplicationSessionCookieConfig(StandardContext context)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Cookie
createSessionCookie(Context context, String sessionId, boolean secure)
Creates a new session cookie for the given session IDString
getAttribute(String name)
Obtain the value for a sesison cookie given attribute.Map<String,String>
getAttributes()
Obtain the Map of attributes and values (excluding version) for this session cookie.String
getComment()
With the adoption of support for RFC 6265, this method should no longer be used.String
getDomain()
Obtain the domain to use for session cookies.int
getMaxAge()
Obtain the maximum age to set for a session cookie.String
getName()
Obtain the name to use for the session cookies.String
getPath()
Obtain the path to use for session cookies.boolean
isHttpOnly()
Will session cookies be created with the httpOnly flag set?boolean
isSecure()
Will session cookies be created with the secure flag set?void
setAttribute(String name, String value)
Sets the value for the given session cookie attribute.void
setComment(String comment)
If called, this method has no effect.void
setDomain(String domain)
Sets the domain for the session cookievoid
setHttpOnly(boolean httpOnly)
Sets the httpOnly flag for the session cookie.void
setMaxAge(int maxAge)
Sets the maximum age.void
setName(String name)
Sets the session cookie name.void
setPath(String path)
Sets the path of the session cookie.void
setSecure(boolean secure)
Sets the secure flag for the session cookie.
-
-
-
Constructor Detail
-
ApplicationSessionCookieConfig
public ApplicationSessionCookieConfig(StandardContext context)
-
-
Method Detail
-
getComment
public String getComment()
Description copied from interface:jakarta.servlet.SessionCookieConfig
With the adoption of support for RFC 6265, this method should no longer be used.- Specified by:
getComment
in interfaceSessionCookieConfig
- Returns:
- always
null
-
getDomain
public String getDomain()
Description copied from interface:jakarta.servlet.SessionCookieConfig
Obtain the domain to use for session cookies.- Specified by:
getDomain
in interfaceSessionCookieConfig
- Returns:
- the domain to use for session cookies.
-
getMaxAge
public int getMaxAge()
Description copied from interface:jakarta.servlet.SessionCookieConfig
Obtain the maximum age to set for a session cookie.- Specified by:
getMaxAge
in interfaceSessionCookieConfig
- Returns:
- the maximum age in seconds
-
getName
public String getName()
Description copied from interface:jakarta.servlet.SessionCookieConfig
Obtain the name to use for the session cookies.- Specified by:
getName
in interfaceSessionCookieConfig
- Returns:
- the name to use for session cookies.
-
getPath
public String getPath()
Description copied from interface:jakarta.servlet.SessionCookieConfig
Obtain the path to use for session cookies. This is normally the context path.- Specified by:
getPath
in interfaceSessionCookieConfig
- Returns:
- The path to use for session cookies.
-
isHttpOnly
public boolean isHttpOnly()
Description copied from interface:jakarta.servlet.SessionCookieConfig
Will session cookies be created with the httpOnly flag set?- Specified by:
isHttpOnly
in interfaceSessionCookieConfig
- Returns:
true
if the flag should be set, otherwisefalse
-
isSecure
public boolean isSecure()
Description copied from interface:jakarta.servlet.SessionCookieConfig
Will session cookies be created with the secure flag set?- Specified by:
isSecure
in interfaceSessionCookieConfig
- Returns:
true
if the flag should be set, otherwisefalse
-
setComment
public void setComment(String comment)
Description copied from interface:jakarta.servlet.SessionCookieConfig
If called, this method has no effect.- Specified by:
setComment
in interfaceSessionCookieConfig
- Parameters:
comment
- Ignore
-
setDomain
public void setDomain(String domain)
Description copied from interface:jakarta.servlet.SessionCookieConfig
Sets the domain for the session cookie- Specified by:
setDomain
in interfaceSessionCookieConfig
- Parameters:
domain
- The session cookie domain
-
setHttpOnly
public void setHttpOnly(boolean httpOnly)
Description copied from interface:jakarta.servlet.SessionCookieConfig
Sets the httpOnly flag for the session cookie.- Specified by:
setHttpOnly
in interfaceSessionCookieConfig
- Parameters:
httpOnly
- The httpOnly setting to use for session cookies
-
setMaxAge
public void setMaxAge(int maxAge)
Description copied from interface:jakarta.servlet.SessionCookieConfig
Sets the maximum age.- Specified by:
setMaxAge
in interfaceSessionCookieConfig
- Parameters:
maxAge
- the maximum age to set
-
setName
public void setName(String name)
Description copied from interface:jakarta.servlet.SessionCookieConfig
Sets the session cookie name.- Specified by:
setName
in interfaceSessionCookieConfig
- Parameters:
name
- The name of the session cookie
-
setPath
public void setPath(String path)
Description copied from interface:jakarta.servlet.SessionCookieConfig
Sets the path of the session cookie.- Specified by:
setPath
in interfaceSessionCookieConfig
- Parameters:
path
- The session cookie path
-
setSecure
public void setSecure(boolean secure)
Description copied from interface:jakarta.servlet.SessionCookieConfig
Sets the secure flag for the session cookie.- Specified by:
setSecure
in interfaceSessionCookieConfig
- Parameters:
secure
- The secure setting to use for session cookies
-
setAttribute
public void setAttribute(String name, String value)
Description copied from interface:jakarta.servlet.SessionCookieConfig
Sets the value for the given session cookie attribute. When a value is set via this method, the value returned by the attribute specific getter (if any) must be consistent with the value set via this method.- Specified by:
setAttribute
in interfaceSessionCookieConfig
- Parameters:
name
- Name of attribute to setvalue
- Value of attribute
-
getAttribute
public String getAttribute(String name)
Description copied from interface:jakarta.servlet.SessionCookieConfig
Obtain the value for a sesison cookie given attribute. Values returned from this method must be consistent with the values set and returned by the attribute specific getters and setters in this class.- Specified by:
getAttribute
in interfaceSessionCookieConfig
- Parameters:
name
- Name of attribute to return- Returns:
- Value of specified attribute
-
getAttributes
public Map<String,String> getAttributes()
Description copied from interface:jakarta.servlet.SessionCookieConfig
Obtain the Map of attributes and values (excluding version) for this session cookie.- Specified by:
getAttributes
in interfaceSessionCookieConfig
- Returns:
- A read-only Map of attributes to values, excluding version.
-
createSessionCookie
public static Cookie createSessionCookie(Context context, String sessionId, boolean secure)
Creates a new session cookie for the given session ID- Parameters:
context
- The Context for the web applicationsessionId
- The ID of the session for which the cookie will be createdsecure
- Should session cookie be configured as secure- Returns:
- the cookie for the session
-
-