Package net.officefloor.server.http
Interface HttpResponseCookie
-
- All Known Implementing Classes:
WritableHttpCookie
public interface HttpResponseCookie
Cookie to send in the
HttpResponse
.Cookie follows RFC 6265
- Author:
- Daniel Sagenschneider
-
-
Field Summary
Fields Modifier and Type Field Description static long
BROWSER_SESSION_MAX_AGE
Value ofMax-Age
indicating no age expire and should expire with the browser session.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description HttpResponseCookie
addExtension(java.lang.String extension)
Allows adding an extension.HttpResponseCookie
clearAttributes()
Clears the attributes.HttpResponseCookie
configure(java.util.function.Consumer<HttpResponseCookie> configurer)
Enables configuring multiple attributes with reduced locking.java.lang.String
getDomain()
Obtains the domain.java.time.temporal.TemporalAccessor
getExpires()
Obtains the expire time.java.lang.String[]
getExtensions()
Obtains the extensions.long
getMaxAge()
Obtains the maximum age in seconds.java.lang.String
getName()
Obtains the name.java.lang.String
getPath()
Obtains the path.java.lang.String
getValue()
Obtains the value.boolean
isHttpOnly()
Indicates if the Cookie is only sent over HTTP connection.boolean
isSecure()
Indicates if only communicated across secure a secure connection.HttpResponseCookie
setDomain(java.lang.String domain)
Specifies the domain.HttpResponseCookie
setExpires(java.time.temporal.TemporalAccessor expires)
Sets the expire time.HttpResponseCookie
setHttpOnly(boolean isHttpOnly)
Indicates if only available over HTTP requests (and not, for example, made available to JavaScript in the browser).HttpResponseCookie
setMaxAge(long maxAge)
Sets the maximum age in seconds.HttpResponseCookie
setPath(java.lang.String path)
Specifies the path.HttpResponseCookie
setSecure(boolean isSecure)
Flags whether the client is only to send the Cookie over a secure connection.HttpResponseCookie
setValue(java.lang.String value)
Sets the value.
-
-
-
Field Detail
-
BROWSER_SESSION_MAX_AGE
static final long BROWSER_SESSION_MAX_AGE
Value ofMax-Age
indicating no age expire and should expire with the browser session.- See Also:
- Constant Field Values
-
-
Method Detail
-
getName
java.lang.String getName()
Obtains the name.- Returns:
- Name.
-
getValue
java.lang.String getValue()
Obtains the value.- Returns:
- Value.
-
setValue
HttpResponseCookie setValue(java.lang.String value)
Sets the value.- Parameters:
value
- Value.- Returns:
- this.
-
getExpires
java.time.temporal.TemporalAccessor getExpires()
Obtains the expire time.- Returns:
- Expire time. May be
null
if no expire.
-
setExpires
HttpResponseCookie setExpires(java.time.temporal.TemporalAccessor expires)
Sets the expire time.- Parameters:
expires
- Expires time.- Returns:
- this.
-
getMaxAge
long getMaxAge()
Obtains the maximum age in seconds.- Returns:
- Maximum age in seconds. Will be
BROWSER_SESSION_MAX_AGE
if not specified.
-
setMaxAge
HttpResponseCookie setMaxAge(long maxAge)
Sets the maximum age in seconds.
As per RFC 6265 this overrides
Expires
.- Parameters:
maxAge
- Maximum age in seconds.- Returns:
- this.
-
getDomain
java.lang.String getDomain()
Obtains the domain.- Returns:
- Domain. May be
null
.
-
setDomain
HttpResponseCookie setDomain(java.lang.String domain)
Specifies the domain.- Parameters:
domain
- Domain.- Returns:
- this.
-
getPath
java.lang.String getPath()
Obtains the path.- Returns:
- Path. May be
null
.
-
setPath
HttpResponseCookie setPath(java.lang.String path)
Specifies the path.- Parameters:
path
- Path.- Returns:
- this.
-
isSecure
boolean isSecure()
Indicates if only communicated across secure a secure connection.
Note that, as per RFC 6265, this does not guarantee the security of the cookie contents. Cookies, as per the specification, are inherently insecure (such as any information sent to the client).
- Returns:
true
to only communicate this Cookie across a secure connection.
-
setSecure
HttpResponseCookie setSecure(boolean isSecure)
Flags whether the client is only to send the Cookie over a secure connection.- Parameters:
isSecure
-true
to request the client to only send this Cookie over a secure connection (assuming the client supports this).- Returns:
- this.
-
isHttpOnly
boolean isHttpOnly()
Indicates if the Cookie is only sent over HTTP connection.- Returns:
true
to only make this Cookie available in HTTP requests.
-
setHttpOnly
HttpResponseCookie setHttpOnly(boolean isHttpOnly)
Indicates if only available over HTTP requests (and not, for example, made available to JavaScript in the browser).- Parameters:
isHttpOnly
-true
to request the client to only send this Cookie in HTTP requests, and not, for example, make available to JavaScript in the browser.- Returns:
- this.
-
addExtension
HttpResponseCookie addExtension(java.lang.String extension)
Allows adding an extension.
The extensions are added as provided (separated by ';') to the end of the
Set-Cookie
HttpHeader
.- Parameters:
extension
- Extension.- Returns:
- this.
-
getExtensions
java.lang.String[] getExtensions()
Obtains the extensions.- Returns:
- Extensions.
-
clearAttributes
HttpResponseCookie clearAttributes()
Clears the attributes.- Returns:
- this.
-
configure
HttpResponseCookie configure(java.util.function.Consumer<HttpResponseCookie> configurer)
Enables configuring multiple attributes with reduced locking.- Parameters:
configurer
-Consumer
to configured theHttpResponseCookie
.- Returns:
- this.
-
-