Top Description Fields Constructors Methods
org.apache.http.impl.cookie

public Class PublicSuffixDomainFilter

extends Object
implements CommonCookieAttributeHandler
Class Inheritance
All Implemented Interfaces
org.apache.http.cookie.CommonCookieAttributeHandler, org.apache.http.cookie.CookieAttributeHandler
Annotations
@Contract
threading:IMMUTABLE_CONDITIONAL
Imports
java.util.Map, java.util.concurrent.ConcurrentHashMap, org.apache.http.annotation.Contract, .ThreadingBehavior, org.apache.http.conn.util.PublicSuffixList, .PublicSuffixMatcher, org.apache.http.cookie.CommonCookieAttributeHandler, .Cookie, .CookieOrigin, .MalformedCookieException, .SetCookie, org.apache.http.util.Args

Wraps a org.apache.http.cookie.CookieAttributeHandler and leverages its match method to never match a suffix from a black list. May be used to provide additional security for cross-site attack types by preventing cookies from apparent domains that are not publicly available.
Since
4.4
See Also
org.apache.http.conn.util.PublicSuffixList, org.apache.http.conn.util.PublicSuffixMatcher

Field Summary

Modifier and TypeField and Description
private final CommonCookieAttributeHandler
private final Map<String, Boolean>
private final PublicSuffixMatcher

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
private static Map<String, Boolean>
public static CommonCookieAttributeHandler
decorate(final CommonCookieAttributeHandler handler, final PublicSuffixMatcher publicSuffixMatcher)

public String
public boolean
match(final Cookie cookie, final CookieOrigin
the cookie source to match against
origin
)

Implements org.apache.http.cookie.CookieAttributeHandler.match.

Never matches if the cookie's domain is from the blacklist.
public void
parse(final SetCookie cookie, final String
cookie attribute value from the cookie response header
value
)

Implements org.apache.http.cookie.CookieAttributeHandler.parse.

Parse the given cookie attribute value and update the corresponding org.apache.http.cookie.Cookie property.
public void
validate(final Cookie cookie, final CookieOrigin
the cookie source to validate against
origin
)

Implements org.apache.http.cookie.CookieAttributeHandler.validate.

Peforms cookie validation for the given attribute value.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

handlerback to summary
private final CommonCookieAttributeHandler handler
localDomainMapback to summary
private final Map<String, Boolean> localDomainMap
publicSuffixMatcherback to summary
private final PublicSuffixMatcher publicSuffixMatcher

Constructor Detail

PublicSuffixDomainFilterback to summary
public PublicSuffixDomainFilter(final CommonCookieAttributeHandler handler, final PublicSuffixMatcher publicSuffixMatcher)
PublicSuffixDomainFilterback to summary
public PublicSuffixDomainFilter(final CommonCookieAttributeHandler handler, final PublicSuffixList suffixList)

Method Detail

createLocalDomainMapback to summary
private static Map<String, Boolean> createLocalDomainMap()
decorateback to summary
public static CommonCookieAttributeHandler decorate(final CommonCookieAttributeHandler handler, final PublicSuffixMatcher publicSuffixMatcher)
getAttributeNameback to summary
public String getAttributeName()

Implements org.apache.http.cookie.CommonCookieAttributeHandler.getAttributeName.

Annotations
@Override
matchback to summary
public boolean match(final Cookie cookie, final CookieOrigin origin)

Implements org.apache.http.cookie.CookieAttributeHandler.match.

Never matches if the cookie's domain is from the blacklist.

Parameters
cookie:Cookie

Doc from org.apache.http.cookie.CookieAttributeHandler.match.

org.apache.http.cookie.Cookie to match

origin:CookieOrigin

Doc from org.apache.http.cookie.CookieAttributeHandler.match.

the cookie source to match against

Returns:boolean

Doc from org.apache.http.cookie.CookieAttributeHandler.match.

true if the match is successful; false otherwise

Annotations
@Override
parseback to summary
public void parse(final SetCookie cookie, final String value) throws MalformedCookieException

Implements org.apache.http.cookie.CookieAttributeHandler.parse.

Doc from org.apache.http.cookie.CookieAttributeHandler.parse.

Parse the given cookie attribute value and update the corresponding org.apache.http.cookie.Cookie property.

Parameters
cookie:SetCookie

org.apache.http.cookie.Cookie to be updated

value:String

cookie attribute value from the cookie response header

Annotations
@Override
validateback to summary
public void validate(final Cookie cookie, final CookieOrigin origin) throws MalformedCookieException

Implements org.apache.http.cookie.CookieAttributeHandler.validate.

Doc from org.apache.http.cookie.CookieAttributeHandler.validate.

Peforms cookie validation for the given attribute value.

Parameters
cookie:Cookie

org.apache.http.cookie.Cookie to validate

origin:CookieOrigin

the cookie source to validate against

Annotations
@Override
Exceptions
MalformedCookieException:
if cookie validation fails for this attribute