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 WritableHttpCookienextNextWritableHttpCookieto 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 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.java.lang.StringtoResponseHeaderValue()Obtains the HTTP Cookie value for the HTTP response.<B> voidwrite(StreamBuffer<B> head, StreamBufferPool<B> bufferPool)Writes this HTTP Cookie to theStreamBufferstream.
-
-
-
Field Detail
-
next
public WritableHttpCookie next
NextWritableHttpCookieto 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 theStreamBufferstream.- Type Parameters:
B- Buffer type.- Parameters:
head- HeadStreamBufferof linked list ofStreamBufferinstances.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:HttpResponseCookieObtains the name.- Specified by:
getNamein interfaceHttpResponseCookie- Returns:
- Name.
-
getValue
public java.lang.String getValue()
Description copied from interface:HttpResponseCookieObtains the value.- Specified by:
getValuein interfaceHttpResponseCookie- Returns:
- Value.
-
setValue
public HttpResponseCookie setValue(java.lang.String value)
Description copied from interface:HttpResponseCookieSets the value.- Specified by:
setValuein interfaceHttpResponseCookie- Parameters:
value- Value.- Returns:
- this.
-
getExpires
public java.time.temporal.TemporalAccessor getExpires()
Description copied from interface:HttpResponseCookieObtains the expire time.- Specified by:
getExpiresin interfaceHttpResponseCookie- Returns:
- Expire time. May be
nullif no expire.
-
setExpires
public HttpResponseCookie setExpires(java.time.temporal.TemporalAccessor expires)
Description copied from interface:HttpResponseCookieSets the expire time.- Specified by:
setExpiresin interfaceHttpResponseCookie- Parameters:
expires- Expires time.- Returns:
- this.
-
getMaxAge
public long getMaxAge()
Description copied from interface:HttpResponseCookieObtains the maximum age in seconds.- Specified by:
getMaxAgein interfaceHttpResponseCookie- Returns:
- Maximum age in seconds. Will be
HttpResponseCookie.BROWSER_SESSION_MAX_AGEif not specified.
-
setMaxAge
public HttpResponseCookie setMaxAge(long maxAge)
Description copied from interface:HttpResponseCookieSets the maximum age in seconds.
As per RFC 6265 this overrides
Expires.- Specified by:
setMaxAgein interfaceHttpResponseCookie- Parameters:
maxAge- Maximum age in seconds.- Returns:
- this.
-
getDomain
public java.lang.String getDomain()
Description copied from interface:HttpResponseCookieObtains the domain.- Specified by:
getDomainin interfaceHttpResponseCookie- Returns:
- Domain. May be
null.
-
setDomain
public HttpResponseCookie setDomain(java.lang.String domain)
Description copied from interface:HttpResponseCookieSpecifies the domain.- Specified by:
setDomainin interfaceHttpResponseCookie- Parameters:
domain- Domain.- Returns:
- this.
-
getPath
public java.lang.String getPath()
Description copied from interface:HttpResponseCookieObtains the path.- Specified by:
getPathin interfaceHttpResponseCookie- Returns:
- Path. May be
null.
-
setPath
public HttpResponseCookie setPath(java.lang.String path)
Description copied from interface:HttpResponseCookieSpecifies the path.- Specified by:
setPathin interfaceHttpResponseCookie- Parameters:
path- Path.- Returns:
- this.
-
isSecure
public boolean isSecure()
Description copied from interface:HttpResponseCookieIndicates 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:
isSecurein interfaceHttpResponseCookie- Returns:
trueto only communicate this Cookie across a secure connection.
-
setSecure
public HttpResponseCookie setSecure(boolean isSecure)
Description copied from interface:HttpResponseCookieFlags whether the client is only to send the Cookie over a secure connection.- Specified by:
setSecurein interfaceHttpResponseCookie- Parameters:
isSecure-trueto 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:HttpResponseCookieIndicates if the Cookie is only sent over HTTP connection.- Specified by:
isHttpOnlyin interfaceHttpResponseCookie- Returns:
trueto only make this Cookie available in HTTP requests.
-
setHttpOnly
public HttpResponseCookie setHttpOnly(boolean isHttpOnly)
Description copied from interface:HttpResponseCookieIndicates if only available over HTTP requests (and not, for example, made available to JavaScript in the browser).- Specified by:
setHttpOnlyin interfaceHttpResponseCookie- 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
public HttpResponseCookie addExtension(java.lang.String extension)
Description copied from interface:HttpResponseCookieAllows adding an extension.
The extensions are added as provided (separated by ';') to the end of the
Set-CookieHttpHeader.- Specified by:
addExtensionin interfaceHttpResponseCookie- Parameters:
extension- Extension.- Returns:
- this.
-
getExtensions
public java.lang.String[] getExtensions()
Description copied from interface:HttpResponseCookieObtains the extensions.- Specified by:
getExtensionsin interfaceHttpResponseCookie- Returns:
- Extensions.
-
clearAttributes
public HttpResponseCookie clearAttributes()
Description copied from interface:HttpResponseCookieClears the attributes.- Specified by:
clearAttributesin interfaceHttpResponseCookie- Returns:
- this.
-
configure
public HttpResponseCookie configure(java.util.function.Consumer<HttpResponseCookie> configurer)
Description copied from interface:HttpResponseCookieEnables configuring multiple attributes with reduced locking.- Specified by:
configurein interfaceHttpResponseCookie- Parameters:
configurer-Consumerto configured theHttpResponseCookie.- Returns:
- this.
-
-