Package net.officefloor.server.http
Interface HttpResponseCookie
-
- All Known Implementing Classes:
WritableHttpCookie
public interface HttpResponseCookieCookie to send in the
HttpResponse.Cookie follows RFC 6265
- Author:
- Daniel Sagenschneider
-
-
Field Summary
Fields Modifier and Type Field Description static longBROWSER_SESSION_MAX_AGEValue ofMax-Ageindicating no age expire and should expire with the browser session.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description HttpResponseCookieaddExtension(java.lang.String extension)Allows adding an extension.HttpResponseCookieclearAttributes()Clears the attributes.HttpResponseCookieconfigure(java.util.function.Consumer<HttpResponseCookie> configurer)Enables configuring multiple attributes with reduced locking.java.lang.StringgetDomain()Obtains the domain.java.time.temporal.TemporalAccessorgetExpires()Obtains the expire time.java.lang.String[]getExtensions()Obtains the extensions.longgetMaxAge()Obtains the maximum age in seconds.java.lang.StringgetName()Obtains the name.java.lang.StringgetPath()Obtains the path.java.lang.StringgetValue()Obtains the value.booleanisHttpOnly()Indicates if the Cookie is only sent over HTTP connection.booleanisSecure()Indicates if only communicated across secure a secure connection.HttpResponseCookiesetDomain(java.lang.String domain)Specifies the domain.HttpResponseCookiesetExpires(java.time.temporal.TemporalAccessor expires)Sets the expire time.HttpResponseCookiesetHttpOnly(boolean isHttpOnly)Indicates if only available over HTTP requests (and not, for example, made available to JavaScript in the browser).HttpResponseCookiesetMaxAge(long maxAge)Sets the maximum age in seconds.HttpResponseCookiesetPath(java.lang.String path)Specifies the path.HttpResponseCookiesetSecure(boolean isSecure)Flags whether the client is only to send the Cookie over a secure connection.HttpResponseCookiesetValue(java.lang.String value)Sets the value.
-
-
-
Field Detail
-
BROWSER_SESSION_MAX_AGE
static final long BROWSER_SESSION_MAX_AGE
Value ofMax-Ageindicating 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
nullif 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_AGEif 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:
trueto 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-trueto 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:
trueto 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-trueto 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-CookieHttpHeader.- 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-Consumerto configured theHttpResponseCookie.- Returns:
- this.
-
-