Top Description Inners Methods
org.eclipse.jetty.http

public Interface HttpCookieStore

Known Direct Implementers
org.eclipse.jetty.http.HttpCookieStore.Empty, org.eclipse.jetty.http.HttpCookieStore.Default
Imports
java.net.URI, java.time.Instant, java.util.ArrayList, .Collection, .Collections, .HashMap, .Iterator, .List, .Locale, .Map, .Objects, java.util.function.Predicate, org.eclipse.jetty.util.NanoTime, .StringUtil, org.eclipse.jetty.util.thread.AutoLock

A container for HttpCookies.

HTTP cookies are stored along with a URI via add(URI, HttpCookie) and retrieved via match(URI), which implements the path matching algorithm defined by RFC 6265.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
HttpCookieStore.Default

A default implementation of HttpCookieStore.

public static class
HttpCookieStore.Empty

An implementation of HttpCookieStore that does not store any cookie.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

whether the cookie has been added
add
(URI
the URI associated with the cookie
uri
,
HttpCookie
the cookie to add
cookie
)

Adds a cookie to this store, if possible.

public List<HttpCookie>

Returns:

all the cookies
all
()

public boolean

Returns:

whether the store modified by this call
clear
()

Removes all the cookies from this store.

public List<HttpCookie>

Returns:

a list of cookies that match the given URI
match
(URI
the URI to match against
uri
)

Returns the cookies that match the given URI.

public boolean

Returns:

whether the cookie has been removed
remove
(URI
the URI associated with the cookie to remove
uri
,
HttpCookie
the cookie to remove
cookie
)

Removes the cookie associated with the given URI.

Method Detail

addback to summary
public boolean add(URI uri, HttpCookie cookie)

Adds a cookie to this store, if possible.

The cookie may not be added for various reasons; for example, it may be already expired, or its domain attribute does not match that of the URI, etc.

The cookie is associated with the given URI, so that a call to match(URI) returns the cookie only if the URIs match.

Parameters
uri:URI

the URI associated with the cookie

cookie:HttpCookie

the cookie to add

Returns:boolean

whether the cookie has been added

allback to summary
public List<HttpCookie> all()
Returns:List<HttpCookie>

all the cookies

clearback to summary
public boolean clear()

Removes all the cookies from this store.

Returns:boolean

whether the store modified by this call

matchback to summary
public List<HttpCookie> match(URI uri)

Returns the cookies that match the given URI.

Parameters
uri:URI

the URI to match against

Returns:List<HttpCookie>

a list of cookies that match the given URI

removeback to summary
public boolean remove(URI uri, HttpCookie cookie)

Removes the cookie associated with the given URI.

Parameters
uri:URI

the URI associated with the cookie to remove

cookie:HttpCookie

the cookie to remove

Returns:boolean

whether the cookie has been removed

org.eclipse.jetty.http back to summary

public Class HttpCookieStore.Default

extends Object
implements HttpCookieStore
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.http.HttpCookieStore

A default implementation of HttpCookieStore.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final Map<String, List<HttpCookieStore.Default.StoredHttpCookie>>
private final AutoLock

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
add(URI
the URI associated with the cookie
uri
,
HttpCookie
the cookie to add
cookie
)

Implements org.eclipse.jetty.http.HttpCookieStore.add.

Adds a cookie to this store, if possible.

public List<HttpCookie>
protected boolean

Returns:

whether the domain should be allowed to associate cookies to
allowDomain
(String
the domain to test
domain
)

Returns whether the given domain should be allowed to associate cookies to.

public boolean
clear()

Implements org.eclipse.jetty.http.HttpCookieStore.clear.

Removes all the cookies from this store.

private static boolean
domainMatches(String uriDomain, String domain, String cookieDomain)

private static boolean
isSameOrSubDomain(String subDomain, String domain)

public List<HttpCookie>
match(URI
the URI to match against
uri
)

Implements org.eclipse.jetty.http.HttpCookieStore.match.

Returns the cookies that match the given URI.

private String
private static boolean
pathMatches(String uriPath, String cookiePath)

public boolean
remove(URI
the URI associated with the cookie to remove
uri
,
HttpCookie
the cookie to remove
cookie
)

Implements org.eclipse.jetty.http.HttpCookieStore.remove.

Removes the cookie associated with the given URI.

private String
private String
resolvePath(URI uri, HttpCookie cookie)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cookiesback to summary
private final Map<String, List<HttpCookieStore.Default.StoredHttpCookie>> cookies
lockback to summary
private final AutoLock lock

Constructor Detail

Defaultback to summary
public Default()

Method Detail

addback to summary
public boolean add(URI uri, HttpCookie cookie)

Implements org.eclipse.jetty.http.HttpCookieStore.add.

Doc from org.eclipse.jetty.http.HttpCookieStore.add.

Adds a cookie to this store, if possible.

The cookie may not be added for various reasons; for example, it may be already expired, or its domain attribute does not match that of the URI, etc.

The cookie is associated with the given URI, so that a call to match(URI) returns the cookie only if the URIs match.

Parameters
uri:URI

the URI associated with the cookie

cookie:HttpCookie

the cookie to add

Returns:boolean

whether the cookie has been added

Annotations
@Override
allback to summary
public List<HttpCookie> all()

Implements org.eclipse.jetty.http.HttpCookieStore.all.

Returns:List<HttpCookie>

Doc from org.eclipse.jetty.http.HttpCookieStore.all.

all the cookies

Annotations
@Override
allowDomainback to summary
protected boolean allowDomain(String domain)

Returns whether the given domain should be allowed to associate cookies to.

Currently rejects "top-level" domains such as "com" or "org", so that it will not be possible to associate cookies to those domains.

Unfortunately, it allows for "top-level" domains that have multiple labels such as "co.uk" or "gov.au".

RFC 6265 prohibits domains that are IP addresses, but this method supports them (both IPv4 and IPv6, the latter must be bracketed) for testing purposes.

Parameters
domain:String

the domain to test

Returns:boolean

whether the domain should be allowed to associate cookies to

clearback to summary
public boolean clear()

Implements org.eclipse.jetty.http.HttpCookieStore.clear.

Doc from org.eclipse.jetty.http.HttpCookieStore.clear.

Removes all the cookies from this store.

Returns:boolean

whether the store modified by this call

Annotations
@Override
domainMatchesback to summary
private static boolean domainMatches(String uriDomain, String domain, String cookieDomain)
isSameOrSubDomainback to summary
private static boolean isSameOrSubDomain(String subDomain, String domain)
matchback to summary
public List<HttpCookie> match(URI uri)

Implements org.eclipse.jetty.http.HttpCookieStore.match.

Doc from org.eclipse.jetty.http.HttpCookieStore.match.

Returns the cookies that match the given URI.

Parameters
uri:URI

the URI to match against

Returns:List<HttpCookie>

a list of cookies that match the given URI

Annotations
@Override
parentDomainback to summary
private String parentDomain(String domain)
pathMatchesback to summary
private static boolean pathMatches(String uriPath, String cookiePath)
removeback to summary
public boolean remove(URI uri, HttpCookie cookie)

Implements org.eclipse.jetty.http.HttpCookieStore.remove.

Doc from org.eclipse.jetty.http.HttpCookieStore.remove.

Removes the cookie associated with the given URI.

Parameters
uri:URI

the URI associated with the cookie to remove

cookie:HttpCookie

the cookie to remove

Returns:boolean

whether the cookie has been removed

Annotations
@Override
resolveDomainback to summary
private String resolveDomain(URI uri, HttpCookie cookie)
resolvePathback to summary
private String resolvePath(URI uri, HttpCookie cookie)
org.eclipse.jetty.http back to summary

private Class HttpCookieStore.Default.StoredHttpCookie

extends Wrapper
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final long
private final String
private final String
private final URI

Constructor Summary

AccessConstructor and Description
private
StoredHttpCookie(HttpCookie wrapped, URI uri, String domain, String path)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the object to test for equality
obj
)

Overrides org.eclipse.jetty.http.HttpCookie.Wrapper.equals.

Implements org.eclipse.jetty.http.HttpCookie.equals.

Indicates whether some other object is "equal to" this one.
public int
hashCode()

Overrides org.eclipse.jetty.http.HttpCookie.Wrapper.hashCode.

Implements org.eclipse.jetty.http.HttpCookie.hashCode.

Returns a hash code value for the object.
public boolean
Inherited from org.eclipse.jetty.http.HttpCookie.Wrapper:
getAttributesgetCommentgetDomaingetExpiresgetMaxAgegetNamegetPathgetSameSitegetValuegetVersiongetWrappedisHttpOnlyisPartitionedisSecuretoString

Field Detail

creationNanoTimeback to summary
private final long creationNanoTime
domainback to summary
private final String domain
pathback to summary
private final String path
uriback to summary
private final URI uri

Constructor Detail

StoredHttpCookieback to summary
private StoredHttpCookie(HttpCookie wrapped, URI uri, String domain, String path)

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides org.eclipse.jetty.http.HttpCookie.Wrapper.equals.

Implements org.eclipse.jetty.http.HttpCookie.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

Doc from org.eclipse.jetty.http.HttpCookie.equals.

the object to test for equality

Returns:boolean

Doc from org.eclipse.jetty.http.HttpCookie.equals.

whether this cookie is equal to the given object

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides org.eclipse.jetty.http.HttpCookie.Wrapper.hashCode.

Implements org.eclipse.jetty.http.HttpCookie.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

Doc from org.eclipse.jetty.http.HttpCookie.hashCode.

the cookie hash code

Annotations
@Override
isExpiredback to summary
public boolean isExpired()

Overrides org.eclipse.jetty.http.HttpCookie.Wrapper.isExpired.

Overrides default org.eclipse.jetty.http.HttpCookie.isExpired.

Returns:boolean

Doc from org.eclipse.jetty.http.HttpCookie.isExpired.

whether the cookie is expired

Annotations
@Override
org.eclipse.jetty.http back to summary

public Class HttpCookieStore.Empty

extends Object
implements HttpCookieStore
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.http.HttpCookieStore

An implementation of HttpCookieStore that does not store any cookie.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
add(URI
the URI associated with the cookie
uri
,
HttpCookie
the cookie to add
cookie
)

Implements org.eclipse.jetty.http.HttpCookieStore.add.

Adds a cookie to this store, if possible.

public List<HttpCookie>
public boolean
clear()

Implements org.eclipse.jetty.http.HttpCookieStore.clear.

Removes all the cookies from this store.

public List<HttpCookie>
match(URI
the URI to match against
uri
)

Implements org.eclipse.jetty.http.HttpCookieStore.match.

Returns the cookies that match the given URI.

public boolean
remove(URI
the URI associated with the cookie to remove
uri
,
HttpCookie
the cookie to remove
cookie
)

Implements org.eclipse.jetty.http.HttpCookieStore.remove.

Removes the cookie associated with the given URI.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Emptyback to summary
public Empty()

Method Detail

addback to summary
public boolean add(URI uri, HttpCookie cookie)

Implements org.eclipse.jetty.http.HttpCookieStore.add.

Doc from org.eclipse.jetty.http.HttpCookieStore.add.

Adds a cookie to this store, if possible.

The cookie may not be added for various reasons; for example, it may be already expired, or its domain attribute does not match that of the URI, etc.

The cookie is associated with the given URI, so that a call to match(URI) returns the cookie only if the URIs match.

Parameters
uri:URI

the URI associated with the cookie

cookie:HttpCookie

the cookie to add

Returns:boolean

whether the cookie has been added

Annotations
@Override
allback to summary
public List<HttpCookie> all()

Implements org.eclipse.jetty.http.HttpCookieStore.all.

Returns:List<HttpCookie>

Doc from org.eclipse.jetty.http.HttpCookieStore.all.

all the cookies

Annotations
@Override
clearback to summary
public boolean clear()

Implements org.eclipse.jetty.http.HttpCookieStore.clear.

Doc from org.eclipse.jetty.http.HttpCookieStore.clear.

Removes all the cookies from this store.

Returns:boolean

whether the store modified by this call

Annotations
@Override
matchback to summary
public List<HttpCookie> match(URI uri)

Implements org.eclipse.jetty.http.HttpCookieStore.match.

Doc from org.eclipse.jetty.http.HttpCookieStore.match.

Returns the cookies that match the given URI.

Parameters
uri:URI

the URI to match against

Returns:List<HttpCookie>

a list of cookies that match the given URI

Annotations
@Override
removeback to summary
public boolean remove(URI uri, HttpCookie cookie)

Implements org.eclipse.jetty.http.HttpCookieStore.remove.

Doc from org.eclipse.jetty.http.HttpCookieStore.remove.

Removes the cookie associated with the given URI.

Parameters
uri:URI

the URI associated with the cookie to remove

cookie:HttpCookie

the cookie to remove

Returns:boolean

whether the cookie has been removed

Annotations
@Override