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
FieldsModifier and TypeFieldDescriptionstatic final longValue ofMax-Ageindicating no age expire and should expire with the browser session. -
Method Summary
Modifier and TypeMethodDescriptionaddExtension(String extension) Allows adding an extension.Clears the attributes.configure(Consumer<HttpResponseCookie> configurer) Enables configuring multiple attributes with reduced locking.Obtains the domain.Obtains the expire time.String[]Obtains the extensions.longObtains the maximum age in seconds.getName()Obtains the name.getPath()Obtains the path.getValue()Obtains the value.booleanIndicates if the Cookie is only sent over HTTP connection.booleanisSecure()Indicates if only communicated across secure a secure connection.Specifies the domain.setExpires(TemporalAccessor expires) Sets the expire time.setHttpOnly(boolean isHttpOnly) Indicates if only available over HTTP requests (and not, for example, made available to JavaScript in the browser).setMaxAge(long maxAge) Sets the maximum age in seconds.Specifies the path.setSecure(boolean isSecure) Flags whether the client is only to send the Cookie over a secure connection.Sets the value.
-
Field Details
-
BROWSER_SESSION_MAX_AGE
static final long BROWSER_SESSION_MAX_AGEValue ofMax-Ageindicating no age expire and should expire with the browser session.- See Also:
-
-
Method Details
-
getName
String getName()Obtains the name.- Returns:
- Name.
-
getValue
String getValue()Obtains the value.- Returns:
- Value.
-
setValue
Sets the value.- Parameters:
value- Value.- Returns:
- this.
-
getExpires
TemporalAccessor getExpires()Obtains the expire time.- Returns:
- Expire time. May be
nullif no expire.
-
setExpires
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
Sets the maximum age in seconds.
As per RFC 6265 this overrides
Expires.- Parameters:
maxAge- Maximum age in seconds.- Returns:
- this.
-
getDomain
String getDomain()Obtains the domain.- Returns:
- Domain. May be
null.
-
setDomain
Specifies the domain.- Parameters:
domain- Domain.- Returns:
- this.
-
getPath
String getPath()Obtains the path.- Returns:
- Path. May be
null.
-
setPath
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
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
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
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
String[] getExtensions()Obtains the extensions.- Returns:
- Extensions.
-
clearAttributes
HttpResponseCookie clearAttributes()Clears the attributes.- Returns:
- this.
-
configure
Enables configuring multiple attributes with reduced locking.- Parameters:
configurer-Consumerto configured theHttpResponseCookie.- Returns:
- this.
-