Class EffectiveTldFinder

    • Field Detail

      • MAX_DOMAIN_LENGTH_PART

        public static final int MAX_DOMAIN_LENGTH_PART
        Max. length in ASCII characters of a dot-separated segment in host names (applies to domain names as well), cf. https://tools.ietf.org/html/rfc1034#section-3.1 and https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_hostnames Note: We only have to validate domain names and not the host names passed as input. For domain names a verification of the segment length also implies that the entire domain names stays in the limit of 253 characters. Wildcard suffixes only allow two additional segments (2*63+1 = 127 chars) and all wildcard suffixes are far away from reaching the critical length of 126 characters.
        See Also:
        Constant Field Values
    • Method Detail

      • getInstance

        public static EffectiveTldFinder getInstance()
        Get singleton instance of EffectiveTldFinder with default configuration.
        Returns:
        singleton instance of EffectiveTldFinder
      • initialize

        public boolean initialize​(InputStream effectiveTldDataStream)
        (Re)initialize EffectiveTldFinder with custom public suffix list.
        Parameters:
        effectiveTldDataStream - content of public suffix list as input stream
        Returns:
        true if (re)initialization was successful
      • getAssignedDomain

        public static String getAssignedDomain​(String hostname)
        This method uses the effective TLD to determine which component of a FQDN is the NIC-assigned domain name (aka "Paid Level Domain").
        Parameters:
        hostname - a string for which to obtain a NIC-assigned domain name
        Returns:
        the NIC-assigned domain name or as fall-back the hostname if no FQDN with valid TLD is found
      • getAssignedDomain

        public static String getAssignedDomain​(String hostname,
                                               boolean strict)
        This method uses the effective TLD to determine which component of a FQDN is the NIC-assigned domain name (aka "Paid Level Domain").
        Parameters:
        hostname - a string for which to obtain a NIC-assigned domain name
        strict - do not return the hostname as fall-back if a FQDN with valid TLD cannot be determined
        Returns:
        the NIC-assigned domain name, null if strict and no FQDN with valid TLD is found
      • getAssignedDomain

        public static String getAssignedDomain​(String hostname,
                                               boolean strict,
                                               boolean excludePrivate)
        This method uses the effective TLD to determine which component of a FQDN is the NIC-assigned domain name.
        Parameters:
        hostname - a string for which to obtain a NIC-assigned domain name
        strict - do not return the hostname as fall-back if a FQDN with valid TLD cannot be determined
        excludePrivate - do not return a domain which is below an eTLD from the PRIVATE section, return the shorter domain which is below the "ICANN" registry suffix
        Returns:
        the NIC-assigned domain name, null if strict and no FQDN with valid TLD is found
      • isConfigured

        public boolean isConfigured()
      • help

        public static void help()