Class MockSessionCookieConfig
- java.lang.Object
- org.springframework.mock.web.MockSessionCookieConfig
- All Implemented Interfaces:
SessionCookieConfig
public class MockSessionCookieConfig extends Object implements SessionCookieConfig
Mock implementation of theSessionCookieConfiginterface.- Since:
- 4.0
- Author:
- Juergen Hoeller
- See Also:
ServletContext.getSessionCookieConfig()
Constructor Summary
Constructors Constructor Description MockSessionCookieConfig()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetComment()Gets the comment that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.StringgetDomain()Gets the domain name that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.intgetMaxAge()Gets the lifetime (in seconds) of the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.StringgetName()Gets the name that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.StringgetPath()Gets the path that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.booleanisHttpOnly()Checks if the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired will be marked as HttpOnly.booleanisSecure()Checks if the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired will be marked as secure even if the request that initiated the corresponding session is using plain HTTP instead of HTTPS.voidsetComment(String comment)Sets the comment that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.voidsetDomain(String domain)Sets the domain name that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.voidsetHttpOnly(boolean httpOnly)Marks or unmarks the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired as HttpOnly.voidsetMaxAge(int maxAge)Sets the lifetime (in seconds) for the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.voidsetName(String name)Sets the name that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.voidsetPath(String path)Sets the path that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.voidsetSecure(boolean secure)Marks or unmarks the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired as secure.
Constructor Detail
MockSessionCookieConfig
public MockSessionCookieConfig()
Method Detail
setName
public void setName(@Nullable String name)
Description copied from interface:javax.servlet.SessionCookieConfigSets the name that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.NOTE: Changing the name of session tracking cookies may break other tiers (for example, a load balancing frontend) that assume the cookie name to be equal to the default JSESSIONID, and therefore should only be done cautiously.
- Specified by:
setNamein interfaceSessionCookieConfig- Parameters:
name- the cookie name to use
getName
@Nullable public String getName()
Description copied from interface:javax.servlet.SessionCookieConfigGets the name that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.By default, JSESSIONID will be used as the cookie name.
- Specified by:
getNamein interfaceSessionCookieConfig- Returns:
- the cookie name set via
SessionCookieConfig.setName(java.lang.String), or null ifSessionCookieConfig.setName(java.lang.String)was never called - See Also:
Cookie.getName()
setDomain
public void setDomain(@Nullable String domain)
Description copied from interface:javax.servlet.SessionCookieConfigSets the domain name that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.- Specified by:
setDomainin interfaceSessionCookieConfig- Parameters:
domain- the cookie domain to use- See Also:
Cookie.setDomain(String)
getDomain
@Nullable public String getDomain()
Description copied from interface:javax.servlet.SessionCookieConfigGets the domain name that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.- Specified by:
getDomainin interfaceSessionCookieConfig- Returns:
- the cookie domain set via
SessionCookieConfig.setDomain(java.lang.String), or null ifSessionCookieConfig.setDomain(java.lang.String)was never called - See Also:
Cookie.getDomain()
setPath
public void setPath(@Nullable String path)
Description copied from interface:javax.servlet.SessionCookieConfigSets the path that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.- Specified by:
setPathin interfaceSessionCookieConfig- Parameters:
path- the cookie path to use- See Also:
Cookie.setPath(String)
getPath
@Nullable public String getPath()
Description copied from interface:javax.servlet.SessionCookieConfigGets the path that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.By default, the context path of the ServletContext from which this SessionCookieConfig was acquired will be used.
- Specified by:
getPathin interfaceSessionCookieConfig- Returns:
- the cookie path set via
SessionCookieConfig.setPath(java.lang.String), or null ifSessionCookieConfig.setPath(java.lang.String)was never called - See Also:
Cookie.getPath()
setComment
public void setComment(@Nullable String comment)
Description copied from interface:javax.servlet.SessionCookieConfigSets the comment that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.As a side effect of this call, the session tracking cookies will be marked with a
Versionattribute equal to1.- Specified by:
setCommentin interfaceSessionCookieConfig- Parameters:
comment- the cookie comment to use- See Also:
Cookie.setComment(String),Cookie.getVersion()
getComment
@Nullable public String getComment()
Description copied from interface:javax.servlet.SessionCookieConfigGets the comment that will be assigned to any session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.- Specified by:
getCommentin interfaceSessionCookieConfig- Returns:
- the cookie comment set via
SessionCookieConfig.setComment(java.lang.String), or null ifSessionCookieConfig.setComment(java.lang.String)was never called - See Also:
Cookie.getComment()
setHttpOnly
public void setHttpOnly(boolean httpOnly)
Description copied from interface:javax.servlet.SessionCookieConfigMarks or unmarks the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired as HttpOnly.A cookie is marked as HttpOnly by adding the HttpOnly attribute to it. HttpOnly cookies are not supposed to be exposed to client-side scripting code, and may therefore help mitigate certain kinds of cross-site scripting attacks.
- Specified by:
setHttpOnlyin interfaceSessionCookieConfig- Parameters:
httpOnly- true if the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired shall be marked as HttpOnly, false otherwise- See Also:
Cookie.setHttpOnly(boolean)
isHttpOnly
public boolean isHttpOnly()
Description copied from interface:javax.servlet.SessionCookieConfigChecks if the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired will be marked as HttpOnly.- Specified by:
isHttpOnlyin interfaceSessionCookieConfig- Returns:
- true if the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired will be marked as HttpOnly, false otherwise
- See Also:
Cookie.isHttpOnly()
setSecure
public void setSecure(boolean secure)
Description copied from interface:javax.servlet.SessionCookieConfigMarks or unmarks the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired as secure.One use case for marking a session tracking cookie as secure, even though the request that initiated the session came over HTTP, is to support a topology where the web container is front-ended by an SSL offloading load balancer. In this case, the traffic between the client and the load balancer will be over HTTPS, whereas the traffic between the load balancer and the web container will be over HTTP.
- Specified by:
setSecurein interfaceSessionCookieConfig- Parameters:
secure- true if the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was 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- See Also:
Cookie.setSecure(boolean),ServletRequest.isSecure()
isSecure
public boolean isSecure()
Description copied from interface:javax.servlet.SessionCookieConfigChecks if the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired will be marked as secure even if the request that initiated the corresponding session is using plain HTTP instead of HTTPS.- Specified by:
isSecurein interfaceSessionCookieConfig- Returns:
- true if the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was 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
- See Also:
Cookie.getSecure(),ServletRequest.isSecure()
setMaxAge
public void setMaxAge(int maxAge)
Description copied from interface:javax.servlet.SessionCookieConfigSets the lifetime (in seconds) for the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.- Specified by:
setMaxAgein interfaceSessionCookieConfig- Parameters:
maxAge- the lifetime (in seconds) of the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.- See Also:
Cookie.setMaxAge(int)
getMaxAge
public int getMaxAge()
Description copied from interface:javax.servlet.SessionCookieConfigGets the lifetime (in seconds) of the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired.By default, -1 is returned.
- Specified by:
getMaxAgein interfaceSessionCookieConfig- Returns:
- the lifetime (in seconds) of the session tracking cookies created on behalf of the application represented by the ServletContext from which this SessionCookieConfig was acquired, or -1 (the default)
- See Also:
Cookie.getMaxAge()