Class SessionCookieConfigImpl
- All Implemented Interfaces:
SessionConfig,SessionCookieConfig
- Author:
- Stuart Douglas
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.undertow.server.session.SessionConfig
SessionConfig.SessionCookieSource -
Field Summary
Fields inherited from interface io.undertow.server.session.SessionConfig
ATTACHMENT_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclearSession(HttpServerExchange exchange, String sessionId) Clears this session from the exchange, removing the attachment and making any changes to the response necessary, such as clearing cookies.findSessionId(HttpServerExchange exchange) Retrieves a session id of an existing session from an exchange.getAttribute(String name) Obtain the value for a given session cookie attribute.Obtain the Map (keys are case insensitive) of all attributes and values, including those set via the attribute specific setters, (excluding version) for this SessionCookieConfig.Deprecated.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.intGets 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.getName()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.getPath()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.booleanChecks 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.rewriteUrl(String originalUrl, String sessionid) sessionCookieSource(HttpServerExchange exchange) voidsetAttribute(String name, String value) Sets the value for the given session cookie attribute.voidsetComment(String comment) Deprecated.voidSets 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.voidsetFallback(SessionConfig fallback) 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.voidSets 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.voidSets 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.voidsetSessionId(HttpServerExchange exchange, String sessionId) Attaches the session to the exchange.
-
Constructor Details
-
SessionCookieConfigImpl
-
-
Method Details
-
rewriteUrl
- Specified by:
rewriteUrlin interfaceSessionConfig
-
setSessionId
Description copied from interface:SessionConfigAttaches the session to the exchange. The method should attach the exchange under an attachment key, and should also modify the exchange to allow the session to be re-attached on the next request.Generally this will involve setting a cookie
Once a session has been attached it must be possible to retrieve it via
SessionConfig.findSessionId(io.undertow.server.HttpServerExchange)- Specified by:
setSessionIdin interfaceSessionConfig- Parameters:
exchange- The exchangesessionId- The session
-
clearSession
Description copied from interface:SessionConfigClears this session from the exchange, removing the attachment and making any changes to the response necessary, such as clearing cookies.- Specified by:
clearSessionin interfaceSessionConfig- Parameters:
exchange- The exchangesessionId- The session id
-
findSessionId
Description copied from interface:SessionConfigRetrieves a session id of an existing session from an exchange.- Specified by:
findSessionIdin interfaceSessionConfig- Parameters:
exchange- The exchange- Returns:
- The session id, or null
-
sessionCookieSource
- Specified by:
sessionCookieSourcein interfaceSessionConfig
-
getName
Description copied from interface: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:
-
setName
Description copied from interface: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
-
getDomain
Description copied from interface: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:
-
setDomain
Description copied from interface: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:
-
getPath
Description copied from interface: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:
-
setPath
Description copied from interface: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:
-
getComment
Deprecated.Description copied from interface:SessionCookieConfigWith the adoption of support for RFC 6265, this method should no longer be used.- Specified by:
getCommentin interfaceSessionCookieConfig- Returns:
- Always
null - See Also:
-
setComment
Deprecated.Description copied from interface:SessionCookieConfigWith the adoption of support for RFC 6265, this method should no longer be used.If called, this method has no effect.
- Specified by:
setCommentin interfaceSessionCookieConfig- Parameters:
comment- ignore- See Also:
-
isHttpOnly
public boolean isHttpOnly()Description copied from interface: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:
-
setHttpOnly
public void setHttpOnly(boolean httpOnly) Description copied from interface: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:
-
isSecure
public boolean isSecure()Description copied from interface: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:
-
setSecure
public void setSecure(boolean secure) Description copied from interface: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:
-
getMaxAge
public int getMaxAge()Description copied from interface: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:
-
setMaxAge
public void setMaxAge(int maxAge) Description copied from interface: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:
-
getFallback
-
setFallback
-
setAttribute
Description copied from interface:SessionCookieConfigSets 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:
setAttributein interfaceSessionCookieConfig- Parameters:
name- Name of attribute to set, case insensitivevalue- Value of attribute
-
getAttribute
Description copied from interface:SessionCookieConfigObtain the value for a given session cookie 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:
getAttributein interfaceSessionCookieConfig- Parameters:
name- Name of attribute to return, case insensitive- Returns:
- Value of specified attribute
-
getAttributes
Description copied from interface:SessionCookieConfigObtain the Map (keys are case insensitive) of all attributes and values, including those set via the attribute specific setters, (excluding version) for this SessionCookieConfig.- Specified by:
getAttributesin interfaceSessionCookieConfig- Returns:
- A read-only Map of attributes to values, excluding version.
-