8201815: Use Mozilla Public Suffix List

Reviewed-by: michaelm, erikj, ihse
This commit is contained in:
Weijun Wang 2018-06-26 18:55:48 +08:00
parent 19f5116cd9
commit 60ff77bd97
13 changed files with 13920 additions and 928 deletions

View File

@ -121,6 +121,9 @@ TOOL_GENCLASSLOADERMAP = $(JAVA_SMALL) $(INTERIM_LANGTOOLS_BOOTCLASSPATH) \
-cp $(call PathList, $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes) \
build.tools.module.GenModuleLoaderMap
TOOL_PUBLICSUFFIXLIST = $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes \
build.tools.publicsuffixlist.GeneratePublicSuffixList
##########################################################################################
endif # _TOOLS_GMK

View File

@ -0,0 +1,2 @@
Github: https://raw.githubusercontent.com/publicsuffix/list/2225db8d9f4a2a27ec697c883360632fa0c16261/public_suffix_list.dat
Date: 2018-05-09

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@ -36,6 +36,8 @@ include GendataBlacklistedCerts.gmk
include GendataCryptoPolicy.gmk
include GendataPublicSuffixList.gmk
################################################################################
GENDATA_UNINAME := $(JDK_OUTPUTDIR)/modules/java.base/java/lang/uniName.dat

View File

@ -0,0 +1,38 @@
#
# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
include $(SPEC)
GENDATA_PUBLICSUFFIXLIST_SRC += $(TOPDIR)/make/data/publicsuffixlist/public_suffix_list.dat
GENDATA_PUBLICSUFFIXLIST := $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE)/security/public_suffix_list.dat
$(GENDATA_PUBLICSUFFIXLIST): $(GENDATA_PUBLICSUFFIXLIST_SRC) $(BUILD_TOOLS)
$(call LogInfo, Generating public suffix list)
$(call MakeDir, $(@D))
$(RM) $@
$(TOOL_PUBLICSUFFIXLIST) $< $@
$(CHMOD) 444 $@
TARGETS += $(GENDATA_PUBLICSUFFIXLIST)

View File

@ -0,0 +1,154 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package build.tools.publicsuffixlist;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.file.attribute.FileTime;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/**
* This tool takes the original Mozilla public suffix rule list as input
* and slices it into a set of files, one for each top-level domain.
* Each file contains only the rules for that domain. Lines containing comments
* or only whitespace are not copied. Each of these files are then combined
* into the target zipfile.
*
* Usage: java GeneratePublicSuffixList mozilla_file destination_zipfile
*/
public final class GeneratePublicSuffixList {
// patterns
private static final String COMMENT = "//";
private static final String BEGIN_PRIVATE = "// ===BEGIN PRIVATE DOMAINS===";
private static final Pattern WHITESPACE = Pattern.compile("\\s*");
private static final byte ICANN = 0x00;
private static final byte PRIVATE = 0x01;
private static class Domain {
final String name;
final byte type;
Domain(String name, byte type) {
this.name = name;
this.type = type;
}
}
public static void main(String[] args) throws Exception {
if (args.length != 2) {
throw new Exception("2 args required: input_file output_file");
}
try (FileInputStream fis = new FileInputStream(args[0]);
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(args[1])))
{
BufferedReader br =
new BufferedReader(new InputStreamReader(fis, "UTF-8"));
List<Domain> domains = new LinkedList<>();
byte type = ICANN;
String line;
while ((line = br.readLine()) != null) {
if (line.startsWith(COMMENT)) {
if (line.startsWith(BEGIN_PRIVATE)) {
type = PRIVATE;
}
continue;
}
if (WHITESPACE.matcher(line).matches()) {
continue;
}
domains.add(new Domain(line, type));
}
// have a list of rules now
// Map of TLD names to rules with the same TLD
Map<String, List<Domain>> rules = addDomains(domains);
// stream for writing the file contents
BufferedWriter bw =
new BufferedWriter(new OutputStreamWriter(zos, "UTF-8"));
// now output each map entry to its own file,
// whose filename is the TLD
writeRules(zos, bw, rules);
}
}
private static Map<String, List<Domain>> addDomains(List<Domain> domains) {
Map<String, List<Domain>> rules = new HashMap<>();
for (Domain domain : domains) {
String tld = getTLD(domain.name);
rules.compute(tld, (k, v) -> {
if (v == null) {
List<Domain> newV = new LinkedList<>();
newV.add(domain);
return newV;
} else {
v.add(domain);
return v;
}
});
}
return rules;
}
private static void writeRules(ZipOutputStream zos, BufferedWriter bw,
Map<String, List<Domain>> rules)
throws IOException {
// Sort keys for deterministic output
List<String> tlds = rules.keySet().stream().sorted().collect(Collectors.toList());
for (String tld : tlds) {
List<Domain> entries = rules.get(tld);
ZipEntry ze = new ZipEntry(tld);
ze.setLastModifiedTime(FileTime.fromMillis(0));
zos.putNextEntry(ze);
for (Domain entry : entries) {
bw.write(entry.type);
bw.write(entry.name, 0, entry.name.length());
bw.newLine();
}
bw.flush();
}
}
private static String getTLD(String line) {
int dotIndex = line.lastIndexOf('.');
return (dotIndex == -1) ? line : line.substring(dotIndex + 1);
}
}

View File

@ -675,9 +675,21 @@ public final class SocketPermission extends Permission
private transient String cdomain, hdomain;
/**
* previously we allowed domain names to be specified in IDN ACE form
* Need to check for that and convert to Unicode
*/
private static String checkForIDN(String name) {
if (name.startsWith("xn--") || name.contains(".xn--")) {
return IDN.toUnicode(name);
} else {
return name;
}
}
private boolean match(String cname, String hname) {
String a = cname.toLowerCase();
String b = hname.toLowerCase();
String a = checkForIDN(cname.toLowerCase());
String b = checkForIDN(hname.toLowerCase());
if (a.startsWith(b) &&
((a.length() == b.length()) || (a.charAt(b.length()) == '.'))) {
return true;

View File

@ -1,913 +0,0 @@
/*
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.net;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/*
* WARNING: This class may contain out-of-date information. It should be
* updated or replaced with an appropriate implementation. See
* sun.security.util.RegisteredDomain for more information.
*
* The naming tables listed below were gathered from publicly available data such as
* the subdomain registration websites listed for each top-level domain by the Internet
* Assigned Numbers Authority and the website of the Internet Corporation for Assigned Names
* and Numbers as well as Wikipedia.
*/
public class RegisteredDomain {
// XX.AA
private static Set<String> top1Set = new HashSet<String>(Arrays.asList("asia", "biz", "cat", "coop",
"edu", "info", "gov", "jobs", "travel", "am", "aq", "ax", "cc", "cf", "cg", "ch", "cv", "cz",
"de", "dj", "dk", "fm", "fo", "ga", "gd", "gf", "gl", "gm", "gq", "gs", "gw", "hm",
"li", "lu", "md", "mh", "mil", "mobi", "mq", "ms", "ms", "ne", "nl", "nu", "si",
"sm", "sr", "su", "tc", "td", "tf", "tg", "tk", "tm", "tv", "va", "vg",
/* ae */ "xn--mgbaam7a8h", /* cn s */ "xn--fiqs8s", /* cn t */ "xn--fiqz9s",
/* eg */ "xn--wgbh1c", /* hk */ "xn--j6w193g", /* jo */ "xn--mgbayh7gpa",
/* lk */ "xn--fzc2c9e2c", /* ps */ "xn--ygbi2ammx", /* ru */ "xn--p1ai",
/* qa */ "xn--wgbl6a", /* sa */ "xn--mgberp4a5d4ar", /* sg */ "xn--yfro4i67o",
/* th */ "xn--o3cw4h", /* tn */ "xn--pgbs0dh", /* tw s */ "xn--kpry57d",
/* tw */ "xn--kprw13d", /* sg tamil */ "xn--clchc0ea0b2g2a9gcd"));
// common pattern: XX.AA or XX.GOV.AA
private static Set<String> top2Set = new HashSet<String>(Arrays.asList("as", "bf", "cd", "cx",
"ie", "lt", "mr", "tl"));
// common pattern: XX.AA or XX.COM.AA or XX.EDU.AA or XX.NET.AA or XX.ORG.AA or XX.GOV.AA
private static Set<String> top4Set = new HashSet<String>(Arrays.asList("af", "bm", "bs", "bt",
"bz", "dm", "ky", "lb", "lr", "mo", "sc", "sl", "ws"));
// AA or less than 3 other XX.BB.AA possible matches
private static Set<String> top3Set = new HashSet<String>(Arrays.asList("ad", "aw", "be", "bw",
"cl", "fi", "int", "io", "mc"));
// AA.UK exceptions
private static Set<String> ukSet = new HashSet<String>(Arrays.asList( "bl", "british-library",
"jet", "nhs", "nls", "parliament", "mod", "police"));
// AA.AR exceptions
private static Set<String> arSet = new HashSet<String>(Arrays.asList( "argentina", "educ",
"gobiernoelectronico", "nic", "promocion", "retina", "uba"));
// AA.OM exceptions
private static Set<String> omSet = new HashSet<String>(Arrays.asList("mediaphone", "nawrastelecom",
"nawras", "omanmobile", "omanpost", "omantel", "rakpetroleum", "siemens", "songfest",
"statecouncil", "shura", "peie", "omran", "omnic", "omanet", "oman", "muriya", "kom"));
// any XX.BB.AA
private static Set<String> top5Set = new HashSet<String>(Arrays.asList("au", "arpa", "bd", "bn", "ck",
"cy", "er", "et", "fj", "fk", "gt", "gu", "il", "jm", "ke", "kh", "kw",
"mm", "mt", "mz", "ni", "np", "nz", "pg", "sb", "sv", "tz", "uy", "ve", "ye",
"za", "zm", "zw"));
// XX.CC.BB.JP
private static Set<String> jpSet = new HashSet<String>(Arrays.asList("aichi", "akita", "aomori",
"chiba", "ehime", "fukui", "fukuoka", "fukushima", "gifu", "gunma", "hiroshima", "hokkaido",
"hyogo", "ibaraki", "ishikawa", "iwate", "kagawa", "kagoshima", "kanagawa", "kawasaki",
"kitakyushu", "kobe", "kochi", "kumamoto", "kyoto", "mie", "miyagi", "miyazaki", "nagano",
"nagasaki", "nagoya", "nara", "niigata", "oita", "okayama", "okinawa", "osaka", "saga",
"saitama", "sapporo", "sendai", "shiga", "shimane", "shizuoka", "tochigi", "tokushima",
"tokyo", "tottori", "toyama", "wakayama", "yamagata", "yamaguchi", "yamanashi", "yokohama"));
// CC.BB.JP exceptions
private static Set<String> jp2Set = new HashSet<String>(Arrays.asList("metro.tokyo.jp",
"pref.aichi.jp", "pref.akita.jp", "pref.aomori.jp", "pref.chiba.jp", "pref.ehime.jp",
"pref.fukui.jp", "pref.fukuoka.jp", "pref.fukushima.jp", "pref.gifu.jp", "pref.gunma.jp",
"pref.hiroshima.jp", "pref.hokkaido.jp", "pref.hyogo.jp", "pref.ibaraki.jp", "pref.ishikawa.jp",
"pref.iwate.jp", "pref.kagawa.jp", "pref.kagoshima.jp", "pref.kanagawa.jp", "pref.kochi.jp",
"pref.kumamoto.jp", "pref.kyoto.jp", "pref.mie.jp", "pref.miyagi.jp", "pref.miyazaki.jp",
"pref.nagano.jp", "pref.nagasaki.jp", "pref.nara.jp", "pref.niigata.jp", "pref.oita.jp",
"pref.okayama.jp", "pref.okinawa.jp", "pref.osaka.jp", "pref.saga.jp", "pref.saitama.jp",
"pref.shiga.jp", "pref.shimane.jp", "pref.shizuoka.jp", "pref.tochigi.jp", "pref.tokushima.jp",
"pref.tottori.jp", "pref.toyama.jp", "pref.wakayama.jp", "pref.yamagata.jp", "pref.yamaguchi.jp",
"pref.yamanashi.jp", "city.chiba.jp", "city.fukuoka.jp", "city.hamamatsu.jp", "city.hiroshima.jp", "city.kawasaki.jp",
"city.kitakyushu.jp", "city.kobe.jp", "city.kyoto.jp", "city.nagoya.jp", "city.niigata.jp",
"city.okayama.jp", "city.osaka.jp", "city.sagamihara.jp", "city.saitama.jp", "city.sapporo.jp", "city.sendai.jp",
"city.shizuoka.jp", "city.yokohama.jp"));
private static Set<String> usStateSet = new HashSet<String>(Arrays.asList("ak",
"al", "ar", "as", "az", "ca", "co", "ct", "dc", "de", "fl", "ga", "gu", "hi", "ia",
"id", "il", "in", "ks", "ky", "la", "ma", "md", "me", "mi", "mn", "mo", "ms", "mt",
"nc", "nd", "ne", "nh", "nj", "nm", "nv", "ny", "oh", "ok", "or", "pa", "pr", "ri",
"sc", "sd", "tn", "tx", "ut", "vi", "vt", "va", "wa", "wi", "wv", "wy"));
private static Set<String> usSubStateSet = new HashSet<String>(Arrays.asList("state",
"lib", "k12", "cc", "tec", "gen", "cog", "mus", "dst"));
private static Map<String,Set<String>> topMap = new HashMap<>();
private static Map<String,Set<String>> top3Map = new HashMap<>();
static {
/*
* XX.AA or XX.BB.AA
*/
topMap.put("ac", new HashSet<String>(Arrays.asList("com", "co", "edu", "gov", "net", "mil", "org")));
topMap.put("ae", new HashSet<String>(Arrays.asList("co", "net", "org", "sch", "ac", "gov", "mil")));
topMap.put("aero", new HashSet<String>(Arrays.asList("accident-investigation",
"accident-prevention", "aerobatic", "aeroclub", "aerodrome", "agents", "aircraft",
"airline", "airport", "air-surveillance", "airtraffic", "air-traffic-control",
"ambulance", "amusement", "association", "author", "ballooning", "broker", "caa",
"cargo", "catering", "certification", "championship", "charter", "civilaviation",
"club", "conference", "consultant", "consulting", "control", "council", "crew",
"design", "dgca", "educator", "emergency", "engine", "engineer", "entertainment",
"equipment", "exchange", "express", "federation", "flight", "freight", "fuel",
"gliding", "government", "groundhandling", "group", "hanggliding", "homebuilt",
"insurance", "journal", "journalist", "leasing", "logistics", "magazine",
"maintenance", "marketplace", "media", "microlight", "modelling", "navigation",
"parachuting", "paragliding", "passenger-association", "pilot", "press", "production",
"recreation", "repbody", "res", "research", "rotorcraft", "safety", "scientist",
"services", "show", "skydiving", "software", "student", "taxi", "trader", "trading",
"trainer", "union", "workinggroup", "works" )));
topMap.put( "ag", new HashSet<String>(Arrays.asList("com", "org", "net", "co", "nom")));
topMap.put( "ai", new HashSet<String>(Arrays.asList("off", "com", "net", "org")));
topMap.put( "al", new HashSet<String>(Arrays.asList("com", "edu", "gov", "mil", "net", "org")));
topMap.put( "an", new HashSet<String>(Arrays.asList("com")));
topMap.put( "ao", new HashSet<String>(Arrays.asList("ed", "gv", "og", "co", "pb", "it")));
topMap.put( "at", new HashSet<String>(Arrays.asList("ac", "co", "gv", "or", "biz", "info", "priv")));
topMap.put( "az", new HashSet<String>(Arrays.asList("com", "net", "int", "gov", "org", "edu", "info",
"pp", "mil", "name", "biz")));
topMap.put( "ba", new HashSet<String>(Arrays.asList("org", "net", "edu", "gov", "mil", "unbi",
"unmo", "unsa", "untz", "unze", "co", "com", "rs")));
topMap.put( "bb", new HashSet<String>(Arrays.asList("biz", "com", "edu", "gov", "info", "net", "org",
"store")));
topMap.put( "bg", new HashSet<String>(Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
"k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1",
"2", "3", "4", "5", "6", "7", "8", "9")));
topMap.put( "bh", new HashSet<String>(Arrays.asList("com", "info", "cc", "edu", "biz", "net",
"org", "gov")));
topMap.put( "bi", new HashSet<String>(Arrays.asList("co", "com", "edu", "gov", "info", "or", "org")));
topMap.put( "bj", new HashSet<String>(Arrays.asList("asso", "barreau", "com", "edu", "gouv", "gov", "mil")));
topMap.put( "bo", new HashSet<String>(Arrays.asList("com", "edu", "gov", "gob", "int", "org", "net",
"mil", "tv")));
topMap.put( "br", new HashSet<String>(Arrays.asList("adm", "adv", "agr", "am", "arq", "art", "ato",
"b", "bio", "blog", "bmd", "cim", "cng", "cnt", "com", "coop", "ecn", "edu", "emp", "eng",
"esp", "etc", "eti", "far", "flog", "fm", "fnd", "fot", "fst", "g12", "ggf", "gov",
"imb", "ind", "inf", "jor", "jus", "lel", "mat", "med", "mil", "mus", "net", "nom",
"not", "ntr", "odo", "org", "ppg", "pro", "psc", "psi", "qsl", "radio", "rec", "slg",
"srv", "taxi", "teo", "tmp", "trd", "tur", "tv", "vet", "vlog", "wiki", "zlg")));
topMap.put( "bw", new HashSet<String>(Arrays.asList("co", "gov", "org")));
topMap.put( "by", new HashSet<String>(Arrays.asList("gov", "mil", "com", "of")));
topMap.put( "ca", new HashSet<String>(Arrays.asList("ab", "bc", "mb", "nb", "nf",
"nl", "ns", "nt", "nu", "on", "pe", "qc", "sk", "yk", "gc")));
topMap.put( "ci", new HashSet<String>(Arrays.asList("org", "or", "com", "co", "edu",
"ed", "ac", "net", "go", "asso", "xn--aroport-bya", "int",
"presse", "md", "gouv")));
topMap.put( "com", new HashSet<String>(Arrays.asList("ad", "ar", "br", "cn", "de", "eu", "gb",
"gr", "hu", "jpn", "kr", "no", "qc", "ru", "sa", "se", "uk", "us", "uy", "za")));
topMap.put( "cm", new HashSet<String>(Arrays.asList("co", "com", "gov", "net")));
topMap.put( "cn", new HashSet<String>(Arrays.asList("ac", "com", "edu", "gov", "net",
"org", "mil", "xn--55qx5d", "xn--io0a7i",
"ah", "bj", "cq", "fj", "gd", "gs", "gz", "gx",
"ha", "hb", "he", "hi", "hl", "hn", "jl", "js", "jx", "ln", "nm", "nx", "qh",
"sc", "sd", "sh", "sn", "sx", "tj", "xj", "xz", "yn", "zj", "hk", "mo", "tw")));
topMap.put( "co", new HashSet<String>(Arrays.asList("arts", "com", "edu", "firm", "gov", "info",
"int", "mil", "net", "nom", "org", "rec", "web")));
topMap.put( "cr", new HashSet<String>(Arrays.asList("ac", "co", "ed", "fi", "go", "or", "sa")));
topMap.put( "cu", new HashSet<String>(Arrays.asList("com", "edu", "org", "net", "gov", "inf")));
topMap.put( "do", new HashSet<String>(Arrays.asList("com", "edu", "org", "net", "gov", "gob",
"web", "art", "sld", "mil")));
topMap.put( "dz", new HashSet<String>(Arrays.asList("com", "org", "net", "gov", "edu", "asso",
"pol", "art")));
topMap.put( "ec", new HashSet<String>(Arrays.asList("com", "info", "net", "fin", "k12", "med",
"pro", "org", "edu", "gov", "gob", "mil")));
topMap.put( "ee", new HashSet<String>(Arrays.asList("edu", "gov", "riik", "lib", "med", "com",
"pri", "aip", "org", "fie")));
topMap.put( "eg", new HashSet<String>(Arrays.asList("com", "edu", "eun", "gov", "mil", "name",
"net", "org", "sci")));
topMap.put( "es", new HashSet<String>(Arrays.asList("com", "nom", "org", "gob", "edu")));
topMap.put( "eu", new HashSet<String>(Arrays.asList("europa")));
topMap.put( "fr", new HashSet<String>(Arrays.asList("com", "asso", "nom", "prd", "presse",
"tm", "aeroport", "assedic", "avocat", "avoues", "cci", "chambagri",
"chirurgiens-dentistes", "experts-comptables", "geometre-expert", "gouv", "greta",
"huissier-justice", "medecin", "notaires", "pharmacien", "port", "veterinaire")));
topMap.put( "ge", new HashSet<String>(Arrays.asList("com", "edu", "gov", "org", "mil", "net", "pvt")));
topMap.put( "gg", new HashSet<String>(Arrays.asList("co", "org", "net", "sch", "gov")));
topMap.put( "gh", new HashSet<String>(Arrays.asList("com", "edu", "gov", "org", "mil")));
topMap.put( "gi", new HashSet<String>(Arrays.asList("com", "ltd", "gov", "mod", "edu", "org")));
topMap.put( "gn", new HashSet<String>(Arrays.asList("ac", "com", "edu", "gov", "org", "net")));
topMap.put( "gp", new HashSet<String>(Arrays.asList("com", "net", "mobi", "edu", "org", "asso")));
topMap.put( "gr", new HashSet<String>(Arrays.asList("com", "co", "net", "edu", "org", "gov",
"mil", "mod", "sch")));
topMap.put( "gy", new HashSet<String>(Arrays.asList("co", "com", "net", "org", "edu", "gov")));
topMap.put( "hk", new HashSet<String>(Arrays.asList("com", "edu", "gov", "idv", "net", "org",
/* com */ "xn--55qx5d", /* edu */ "xn--wcvs22d", /* gov */"xn--mxtq1m",
/* idv */ "xn--gmqw5a", /* net */ "xn--od0alg", /*org*/ "xn--uc0atv")));
topMap.put( /* hk */ "xn--j6w193g", new HashSet<String>(Arrays.asList(
/* com */ "xn--55qx5d", /* edu */ "xn--wcvs22d", /* gov */"xn--mxtq1m",
/* idv */ "xn--gmqw5a", /* net */ "xn--od0alg", /*org*/ "xn--uc0atv")));
topMap.put( "hn", new HashSet<String>(Arrays.asList("com", "edu", "org", "net", "mil", "gob")));
topMap.put( "hr", new HashSet<String>(Arrays.asList("iz.hr", "from.hr", "name.hr", "com.hr")));
topMap.put( "ht", new HashSet<String>(Arrays.asList("com", "shop", "firm", "info", "adult",
"net", "pro", "org", "med", "art", "coop", "pol", "asso", "edu", "rel", "gouv", "perso")));
topMap.put( "hu", new HashSet<String>(Arrays.asList("co", "info", "org", "priv", "sport", "tm",
"2000", "agrar", "bolt", "casino", "city", "erotica", "erotika", "film", "forum",
"games", "hotel", "ingatlan", "jogasz", "konyvelo", "lakas", "media", "news", "reklam",
"sex", "shop", "suli", "szex", "tozsde", "utazas", "video")));
topMap.put( "id", new HashSet<String>(Arrays.asList("ac", "co", "go", "mil", "net", "or", "sch",
"web")));
topMap.put( "im", new HashSet<String>(Arrays.asList("co.im", "com", "net.im", "gov.im", "org.im",
"ac.im")));
topMap.put( "in", new HashSet<String>(Arrays.asList("co", "firm", "ernet", "net", "org", "gen", "ind",
"nic", "ac", "edu", "res", "gov", "mil")));
topMap.put( "iq", new HashSet<String>(Arrays.asList("gov", "edu", "mil", "com", "org", "net" )));
topMap.put( "ir", new HashSet<String>(Arrays.asList("ac", "co", "gov", "id", "net", "org", "sch"
)));
topMap.put( "is", new HashSet<String>(Arrays.asList("net", "com", "edu", "gov", "org", "int")));
topMap.put( "it", new HashSet<String>(Arrays.asList("gov", "edu", "agrigento", "ag", "alessandria",
"al", "ancona", "an", "aosta", "aoste", "ao", "arezzo", "ar", "ascoli-piceno",
"ascolipiceno", "ap", "asti", "at", "avellino", "av", "bari", "ba",
"andria-barletta-trani", "andriabarlettatrani", "trani-barletta-andria",
"tranibarlettaandria", "barletta-trani-andria", "barlettatraniandria",
"andria-trani-barletta", "andriatranibarletta", "trani-andria-barletta",
"traniandriabarletta", "bt", "belluno", "bl", "benevento", "bn", "bergamo", "bg",
"biella", "bi", "bologna", "bo", "bolzano", "bozen", "balsan", "alto-adige",
"altoadige", "suedtirol", "bz", "brescia", "bs", "brindisi", "br", "cagliari",
"ca", "caltanissetta", "cl", "campobasso", "cb", "carboniaiglesias", "carbonia-iglesias",
"iglesias-carbonia", "iglesiascarbonia", "ci", "caserta", "ce", "catania", "ct",
"catanzaro", "cz", "chieti", "ch", "como", "co", "cosenza", "cs", "cremona", "cr",
"crotone", "kr", "cuneo", "cn", "dell-ogliastra", "dellogliastra", "ogliastra", "og",
"enna", "en", "ferrara", "fe", "fermo", "fm", "firenze", "florence", "fi", "foggia",
"fg", "forli-cesena", "forlicesena", "cesena-forli", "cesenaforli", "fc", "frosinone",
"fr", "genova", "genoa", "ge", "gorizia", "go", "grosseto", "gr", "imperia", "im",
"isernia", "is", "laquila", "aquila", "aq", "la-spezia", "laspezia", "sp", "latina",
"lt", "lecce", "le", "lecco", "lc", "livorno", "li", "lodi", "lo", "lucca", "lu",
"macerata", "mc", "mantova", "mn", "massa-carrara", "massacarrara", "carrara-massa",
"carraramassa", "ms", "matera", "mt", "medio-campidano", "mediocampidano",
"campidano-medio", "campidanomedio", "vs", "messina", "me", "milano", "milan",
"mi", "modena", "mo", "monza", "monza-brianza", "monzabrianza", "monzaebrianza",
"monzaedellabrianza", "monza-e-della-brianza", "mb", "napoli", "naples", "na",
"novara", "no", "nuoro", "nu", "oristano", "or", "padova", "padua", "pd", "palermo",
"pa", "parma", "pr", "pavia", "pv", "perugia", "pg", "pescara", "pe", "pesaro-urbino",
"pesarourbino", "urbino-pesaro", "urbinopesaro", "pu", "piacenza", "pc", "pisa",
"pi", "pistoia", "pt", "pordenone", "pn", "potenza", "pz", "prato", "po", "ragusa",
"rg", "ravenna", "ra", "reggio-calabria", "reggiocalabria", "rc", "reggio-emilia",
"reggioemilia", "re", "rieti", "ri", "rimini", "rn", "roma", "rome", "rm", "rovigo",
"ro", "salerno", "sa", "sassari", "ss", "savona", "sv", "siena", "si", "siracusa",
"sr", "sondrio", "so", "taranto", "ta", "tempio-olbia", "tempioolbia", "olbia-tempio",
"olbiatempio", "ot", "teramo", "te", "terni", "tr", "torino", "turin", "to",
"trapani", "tp", "trento", "trentino", "tn", "treviso", "tv", "trieste", "ts",
"udine", "ud", "varese", "va", "venezia", "venice", "ve", "verbania", "vb",
"vercelli", "vc", "verona", "vr", "vibo-valentia", "vibovalentia", "vv", "vicenza",
"vi", "viterbo", "vt")));
topMap.put( "je", new HashSet<String>(Arrays.asList("co", "org", "net", "sch", "gov")));
topMap.put( "jo", new HashSet<String>(Arrays.asList("com", "org", "net", "edu", "sch",
"gov", "mil", "name")));
topMap.put( "jp", new HashSet<String>(Arrays.asList("ac", "ad", "co", "ed", "go", "gr", "lg",
"ne", "or")));
topMap.put( "kg", new HashSet<String>(Arrays.asList("org", "net", "com", "edu", "gov", "mil")));
topMap.put( "ki", new HashSet<String>(Arrays.asList("edu", "biz", "net", "org", "gov",
"info", "com")));
topMap.put( "km", new HashSet<String>(Arrays.asList("org", "nom", "gov", "prd", "tm", "edu",
"mil", "ass", "com", "coop", "asso", "presse", "medecin", "notaires", "pharmaciens",
"veterinaire", "gouv")));
topMap.put( "kn", new HashSet<String>(Arrays.asList("net", "org", "edu", "gov")));
topMap.put( "kp", new HashSet<String>(Arrays.asList("com", "edu", "gov", "org", "rep", "tra")));
topMap.put( "kr", new HashSet<String>(Arrays.asList("ac", "co", "es", "go", "hs", "kg", "mil",
"ms", "ne", "or", "pe", "re", "sc", "busan", "chungbuk", "chungnam", "daegu",
"daejeon", "gangwon", "gwangju", "gyeongbuk", "gyeonggi", "gyeongnam", "incheon",
"jeju", "jeonbuk", "jeonnam", "seoul", "ulsan")));
topMap.put( "kz", new HashSet<String>(Arrays.asList("org", "edu", "net", "gov", "mil", "com")));
topMap.put( "la", new HashSet<String>(Arrays.asList("int", "net", "info", "edu", "gov", "per",
"com", "org", "c")));
topMap.put( "lc", new HashSet<String>(Arrays.asList("com", "net", "co", "org", "edu", "gov",
"l.lc", "p.lc")));
topMap.put( "lk", new HashSet<String>(Arrays.asList("gov", "sch", "net", "int", "com", "org",
"edu", "ngo", "soc", "web", "ltd", "assn", "grp", "hotel")));
topMap.put( "ls", new HashSet<String>(Arrays.asList("co", "gov", "ac", "org")));
topMap.put( "lv", new HashSet<String>(Arrays.asList("com", "edu", "gov", "org", "mil",
"id", "net", "asn", "conf")));
topMap.put( "ly", new HashSet<String>(Arrays.asList("com", "net", "gov", "plc", "edu", "sch",
"med", "org", "id")));
topMap.put( "ma", new HashSet<String>(Arrays.asList("co", "net", "gov", "org", "ac", "press")));
topMap.put( "me", new HashSet<String>(Arrays.asList("co", "net", "org", "edu", "ac", "gov",
"its", "priv")));
topMap.put( "mg", new HashSet<String>(Arrays.asList("org", "nom", "gov", "prd", "tm",
"edu", "mil", "com")));
topMap.put( "mk", new HashSet<String>(Arrays.asList("com", "org", "net", "edu", "gov", "inf",
"name", "pro")));
topMap.put( "ml", new HashSet<String>(Arrays.asList("com", "edu", "gouv", "gov", "net",
"org", "presse")));
topMap.put( "mn", new HashSet<String>(Arrays.asList("gov", "edu", "org")));
topMap.put( "mp", new HashSet<String>(Arrays.asList("gov", "co", "org")));
topMap.put( "mu", new HashSet<String>(Arrays.asList("com", "net", "org", "gov", "ac",
"co", "or")));
topMap.put( "museum", new HashSet<String>(Arrays.asList("academy", "agriculture", "air",
"airguard", "alabama", "alaska", "amber", "ambulance", "american", "americana",
"americanantiques", "americanart", "amsterdam", "and", "annefrank", "anthro",
"anthropology", "antiques", "aquarium", "arboretum", "archaeological", "archaeology",
"architecture", "art", "artanddesign", "artcenter", "artdeco", "arteducation",
"artgallery", "arts", "artsandcrafts", "asmatart", "assassination", "assisi",
"association", "astronomy", "atlanta", "austin", "australia", "automotive", "aviation",
"axis", "badajoz", "baghdad", "bahn", "bale", "baltimore", "barcelona", "baseball",
"basel", "baths", "bauern", "beauxarts", "beeldengeluid", "bellevue", "bergbau",
"berkeley", "berlin", "bern", "bible", "bilbao", "bill", "birdart", "birthplace",
"bonn", "boston", "botanical", "botanicalgarden", "botanicgarden", "botany",
"brandywinevalley", "brasil", "bristol", "british", "britishcolumbia", "broadcast",
"brunel", "brussel", "brussels", "bruxelles", "building", "burghof", "bus", "bushey",
"cadaques", "california", "cambridge", "can", "canada", "capebreton", "carrier",
"cartoonart", "casadelamoneda", "castle", "castres", "celtic", "center", "chattanooga",
"cheltenham", "chesapeakebay", "chicago", "children", "childrens", "childrensgarden",
"chiropractic", "chocolate", "christiansburg", "cincinnati", "cinema", "circus",
"civilisation", "civilization", "civilwar", "clinton", "clock", "coal", "coastaldefence",
"cody", "coldwar", "collection", "colonialwilliamsburg", "coloradoplateau", "columbia",
"columbus", "communication", "communications", "community", "computer",
"computerhistory", "xn--comunicaes-v6a2o", "contemporary", "contemporaryart",
"convent", "copenhagen", "corporation", "xn--correios-e-telecomunicaes-ghc29a",
"corvette", "costume", "countryestate", "county", "crafts", "cranbrook", "creation",
"cultural", "culturalcenter", "culture", "cyber", "cymru", "dali", "dallas", "database",
"ddr", "decorativearts", "delaware", "delmenhorst", "denmark", "depot", "design",
"detroit", "dinosaur", "discovery", "dolls", "donostia", "durham", "eastafrica",
"eastcoast", "education", "educational", "egyptian", "eisenbahn", "elburg",
"elvendrell", "embroidery", "encyclopedic", "england", "entomology", "environment",
"environmentalconservation", "epilepsy", "essex", "estate", "ethnology", "exeter",
"exhibition", "family", "farm", "farmequipment", "farmers", "farmstead", "field",
"figueres", "filatelia", "film", "fineart", "finearts", "finland", "flanders", "florida",
"force", "fortmissoula", "fortworth", "foundation", "francaise", "frankfurt",
"franziskaner", "freemasonry", "freiburg", "fribourg", "frog", "fundacio", "furniture",
"gallery", "garden", "gateway", "geelvinck", "gemological", "geology", "georgia",
"giessen", "glas", "glass", "gorge", "grandrapids", "graz", "guernsey", "halloffame",
"hamburg", "handson", "harvestcelebration", "hawaii", "health", "heimatunduhren",
"hellas", "helsinki", "hembygdsforbund", "heritage", "histoire", "historical",
"historicalsociety", "historichouses", "historisch", "historisches", "history",
"historyofscience", "horology", "house", "humanities", "illustration", "imageandsound",
"indian", "indiana", "indianapolis", "indianmarket", "intelligence", "interactive",
"iraq", "iron", "isleofman", "jamison", "jefferson", "jerusalem", "jewelry",
"jewish", "jewishart", "jfk", "journalism", "judaica", "judygarland", "juedisches",
"juif", "karate", "karikatur", "kids", "koebenhavn", "koeln", "kunst", "kunstsammlung",
"kunstunddesign", "labor", "labour", "lajolla", "lancashire", "landes", "lans",
"xn--lns-qla", "larsson", "lewismiller", "lincoln", "linz", "living", "livinghistory",
"localhistory", "london", "losangeles", "louvre", "loyalist", "lucerne", "luxembourg",
"luzern", "mad", "madrid", "mallorca", "manchester", "mansion", "mansions", "manx",
"marburg", "maritime", "maritimo", "maryland", "marylhurst", "media", "medical",
"medizinhistorisches", "meeres", "memorial", "mesaverde", "michigan", "midatlantic",
"military", "mill", "miners", "mining", "minnesota", "missile", "missoula", "modern",
"moma", "money", "monmouth", "monticello", "montreal", "moscow", "motorcycle", "muenchen",
"muenster", "mulhouse", "muncie", "museet", "museumcenter", "museumvereniging", "music",
"national", "nationalfirearms", "nationalheritage", "nativeamerican", "naturalhistory",
"naturalhistorymuseum", "naturalsciences", "nature", "naturhistorisches",
"natuurwetenschappen", "naumburg", "naval", "nebraska", "neues", "newhampshire",
"newjersey", "newmexico", "newport", "newspaper", "newyork", "niepce", "norfolk",
"north", "nrw", "nuernberg", "nuremberg", "nyc", "nyny", "oceanographic",
"oceanographique", "omaha", "online", "ontario", "openair", "oregon", "oregontrail",
"otago", "oxford", "pacific", "paderborn", "palace", "paleo", "palmsprings", "panama",
"paris", "pasadena", "pharmacy", "philadelphia", "philadelphiaarea", "philately",
"phoenix", "photography", "pilots", "pittsburgh", "planetarium", "plantation",
"plants", "plaza", "portal", "portland", "portlligat", "posts-and-telecommunications",
"preservation", "presidio", "press", "project", "public", "pubol", "quebec",
"railroad", "railway", "research", "resistance", "riodejaneiro", "rochester", "rockart",
"roma", "russia", "saintlouis", "salem", "salvadordali", "salzburg", "sandiego",
"sanfrancisco", "santabarbara", "santacruz", "santafe", "saskatchewan", "satx",
"savannahga", "schlesisches", "schoenbrunn", "schokoladen", "school", "schweiz",
"science", "scienceandhistory", "scienceandindustry", "sciencecenter", "sciencecenters",
"science-fiction", "sciencehistory", "sciences", "sciencesnaturelles", "scotland",
"seaport", "settlement", "settlers", "shell", "sherbrooke", "sibenik", "silk", "ski",
"skole", "society", "sologne", "soundandvision", "southcarolina", "southwest", "space",
"spy", "square", "stadt", "stalbans", "starnberg", "state", "stateofdelaware",
"station", "steam", "steiermark", "stjohn", "stockholm", "stpetersburg", "stuttgart",
"suisse", "surgeonshall", "surrey", "svizzera", "sweden", "sydney", "tank", "tcm",
"technology", "telekommunikation", "television", "texas", "textile", "theater",
"time", "timekeeping", "topology", "torino", "touch", "town", "transport", "tree",
"trolley", "trust", "trustee", "uhren", "ulm", "undersea", "university", "usa",
"usantiques", "usarts", "uscountryestate", "usculture", "usdecorativearts", "usgarden",
"ushistory", "ushuaia", "uslivinghistory", "utah", "uvic", "valley", "vantaa",
"versailles", "viking", "village", "virginia", "virtual", "virtuel", "vlaanderen",
"volkenkunde", "wales", "wallonie", "war", "washingtondc", "watchandclock",
"watch-and-clock", "western", "westfalen", "whaling", "wildlife", "williamsburg",
"windmill", "workshop", "york", "yorkshire", "yosemite", "youth", "zoological",
"zoology", "xn--9dbhblg6di", "xn--h1aegh")));
topMap.put( "mv", new HashSet<String>(Arrays.asList("aero", "biz", "com", "coop", "edu", "gov",
"info", "int", "mil", "museum", "name", "net", "org", "pro")));
topMap.put( "mw", new HashSet<String>(Arrays.asList("ac", "biz", "co", "com", "coop", "edu",
"gov", "int", "museum", "net", "org")));
topMap.put( "mx", new HashSet<String>(Arrays.asList("com", "org", "gob", "edu", "net")));
topMap.put( "my", new HashSet<String>(Arrays.asList("com", "net", "org", "gov", "edu",
"mil", "name", "sch")));
topMap.put( "na", new HashSet<String>(Arrays.asList("co", "com", "org", "edu", "edunet", "net",
"alt", "biz", "info")));
topMap.put( "nc", new HashSet<String>(Arrays.asList("asso", "nom")));
topMap.put( "net", new HashSet<String>(Arrays.asList("gb", "se", "uk", "za")));
topMap.put( "ng", new HashSet<String>(Arrays.asList("name", "sch", "mil", "mobi", "com",
"edu", "gov", "net", "org")));
topMap.put( "nf", new HashSet<String>(Arrays.asList("com", "net", "per", "rec", "web",
"arts", "firm", "info", "other", "store")));
topMap.put( "no", new HashSet<String>(Arrays.asList("fhs", "vgs", "fylkesbibl", "folkebibl",
"museum", "idrett", "priv", "mil", "stat", "dep", "kommune", "herad", "aa",
"ah", "bu", "fm", "hl", "hm", "jan-mayen", "mr", "nl", "nt", "of", "ol", "oslo",
"rl", "sf", "st", "svalbard", "tm", "tr", "va", "vf", "akrehamn",
"xn--krehamn-dxa", "algard", "xn--lgrd-poac", "arna", "brumunddal",
"bryne", "bronnoysund", "xn--brnnysund-m8ac", "drobak",
"xn--drbak-wua", "egersund", "fetsund", "floro", "xn--flor-jra",
"fredrikstad", "hokksund", "honefoss", "xn--hnefoss-q1a",
"jessheim", "jorpeland", "xn--jrpeland-54a", "kirkenes", "kopervik",
"krokstadelva", "langevag", "xn--langevg-jxa", "leirvik", "mjondalen",
"xn--mjndalen-64a", "mo-i-rana", "mosjoen", "xn--mosjen-eya",
"nesoddtangen", "orkanger", "osoyro", "xn--osyro-wua",
"raholt", "xn--rholt-mra", "sandnessjoen", "xn--sandnessjen-ogb",
"skedsmokorset", "slattum", "spjelkavik", "stathelle", "stavern", "stjordalshalsen",
"xn--stjrdalshalsen-sqb", "tananger", "tranby", "vossevangen", "tranby",
"vossevangen", "afjord", "xn--fjord-lra", "agdenes", "al",
"xn--l-1fa", "alesund", "xn--lesund-hua",
"alstahaug", "alta", "xn--lt-liac", "alaheadju",
"xn--laheadju-7ya", "alvdal", "amli", "xn--mli-tla",
"amot", "xn--mot-tla", "andebu", "andoy", "xn--andy-ira",
"andasuolo", "ardal", "xn--rdal-poa", "aremark", "arendal",
"xn--s-1fa", "aseral", "xn--seral-lra",
"asker", "askim", "askvoll", "askoy", "xn--asky-ira",
"asnes", "xn--snes-poa", "audnedaln", "aukra", "aure", "aurland",
"aurskog-holand", "xn--aurskog-hland-jnb",
"austevoll", "austrheim", "averoy", "xn--avery-yua",
"balestrand", "ballangen", "balat", "xn--blt-elab",
"balsfjord", "bahccavuotna", "xn--bhccavuotna-k7a",
"bamble", "bardu", "beardu", "beiarn", "bajddar", "xn--bjddar-pta",
"baidar", "xn--bidr-5nac", "berg", "bergen", "berlevag", "xn--berlevg-jxa",
"bearalvahki", "xn--bearalvhki-y4a", "bindal", "birkenes", "bjarkoy",
"xn--bjarky-fya", "bjerkreim", "bjugn", "bodo", "xn--bod-2na",
"badaddja", "xn--bdddj-mrabd", "budejju", "bokn",
"bremanger", "bronnoy", "xn--brnny-wuac", "bygland",
"bykle", "barum", "xn--brum-voa", "bievat", "xn--bievt-0qa",
"bomlo", "xn--bmlo-gra", "batsfjord", "xn--btsfjord-9za", "bahcavuotna",
"xn--bhcavuotna-s4a", "dovre", "drammen", "drangedal", "dyroy",
"xn--dyry-ira", "donna", "xn--dnna-gra",
"eid", "eidfjord", "eidsberg", "eidskog", "eidsvoll", "eigersund", "elverum",
"enebakk", "engerdal", "etne", "etnedal", "evenes", "evenassi",
"xn--eveni-0qa01ga", "evje-og-hornnes", "farsund", "fauske",
"fuossko", "fuoisku", "fedje", "fet", "finnoy", "xn--finny-yua",
"fitjar", "fjaler", "fjell", "flakstad", "flatanger", "flekkefjord", "flesberg",
"flora", "fla", "xn--fl-zia", "folldal", "forsand", "fosnes", "frei",
"frogn", "froland", "frosta", "frana", "xn--frna-woa",
"froya", "xn--frya-hra", "fusa", "fyresdal", "forde",
"xn--frde-gra", "gamvik", "gangaviika", "xn--ggaviika-8ya47h",
"gaular", "gausdal", "gildeskal", "xn--gildeskl-g0a",
"giske", "gjemnes", "gjerdrum", "gjerstad", "gjesdal", "gjovik",
"xn--gjvik-wua", "gloppen", "gol", "gran", "grane", "granvin",
"gratangen", "grimstad", "grong", "kraanghke", "xn--kranghke-b0a",
"grue", "gulen", "hadsel", "halden", "halsa", "hamar", "hamaroy", "habmer",
"xn--hbmer-xqa", "hapmir", "xn--hpmir-xqa",
"hammerfest", "hammarfeasta", "xn--hmmrfeasta-s4ac",
"haram", "hareid", "harstad", "hasvik", "aknoluokta", "xn--koluokta-7ya57h",
"hattfjelldal", "aarborte", "haugesund", "hemne", "hemnes", "hemsedal",
"hitra", "hjartdal", "hjelmeland",
"hobol", "xn--hobl-ira", "hof", "hol", "hole", "holmestrand", "holtalen",
"xn--holtlen-hxa", "hornindal", "horten", "hurdal", "hurum", "hvaler",
"hyllestad", "hagebostad", "xn--hgebostad-g3a", "hoyanger",
"xn--hyanger-q1a", "hoylandet", "xn--hylandet-54a",
"ha", "xn--h-2fa", "ibestad", "inderoy", "xn--indery-fya",
"iveland", "jevnaker", "jondal", "jolster", "xn--jlster-bya",
"karasjok", "karasjohka", "xn--krjohka-hwab49j",
"karlsoy", "galsa", "xn--gls-elac", "karmoy",
"xn--karmy-yua", "kautokeino", "guovdageaidnu", "klepp", "klabu",
"xn--klbu-woa", "kongsberg", "kongsvinger", "kragero", "xn--krager-gya",
"kristiansand", "kristiansund", "krodsherad", "xn--krdsherad-m8a",
"kvalsund", "rahkkeravju", "xn--rhkkervju-01af",
"kvam", "kvinesdal", "kvinnherad", "kviteseid", "kvitsoy", "xn--kvitsy-fya",
"kvafjord", "xn--kvfjord-nxa", "giehtavuoatna", "kvanangen",
"xn--kvnangen-k0a", "navuotna", "xn--nvuotna-hwa",
"kafjord", "xn--kfjord-iua", "gaivuotna", "xn--givuotna-8ya",
"larvik", "lavangen", "lavagis", "loabat", "xn--loabt-0qa",
"lebesby", "davvesiida", "leikanger", "leirfjord", "leka", "leksvik", "lenvik",
"leangaviika", "xn--leagaviika-52b", "lesja", "levanger", "lier", "lierne",
"lillehammer", "lillesand", "lindesnes", "lindas", "xn--linds-pra",
"lom", "loppa", "lahppi", "xn--lhppi-xqa", "lund", "lunner", "luroy",
"xn--lury-ira", "luster", "lyngdal", "lyngen", "ivgu", "lardal", "lerdal",
"xn--lrdal-sra", "lodingen", "xn--ldingen-q1a", "lorenskog",
"xn--lrenskog-54a", "loten", "xn--lten-gra", "malvik",
"masoy", "xn--msy-ula0h", "muosat", "xn--muost-0qa",
"mandal", "marker", "marnardal", "masfjorden", "meland", "meldal", "melhus",
"meloy", "xn--mely-ira", "meraker", "xn--merker-kua", "moareke",
"xn--moreke-jua", "midsund", "midtre-gauldal", "modalen", "modum",
"molde", "moskenes", "moss", "mosvik", "malselv", "xn--mlselv-iua",
"malatvuopmi", "xn--mlatvuopmi-s4a", "namdalseid", "aejrie", "namsos",
"namsskogan", "naamesjevuemie", "xn--nmesjevuemie-tcba",
"laakesvuemie", "nannestad", "narvik", "narviika", "naustdal", "nedre-eiker",
"nesna", "nesodden", "nesseby", "unjarga", "xn--unjrga-rta", "nesset",
"nissedal", "nittedal", "nord-aurdal", "nord-fron", "nord-odal", "norddal",
"nordkapp", "davvenjarga", "xn--davvenjrga-y4a", "nordre-land",
"nordreisa", "raisa", "xn--risa-5na", "nore-og-uvdal", "notodden", "naroy",
"xn--nry-yla5g", "notteroy", "xn--nttery-byae",
"odda", "oksnes", "xn--ksnes-uua", "oppdal", "oppegard",
"xn--oppegrd-ixa", "orkdal", "orland", "xn--rland-uua",
"orskog", "xn--rskog-uua", "orsta", "xn--rsta-fra",
"os.hedmark", "os.hordaland", "osen", "osteroy", "xn--ostery-fya",
"ostre-toten", "xn--stre-toten-zcb", "overhalla", "ovre-eiker",
"xn--vre-eiker-k8a", "oyer", "xn--yer-zna",
"oygarden", "xn--ygarden-p1a", "oystre-slidre", "xn--ystre-slidre-ujb",
"porsanger", "porsangu", "xn--porsgu-sta26f", "porsgrunn",
"radoy", "xn--rady-ira", "rakkestad", "rana", "ruovat", "randaberg",
"rauma", "rendalen", "rennebu", "rennesoy", "xn--rennesy-v1a",
"rindal", "ringebu", "ringerike", "ringsaker", "rissa", "risor",
"xn--risr-ira", "roan", "rollag", "rygge", "ralingen", "xn--rlingen-mxa",
"rodoy", "xn--rdy-0nab", "romskog", "xn--rmskog-bya",
"roros", "xn--rros-gra", "rost", "xn--rst-0na",
"royken", "xn--ryken-vua", "royrvik", "xn--ryrvik-bya",
"rade", "xn--rde-ula", "salangen", "siellak", "saltdal", "salat",
"xn--slt-elab", "xn--slat-5na", "samnanger",
"sandefjord", "sandnes", "sandoy", "xn--sandy-yua", "sarpsborg",
"sauda", "sauherad", "sel", "selbu", "selje", "seljord", "sigdal", "siljan",
"sirdal", "skaun", "skedsmo", "ski", "skien", "skiptvet", "skjervoy",
"xn--skjervy-v1a", "skierva", "xn--skierv-uta",
"skjak", "xn--skjk-soa", "skodje", "skanland", "xn--sknland-fxa",
"skanit", "xn--sknit-yqa", "smola", "xn--smla-hra",
"snillfjord", "snasa", "xn--snsa-roa", "snoasa", "snaase",
"xn--snase-nra", "sogndal", "sokndal", "sola", "solund", "songdalen",
"sortland", "spydeberg", "stange", "stavanger", "steigen", "steinkjer",
"stjordal", "xn--stjrdal-s1a", "stokke", "stor-elvdal", "stord", "stordal",
"storfjord", "omasvuotna", "strand", "stranda", "stryn", "sula", "suldal",
"sund", "sunndal", "surnadal", "sveio", "svelvik", "sykkylven", "sogne",
"xn--sgne-gra", "somna", "xn--smna-gra", "sondre-land",
"xn--sndre-land-0cb", "sor-aurdal", "xn--sr-aurdal-l8a",
"sor-fron", "xn--sr-fron-q1a", "sor-odal", "xn--sr-odal-q1a",
"sor-varanger", "xn--sr-varanger-ggb", "matta-varjjat",
"xn--mtta-vrjjat-k7af", "sorfold", "xn--srfold-bya",
"sorreisa", "xn--srreisa-q1a", "sorum", "xn--srum-gra",
"tana", "deatnu", "time", "tingvoll", "tinn", "tjeldsund", "dielddanuorri",
"tjome", "xn--tjme-hra", "tokke", "tolga", "torsken", "tranoy",
"xn--trany-yua", "tromso", "xn--troms-zua", "tromsa", "romsa",
"trondheim", "troandin", "trysil", "trana", "xn--trna-woa",
"trogstad", "xn--trgstad-r1a", "tvedestrand", "tydal", "tynset",
"tysfjord", "divtasvuodna", "divttasvuotna", "tysnes", "tysvar",
"xn--tysvr-vra", "tonsberg", "xn--tnsberg-q1a",
"ullensaker", "ullensvang", "ulvik", "utsira", "vadso", "xn--vads-jra",
"cahcesuolo", "xn--hcesuolo-7ya35b", "vaksdal", "valle", "vang",
"vanylven", "vardo", "xn--vard-jra", "varggat", "xn--vrggt-xqad",
"vefsn", "vaapste", "vega", "vegarshei", "xn--vegrshei-c0a", "vennesla",
"verdal", "verran", "vestby", "vestnes", "vestre-slidre", "vestre-toten",
"vestvagoy", "xn--vestvgy-ixa6o", "vevelstad", "vik", "vikna",
"vindafjord", "volda", "voss", "varoy", "xn--vry-yla5g",
"vagan", "xn--vgan-qoa", "voagat", "vagsoy", "xn--vgsy-qoa0j",
"vaga", "xn--vg-yiab")));
topMap.put( "nr", new HashSet<String>(Arrays.asList("biz", "info", "gov", "edu", "org",
"net", "com", "co")));
topMap.put( "pa", new HashSet<String>(Arrays.asList("ac", "gob", "com", "org",
"sld", "edu", "net", "ing", "abo", "med", "nom")));
topMap.put( "pe", new HashSet<String>(Arrays.asList("edu", "gob", "nom", "mil", "org", "com",
"net", "sld")));
topMap.put( "pf", new HashSet<String>(Arrays.asList( "com")));
topMap.put( "ph", new HashSet<String>(Arrays.asList("com", "net", "org", "gov", "edu", "ngo", "mil")));
topMap.put( "pk", new HashSet<String>(Arrays.asList("com", "net", "edu", "org", "fam", "biz",
"web", "gov", "gob", "gok", "gon", "gop", "gos", "gog", "gkp", "info")));
topMap.put( "pl", new HashSet<String>(Arrays.asList("aid", "agro", "atm", "auto", "biz", "com",
"edu", "gmina", "gsm", "info", "mail", "miasta", "media", "mil", "net", "nieruchomosci",
"nom", "org", "pc", "powiat", "priv", "realestate", "rel", "sex", "shop", "sklep",
"sos", "szkola", "targi", "tm", "tourism", "travel", "turystyka", "art",
"gov", "ngo", "augustow", "babia-gora", "bedzin", "beskidy",
"bialowieza", "bialystok", "bielawa", "bieszczady", "boleslawiec", "bydgoszcz",
"bytom", "cieszyn", "czeladz", "czest", "dlugoleka", "elblag", "elk", "glogow",
"gniezno", "gorlice", "grajewo", "ilawa", "jaworzno", "jelenia-gora", "jgora",
"kalisz", "kazimierz-dolny", "karpacz", "kartuzy", "kaszuby", "katowice", "kepno",
"ketrzyn", "klodzko", "kobierzyce", "kolobrzeg", "konin", "konskowola", "kutno",
"lapy", "lebork", "legnica", "lezajsk", "limanowa", "lomza", "lowicz", "lubin",
"lukow", "malbork", "malopolska", "mazowsze", "mazury", "mielec", "mielno", "mragowo",
"naklo", "nowaruda", "nysa", "olawa", "olecko", "olkusz", "olsztyn", "opoczno",
"opole", "ostroda", "ostroleka", "ostrowiec", "ostrowwlkp", "pila", "pisz", "podhale",
"podlasie", "polkowice", "pomorze", "pomorskie", "prochowice", "pruszkow", "przeworsk",
"pulawy", "radom", "rawa-maz", "rybnik", "rzeszow", "sanok", "sejny", "siedlce",
"slask", "slupsk", "sosnowiec", "stalowa-wola", "skoczow", "starachowice", "stargard",
"suwalki", "swidnica", "swiebodzin", "swinoujscie", "szczecin", "szczytno", "tarnobrzeg",
"tgory", "turek", "tychy", "ustka", "walbrzych", "warmia", "warszawa", "waw",
"wegrow", "wielun", "wlocl", "wloclawek", "wodzislaw", "wolomin", "wroclaw",
"zachpomor", "zagan", "zarow", "zgora", "zgorzelec", "gda", "gdansk",
"krakow", "poznan", "wroc", "co",
"lodz", "lublin", "torun")));
topMap.put( "pn", new HashSet<String>(Arrays.asList("gov", "co", "org", "edu", "net")));
topMap.put( "pr", new HashSet<String>(Arrays.asList("com", "net", "org", "gov", "edu", "isla",
"pro", "biz", "info", "name", "est", "prof", "ac", "gobierno")));
topMap.put( "pro", new HashSet<String>(Arrays.asList("aca", "bar", "cpa", "jur", "law",
"med", "eng")));
topMap.put( "ps", new HashSet<String>(Arrays.asList("edu", "gov", "sec", "plo", "com", "org", "net")));
topMap.put( "pt", new HashSet<String>(Arrays.asList("net", "gov", "org", "edu", "int", "publ",
"com", "nome")));
topMap.put( "pw", new HashSet<String>(Arrays.asList("co", "ne", "or", "ed", "go", "belau")));
topMap.put( "qa", new HashSet<String>(Arrays.asList("com", "net", "org", "gov", "edu", "mil")));
topMap.put( "re", new HashSet<String>(Arrays.asList("com", "asso", "nom")));
topMap.put( "ro", new HashSet<String>(Arrays.asList("com", "org", "tm", "nt", "nom", "info",
"rec", "arts", "firm", "store", "www")));
topMap.put( "rs", new HashSet<String>(Arrays.asList("co", "org", "edu", "ac", "gov", "in")));
topMap.put( "ru", new HashSet<String>(Arrays.asList("ac", "com", "edu", "int", "net", "org",
"pp", "adygeya", "altai", "amur", "arkhangelsk", "astrakhan", "bashkiria",
"belgorod", "bir", "bryansk", "buryatia", "cap", "cbg", "chel", "chelyabinsk", "chita",
"chukotka", "dagestan", "e-burg", "grozny", "irkutsk",
"ivanovo", "izhevsk", "jar", "joshkar-ola", "kalmykia", "kaluga", "kamchatka",
"karelia", "kazan", "kchr", "kemerovo", "khabarovsk", "khakassia", "khv", "kirov",
"koenig", "komi", "kostroma", "krasnoyarsk", "kuban", "kurgan", "kursk", "lipetsk",
"magadan", "mari", "mari-el", "marine", "mordovia", "mosreg", "msk", "murmansk",
"nalchik", "nnov", "nov", "novosibirsk", "nsk", "omsk", "orenburg", "oryol",
"palana", "penza", "perm", "pskov", "ptz", "rnd", "ryazan", "sakhalin", "samara",
"saratov", "simbirsk", "smolensk", "spb", "stavropol", "stv", "surgut", "tambov",
"tatarstan", "tom", "tomsk", "tsaritsyn", "tsk", "tula", "tuva", "tver", "tyumen",
"udm", "udmurtia", "ulan-ude", "vladikavkaz", "vladimir", "vladivostok", "volgograd",
"vologda", "voronezh", "vrn", "vyatka", "yakutia", "yamal", "yaroslavl",
"yekaterinburg", "yuzhno-sakhalinsk", "amursk", "baikal", "cmw", "fareast",
"jamal", "kms", "k-uralsk", "kustanai", "kuzbass", "magnitka", "mytis",
"nakhodka", "nkz", "norilsk", "oskol", "pyatigorsk", "rubtsovsk", "snz", "syzran",
"vdonsk", "zgrad", "gov", "mil", "test")));
topMap.put( "rw", new HashSet<String>(Arrays.asList("gov", "net", "edu", "ac", "com", "co",
"int", "mil", "gouv")));
topMap.put( "sa", new HashSet<String>(Arrays.asList("com", "net", "org", "gov", "med", "pub",
"edu", "sch")));
topMap.put( "sd", new HashSet<String>(Arrays.asList("com", "net", "org", "edu", "med", "gov",
"info", "tv")));
topMap.put( "se", new HashSet<String>(Arrays.asList("a", "ac", "b", "bd", "brand", "c", "d",
"e", "f", "fh", "fhsk", "fhv", "g", "h", "i", "k", "komforb", "kommunalforbund",
"komvux", "l", "lanarb", "lanbib", "m", "n", "naturbruksgymn", "o", "org", "p", "parti",
"pp", "press", "r", "s", "sshn", "t", "tm", "u", "w", "x", "y", "z")));
topMap.put( "sg", new HashSet<String>(Arrays.asList("com", "net", "org", "gov", "edu", "per")));
topMap.put( "sh", new HashSet<String>(Arrays.asList("co", "com", "net", "org", "gov", "edu", "nom")));
topMap.put( "sk", new HashSet<String>(Arrays.asList("gov", "edu")));
topMap.put( "sn", new HashSet<String>(Arrays.asList("art", "com", "edu", "gouv", "org", "perso",
"univ")));
topMap.put( "so", new HashSet<String>(Arrays.asList("com", "net", "org")));
topMap.put( "sr", new HashSet<String>(Arrays.asList("co", "com", "consulado", "edu", "embaixada",
"gov", "mil", "net", "org", "principe", "saotome", "store")));
topMap.put( "sy", new HashSet<String>(Arrays.asList("edu", "gov", "net", "mil", "com", "org", "news")));
topMap.put( "sz", new HashSet<String>(Arrays.asList("co", "ac", "org")));
topMap.put( "th", new HashSet<String>(Arrays.asList("ac", "co", "go", "in", "mi", "net", "or")));
topMap.put( "tj", new HashSet<String>(Arrays.asList("ac", "biz", "co", "com", "edu", "go", "gov",
"int", "mil", "name", "net", "nic", "org", "test", "web")));
topMap.put( "tn", new HashSet<String>(Arrays.asList("com", "ens", "fin", "gov", "ind", "intl",
"nat", "net", "org", "info", "perso", "tourism", "edunet", "rnrt", "rns", "rnu",
"mincom", "agrinet", "defense", "turen")));
topMap.put( "to", new HashSet<String>(Arrays.asList("gov")));
topMap.put( "tt", new HashSet<String>(Arrays.asList("co", "com", "org", "net", "biz", "info",
"pro", "int", "coop", "jobs", "mobi", "travel", "museum", "aero", "name", "gov",
"edu", "cat", "tel", "mil")));
topMap.put( "tw", new HashSet<String>(Arrays.asList("edu", "gov", "mil", "com", "net", "org",
"idv", "game", "ebiz", "club", "xn--zf0ao64a", "xn--uc0atv", "xn--czrw28b")));
topMap.put( "ua", new HashSet<String>(Arrays.asList("com", "edu", "gov", "in", "net", "org",
"cherkassy", "chernigov", "chernovtsy", "ck", "cn", "crimea", "cv", "dn",
"dnepropetrovsk", "donetsk", "dp", "if", "ivano-frankivsk", "kh", "kharkov",
"kherson", "kiev", "kirovograd", "km", "kr", "ks", "lg",
"lugansk", "lutsk", "lviv", "mk", "nikolaev", "od", "odessa", "pl", "poltava",
"rovno", "rv", "sebastopol", "sumy", "te", "ternopil", "uzhgorod", "vinnica", "vn",
"zaporizhzhe", "zp", "zhitomir", "zt", "cr", "lt", "lv", "sb", "sm", "tr",
"co", "biz", "in", "ne", "pp", "uz", "dominic")));
topMap.put( "ug", new HashSet<String>(Arrays.asList("co", "ac", "sc", "go", "ne", "or", "org", "com")));
topMap.put( "us", new HashSet<String>(Arrays.asList("dni", "fed", "isa", "kids", "nsn", "kyschools")));
topMap.put( "uz", new HashSet<String>(Arrays.asList("co", "com", "org", "gov", "ac", "edu", "int", "pp", "net")));
topMap.put( "vc", new HashSet<String>(Arrays.asList("com", "net", "org", "gov")));
topMap.put( "vi", new HashSet<String>(Arrays.asList("co", "com", "k12", "net", "org")));
topMap.put( "vn", new HashSet<String>(Arrays.asList( "com", "net", "org", "edu", "gov", "int",
"ac", "biz", "info", "name", "pro", "health")));
topMap.put( "vu", new HashSet<String>(Arrays.asList("co", "com", "net", "org", "edu", "gov", "de")));
topMap.put("org", new HashSet<String>(Arrays.asList("ae", "za")));
topMap.put("pro", new HashSet<String>(Arrays.asList("aca", "bar", "cpa", "jur", "law", "med", "eng")));
top3Map.put("au", new HashSet<String>(Arrays.asList("act.edu.au", "eq.edu.au",
"nsw.edu.au", "nt.edu.au", "qld.edu.au", "sa.edu.au", "tas.edu.au", "vic.edu.au",
"wa.edu.au", "act.gov.au", "nsw.gov.au", "nt.gov.au", "qld.gov.au", "sa.gov.au",
"tas.gov.au", "vic.gov.au", "wa.gov.au")));
top3Map.put("im", new HashSet<String>(Arrays.asList("ltd.co.im", "plc.co.im")));
top3Map.put("no", new HashSet<String>(Arrays.asList("gs.aa.no", "gs.ah.no", "gs.bu.no",
"gs.fm.no", "gs.hl.no", "gs.hm.no", "gs.jan-mayen.no", "gs.mr.no", "gs.nl.no",
"gs.nt.no", "gs.of.no", "gs.ol.no", "gs.oslo.no", "gs.rl.no", "gs.sf.no",
"gs.st.no", "gs.svalbard.no", "gs.tm.no", "gs.tr.no", "gs.va.no", "gs.vf.no",
"bo.telemark.no", "xn--b-5ga.telemark.no", "bo.nordland.no",
"xn--b-5ga.nordland.no", "heroy.more-og-romsdal.no",
"xn--hery-ira.xn--mre-og-romsdal-qqb.no", "heroy.nordland.no",
"xn--hery-ira.nordland.no", "nes.akershus.no", "nes.buskerud.no",
"os.hedmark.no", "os.hordaland.no",
"sande.more-og-romsdal.no", "sande.xn--mre-og-romsdal-qqb.no",
"sande.vestfold.no", "valer.ostfold.no", "xn--vler-qoa.xn--stfold-9xa.no",
"valer.hedmark.no", "xn--vler-qoa.hedmark.no")));
top3Map.put("tr", new HashSet<String>(Arrays.asList("gov.nc.tr")));
}
/**
* Returns a {@code sun.security.util.RegisteredDomain} representing the
* registered part of the specified domain.
*
* @param domain the domain name
* @return a {@code sun.security.util.RegisteredDomain} or null
* if the domain is unknown or not registerable
* @throws NullPointerException if domain is null
*/
public static sun.security.util.RegisteredDomain registeredDomain(String domain) {
String name = getRegisteredDomain(domain);
if (name.equals(domain)) {
return null;
}
return new sun.security.util.RegisteredDomain() {
private String rname = name;
@Override
public String name() {
return rname;
}
@Override
public sun.security.util.RegisteredDomain.Type type() {
return sun.security.util.RegisteredDomain.Type.ICANN;
}
@Override
public String publicSuffix() {
return rname.substring(rname.indexOf(".") + 1);
}
};
}
/*
* Return the registered part of a qualified domain
* name or the original if no match is found.
*/
public static String getRegisteredDomain(String cname) {
int dot;
/*
* If one dot or less than just return.
*/
dot = cname.lastIndexOf('.');
if (dot == -1)
return cname;
if (dot == 0)
return "";
if (dot == cname.length() - 1) {
cname = cname.substring(0, cname.length() -1);
dot = cname.lastIndexOf('.');
if (dot == -1)
return cname;
if (dot == 0)
return "";
}
if (dot == cname.length() - 1)
return "";
/*
* Break it up into seperate labels.
*/
int second = cname.lastIndexOf('.', dot - 1);
if (second == -1)
return cname;
if (second == 0)
return "";
int third = cname.lastIndexOf('.', second - 1);
int fourth = -1;
if (third > 0) {
fourth = cname.lastIndexOf('.', third - 1);
}
int fifth = -1;
if (fourth > 0) {
fifth = cname.lastIndexOf('.', fourth - 1);
}
String s = cname.substring(dot + 1);
String s2 = cname.substring(second + 1, dot);
/*
* Look for longest matches first.
* XX.PVT.K12.MA.US etc.
*/
if (fourth != -1 && s.equals("us") && usStateSet.contains(s2)) {
String s3 = cname.substring(third + 1, second);
String s4 = cname.substring(fourth + 1, third);
if (s3.equals("k12")) {
if (s2.equals("ma") && (s4.equals("chtr") || s4.equals("paroch"))) {
return cname.substring(fifth + 1);
} else if (s4.equals("pvt")) {
return cname.substring(fifth + 1);
}
}
}
/*
* XX.K12.MA.US.
*/
String str = cname.substring(third + 1);
if (third != -1) {
Set<String> set = top3Map.get(s);
if (set != null) {
if (set.contains(str)) {
return cname.substring(fourth + 1);
}
} else if (s.equals("us") && usStateSet.contains(s2)) {
// check for known third level labels
String s3 = cname.substring(third + 1, second);
if (usSubStateSet.contains(s3)) {
return fourth != -1? cname.substring(fourth + 1): cname;
} else {
return cname.substring(third + 1);
}
} else if (s.equals("uk")) {
if (s2.equals("sch")) {
return cname.substring(fourth + 1);
}
} else if (s.equals("jp")) {
if (jpSet.contains(s2)) {
if (jp2Set.contains(str)) {
return cname.substring(third + 1);
}
return cname.substring(fourth + 1);
}
}
}
/*
* PREF.AKITA.JP etc.
*/
if (jp2Set.contains(str)) {
return cname.substring(third + 1);
}
/*
* XX.MA.US.
*/
Set<String> topSet = topMap.get(s);
if (topSet != null) {
if (topSet.contains(s2)) {
return cname.substring(third + 1);
}
if (!((s.equals("us") && usStateSet.contains(s2)) || (s.equals("jp") && jpSet.contains(s2)))) {
return cname.substring(second + 1);
}
} else if (top2Set.contains(s)) {
if (s2.equals("gov")) {
return cname.substring(third + 1);
}
return cname.substring(second + 1);
} else if (top3Set.contains(s)) {
if (s.equals("ad") && s2.equals("nom") ||
s.equals("aw") && s2.equals("com") ||
s.equals("be") && s2.equals("ac") ||
s.equals("cl") && s2.equals("gov") ||
s.equals("cl") && s2.equals("gob") ||
s.equals("fi") && s2.equals("aland") ||
s.equals("int") && s2.equals("eu") ||
s.equals("io") && s2.equals("com") ||
s.equals("mc") && s2.equals("tm") ||
s.equals("mc") && s2.equals("asso") ||
s.equals("vc") && s2.equals("com")) {
return cname.substring(third + 1);
}
return cname.substring(second + 1);
} else if (top4Set.contains(s)) {
if (s2.equals("com") || s2.equals("edu") || s2.equals("gov") ||
s2.equals("net") || s2.equals("org")) {
return cname.substring(third + 1);
}
return cname.substring(second + 1);
} else if (top5Set.contains(s)) {
return cname.substring(third + 1);
}
/*
* BB.AA exception cases.
*/
if (s.equals("tr")) {
if (!s2.equals("nic") && !s2.equals("tsk")) {
return cname.substring(third + 1);
}
return cname.substring(second + 1);
} else if (s.equals("uk")) {
if (!ukSet.contains(s2)) {
return cname.substring(third + 1);
}
return cname.substring(second + 1);
} else if (s.equals("ar")) {
if (!arSet.contains(s2)) {
return cname.substring(third + 1);
}
return cname.substring(second + 1);
} else if (s.equals("om")) {
if (!omSet.contains(s2)) {
return cname.substring(third + 1);
}
return cname.substring(second + 1);
}
/*
* XX.AA
*/
if (top1Set.contains(s)) {
return cname.substring(second + 1);
}
/*
* Nothing matched so we can't shorten the string.
*/
return cname;
}
}

View File

@ -0,0 +1,637 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.security.util;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import sun.security.ssl.SSLLogger;
/**
* Allows public suffixes and registered domains to be determined from a
* string that represents a target domain name. A database of known
* registered suffixes is used to perform the determination.
*
* A public suffix is defined as the rightmost part of a domain name
* that is not owned by an individual registrant. Examples of
* public suffixes are:
* com
* edu
* co.uk
* k12.ak.us
* com.tw
* \u7db2\u8def.tw
*
* Public suffixes effectively denote registration authorities.
*
* A registered domain is a public suffix preceded by one domain label
* and a ".". Examples are:
* oracle.com
* mit.edu
*
* The internal database is derived from the information maintained at
* http://publicsuffix.org. The information is fixed for a particular
* JDK installation, but may be updated in future releases or updates.
*
* Because of the large number of top-level domains (TLDs) and public
* suffix rules, we only load the rules on demand -- from a Zip file
* containing an entry for each TLD.
*
* As each entry is loaded, its data is stored permanently in a cache.
*
* The containment hierarchy for the data is shown below:
*
* Rules --> contains all the rules for a particular TLD
* RuleSet --> contains all the rules that match 1 label
* RuleSet --> contains all the rules that match 2 labels
* RuleSet --> contains all the rules that match 3 labels
* :
* RuleSet --> contains all the rules that match N labels
* HashSet of rules, where each rule is an exception rule, a "normal"
* rule, a wildcard rule (rules that contain a wildcard prefix only),
* or a LinkedList of "other" rules
*
* The general matching algorithm tries to find a longest match. So, the
* search begins at the RuleSet with the most labels, and works backwards.
*
* Exceptions take priority over all other rules, and if a Rule contains
* any exceptions, then even if we find a "normal" match, we search all
* other RuleSets for exceptions. It is assumed that all other rules don't
* intersect/overlap. If this happens, a match will be returned, but not
* necessarily the expected one. For a further explanation of the rules,
* see http://publicsuffix.org/list/.
*
* The "other" rules are for the (possible future) case where wildcards
* are located in a rule any place other than the beginning.
*/
class DomainName {
/**
* For efficiency, the set of rules for each TLD is kept
* in text files and only loaded if needed.
*/
private static final Map<String, Rules> cache = new ConcurrentHashMap<>();
private DomainName() {}
/**
* Returns the registered domain of the specified domain.
*
* @param domain the domain name
* @return the registered domain, or null if not known or not registerable
* @throws NullPointerException if domain is null
*/
public static RegisteredDomain registeredDomain(String domain) {
Match match = getMatch(domain);
return (match != null) ? match.registeredDomain() : null;
}
private static Match getMatch(String domain) {
if (domain == null) {
throw new NullPointerException();
}
Rules rules = Rules.getRules(domain);
return rules == null ? null : rules.match(domain);
}
/**
* A Rules object contains a list of rules for a particular TLD.
*
* Rules are stored in a linked list of RuleSet objects. The list is
* indexed according to the number of labels in the name (minus one)
* such that all rules with the same number of labels are stored
* in the same RuleSet.
*
* Doing this means we can find the longest match first, and also we
* can stop comparing as soon as we find a match.
*/
private static class Rules {
private final LinkedList<RuleSet> ruleSets = new LinkedList<>();
private final boolean hasExceptions;
private Rules(InputStream is) throws IOException {
InputStreamReader isr = new InputStreamReader(is, "UTF-8");
BufferedReader reader = new BufferedReader(isr);
boolean hasExceptions = false;
String line;
int type = reader.read();
while (type != -1 && (line = reader.readLine()) != null) {
int numLabels = RuleSet.numLabels(line);
if (numLabels != 0) {
RuleSet ruleset = getRuleSet(numLabels - 1);
ruleset.addRule(type, line);
hasExceptions |= ruleset.hasExceptions;
}
type = reader.read();
}
this.hasExceptions = hasExceptions;
}
static Rules getRules(String domain) {
String tld = getTopLevelDomain(domain);
if (tld.isEmpty()) {
return null;
}
return cache.computeIfAbsent(tld, k -> createRules(tld));
}
private static String getTopLevelDomain(String domain) {
int n = domain.lastIndexOf('.');
if (n == -1) {
return domain;
}
return domain.substring(n + 1);
}
private static Rules createRules(String tld) {
try (InputStream pubSuffixStream = getPubSuffixStream()) {
if (pubSuffixStream == null) {
return null;
}
return getRules(tld, new ZipInputStream(pubSuffixStream));
} catch (IOException e) {
if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
SSLLogger.fine(
"cannot parse public suffix data for " + tld +
": " + e.getMessage());
}
return null;
}
}
private static InputStream getPubSuffixStream() {
InputStream is = AccessController.doPrivileged(
new PrivilegedAction<>() {
@Override
public InputStream run() {
File f = new File(System.getProperty("java.home"),
"lib/security/public_suffix_list.dat");
try {
return new FileInputStream(f);
} catch (FileNotFoundException e) {
return null;
}
}
}
);
if (is == null) {
if (SSLLogger.isOn && SSLLogger.isOn("ssl") &&
SSLLogger.isOn("trustmanager")) {
SSLLogger.fine(
"lib/security/public_suffix_list.dat not found");
}
}
return is;
}
private static Rules getRules(String tld,
ZipInputStream zis) throws IOException {
boolean found = false;
ZipEntry ze = zis.getNextEntry();
while (ze != null && !found) {
if (ze.getName().equals(tld)) {
found = true;
} else {
ze = zis.getNextEntry();
}
}
if (!found) {
if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
SSLLogger.fine("Domain " + tld + " not found");
}
return null;
}
return new Rules(zis);
}
/**
* Return the requested RuleSet. If it hasn't been created yet,
* create it and any RuleSets leading up to it.
*/
private RuleSet getRuleSet(int index) {
if (index < ruleSets.size()) {
return ruleSets.get(index);
}
RuleSet r = null;
for (int i = ruleSets.size(); i <= index; i++) {
r = new RuleSet(i + 1);
ruleSets.add(r);
}
return r;
}
/**
* Find a match for the target string.
*/
Match match(String domain) {
// Start at the end of the rules list, looking for longest match.
// After we find a normal match, we only look for exceptions.
Match possibleMatch = null;
Iterator<RuleSet> it = ruleSets.descendingIterator();
while (it.hasNext()) {
RuleSet ruleSet = it.next();
Match match = ruleSet.match(domain);
if (match != null) {
if (match.type() == Rule.Type.EXCEPTION || !hasExceptions) {
return match;
}
if (possibleMatch == null) {
possibleMatch = match;
}
}
}
return possibleMatch;
}
/**
* Represents a set of rules with the same number of labels
* and for a particular TLD.
*
* Examples:
* numLabels = 2
* names: co.uk, ac.uk
* wildcards *.de (only "de" stored in HashSet)
* exceptions: !foo.de (stored as "foo.de")
*/
private static class RuleSet {
// the number of labels in this ruleset
private final int numLabels;
private final Set<Rule> rules = new HashSet<>();
boolean hasExceptions = false;
private static final RegisteredDomain.Type[] AUTHS =
RegisteredDomain.Type.values();
RuleSet(int n) {
numLabels = n;
}
void addRule(int auth, String rule) {
if (rule.startsWith("!")) {
rules.add(new Rule(rule.substring(1), Rule.Type.EXCEPTION,
AUTHS[auth]));
hasExceptions = true;
} else if (rule.startsWith("*.") &&
rule.lastIndexOf('*') == 0) {
rules.add(new Rule(rule.substring(2), Rule.Type.WILDCARD,
AUTHS[auth]));
} else if (rule.indexOf('*') == -1) {
// a "normal" label
rules.add(new Rule(rule, Rule.Type.NORMAL, AUTHS[auth]));
} else {
// There is a wildcard in a non-leading label. This case
// doesn't currently exist, but we need to handle it anyway.
rules.add(new OtherRule(rule, AUTHS[auth], split(rule)));
}
}
Match match(String domain) {
Match match = null;
for (Rule rule : rules) {
switch (rule.type) {
case NORMAL:
if (match == null) {
match = matchNormal(domain, rule);
}
break;
case WILDCARD:
if (match == null) {
match = matchWildcard(domain, rule);
}
break;
case OTHER:
if (match == null) {
match = matchOther(domain, rule);
}
break;
case EXCEPTION:
Match excMatch = matchException(domain, rule);
if (excMatch != null) {
return excMatch;
}
break;
}
}
return match;
}
private static LinkedList<String> split(String rule) {
String[] labels = rule.split("\\.");
return new LinkedList<>(Arrays.asList(labels));
}
private static int numLabels(String rule) {
if (rule.equals("")) {
return 0;
}
int len = rule.length();
int count = 0;
int index = 0;
while (index < len) {
int pos;
if ((pos = rule.indexOf('.', index)) == -1) {
return count + 1;
}
index = pos + 1;
count++;
}
return count;
}
/**
* Check for a match with an explicit name rule or a wildcard rule
* (i.e., a non-exception rule).
*/
private Match matchNormal(String domain, Rule rule) {
int index = labels(domain, numLabels);
if (index == -1) {
return null;
}
// Check for explicit names.
String substring = domain.substring(index);
if (rule.domain.equals(substring)) {
return new CommonMatch(domain, rule, index);
}
return null;
}
private Match matchWildcard(String domain, Rule rule) {
// Now check for wildcards. In this case, there is one fewer
// label than numLabels.
int index = labels(domain, numLabels - 1);
if (index > 0) {
String substring = domain.substring(index);
if (rule.domain.equals(substring)) {
return new CommonMatch(domain, rule,
labels(domain, numLabels));
}
}
return null;
}
/**
* Check for a match with an exception rule.
*/
private Match matchException(String domain, Rule rule) {
int index = labels(domain, numLabels);
if (index == -1) {
return null;
}
String substring = domain.substring(index);
if (rule.domain.equals(substring)) {
return new CommonMatch(domain, rule,
labels(domain, numLabels - 1));
}
return null;
}
/**
* A left-to-right comparison of labels.
* The simplest approach to doing match() would be to
* use a descending iterator giving a right-to-left comparison.
* But, it's more efficient to do left-to-right compares
* because the left most labels are the ones most likely to be
* different. We just have to figure out which label to start at.
*/
private Match matchOther(String domain, Rule rule) {
OtherRule otherRule = (OtherRule)rule;
LinkedList<String> target = split(domain);
int diff = target.size() - numLabels;
if (diff < 0) {
return null;
}
boolean found = true;
for (int i = 0; i < numLabels; i++) {
String ruleLabel = otherRule.labels.get(i);
String targetLabel = target.get(i + diff);
if (ruleLabel.charAt(0) != '*' &&
!ruleLabel.equalsIgnoreCase(targetLabel)) {
found = false;
break;
}
}
if (found) {
return new OtherMatch(rule, numLabels, target);
}
return null;
}
/**
* Returns a substring (index) with the n right-most labels from s.
* Returns -1 if s does not have at least n labels, 0, if the
* substring is s.
*/
private static int labels(String s, int n) {
if (n < 1) {
return -1;
}
int index = s.length();
for (int i = 0; i < n; i++) {
int next = s.lastIndexOf('.', index);
if (next == -1) {
if (i == n - 1) {
return 0;
} else {
return -1;
}
}
index = next - 1;
}
return index + 2;
}
}
}
private static class Rule {
enum Type { EXCEPTION, NORMAL, OTHER, WILDCARD }
String domain;
Type type;
RegisteredDomain.Type auth;
Rule(String domain, Type type, RegisteredDomain.Type auth) {
this.domain = domain;
this.type = type;
this.auth = auth;
}
}
private static class OtherRule extends Rule {
List<String> labels;
OtherRule(String domain, RegisteredDomain.Type auth,
List<String> labels) {
super(domain, Type.OTHER, auth);
this.labels = labels;
}
}
/**
* Represents a string's match with a rule in the public suffix list.
*/
private interface Match {
RegisteredDomain registeredDomain();
Rule.Type type();
}
private static class RegisteredDomainImpl implements RegisteredDomain {
private final String name;
private final Type type;
private final String publicSuffix;
RegisteredDomainImpl(String name, Type type, String publicSuffix) {
this.name = name;
this.type = type;
this.publicSuffix = publicSuffix;
}
@Override
public String name() {
return name;
}
@Override
public Type type() {
return type;
}
@Override
public String publicSuffix() {
return publicSuffix;
}
}
/**
* Represents a match against a standard rule in the public suffix list.
* A standard rule is an explicit name, a wildcard rule with a wildcard
* only in the leading label, or an exception rule.
*/
private static class CommonMatch implements Match {
private String domain;
private int publicSuffix; // index to
private int registeredDomain; // index to
private final Rule rule;
CommonMatch(String domain, Rule rule, int publicSuffix) {
this.domain = domain;
this.publicSuffix = publicSuffix;
this.rule = rule;
// now locate the previous label
registeredDomain = domain.lastIndexOf('.', publicSuffix - 2);
if (registeredDomain == -1) {
registeredDomain = 0;
} else {
registeredDomain++;
}
}
@Override
public RegisteredDomain registeredDomain() {
if (publicSuffix == 0) {
return null;
}
return new RegisteredDomainImpl(domain.substring(registeredDomain),
rule.auth,
domain.substring(publicSuffix));
}
@Override
public Rule.Type type() {
return rule.type;
}
}
/**
* Represents a non-match with {@code NO_MATCH} or a match against
* a non-standard rule in the public suffix list. A non-standard rule
* is a wildcard rule that includes wildcards in a label other than
* the leading label. The public suffix list doesn't currently have
* such rules.
*/
private static class OtherMatch implements Match {
private final Rule rule;
private final int numLabels;
private final LinkedList<String> target;
OtherMatch(Rule rule, int numLabels, LinkedList<String> target) {
this.rule = rule;
this.numLabels = numLabels;
this.target = target;
}
@Override
public RegisteredDomain registeredDomain() {
int nlabels = numLabels + 1;
if (nlabels > target.size()) {
// special case when registered domain is same as pub suff
return null;
}
return new RegisteredDomainImpl(getSuffixes(nlabels),
rule.auth, getSuffixes(numLabels));
}
@Override
public Rule.Type type() {
return rule.type;
}
private String getSuffixes(int n) {
Iterator<String> targetIter = target.descendingIterator();
StringBuilder sb = new StringBuilder();
while (n > 0 && targetIter.hasNext()) {
String s = targetIter.next();
sb.insert(0, s);
if (n > 1) {
sb.insert(0, '.');
}
n--;
}
return sb.toString();
}
}
}

View File

@ -26,6 +26,7 @@
package sun.security.util;
import java.io.IOException;
import java.net.IDN;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.security.Principal;
@ -261,6 +262,11 @@ public class HostnameChecker {
*/
private boolean isMatched(String name, String template,
boolean chainsToPublicCA) {
// Normalize to Unicode, because PSL is in Unicode.
name = IDN.toUnicode(IDN.toASCII(name));
template = IDN.toUnicode(IDN.toASCII(template));
if (hasIllegalWildcard(name, template, chainsToPublicCA)) {
return false;
}
@ -271,7 +277,7 @@ public class HostnameChecker {
// the domain name template validity.
//
// Using the checking implemented in SNIHostName
SNIHostName sni = new SNIHostName(template.replace('*', 'x'));
new SNIHostName(template.replace('*', 'x'));
} catch (IllegalArgumentException iae) {
// It would be nice to add debug log if not matching.
return false;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -74,20 +74,12 @@ public interface RegisteredDomain {
* Returns an {@code Optional<RegisteredDomain>} representing the
* registered part of the specified domain.
*
* {@implNote}
* The default implementation is based on the legacy
* {@code sun.net.RegisteredDomain} class which is no longer maintained.
* It should be updated or replaced with an appropriate implementation.
*
* @param domain the domain name
* @return an {@code Optional<RegisteredDomain>}; the {@code Optional} is
* empty if the domain is unknown or not registerable
* @throws NullPointerException if domain is null
*/
public static Optional<RegisteredDomain> from(String domain) {
if (domain == null) {
throw new NullPointerException();
}
return Optional.ofNullable(sun.net.RegisteredDomain.registeredDomain(domain));
return Optional.ofNullable(DomainName.registeredDomain(domain));
}
}

View File

@ -0,0 +1,399 @@
## Mozilla Public Suffix List
### Public Suffix Notice
<pre>
You are receiving a copy of the Mozilla Public Suffix List in the following
file: <java-home>/lib/security/public_suffix_list.dat. The terms of the
Oracle license do NOT apply to this file; it is licensed under the
Mozilla Public License 2.0, separately from the Oracle programs you receive.
If you do not wish to use the Public Suffix List, you may remove the
<java-home>/lib/security/public_suffix_list.dat file.
The Source Code of this file is available under the
Mozilla Public License, v. 2.0 and is located at
https://github.com/publicsuffix/list/blob/03089bfe4aa5b7a2e291f33e07a28d20f875cb83/public_suffix_list.dat
If a copy of the MPL was not distributed with this file, you can obtain one
at http://mozilla.org/MPL/2.0/.
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.
</pre>
### MPL v2.0
<pre>
Mozilla Public License Version 2.0
==================================
1. Definitions
--------------
1.1. "Contributor"
means each individual or legal entity that creates, contributes to
the creation of, or owns Covered Software.
1.2. "Contributor Version"
means the combination of the Contributions of others (if any) used
by a Contributor and that particular Contributor's Contribution.
1.3. "Contribution"
means Covered Software of a particular Contributor.
1.4. "Covered Software"
means Source Code Form to which the initial Contributor has attached
the notice in Exhibit A, the Executable Form of such Source Code
Form, and Modifications of such Source Code Form, in each case
including portions thereof.
1.5. "Incompatible With Secondary Licenses"
means
(a) that the initial Contributor has attached the notice described
in Exhibit B to the Covered Software; or
(b) that the Covered Software was made available under the terms of
version 1.1 or earlier of the License, but not also under the
terms of a Secondary License.
1.6. "Executable Form"
means any form of the work other than Source Code Form.
1.7. "Larger Work"
means a work that combines Covered Software with other material, in
a separate file or files, that is not Covered Software.
1.8. "License"
means this document.
1.9. "Licensable"
means having the right to grant, to the maximum extent possible,
whether at the time of the initial grant or subsequently, any and
all of the rights conveyed by this License.
1.10. "Modifications"
means any of the following:
(a) any file in Source Code Form that results from an addition to,
deletion from, or modification of the contents of Covered
Software; or
(b) any new file in Source Code Form that contains any Covered
Software.
1.11. "Patent Claims" of a Contributor
means any patent claim(s), including without limitation, method,
process, and apparatus claims, in any patent Licensable by such
Contributor that would be infringed, but for the grant of the
License, by the making, using, selling, offering for sale, having
made, import, or transfer of either its Contributions or its
Contributor Version.
1.12. "Secondary License"
means either the GNU General Public License, Version 2.0, the GNU
Lesser General Public License, Version 2.1, the GNU Affero General
Public License, Version 3.0, or any later versions of those
licenses.
1.13. "Source Code Form"
means the form of the work preferred for making modifications.
1.14. "You" (or "Your")
means an individual or a legal entity exercising rights under this
License. For legal entities, "You" includes any entity that
controls, is controlled by, or is under common control with You. For
purposes of this definition, "control" means (a) the power, direct
or indirect, to cause the direction or management of such entity,
whether by contract or otherwise, or (b) ownership of more than
fifty percent (50%) of the outstanding shares or beneficial
ownership of such entity.
2. License Grants and Conditions
--------------------------------
2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license:
(a) under intellectual property rights (other than patent or trademark)
Licensable by such Contributor to use, reproduce, make available,
modify, display, perform, distribute, and otherwise exploit its
Contributions, either on an unmodified basis, with Modifications, or
as part of a Larger Work; and
(b) under Patent Claims of such Contributor to make, use, sell, offer
for sale, have made, import, and otherwise transfer either its
Contributions or its Contributor Version.
2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution
become effective for each Contribution on the date the Contributor first
distributes such Contribution.
2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under
this License. No additional rights or licenses will be implied from the
distribution or licensing of Covered Software under this License.
Notwithstanding Section 2.1(b) above, no patent license is granted by a
Contributor:
(a) for any code that a Contributor has removed from Covered Software;
or
(b) for infringements caused by: (i) Your and any other third party's
modifications of Covered Software, or (ii) the combination of its
Contributions with other software (except as part of its Contributor
Version); or
(c) under Patent Claims infringed by Covered Software in the absence of
its Contributions.
This License does not grant any rights in the trademarks, service marks,
or logos of any Contributor (except as may be necessary to comply with
the notice requirements in Section 3.4).
2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to
distribute the Covered Software under a subsequent version of this
License (see Section 10.2) or under the terms of a Secondary License (if
permitted under the terms of Section 3.3).
2.5. Representation
Each Contributor represents that the Contributor believes its
Contributions are its original creation(s) or it has sufficient rights
to grant the rights to its Contributions conveyed by this License.
2.6. Fair Use
This License is not intended to limit any rights You have under
applicable copyright doctrines of fair use, fair dealing, or other
equivalents.
2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
in Section 2.1.
3. Responsibilities
-------------------
3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any
Modifications that You create or to which You contribute, must be under
the terms of this License. You must inform recipients that the Source
Code Form of the Covered Software is governed by the terms of this
License, and how they can obtain a copy of this License. You may not
attempt to alter or restrict the recipients' rights in the Source Code
Form.
3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then:
(a) such Covered Software must also be made available in Source Code
Form, as described in Section 3.1, and You must inform recipients of
the Executable Form how they can obtain a copy of such Source Code
Form by reasonable means in a timely manner, at a charge no more
than the cost of distribution to the recipient; and
(b) You may distribute such Executable Form under the terms of this
License, or sublicense it under different terms, provided that the
license for the Executable Form does not attempt to limit or alter
the recipients' rights in the Source Code Form under this License.
3.3. Distribution of a Larger Work
You may create and distribute a Larger Work under terms of Your choice,
provided that You also comply with the requirements of this License for
the Covered Software. If the Larger Work is a combination of Covered
Software with a work governed by one or more Secondary Licenses, and the
Covered Software is not Incompatible With Secondary Licenses, this
License permits You to additionally distribute such Covered Software
under the terms of such Secondary License(s), so that the recipient of
the Larger Work may, at their option, further distribute the Covered
Software under the terms of either this License or such Secondary
License(s).
3.4. Notices
You may not remove or alter the substance of any license notices
(including copyright notices, patent notices, disclaimers of warranty,
or limitations of liability) contained within the Source Code Form of
the Covered Software, except that You may alter any license notices to
the extent required to remedy known factual inaccuracies.
3.5. Application of Additional Terms
You may choose to offer, and to charge a fee for, warranty, support,
indemnity or liability obligations to one or more recipients of Covered
Software. However, You may do so only on Your own behalf, and not on
behalf of any Contributor. You must make it absolutely clear that any
such warranty, support, indemnity, or liability obligation is offered by
You alone, and You hereby agree to indemnify every Contributor for any
liability incurred by such Contributor as a result of warranty, support,
indemnity or liability terms You offer. You may include additional
disclaimers of warranty and limitations of liability specific to any
jurisdiction.
4. Inability to Comply Due to Statute or Regulation
---------------------------------------------------
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Software due to
statute, judicial order, or regulation then You must: (a) comply with
the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description must
be placed in a text file included with all distributions of the Covered
Software under this License. Except to the extent prohibited by statute
or regulation, such description must be sufficiently detailed for a
recipient of ordinary skill to be able to understand it.
5. Termination
--------------
5.1. The rights granted under this License will terminate automatically
if You fail to comply with any of its terms. However, if You become
compliant, then the rights granted under this License from a particular
Contributor are reinstated (a) provisionally, unless and until such
Contributor explicitly and finally terminates Your grants, and (b) on an
ongoing basis, if such Contributor fails to notify You of the
non-compliance by some reasonable means prior to 60 days after You have
come back into compliance. Moreover, Your grants from a particular
Contributor are reinstated on an ongoing basis if such Contributor
notifies You of the non-compliance by some reasonable means, this is the
first time You have received notice of non-compliance with this License
from such Contributor, and You become compliant prior to 30 days after
Your receipt of the notice.
5.2. If You initiate litigation against any entity by asserting a patent
infringement claim (excluding declaratory judgment actions,
counter-claims, and cross-claims) alleging that a Contributor Version
directly or indirectly infringes any patent, then the rights granted to
You by any and all Contributors for the Covered Software under Section
2.1 of this License shall terminate.
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
end user license agreements (excluding distributors and resellers) which
have been validly granted by You or Your distributors under this License
prior to termination shall survive termination.
************************************************************************
* *
* 6. Disclaimer of Warranty *
* ------------------------- *
* *
* Covered Software is provided under this License on an "as is" *
* basis, without warranty of any kind, either expressed, implied, or *
* statutory, including, without limitation, warranties that the *
* Covered Software is free of defects, merchantable, fit for a *
* particular purpose or non-infringing. The entire risk as to the *
* quality and performance of the Covered Software is with You. *
* Should any Covered Software prove defective in any respect, You *
* (not any Contributor) assume the cost of any necessary servicing, *
* repair, or correction. This disclaimer of warranty constitutes an *
* essential part of this License. No use of any Covered Software is *
* authorized under this License except under this disclaimer. *
* *
************************************************************************
************************************************************************
* *
* 7. Limitation of Liability *
* -------------------------- *
* *
* Under no circumstances and under no legal theory, whether tort *
* (including negligence), contract, or otherwise, shall any *
* Contributor, or anyone who distributes Covered Software as *
* permitted above, be liable to You for any direct, indirect, *
* special, incidental, or consequential damages of any character *
* including, without limitation, damages for lost profits, loss of *
* goodwill, work stoppage, computer failure or malfunction, or any *
* and all other commercial damages or losses, even if such party *
* shall have been informed of the possibility of such damages. This *
* limitation of liability shall not apply to liability for death or *
* personal injury resulting from such party's negligence to the *
* extent applicable law prohibits such limitation. Some *
* jurisdictions do not allow the exclusion or limitation of *
* incidental or consequential damages, so this exclusion and *
* limitation may not apply to You. *
* *
************************************************************************
8. Litigation
-------------
Any litigation relating to this License may be brought only in the
courts of a jurisdiction where the defendant maintains its principal
place of business and such litigation shall be governed by laws of that
jurisdiction, without reference to its conflict-of-law provisions.
Nothing in this Section shall prevent a party's ability to bring
cross-claims or counter-claims.
9. Miscellaneous
----------------
This License represents the complete agreement concerning the subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. Any law or regulation which provides
that the language of a contract shall be construed against the drafter
shall not be used to construe this License against a Contributor.
10. Versions of the License
---------------------------
10.1. New Versions
Mozilla Foundation is the license steward. Except as provided in Section
10.3, no one other than the license steward has the right to modify or
publish new versions of this License. Each version will be given a
distinguishing version number.
10.2. Effect of New Versions
You may distribute the Covered Software under the terms of the version
of the License under which You originally received the Covered Software,
or under the terms of any subsequent version published by the license
steward.
10.3. Modified Versions
If you create software not governed by this License, and you want to
create a new license for such software, you may create and use a
modified version of this License if you rename the license and remove
any references to the name of the license steward (except to note that
such modified license differs from this License).
10.4. Distributing Source Code Form that is Incompatible With Secondary
Licenses
If You choose to distribute Source Code Form that is Incompatible With
Secondary Licenses under the terms of this version of the License, the
notice described in Exhibit B of this License must be attached.
Exhibit A - Source Code Form License Notice
-------------------------------------------
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular
file, then You may include the notice in a location (such as a LICENSE
file in a relevant directory) where a recipient would be likely to look
for such a notice.
You may add additional accurate notices of copyright ownership.
Exhibit B - "Incompatible With Secondary Licenses" Notice
---------------------------------------------------------
This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.
</pre>

View File

@ -33,4 +33,3 @@ exclude sun.reflect.misc.Trampoline.invoke(Ljava/lang/reflect/Method;Ljava/lang/
# assert(referenceMask != -1) failed: must not be a derived reference type
exclude com.sun.crypto.provider.AESWrapCipher.engineUnwrap([BLjava/lang/String;I)Ljava/security/Key;
exclude sun.security.ssl.*
exclude sun.net.RegisteredDomain.<clinit>()V