Interface Cookie
-
- All Known Subinterfaces:
SetCookie
- All Known Implementing Classes:
BasicClientCookie
public interface CookieCookie interface represents a token or short packet of state information (also referred to as "magic-cookie") that the HTTP agent and the target server can exchange to maintain a session. In its simples form an HTTP cookie is merely a name / value pair.- Since:
- 4.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDOMAIN_ATTRstatic java.lang.StringEXPIRES_ATTRstatic java.lang.StringHTTP_ONLY_ATTRstatic java.lang.StringMAX_AGE_ATTRstatic java.lang.StringPATH_ATTRstatic java.lang.StringSECURE_ATTR
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description booleancontainsAttribute(java.lang.String name)java.lang.StringgetAttribute(java.lang.String name)java.util.DategetCreationDate()Deprecated.default java.time.InstantgetCreationInstant()Returns creation time of the cookie.java.lang.StringgetDomain()Returns domain attribute of the cookie.java.util.DategetExpiryDate()Deprecated.Use {getExpiryInstant()}default java.time.InstantgetExpiryInstant()Returns the expirationInstantof the cookie, ornullif none exists.java.lang.StringgetName()Returns the name.java.lang.StringgetPath()Returns the path attribute of the cookie.java.lang.StringgetValue()Returns the value.default booleanisExpired(java.time.Instant date)Returns true if this cookie has expired.booleanisExpired(java.util.Date date)Deprecated.Use {isExpired(Instant)}default booleanisHttpOnly()Checks whether this Cookie has been marked ashttpOnly.booleanisPersistent()Returnsfalseif the cookie should be discarded at the end of the "session";trueotherwise.booleanisSecure()Indicates whether this cookie requires a secure connection.
-
-
-
Field Detail
-
PATH_ATTR
static final java.lang.String PATH_ATTR
- See Also:
- Constant Field Values
-
DOMAIN_ATTR
static final java.lang.String DOMAIN_ATTR
- See Also:
- Constant Field Values
-
MAX_AGE_ATTR
static final java.lang.String MAX_AGE_ATTR
- See Also:
- Constant Field Values
-
SECURE_ATTR
static final java.lang.String SECURE_ATTR
- See Also:
- Constant Field Values
-
EXPIRES_ATTR
static final java.lang.String EXPIRES_ATTR
- See Also:
- Constant Field Values
-
HTTP_ONLY_ATTR
static final java.lang.String HTTP_ONLY_ATTR
- See Also:
- Constant Field Values
-
-
Method Detail
-
getAttribute
java.lang.String getAttribute(java.lang.String name)
- Since:
- 5.0
-
containsAttribute
boolean containsAttribute(java.lang.String name)
- Since:
- 5.0
-
getName
java.lang.String getName()
Returns the name.- Returns:
- String name The name
-
getValue
java.lang.String getValue()
Returns the value.- Returns:
- String value The current value.
-
getExpiryDate
@Deprecated java.util.Date getExpiryDate()
Deprecated.Use {getExpiryInstant()}Returns the expirationDateof the cookie, ornullif none exists.Note: the object returned by this method is considered immutable. Changing it (e.g. using setTime()) could result in undefined behaviour. Do so at your peril.
- Returns:
- Expiration
Date, ornull.
-
getExpiryInstant
default java.time.Instant getExpiryInstant()
Returns the expirationInstantof the cookie, ornullif none exists.Note: the object returned by this method is considered immutable. Changing it (e.g. using setTime()) could result in undefined behaviour. Do so at your peril.
- Returns:
- Expiration
Instant, ornull. - Since:
- 5.2
-
isPersistent
boolean isPersistent()
Returnsfalseif the cookie should be discarded at the end of the "session";trueotherwise.- Returns:
falseif the cookie should be discarded at the end of the "session";trueotherwise
-
getDomain
java.lang.String getDomain()
Returns domain attribute of the cookie. The value of the Domain attribute specifies the domain for which the cookie is valid.- Returns:
- the value of the domain attribute.
-
getPath
java.lang.String getPath()
Returns the path attribute of the cookie. The value of the Path attribute specifies the subset of URLs on the origin server to which this cookie applies.- Returns:
- The value of the path attribute.
-
isSecure
boolean isSecure()
Indicates whether this cookie requires a secure connection.- Returns:
trueif this cookie should only be sent over secure connections,falseotherwise.
-
isExpired
@Deprecated boolean isExpired(java.util.Date date)
Deprecated.Use {isExpired(Instant)}Returns true if this cookie has expired.- Parameters:
date- Current time- Returns:
trueif the cookie has expired.
-
isExpired
default boolean isExpired(java.time.Instant date)
Returns true if this cookie has expired.- Parameters:
date- Current time- Returns:
trueif the cookie has expired.- Since:
- 5.2
-
getCreationDate
@Deprecated java.util.Date getCreationDate()
Deprecated.Returns creation time of the cookie.
-
getCreationInstant
default java.time.Instant getCreationInstant()
Returns creation time of the cookie.
-
isHttpOnly
default boolean isHttpOnly()
Checks whether this Cookie has been marked ashttpOnly.The default implementation returns
false.- Returns:
- true if this Cookie has been marked as
httpOnly, false otherwise - Since:
- 5.2
-
-