Package net.officefloor.server.http
Class WritableHttpCookie
- java.lang.Object
-
- net.officefloor.server.http.WritableHttpCookie
-
- All Implemented Interfaces:
HttpResponseCookie
public class WritableHttpCookie extends java.lang.Object implements HttpResponseCookie
Writable HTTP Cookie.- Author:
- Daniel Sagenschneider
-
-
Field Summary
Fields Modifier and Type Field Description WritableHttpCookie
next
NextWritableHttpCookie
to enable chaining together into linked list.-
Fields inherited from interface net.officefloor.server.http.HttpResponseCookie
BROWSER_SESSION_MAX_AGE
-
-
Constructor Summary
Constructors Constructor Description WritableHttpCookie(java.lang.String name, java.lang.String value, ManagedObjectContext context)
Instantiate.
-
Method Summary
All Methods Instance Methods Concrete 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.java.lang.String
toResponseHeaderValue()
Obtains the HTTP Cookie value for the HTTP response.<B> void
write(StreamBuffer<B> head, StreamBufferPool<B> bufferPool)
Writes this HTTP Cookie to theStreamBuffer
stream.
-
-
-
Field Detail
-
next
public WritableHttpCookie next
NextWritableHttpCookie
to enable chaining together into linked list.
-
-
Constructor Detail
-
WritableHttpCookie
public WritableHttpCookie(java.lang.String name, java.lang.String value, ManagedObjectContext context)
Instantiate.- Parameters:
name
- Name.value
- Value.context
-ManagedObjectContext
.
-
-
Method Detail
-
write
public <B> void write(StreamBuffer<B> head, StreamBufferPool<B> bufferPool)
Writes this HTTP Cookie to theStreamBuffer
stream.- Type Parameters:
B
- Buffer type.- Parameters:
head
- HeadStreamBuffer
of linked list ofStreamBuffer
instances.bufferPool
-StreamBufferPool
.
-
toResponseHeaderValue
public java.lang.String toResponseHeaderValue()
Obtains the HTTP Cookie value for the HTTP response.- Returns:
- HTTP header value.
-
getName
public java.lang.String getName()
Description copied from interface:HttpResponseCookie
Obtains the name.- Specified by:
getName
in interfaceHttpResponseCookie
- Returns:
- Name.
-
getValue
public java.lang.String getValue()
Description copied from interface:HttpResponseCookie
Obtains the value.- Specified by:
getValue
in interfaceHttpResponseCookie
- Returns:
- Value.
-
setValue
public HttpResponseCookie setValue(java.lang.String value)
Description copied from interface:HttpResponseCookie
Sets the value.- Specified by:
setValue
in interfaceHttpResponseCookie
- Parameters:
value
- Value.- Returns:
- this.
-
getExpires
public java.time.temporal.TemporalAccessor getExpires()
Description copied from interface:HttpResponseCookie
Obtains the expire time.- Specified by:
getExpires
in interfaceHttpResponseCookie
- Returns:
- Expire time. May be
null
if no expire.
-
setExpires
public HttpResponseCookie setExpires(java.time.temporal.TemporalAccessor expires)
Description copied from interface:HttpResponseCookie
Sets the expire time.- Specified by:
setExpires
in interfaceHttpResponseCookie
- Parameters:
expires
- Expires time.- Returns:
- this.
-
getMaxAge
public long getMaxAge()
Description copied from interface:HttpResponseCookie
Obtains the maximum age in seconds.- Specified by:
getMaxAge
in interfaceHttpResponseCookie
- Returns:
- Maximum age in seconds. Will be
HttpResponseCookie.BROWSER_SESSION_MAX_AGE
if not specified.
-
setMaxAge
public HttpResponseCookie setMaxAge(long maxAge)
Description copied from interface:HttpResponseCookie
Sets the maximum age in seconds.
As per RFC 6265 this overrides
Expires
.- Specified by:
setMaxAge
in interfaceHttpResponseCookie
- Parameters:
maxAge
- Maximum age in seconds.- Returns:
- this.
-
getDomain
public java.lang.String getDomain()
Description copied from interface:HttpResponseCookie
Obtains the domain.- Specified by:
getDomain
in interfaceHttpResponseCookie
- Returns:
- Domain. May be
null
.
-
setDomain
public HttpResponseCookie setDomain(java.lang.String domain)
Description copied from interface:HttpResponseCookie
Specifies the domain.- Specified by:
setDomain
in interfaceHttpResponseCookie
- Parameters:
domain
- Domain.- Returns:
- this.
-
getPath
public java.lang.String getPath()
Description copied from interface:HttpResponseCookie
Obtains the path.- Specified by:
getPath
in interfaceHttpResponseCookie
- Returns:
- Path. May be
null
.
-
setPath
public HttpResponseCookie setPath(java.lang.String path)
Description copied from interface:HttpResponseCookie
Specifies the path.- Specified by:
setPath
in interfaceHttpResponseCookie
- Parameters:
path
- Path.- Returns:
- this.
-
isSecure
public boolean isSecure()
Description copied from interface:HttpResponseCookie
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).
- Specified by:
isSecure
in interfaceHttpResponseCookie
- Returns:
true
to only communicate this Cookie across a secure connection.
-
setSecure
public HttpResponseCookie setSecure(boolean isSecure)
Description copied from interface:HttpResponseCookie
Flags whether the client is only to send the Cookie over a secure connection.- Specified by:
setSecure
in interfaceHttpResponseCookie
- Parameters:
isSecure
-true
to request the client to only send this Cookie over a secure connection (assuming the client supports this).- Returns:
- this.
-
isHttpOnly
public boolean isHttpOnly()
Description copied from interface:HttpResponseCookie
Indicates if the Cookie is only sent over HTTP connection.- Specified by:
isHttpOnly
in interfaceHttpResponseCookie
- Returns:
true
to only make this Cookie available in HTTP requests.
-
setHttpOnly
public HttpResponseCookie setHttpOnly(boolean isHttpOnly)
Description copied from interface:HttpResponseCookie
Indicates if only available over HTTP requests (and not, for example, made available to JavaScript in the browser).- Specified by:
setHttpOnly
in interfaceHttpResponseCookie
- 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
public HttpResponseCookie addExtension(java.lang.String extension)
Description copied from interface:HttpResponseCookie
Allows adding an extension.
The extensions are added as provided (separated by ';') to the end of the
Set-Cookie
HttpHeader
.- Specified by:
addExtension
in interfaceHttpResponseCookie
- Parameters:
extension
- Extension.- Returns:
- this.
-
getExtensions
public java.lang.String[] getExtensions()
Description copied from interface:HttpResponseCookie
Obtains the extensions.- Specified by:
getExtensions
in interfaceHttpResponseCookie
- Returns:
- Extensions.
-
clearAttributes
public HttpResponseCookie clearAttributes()
Description copied from interface:HttpResponseCookie
Clears the attributes.- Specified by:
clearAttributes
in interfaceHttpResponseCookie
- Returns:
- this.
-
configure
public HttpResponseCookie configure(java.util.function.Consumer<HttpResponseCookie> configurer)
Description copied from interface:HttpResponseCookie
Enables configuring multiple attributes with reduced locking.- Specified by:
configure
in interfaceHttpResponseCookie
- Parameters:
configurer
-Consumer
to configured theHttpResponseCookie
.- Returns:
- this.
-
-