public class DefaultCookieSerializer extends java.lang.Object implements CookieSerializer
CookieSerializer
.CookieSerializer.CookieValue
Constructor and Description |
---|
DefaultCookieSerializer() |
Modifier and Type | Method and Description |
---|---|
java.util.List<java.lang.String> |
readCookieValues(HttpServletRequest request)
Reads all the matching cookies from the
HttpServletRequest . |
void |
setCookieMaxAge(int cookieMaxAge)
Sets the maxAge property of the Cookie.
|
void |
setCookieName(java.lang.String cookieName) |
void |
setCookiePath(java.lang.String cookiePath)
Sets the path of the Cookie.
|
void |
setDomainName(java.lang.String domainName)
Sets an explicit Domain Name.
|
void |
setDomainNamePattern(java.lang.String domainNamePattern)
Sets a case insensitive pattern used to extract the domain name from the
ServletRequest.getServerName() . |
void |
setJvmRoute(java.lang.String jvmRoute)
Used to identify which JVM to route to for session affinity.
|
void |
setRememberMeRequestAttribute(java.lang.String rememberMeRequestAttribute)
Set the request attribute name that indicates remember-me login.
|
void |
setUseBase64Encoding(boolean useBase64Encoding)
Set if the Base64 encoding of cookie value should be used.
|
void |
setUseHttpOnlyCookie(boolean useHttpOnlyCookie)
Sets if a Cookie marked as HTTP Only should be used.
|
void |
setUseSecureCookie(boolean useSecureCookie)
Sets if a Cookie marked as secure should be used.
|
void |
writeCookieValue(CookieSerializer.CookieValue cookieValue)
Writes a given
CookieSerializer.CookieValue to the provided HttpServletResponse . |
public java.util.List<java.lang.String> readCookieValues(HttpServletRequest request)
CookieSerializer
HttpServletRequest
. The result is a
List since there can be multiple Cookie
in a single request with a matching
name. For example, one Cookie may have a path of / and another of /context, but the
path is not transmitted in the request.readCookieValues
in interface CookieSerializer
request
- the HttpServletRequest
to read the cookie from. Cannot be
null.public void writeCookieValue(CookieSerializer.CookieValue cookieValue)
CookieSerializer
CookieSerializer.CookieValue
to the provided HttpServletResponse
.writeCookieValue
in interface CookieSerializer
cookieValue
- the CookieSerializer.CookieValue
to write to
CookieSerializer.CookieValue.getResponse()
. Cannot be null.public void setUseSecureCookie(boolean useSecureCookie)
ServletRequest.isSecure()
.useSecureCookie
- determines if the cookie should be marked as secure.public void setUseHttpOnlyCookie(boolean useHttpOnlyCookie)
useHttpOnlyCookie
- determines if the cookie should be marked as HTTP Only.public void setCookiePath(java.lang.String cookiePath)
HttpServletRequest
.cookiePath
- the path of the Cookie. If null, the default of the context path
will be used.public void setCookieName(java.lang.String cookieName)
public void setCookieMaxAge(int cookieMaxAge)
cookieMaxAge
- the maxAge property of the Cookiepublic void setDomainName(java.lang.String domainName)
domainName
- the name of the domain to use. (i.e. "example.com")java.lang.IllegalStateException
- if the domainNamePattern is also setpublic void setDomainNamePattern(java.lang.String domainNamePattern)
Sets a case insensitive pattern used to extract the domain name from the
ServletRequest.getServerName()
. The pattern should provide a single
grouping that defines what the value is that should be matched. User's should be
careful not to output malicious characters like new lines to prevent from things
like HTTP
Response Splitting.
If the pattern does not match, then no domain will be set. This is useful to ensure the domain is not set during development when localhost might be used.
An example value might be "^.+?\\.(\\w+\\.[a-z]+)$". For the given input, it would provide the following explicit domain (null means no domain name is set):
domainNamePattern
- the case insensitive pattern to extract the domain name
withjava.lang.IllegalStateException
- if the domainName is also setpublic void setJvmRoute(java.lang.String jvmRoute)
Used to identify which JVM to route to for session affinity. With some implementations (i.e. Redis) this provides no performance benefit. However, this can help with tracing logs of a particular user. This will ensure that the value of the cookie is formatted as
sessionId + "." jvmRoute
To use set a custom route on each JVM instance and setup a frontend proxy to forward all requests to the JVM based on the route.
jvmRoute
- the JVM Route to use (i.e. "node01jvmA", "n01ja", etc)public void setUseBase64Encoding(boolean useBase64Encoding)
useBase64Encoding
- the flag to indicate whether to use Base64 encodingpublic void setRememberMeRequestAttribute(java.lang.String rememberMeRequestAttribute)
rememberMeRequestAttribute
- the remember-me request attribute name