Package org.apache.http.conn.util
Class PublicSuffixMatcher
- java.lang.Object
-
- org.apache.http.conn.util.PublicSuffixMatcher
-
@Contract(threading=SAFE) public final class PublicSuffixMatcher extends java.lang.Object
Utility class that can test if DNS names match the content of the Public Suffix List.An up-to-date list of suffixes can be obtained from publicsuffix.org
- Since:
- 4.4
- See Also:
PublicSuffixList
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,DomainType>
exceptions
private java.util.Map<java.lang.String,DomainType>
rules
-
Constructor Summary
Constructors Constructor Description PublicSuffixMatcher(java.util.Collection<java.lang.String> rules, java.util.Collection<java.lang.String> exceptions)
PublicSuffixMatcher(java.util.Collection<PublicSuffixList> lists)
PublicSuffixMatcher(DomainType domainType, java.util.Collection<java.lang.String> rules, java.util.Collection<java.lang.String> exceptions)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getDomainRoot(java.lang.String domain)
Returns registrable part of the domain for the given domain name ornull
if given domain represents a public suffix.java.lang.String
getDomainRoot(java.lang.String domain, DomainType expectedType)
Returns registrable part of the domain for the given domain name ornull
if given domain represents a public suffix.private static boolean
hasEntry(java.util.Map<java.lang.String,DomainType> map, java.lang.String rule, DomainType expectedType)
private boolean
hasException(java.lang.String exception, DomainType expectedType)
private boolean
hasRule(java.lang.String rule, DomainType expectedType)
boolean
matches(java.lang.String domain)
Tests whether the given domain matches any of entry from the public suffix list.boolean
matches(java.lang.String domain, DomainType expectedType)
Tests whether the given domain matches any of entry from the public suffix list.
-
-
-
Field Detail
-
rules
private final java.util.Map<java.lang.String,DomainType> rules
-
exceptions
private final java.util.Map<java.lang.String,DomainType> exceptions
-
-
Constructor Detail
-
PublicSuffixMatcher
public PublicSuffixMatcher(java.util.Collection<java.lang.String> rules, java.util.Collection<java.lang.String> exceptions)
-
PublicSuffixMatcher
public PublicSuffixMatcher(DomainType domainType, java.util.Collection<java.lang.String> rules, java.util.Collection<java.lang.String> exceptions)
- Since:
- 4.5
-
PublicSuffixMatcher
public PublicSuffixMatcher(java.util.Collection<PublicSuffixList> lists)
- Since:
- 4.5
-
-
Method Detail
-
hasEntry
private static boolean hasEntry(java.util.Map<java.lang.String,DomainType> map, java.lang.String rule, DomainType expectedType)
-
hasRule
private boolean hasRule(java.lang.String rule, DomainType expectedType)
-
hasException
private boolean hasException(java.lang.String exception, DomainType expectedType)
-
getDomainRoot
public java.lang.String getDomainRoot(java.lang.String domain)
Returns registrable part of the domain for the given domain name ornull
if given domain represents a public suffix.- Parameters:
domain
-- Returns:
- domain root
-
getDomainRoot
public java.lang.String getDomainRoot(java.lang.String domain, DomainType expectedType)
Returns registrable part of the domain for the given domain name ornull
if given domain represents a public suffix.- Parameters:
domain
-expectedType
- expected domain type ornull
if any.- Returns:
- domain root
- Since:
- 4.5
-
matches
public boolean matches(java.lang.String domain)
Tests whether the given domain matches any of entry from the public suffix list.
-
matches
public boolean matches(java.lang.String domain, DomainType expectedType)
Tests whether the given domain matches any of entry from the public suffix list.- Parameters:
domain
-expectedType
- expected domain type ornull
if any.- Returns:
true
if the given domain matches any of the public suffixes.- Since:
- 4.5
-
-