Package io.milton.http
Class BeanCookie
java.lang.Object
io.milton.http.BeanCookie
- All Implemented Interfaces:
Cookie
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThis returns the domain for this cookie.intThis returns the number of seconds a cookie lives for.getName()This returns the name for this cookie.getPath()This returns the path for this cookie.booleanThis determines whether the cookie is secure.getValue()This returns the value for this cookie.intThis returns the version for this cookie.booleanbooleanisSecure()voidThis enables the domain for thisCookieto be set.voidsetExpiry(int expiry) This allows a lifetime to be specified for the cookie.voidsetHttpOnly(boolean httpOnly) voidThis is used to set the cookie path for this cookie.voidsetSecure(boolean secure) This is used to determine if the client browser should send this cookie over a secure protocol.voidThis enables the value of the cookie to be changed.voidsetVersion(int version) This enables the version of theCookieto be set.static StringFormats the cookie in a suitable format for a SetCookie responsestatic String
-
Constructor Details
-
BeanCookie
-
-
Method Details
-
toHeader
Formats the cookie in a suitable format for a SetCookie response- Returns:
-
toHeader
-
getVersion
public int getVersion()Description copied from interface:CookieThis returns the version for this cookie. The version is not optional and so will always return the version this cookie uses. If no version number is specified this will return a version of 1, to comply with RFC 2109.- Specified by:
getVersionin interfaceCookie- Returns:
- the version value from this cookie instance
-
setVersion
public void setVersion(int version) Description copied from interface:CookieThis enables the version of theCookieto be set. By default the version of theCookieis set to 1. It is not advisable to set the version higher than 1, unless it is known that the client will accept it.Some old browsers can only handle cookie version 0. This can be used to comply with the original Netscape cookie specification. Version 1 complies with RFC 2109.
- Specified by:
setVersionin interfaceCookie- Parameters:
version- this is the version number for the cookie
-
getName
Description copied from interface:CookieThis returns the name for this cookie. The name and value attributes of a cookie define what theCookieis for, these values will always be present. These are mandatory for both the Cookie and Set-Cookie headers.Because the cookie may be stored by name, the cookie name cannot be modified after the creation of the cookie object.
-
getValue
Description copied from interface:CookieThis returns the value for this cookie. The name and value attributes of a cookie define what theCookieis for, these values will always be present. These are mandatory for both the Cookie and Set-Cookie headers. -
setValue
Description copied from interface:CookieThis enables the value of the cookie to be changed. This can be set to any value the server wishes to send. Cookie values can contain space characters as they are transmitted in quotes. For example a value ofsome valueis perfectly legal. However for maximum compatibility across the different plaforms such as PHP, JavaScript and others, quotations should be avoided. If quotations are required they must be added to the string. For example a quoted value could be created as"some value". -
isSecure
public boolean isSecure() -
getSecure
public boolean getSecure()Description copied from interface:CookieThis determines whether the cookie is secure. The cookie is secure if it has the "secure" token set, as defined by RFC 2109. If this token is set then the cookie is only sent over secure channels such as SSL and TLS and ensures that a third party cannot intercept and spoof the cookie. -
setSecure
public void setSecure(boolean secure) Description copied from interface:CookieThis is used to determine if the client browser should send this cookie over a secure protocol. If this is true then the client browser should only send the cookie over secure channels such as SSL and TLS. This ensures that the value of the cookie cannot be intercepted by a third party. -
getExpiry
public int getExpiry()Description copied from interface:CookieThis returns the number of seconds a cookie lives for. This determines how long the cookie will live on the client side. If the expiry is less than zero the cookie lifetime is the duration of the client browser session, if it is zero then the cookie will be deleted from the client browser. -
setExpiry
public void setExpiry(int expiry) Description copied from interface:CookieThis allows a lifetime to be specified for the cookie. This will make use of the "max-age" token specified by RFC 2109 the specifies the number of seconds a browser should keep a cookie for. This is useful if the cookie is to be kept beyond the lifetime of the client session. If the valie of this is zero then this will remove the client cookie, if it is less than zero then the "max-age" field is ignored. -
getDomain
Description copied from interface:CookieThis returns the domain for this cookie. The domain is in both the Cookie and Set-Cookie headers and so may return null if there is no domain value. If either thetoStringortoClientStringis invoked the domain will not be present if this is null. -
setDomain
Description copied from interface:CookieThis enables the domain for thisCookieto be set. The form of the domain is specified by RFC 2109. The value can begin with a dot, like.host.com. This means that the cookie is visible within a specific DNS zone likewww.host.com. By default this value is null which means it is sent back to its origin. -
getPath
Description copied from interface:CookieThis returns the path for this cookie. The path is in both the Cookie and Set-Cookie headers and so may return null if there is no domain value. If thetoStringortoClientStringis invoked the path will not be present if the path attribute is null. -
setPath
Description copied from interface:CookieThis is used to set the cookie path for this cookie. This is set so that the cookie can specify the directories that the cookie is sent with. For example if the path attribute is set to/pub/bin, then requests for the resourcehttp://hostname:port/pub/bin/READMEwill be issued with this cookie. The cookie is issued for all resources in the path and all subdirectories. -
setHttpOnly
public void setHttpOnly(boolean httpOnly) - Specified by:
setHttpOnlyin interfaceCookie
-
isHttpOnly
public boolean isHttpOnly()- Specified by:
isHttpOnlyin interfaceCookie
-