001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.openstreetmap.josm.data.validation.routines;
018
019import java.net.IDN;
020import java.util.Arrays;
021import java.util.Locale;
022
023/**
024 * <p><b>Domain name</b> validation routines.</p>
025 *
026 * <p>
027 * This validator provides methods for validating Internet domain names
028 * and top-level domains.
029 * </p>
030 *
031 * <p>Domain names are evaluated according
032 * to the standards <a href="http://www.ietf.org/rfc/rfc1034.txt">RFC1034</a>,
033 * section 3, and <a href="http://www.ietf.org/rfc/rfc1123.txt">RFC1123</a>,
034 * section 2.1. No accommodation is provided for the specialized needs of
035 * other applications; if the domain name has been URL-encoded, for example,
036 * validation will fail even though the equivalent plaintext version of the
037 * same name would have passed.
038 * </p>
039 *
040 * <p>
041 * Validation is also provided for top-level domains (TLDs) as defined and
042 * maintained by the Internet Assigned Numbers Authority (IANA):
043 * </p>
044 *
045 *   <ul>
046 *     <li>{@link #isValidInfrastructureTld} - validates infrastructure TLDs
047 *         (<code>.arpa</code>, etc.)</li>
048 *     <li>{@link #isValidGenericTld} - validates generic TLDs
049 *         (<code>.com, .org</code>, etc.)</li>
050 *     <li>{@link #isValidCountryCodeTld} - validates country code TLDs
051 *         (<code>.us, .uk, .cn</code>, etc.)</li>
052 *   </ul>
053 *
054 * <p>
055 * (<b>NOTE</b>: This class does not provide IP address lookup for domain names or
056 * methods to ensure that a given domain name matches a specific IP; see
057 * {@link java.net.InetAddress} for that functionality.)
058 * </p>
059 *
060 * @version $Revision: 1725571 $
061 * @since Validator 1.4
062 */
063public final class DomainValidator extends AbstractValidator {
064
065    private static final int MAX_DOMAIN_LENGTH = 253;
066
067    private static final String[] EMPTY_STRING_ARRAY = new String[0];
068
069    // Regular expression strings for hostnames (derived from RFC2396 and RFC 1123)
070
071    // RFC2396: domainlabel   = alphanum | alphanum *( alphanum | "-" ) alphanum
072    // Max 63 characters
073    private static final String DOMAIN_LABEL_REGEX = "\\p{Alnum}(?>[\\p{Alnum}-]{0,61}\\p{Alnum})?";
074
075    // RFC2396 toplabel = alpha | alpha *( alphanum | "-" ) alphanum
076    // Max 63 characters
077    private static final String TOP_LABEL_REGEX = "\\p{Alpha}(?>[\\p{Alnum}-]{0,61}\\p{Alnum})?";
078
079    // RFC2396 hostname = *( domainlabel "." ) toplabel [ "." ]
080    // Note that the regex currently requires both a domain label and a top level label, whereas
081    // the RFC does not. This is because the regex is used to detect if a TLD is present.
082    // If the match fails, input is checked against DOMAIN_LABEL_REGEX (hostnameRegex)
083    // RFC1123 sec 2.1 allows hostnames to start with a digit
084    private static final String DOMAIN_NAME_REGEX =
085            "^(?:" + DOMAIN_LABEL_REGEX + "\\.)+" + "(" + TOP_LABEL_REGEX + ")\\.?$";
086
087    private final boolean allowLocal;
088
089    /**
090     * Singleton instance of this validator, which
091     *  doesn't consider local addresses as valid.
092     */
093    private static final DomainValidator DOMAIN_VALIDATOR = new DomainValidator(false);
094
095    /**
096     * Singleton instance of this validator, which does
097     *  consider local addresses valid.
098     */
099    private static final DomainValidator DOMAIN_VALIDATOR_WITH_LOCAL = new DomainValidator(true);
100
101    /**
102     * RegexValidator for matching domains.
103     */
104    private final RegexValidator domainRegex =
105            new RegexValidator(DOMAIN_NAME_REGEX);
106    /**
107     * RegexValidator for matching a local hostname
108     */
109    // RFC1123 sec 2.1 allows hostnames to start with a digit
110    private final RegexValidator hostnameRegex =
111            new RegexValidator(DOMAIN_LABEL_REGEX);
112
113    /**
114     * Returns the singleton instance of this validator. It
115     *  will not consider local addresses as valid.
116     * @return the singleton instance of this validator
117     */
118    public static synchronized DomainValidator getInstance() {
119        inUse = true;
120        return DOMAIN_VALIDATOR;
121    }
122
123    /**
124     * Returns the singleton instance of this validator,
125     *  with local validation as required.
126     * @param allowLocal Should local addresses be considered valid?
127     * @return the singleton instance of this validator
128     */
129    public static synchronized DomainValidator getInstance(boolean allowLocal) {
130        inUse = true;
131        if (allowLocal) {
132            return DOMAIN_VALIDATOR_WITH_LOCAL;
133        }
134        return DOMAIN_VALIDATOR;
135    }
136
137    /**
138     * Private constructor.
139     * @param allowLocal whether to allow local domains
140     */
141    private DomainValidator(boolean allowLocal) {
142        this.allowLocal = allowLocal;
143    }
144
145    /**
146     * Returns true if the specified <code>String</code> parses
147     * as a valid domain name with a recognized top-level domain.
148     * The parsing is case-insensitive.
149     * @param domain the parameter to check for domain name syntax
150     * @return true if the parameter is a valid domain name
151     */
152    @Override
153    public boolean isValid(String domain) {
154        if (domain == null) {
155            return false;
156        }
157        domain = unicodeToASCII(domain);
158        // hosts must be equally reachable via punycode and Unicode
159        // Unicode is never shorter than punycode, so check punycode
160        // if domain did not convert, then it will be caught by ASCII
161        // checks in the regexes below
162        if (domain.length() > MAX_DOMAIN_LENGTH) {
163            return false;
164        }
165        String[] groups = domainRegex.match(domain);
166        if (groups != null && groups.length > 0) {
167            return isValidTld(groups[0]);
168        }
169        return allowLocal && hostnameRegex.isValid(domain);
170    }
171
172    @Override
173    public String getValidatorName() {
174        return null;
175    }
176
177    // package protected for unit test access
178    // must agree with isValid() above
179    boolean isValidDomainSyntax(String domain) {
180        if (domain == null) {
181            return false;
182        }
183        domain = unicodeToASCII(domain);
184        // hosts must be equally reachable via punycode and Unicode
185        // Unicode is never shorter than punycode, so check punycode
186        // if domain did not convert, then it will be caught by ASCII
187        // checks in the regexes below
188        if (domain.length() > MAX_DOMAIN_LENGTH) {
189            return false;
190        }
191        String[] groups = domainRegex.match(domain);
192        return (groups != null && groups.length > 0)
193                || hostnameRegex.isValid(domain);
194    }
195
196    /**
197     * Returns true if the specified <code>String</code> matches any
198     * IANA-defined top-level domain. Leading dots are ignored if present.
199     * The search is case-insensitive.
200     * @param tld the parameter to check for TLD status, not null
201     * @return true if the parameter is a TLD
202     */
203    public boolean isValidTld(String tld) {
204        tld = unicodeToASCII(tld);
205        if (allowLocal && isValidLocalTld(tld)) {
206            return true;
207        }
208        return isValidInfrastructureTld(tld)
209                || isValidGenericTld(tld)
210                || isValidCountryCodeTld(tld);
211    }
212
213    /**
214     * Returns true if the specified <code>String</code> matches any
215     * IANA-defined infrastructure top-level domain. Leading dots are
216     * ignored if present. The search is case-insensitive.
217     * @param iTld the parameter to check for infrastructure TLD status, not null
218     * @return true if the parameter is an infrastructure TLD
219     */
220    public boolean isValidInfrastructureTld(String iTld) {
221        final String key = chompLeadingDot(unicodeToASCII(iTld).toLowerCase(Locale.ENGLISH));
222        return arrayContains(INFRASTRUCTURE_TLDS, key);
223    }
224
225    /**
226     * Returns true if the specified <code>String</code> matches any
227     * IANA-defined generic top-level domain. Leading dots are ignored
228     * if present. The search is case-insensitive.
229     * @param gTld the parameter to check for generic TLD status, not null
230     * @return true if the parameter is a generic TLD
231     */
232    public boolean isValidGenericTld(String gTld) {
233        final String key = chompLeadingDot(unicodeToASCII(gTld).toLowerCase(Locale.ENGLISH));
234        return (arrayContains(GENERIC_TLDS, key) || arrayContains(genericTLDsPlus, key))
235                && !arrayContains(genericTLDsMinus, key);
236    }
237
238    /**
239     * Returns true if the specified <code>String</code> matches any
240     * IANA-defined country code top-level domain. Leading dots are
241     * ignored if present. The search is case-insensitive.
242     * @param ccTld the parameter to check for country code TLD status, not null
243     * @return true if the parameter is a country code TLD
244     */
245    public boolean isValidCountryCodeTld(String ccTld) {
246        final String key = chompLeadingDot(unicodeToASCII(ccTld).toLowerCase(Locale.ENGLISH));
247        return (arrayContains(COUNTRY_CODE_TLDS, key) || arrayContains(countryCodeTLDsPlus, key))
248                && !arrayContains(countryCodeTLDsMinus, key);
249    }
250
251    /**
252     * Returns true if the specified <code>String</code> matches any
253     * widely used "local" domains (localhost or localdomain). Leading dots are
254     * ignored if present. The search is case-insensitive.
255     * @param lTld the parameter to check for local TLD status, not null
256     * @return true if the parameter is an local TLD
257     */
258    public boolean isValidLocalTld(String lTld) {
259        final String key = chompLeadingDot(unicodeToASCII(lTld).toLowerCase(Locale.ENGLISH));
260        return arrayContains(LOCAL_TLDS, key);
261    }
262
263    private static String chompLeadingDot(String str) {
264        if (str.startsWith(".")) {
265            return str.substring(1);
266        }
267        return str;
268    }
269
270    // ---------------------------------------------
271    // ----- TLDs defined by IANA
272    // ----- Authoritative and comprehensive list at:
273    // ----- http://data.iana.org/TLD/tlds-alpha-by-domain.txt
274
275    // Note that the above list is in UPPER case.
276    // The code currently converts strings to lower case (as per the tables below)
277
278    // IANA also provide an HTML list at http://www.iana.org/domains/root/db
279    // Note that this contains several country code entries which are NOT in
280    // the text file. These all have the "Not assigned" in the "Sponsoring Organisation" column
281    // For example (as of 2015-01-02):
282    // .bl  country-code    Not assigned
283    // .um  country-code    Not assigned
284
285    // WARNING: this array MUST be sorted, otherwise it cannot be searched reliably using binary search
286    private static final String[] INFRASTRUCTURE_TLDS = new String[] {
287        "arpa",               // internet infrastructure
288    };
289
290    // WARNING: this array MUST be sorted, otherwise it cannot be searched reliably using binary search
291    private static final String[] GENERIC_TLDS = new String[] {
292        // Taken from Version 2016060300, Last Updated Fri Jun  3 07:07:01 2016 UTC
293        "aaa", // aaa American Automobile Association, Inc.
294        "aarp", // aarp AARP
295        "abb", // abb ABB Ltd
296        "abbott", // abbott Abbott Laboratories, Inc.
297        "abbvie", // abbvie AbbVie Inc.
298        "abogado", // abogado Top Level Domain Holdings Limited
299        "abudhabi", // abudhabi Abu Dhabi Systems and Information Centre
300        "academy", // academy Half Oaks, LLC
301        "accenture", // accenture Accenture plc
302        "accountant", // accountant dot Accountant Limited
303        "accountants", // accountants Knob Town, LLC
304        "aco", // aco ACO Severin Ahlmann GmbH &amp; Co. KG
305        "active", // active The Active Network, Inc
306        "actor", // actor United TLD Holdco Ltd.
307        "adac", // adac Allgemeiner Deutscher Automobil-Club e.V. (ADAC)
308        "ads", // ads Charleston Road Registry Inc.
309        "adult", // adult ICM Registry AD LLC
310        "aeg", // aeg Aktiebolaget Electrolux
311        "aero", // aero Societe Internationale de Telecommunications Aeronautique (SITA INC USA)
312        "aetna", // aetna Aetna Life Insurance Company
313        "afl", // afl Australian Football League
314        "agakhan", // agakhan Fondation Aga Khan (Aga Khan Foundation)
315        "agency", // agency Steel Falls, LLC
316        "aig", // aig American International Group, Inc.
317        "airforce", // airforce United TLD Holdco Ltd.
318        "airtel", // airtel Bharti Airtel Limited
319        "akdn", // akdn Fondation Aga Khan (Aga Khan Foundation)
320        "alibaba", // alibaba Alibaba Group Holding Limited
321        "alipay", // alipay Alibaba Group Holding Limited
322        "allfinanz", // allfinanz Allfinanz Deutsche Vermögensberatung Aktiengesellschaft
323        "ally", // ally Ally Financial Inc.
324        "alsace", // alsace REGION D ALSACE
325        "amica", // amica Amica Mutual Insurance Company
326        "amsterdam", // amsterdam Gemeente Amsterdam
327        "analytics", // analytics Campus IP LLC
328        "android", // android Charleston Road Registry Inc.
329        "anquan", // anquan QIHOO 360 TECHNOLOGY CO. LTD.
330        "apartments", // apartments June Maple, LLC
331        "app", // app Charleston Road Registry Inc.
332        "apple", // apple Apple Inc.
333        "aquarelle", // aquarelle Aquarelle.com
334        "aramco", // aramco Aramco Services Company
335        "archi", // archi STARTING DOT LIMITED
336        "army", // army United TLD Holdco Ltd.
337        "arte", // arte Association Relative à la Télévision Européenne G.E.I.E.
338        "asia", // asia DotAsia Organisation Ltd.
339        "associates", // associates Baxter Hill, LLC
340        "attorney", // attorney United TLD Holdco, Ltd
341        "auction", // auction United TLD HoldCo, Ltd.
342        "audi", // audi AUDI Aktiengesellschaft
343        "audio", // audio Uniregistry, Corp.
344        "author", // author Amazon Registry Services, Inc.
345        "auto", // auto Uniregistry, Corp.
346        "autos", // autos DERAutos, LLC
347        "avianca", // avianca Aerovias del Continente Americano S.A. Avianca
348        "aws", // aws Amazon Registry Services, Inc.
349        "axa", // axa AXA SA
350        "azure", // azure Microsoft Corporation
351        "baby", // baby Johnson &amp; Johnson Services, Inc.
352        "baidu", // baidu Baidu, Inc.
353        "band", // band United TLD Holdco, Ltd
354        "bank", // bank fTLD Registry Services, LLC
355        "bar", // bar Punto 2012 Sociedad Anonima Promotora de Inversion de Capital Variable
356        "barcelona", // barcelona Municipi de Barcelona
357        "barclaycard", // barclaycard Barclays Bank PLC
358        "barclays", // barclays Barclays Bank PLC
359        "barefoot", // barefoot Gallo Vineyards, Inc.
360        "bargains", // bargains Half Hallow, LLC
361        "bauhaus", // bauhaus Werkhaus GmbH
362        "bayern", // bayern Bayern Connect GmbH
363        "bbc", // bbc British Broadcasting Corporation
364        "bbva", // bbva BANCO BILBAO VIZCAYA ARGENTARIA, S.A.
365        "bcg", // bcg The Boston Consulting Group, Inc.
366        "bcn", // bcn Municipi de Barcelona
367        "beats", // beats Beats Electronics, LLC
368        "beer", // beer Top Level Domain Holdings Limited
369        "bentley", // bentley Bentley Motors Limited
370        "berlin", // berlin dotBERLIN GmbH &amp; Co. KG
371        "best", // best BestTLD Pty Ltd
372        "bet", // bet Afilias plc
373        "bharti", // bharti Bharti Enterprises (Holding) Private Limited
374        "bible", // bible American Bible Society
375        "bid", // bid dot Bid Limited
376        "bike", // bike Grand Hollow, LLC
377        "bing", // bing Microsoft Corporation
378        "bingo", // bingo Sand Cedar, LLC
379        "bio", // bio STARTING DOT LIMITED
380        "biz", // biz Neustar, Inc.
381        "black", // black Afilias Limited
382        "blackfriday", // blackfriday Uniregistry, Corp.
383        "blog", // blog Knock Knock WHOIS There, LLC
384        "bloomberg", // bloomberg Bloomberg IP Holdings LLC
385        "blue", // blue Afilias Limited
386        "bms", // bms Bristol-Myers Squibb Company
387        "bmw", // bmw Bayerische Motoren Werke Aktiengesellschaft
388        "bnl", // bnl Banca Nazionale del Lavoro
389        "bnpparibas", // bnpparibas BNP Paribas
390        "boats", // boats DERBoats, LLC
391        "boehringer", // boehringer Boehringer Ingelheim International GmbH
392        "bom", // bom Núcleo de Informação e Coordenação do Ponto BR - NIC.br
393        "bond", // bond Bond University Limited
394        "boo", // boo Charleston Road Registry Inc.
395        "book", // book Amazon Registry Services, Inc.
396        "boots", // boots THE BOOTS COMPANY PLC
397        "bosch", // bosch Robert Bosch GMBH
398        "bostik", // bostik Bostik SA
399        "bot", // bot Amazon Registry Services, Inc.
400        "boutique", // boutique Over Galley, LLC
401        "bradesco", // bradesco Banco Bradesco S.A.
402        "bridgestone", // bridgestone Bridgestone Corporation
403        "broadway", // broadway Celebrate Broadway, Inc.
404        "broker", // broker DOTBROKER REGISTRY LTD
405        "brother", // brother Brother Industries, Ltd.
406        "brussels", // brussels DNS.be vzw
407        "budapest", // budapest Top Level Domain Holdings Limited
408        "bugatti", // bugatti Bugatti International SA
409        "build", // build Plan Bee LLC
410        "builders", // builders Atomic Madison, LLC
411        "business", // business Spring Cross, LLC
412        "buy", // buy Amazon Registry Services, INC
413        "buzz", // buzz DOTSTRATEGY CO.
414        "bzh", // bzh Association www.bzh
415        "cab", // cab Half Sunset, LLC
416        "cafe", // cafe Pioneer Canyon, LLC
417        "cal", // cal Charleston Road Registry Inc.
418        "call", // call Amazon Registry Services, Inc.
419        "camera", // camera Atomic Maple, LLC
420        "camp", // camp Delta Dynamite, LLC
421        "cancerresearch", // cancerresearch Australian Cancer Research Foundation
422        "canon", // canon Canon Inc.
423        "capetown", // capetown ZA Central Registry NPC trading as ZA Central Registry
424        "capital", // capital Delta Mill, LLC
425        "car", // car Cars Registry Limited
426        "caravan", // caravan Caravan International, Inc.
427        "cards", // cards Foggy Hollow, LLC
428        "care", // care Goose Cross, LLC
429        "career", // career dotCareer LLC
430        "careers", // careers Wild Corner, LLC
431        "cars", // cars Uniregistry, Corp.
432        "cartier", // cartier Richemont DNS Inc.
433        "casa", // casa Top Level Domain Holdings Limited
434        "cash", // cash Delta Lake, LLC
435        "casino", // casino Binky Sky, LLC
436        "cat", // cat Fundacio puntCAT
437        "catering", // catering New Falls. LLC
438        "cba", // cba COMMONWEALTH BANK OF AUSTRALIA
439        "cbn", // cbn The Christian Broadcasting Network, Inc.
440        "ceb", // ceb The Corporate Executive Board Company
441        "center", // center Tin Mill, LLC
442        "ceo", // ceo CEOTLD Pty Ltd
443        "cern", // cern European Organization for Nuclear Research (&quot;CERN&quot;)
444        "cfa", // cfa CFA Institute
445        "cfd", // cfd DOTCFD REGISTRY LTD
446        "chanel", // chanel Chanel International B.V.
447        "channel", // channel Charleston Road Registry Inc.
448        "chase", // chase JPMorgan Chase &amp; Co.
449        "chat", // chat Sand Fields, LLC
450        "cheap", // cheap Sand Cover, LLC
451        "chloe", // chloe Richemont DNS Inc.
452        "christmas", // christmas Uniregistry, Corp.
453        "chrome", // chrome Charleston Road Registry Inc.
454        "church", // church Holly Fileds, LLC
455        "cipriani", // cipriani Hotel Cipriani Srl
456        "circle", // circle Amazon Registry Services, Inc.
457        "cisco", // cisco Cisco Technology, Inc.
458        "citic", // citic CITIC Group Corporation
459        "city", // city Snow Sky, LLC
460        "cityeats", // cityeats Lifestyle Domain Holdings, Inc.
461        "claims", // claims Black Corner, LLC
462        "cleaning", // cleaning Fox Shadow, LLC
463        "click", // click Uniregistry, Corp.
464        "clinic", // clinic Goose Park, LLC
465        "clinique", // clinique The Estée Lauder Companies Inc.
466        "clothing", // clothing Steel Lake, LLC
467        "cloud", // cloud ARUBA S.p.A.
468        "club", // club .CLUB DOMAINS, LLC
469        "clubmed", // clubmed Club Méditerranée S.A.
470        "coach", // coach Koko Island, LLC
471        "codes", // codes Puff Willow, LLC
472        "coffee", // coffee Trixy Cover, LLC
473        "college", // college XYZ.COM LLC
474        "cologne", // cologne NetCologne Gesellschaft für Telekommunikation mbH
475        "com", // com VeriSign Global Registry Services
476        "commbank", // commbank COMMONWEALTH BANK OF AUSTRALIA
477        "community", // community Fox Orchard, LLC
478        "company", // company Silver Avenue, LLC
479        "compare", // compare iSelect Ltd
480        "computer", // computer Pine Mill, LLC
481        "comsec", // comsec VeriSign, Inc.
482        "condos", // condos Pine House, LLC
483        "construction", // construction Fox Dynamite, LLC
484        "consulting", // consulting United TLD Holdco, LTD.
485        "contact", // contact Top Level Spectrum, Inc.
486        "contractors", // contractors Magic Woods, LLC
487        "cooking", // cooking Top Level Domain Holdings Limited
488        "cool", // cool Koko Lake, LLC
489        "coop", // coop DotCooperation LLC
490        "corsica", // corsica Collectivité Territoriale de Corse
491        "country", // country Top Level Domain Holdings Limited
492        "coupon", // coupon Amazon Registry Services, Inc.
493        "coupons", // coupons Black Island, LLC
494        "courses", // courses OPEN UNIVERSITIES AUSTRALIA PTY LTD
495        "credit", // credit Snow Shadow, LLC
496        "creditcard", // creditcard Binky Frostbite, LLC
497        "creditunion", // creditunion CUNA Performance Resources, LLC
498        "cricket", // cricket dot Cricket Limited
499        "crown", // crown Crown Equipment Corporation
500        "crs", // crs Federated Co-operatives Limited
501        "cruises", // cruises Spring Way, LLC
502        "csc", // csc Alliance-One Services, Inc.
503        "cuisinella", // cuisinella SALM S.A.S.
504        "cymru", // cymru Nominet UK
505        "cyou", // cyou Beijing Gamease Age Digital Technology Co., Ltd.
506        "dabur", // dabur Dabur India Limited
507        "dad", // dad Charleston Road Registry Inc.
508        "dance", // dance United TLD Holdco Ltd.
509        "date", // date dot Date Limited
510        "dating", // dating Pine Fest, LLC
511        "datsun", // datsun NISSAN MOTOR CO., LTD.
512        "day", // day Charleston Road Registry Inc.
513        "dclk", // dclk Charleston Road Registry Inc.
514        "dds", // dds Minds + Machines Group Limited
515        "dealer", // dealer Dealer Dot Com, Inc.
516        "deals", // deals Sand Sunset, LLC
517        "degree", // degree United TLD Holdco, Ltd
518        "delivery", // delivery Steel Station, LLC
519        "dell", // dell Dell Inc.
520        "deloitte", // deloitte Deloitte Touche Tohmatsu
521        "delta", // delta Delta Air Lines, Inc.
522        "democrat", // democrat United TLD Holdco Ltd.
523        "dental", // dental Tin Birch, LLC
524        "dentist", // dentist United TLD Holdco, Ltd
525        "desi", // desi Desi Networks LLC
526        "design", // design Top Level Design, LLC
527        "dev", // dev Charleston Road Registry Inc.
528        "dhl", // dhl Deutsche Post AG
529        "diamonds", // diamonds John Edge, LLC
530        "diet", // diet Uniregistry, Corp.
531        "digital", // digital Dash Park, LLC
532        "direct", // direct Half Trail, LLC
533        "directory", // directory Extra Madison, LLC
534        "discount", // discount Holly Hill, LLC
535        "dnp", // dnp Dai Nippon Printing Co., Ltd.
536        "docs", // docs Charleston Road Registry Inc.
537        "dog", // dog Koko Mill, LLC
538        "doha", // doha Communications Regulatory Authority (CRA)
539        "domains", // domains Sugar Cross, LLC
540        "dot", // dot Dish DBS Corporation
541        "download", // download dot Support Limited
542        "drive", // drive Charleston Road Registry Inc.
543        "dtv", // dtv Dish DBS Corporation
544        "dubai", // dubai Dubai Smart Government Department
545        "durban", // durban ZA Central Registry NPC trading as ZA Central Registry
546        "dvag", // dvag Deutsche Vermögensberatung Aktiengesellschaft DVAG
547        "earth", // earth Interlink Co., Ltd.
548        "eat", // eat Charleston Road Registry Inc.
549        "edeka", // edeka EDEKA Verband kaufmännischer Genossenschaften e.V.
550        "edu", // edu EDUCAUSE
551        "education", // education Brice Way, LLC
552        "email", // email Spring Madison, LLC
553        "emerck", // emerck Merck KGaA
554        "energy", // energy Binky Birch, LLC
555        "engineer", // engineer United TLD Holdco Ltd.
556        "engineering", // engineering Romeo Canyon
557        "enterprises", // enterprises Snow Oaks, LLC
558        "epson", // epson Seiko Epson Corporation
559        "equipment", // equipment Corn Station, LLC
560        "erni", // erni ERNI Group Holding AG
561        "esq", // esq Charleston Road Registry Inc.
562        "estate", // estate Trixy Park, LLC
563        "eurovision", // eurovision European Broadcasting Union (EBU)
564        "eus", // eus Puntueus Fundazioa
565        "events", // events Pioneer Maple, LLC
566        "everbank", // everbank EverBank
567        "exchange", // exchange Spring Falls, LLC
568        "expert", // expert Magic Pass, LLC
569        "exposed", // exposed Victor Beach, LLC
570        "express", // express Sea Sunset, LLC
571        "extraspace", // extraspace Extra Space Storage LLC
572        "fage", // fage Fage International S.A.
573        "fail", // fail Atomic Pipe, LLC
574        "fairwinds", // fairwinds FairWinds Partners, LLC
575        "faith", // faith dot Faith Limited
576        "family", // family United TLD Holdco Ltd.
577        "fan", // fan Asiamix Digital Ltd
578        "fans", // fans Asiamix Digital Limited
579        "farm", // farm Just Maple, LLC
580        "fashion", // fashion Top Level Domain Holdings Limited
581        "fast", // fast Amazon Registry Services, Inc.
582        "feedback", // feedback Top Level Spectrum, Inc.
583        "ferrero", // ferrero Ferrero Trading Lux S.A.
584        "film", // film Motion Picture Domain Registry Pty Ltd
585        "final", // final Núcleo de Informação e Coordenação do Ponto BR - NIC.br
586        "finance", // finance Cotton Cypress, LLC
587        "financial", // financial Just Cover, LLC
588        "firestone", // firestone Bridgestone Corporation
589        "firmdale", // firmdale Firmdale Holdings Limited
590        "fish", // fish Fox Woods, LLC
591        "fishing", // fishing Top Level Domain Holdings Limited
592        "fit", // fit Minds + Machines Group Limited
593        "fitness", // fitness Brice Orchard, LLC
594        "flickr", // flickr Yahoo! Domain Services Inc.
595        "flights", // flights Fox Station, LLC
596        "flir", // flir FLIR Systems, Inc.
597        "florist", // florist Half Cypress, LLC
598        "flowers", // flowers Uniregistry, Corp.
599        "flsmidth", // flsmidth FLSmidth A/S
600        "fly", // fly Charleston Road Registry Inc.
601        "foo", // foo Charleston Road Registry Inc.
602        "football", // football Foggy Farms, LLC
603        "ford", // ford Ford Motor Company
604        "forex", // forex DOTFOREX REGISTRY LTD
605        "forsale", // forsale United TLD Holdco, LLC
606        "forum", // forum Fegistry, LLC
607        "foundation", // foundation John Dale, LLC
608        "fox", // fox FOX Registry, LLC
609        "fresenius", // fresenius Fresenius Immobilien-Verwaltungs-GmbH
610        "frl", // frl FRLregistry B.V.
611        "frogans", // frogans OP3FT
612        "frontier", // frontier Frontier Communications Corporation
613        "ftr", // ftr Frontier Communications Corporation
614        "fund", // fund John Castle, LLC
615        "furniture", // furniture Lone Fields, LLC
616        "futbol", // futbol United TLD Holdco, Ltd.
617        "fyi", // fyi Silver Tigers, LLC
618        "gal", // gal Asociación puntoGAL
619        "gallery", // gallery Sugar House, LLC
620        "gallo", // gallo Gallo Vineyards, Inc.
621        "gallup", // gallup Gallup, Inc.
622        "game", // game Uniregistry, Corp.
623        "games", // games United TLD Holdco Ltd.
624        "garden", // garden Top Level Domain Holdings Limited
625        "gbiz", // gbiz Charleston Road Registry Inc.
626        "gdn", // gdn Joint Stock Company "Navigation-information systems"
627        "gea", // gea GEA Group Aktiengesellschaft
628        "gent", // gent COMBELL GROUP NV/SA
629        "genting", // genting Resorts World Inc. Pte. Ltd.
630        "ggee", // ggee GMO Internet, Inc.
631        "gift", // gift Uniregistry, Corp.
632        "gifts", // gifts Goose Sky, LLC
633        "gives", // gives United TLD Holdco Ltd.
634        "giving", // giving Giving Limited
635        "glass", // glass Black Cover, LLC
636        "gle", // gle Charleston Road Registry Inc.
637        "global", // global Dot Global Domain Registry Limited
638        "globo", // globo Globo Comunicação e Participações S.A
639        "gmail", // gmail Charleston Road Registry Inc.
640        "gmbh", // gmbh Extra Dynamite, LLC
641        "gmo", // gmo GMO Internet, Inc.
642        "gmx", // gmx 1&amp;1 Mail &amp; Media GmbH
643        "gold", // gold June Edge, LLC
644        "goldpoint", // goldpoint YODOBASHI CAMERA CO.,LTD.
645        "golf", // golf Lone Falls, LLC
646        "goo", // goo NTT Resonant Inc.
647        "goog", // goog Charleston Road Registry Inc.
648        "google", // google Charleston Road Registry Inc.
649        "gop", // gop Republican State Leadership Committee, Inc.
650        "got", // got Amazon Registry Services, Inc.
651        "gov", // gov General Services Administration Attn: QTDC, 2E08 (.gov Domain Registration)
652        "grainger", // grainger Grainger Registry Services, LLC
653        "graphics", // graphics Over Madison, LLC
654        "gratis", // gratis Pioneer Tigers, LLC
655        "green", // green Afilias Limited
656        "gripe", // gripe Corn Sunset, LLC
657        "group", // group Romeo Town, LLC
658        "guardian", // guardian The Guardian Life Insurance Company of America
659        "gucci", // gucci Guccio Gucci S.p.a.
660        "guge", // guge Charleston Road Registry Inc.
661        "guide", // guide Snow Moon, LLC
662        "guitars", // guitars Uniregistry, Corp.
663        "guru", // guru Pioneer Cypress, LLC
664        "hamburg", // hamburg Hamburg Top-Level-Domain GmbH
665        "hangout", // hangout Charleston Road Registry Inc.
666        "haus", // haus United TLD Holdco, LTD.
667        "hdfcbank", // hdfcbank HDFC Bank Limited
668        "health", // health DotHealth, LLC
669        "healthcare", // healthcare Silver Glen, LLC
670        "help", // help Uniregistry, Corp.
671        "helsinki", // helsinki City of Helsinki
672        "here", // here Charleston Road Registry Inc.
673        "hermes", // hermes Hermes International
674        "hiphop", // hiphop Uniregistry, Corp.
675        "hisamitsu", // hisamitsu Hisamitsu Pharmaceutical Co.,Inc.
676        "hitachi", // hitachi Hitachi, Ltd.
677        "hiv", // hiv dotHIV gemeinnuetziger e.V.
678        "hkt", // hkt PCCW-HKT DataCom Services Limited
679        "hockey", // hockey Half Willow, LLC
680        "holdings", // holdings John Madison, LLC
681        "holiday", // holiday Goose Woods, LLC
682        "homedepot", // homedepot Homer TLC, Inc.
683        "homes", // homes DERHomes, LLC
684        "honda", // honda Honda Motor Co., Ltd.
685        "horse", // horse Top Level Domain Holdings Limited
686        "host", // host DotHost Inc.
687        "hosting", // hosting Uniregistry, Corp.
688        "hoteles", // hoteles Travel Reservations SRL
689        "hotmail", // hotmail Microsoft Corporation
690        "house", // house Sugar Park, LLC
691        "how", // how Charleston Road Registry Inc.
692        "hsbc", // hsbc HSBC Holdings PLC
693        "htc", // htc HTC corporation
694        "hyundai", // hyundai Hyundai Motor Company
695        "ibm", // ibm International Business Machines Corporation
696        "icbc", // icbc Industrial and Commercial Bank of China Limited
697        "ice", // ice IntercontinentalExchange, Inc.
698        "icu", // icu One.com A/S
699        "ifm", // ifm ifm electronic gmbh
700        "iinet", // iinet Connect West Pty. Ltd.
701        "imamat", // imamat Fondation Aga Khan (Aga Khan Foundation)
702        "immo", // immo Auburn Bloom, LLC
703        "immobilien", // immobilien United TLD Holdco Ltd.
704        "industries", // industries Outer House, LLC
705        "infiniti", // infiniti NISSAN MOTOR CO., LTD.
706        "info", // info Afilias Limited
707        "ing", // ing Charleston Road Registry Inc.
708        "ink", // ink Top Level Design, LLC
709        "institute", // institute Outer Maple, LLC
710        "insurance", // insurance fTLD Registry Services LLC
711        "insure", // insure Pioneer Willow, LLC
712        "int", // int Internet Assigned Numbers Authority
713        "international", // international Wild Way, LLC
714        "investments", // investments Holly Glen, LLC
715        "ipiranga", // ipiranga Ipiranga Produtos de Petroleo S.A.
716        "irish", // irish Dot-Irish LLC
717        "iselect", // iselect iSelect Ltd
718        "ismaili", // ismaili Fondation Aga Khan (Aga Khan Foundation)
719        "ist", // ist Istanbul Metropolitan Municipality
720        "istanbul", // istanbul Istanbul Metropolitan Municipality / Medya A.S.
721        "itau", // itau Itau Unibanco Holding S.A.
722        "iwc", // iwc Richemont DNS Inc.
723        "jaguar", // jaguar Jaguar Land Rover Ltd
724        "java", // java Oracle Corporation
725        "jcb", // jcb JCB Co., Ltd.
726        "jcp", // jcp JCP Media, Inc.
727        "jetzt", // jetzt New TLD Company AB
728        "jewelry", // jewelry Wild Bloom, LLC
729        "jlc", // jlc Richemont DNS Inc.
730        "jll", // jll Jones Lang LaSalle Incorporated
731        "jmp", // jmp Matrix IP LLC
732        "jnj", // jnj Johnson &amp; Johnson Services, Inc.
733        "jobs", // jobs Employ Media LLC
734        "joburg", // joburg ZA Central Registry NPC trading as ZA Central Registry
735        "jot", // jot Amazon Registry Services, Inc.
736        "joy", // joy Amazon Registry Services, Inc.
737        "jpmorgan", // jpmorgan JPMorgan Chase &amp; Co.
738        "jprs", // jprs Japan Registry Services Co., Ltd.
739        "juegos", // juegos Uniregistry, Corp.
740        "kaufen", // kaufen United TLD Holdco Ltd.
741        "kddi", // kddi KDDI CORPORATION
742        "kerryhotels", // kerryhotels Kerry Trading Co. Limited
743        "kerrylogistics", // kerrylogistics Kerry Trading Co. Limited
744        "kerryproperties", // kerryproperties Kerry Trading Co. Limited
745        "kfh", // kfh Kuwait Finance House
746        "kia", // kia KIA MOTORS CORPORATION
747        "kim", // kim Afilias Limited
748        "kinder", // kinder Ferrero Trading Lux S.A.
749        "kitchen", // kitchen Just Goodbye, LLC
750        "kiwi", // kiwi DOT KIWI LIMITED
751        "koeln", // koeln NetCologne Gesellschaft für Telekommunikation mbH
752        "komatsu", // komatsu Komatsu Ltd.
753        "kpmg", // kpmg KPMG International Cooperative (KPMG International Genossenschaft)
754        "kpn", // kpn Koninklijke KPN N.V.
755        "krd", // krd KRG Department of Information Technology
756        "kred", // kred KredTLD Pty Ltd
757        "kuokgroup", // kuokgroup Kerry Trading Co. Limited
758        "kyoto", // kyoto Academic Institution: Kyoto Jyoho Gakuen
759        "lacaixa", // lacaixa CAIXA D&#39;ESTALVIS I PENSIONS DE BARCELONA
760        "lamborghini", // lamborghini Automobili Lamborghini S.p.A.
761        "lamer", // lamer The Estée Lauder Companies Inc.
762        "lancaster", // lancaster LANCASTER
763        "land", // land Pine Moon, LLC
764        "landrover", // landrover Jaguar Land Rover Ltd
765        "lanxess", // lanxess LANXESS Corporation
766        "lasalle", // lasalle Jones Lang LaSalle Incorporated
767        "lat", // lat ECOM-LAC Federación de Latinoamérica y el Caribe para Internet y el Comercio Electrónico
768        "latrobe", // latrobe La Trobe University
769        "law", // law Minds + Machines Group Limited
770        "lawyer", // lawyer United TLD Holdco, Ltd
771        "lds", // lds IRI Domain Management, LLC
772        "lease", // lease Victor Trail, LLC
773        "leclerc", // leclerc A.C.D. LEC Association des Centres Distributeurs Edouard Leclerc
774        "legal", // legal Blue Falls, LLC
775        "lexus", // lexus TOYOTA MOTOR CORPORATION
776        "lgbt", // lgbt Afilias Limited
777        "liaison", // liaison Liaison Technologies, Incorporated
778        "lidl", // lidl Schwarz Domains und Services GmbH &amp; Co. KG
779        "life", // life Trixy Oaks, LLC
780        "lifeinsurance", // lifeinsurance American Council of Life Insurers
781        "lifestyle", // lifestyle Lifestyle Domain Holdings, Inc.
782        "lighting", // lighting John McCook, LLC
783        "like", // like Amazon Registry Services, Inc.
784        "limited", // limited Big Fest, LLC
785        "limo", // limo Hidden Frostbite, LLC
786        "lincoln", // lincoln Ford Motor Company
787        "linde", // linde Linde Aktiengesellschaft
788        "link", // link Uniregistry, Corp.
789        "lipsy", // lipsy Lipsy Ltd
790        "live", // live United TLD Holdco Ltd.
791        "living", // living Lifestyle Domain Holdings, Inc.
792        "lixil", // lixil LIXIL Group Corporation
793        "loan", // loan dot Loan Limited
794        "loans", // loans June Woods, LLC
795        "locker", // locker Dish DBS Corporation
796        "locus", // locus Locus Analytics LLC
797        "lol", // lol Uniregistry, Corp.
798        "london", // london Dot London Domains Limited
799        "lotte", // lotte Lotte Holdings Co., Ltd.
800        "lotto", // lotto Afilias Limited
801        "love", // love Merchant Law Group LLP
802        "ltd", // ltd Over Corner, LLC
803        "ltda", // ltda InterNetX Corp.
804        "lupin", // lupin LUPIN LIMITED
805        "luxe", // luxe Top Level Domain Holdings Limited
806        "luxury", // luxury Luxury Partners LLC
807        "madrid", // madrid Comunidad de Madrid
808        "maif", // maif Mutuelle Assurance Instituteur France (MAIF)
809        "maison", // maison Victor Frostbite, LLC
810        "makeup", // makeup L&#39;Oréal
811        "man", // man MAN SE
812        "management", // management John Goodbye, LLC
813        "mango", // mango PUNTO FA S.L.
814        "market", // market Unitied TLD Holdco, Ltd
815        "marketing", // marketing Fern Pass, LLC
816        "markets", // markets DOTMARKETS REGISTRY LTD
817        "marriott", // marriott Marriott Worldwide Corporation
818        "mattel", // mattel Mattel Sites, Inc.
819        "mba", // mba Lone Hollow, LLC
820        "med", // med Medistry LLC
821        "media", // media Grand Glen, LLC
822        "meet", // meet Afilias Limited
823        "melbourne", // melbourne The Crown in right of the State of Victoria
824        "meme", // meme Charleston Road Registry Inc.
825        "memorial", // memorial Dog Beach, LLC
826        "men", // men Exclusive Registry Limited
827        "menu", // menu Wedding TLD2, LLC
828        "meo", // meo PT Comunicacoes S.A.
829        "metlife", // metlife MetLife Services and Solutions, LLC
830        "miami", // miami Top Level Domain Holdings Limited
831        "microsoft", // microsoft Microsoft Corporation
832        "mil", // mil DoD Network Information Center
833        "mini", // mini Bayerische Motoren Werke Aktiengesellschaft
834        "mlb", // mlb MLB Advanced Media DH, LLC
835        "mls", // mls The Canadian Real Estate Association
836        "mma", // mma MMA IARD
837        "mobi", // mobi Afilias Technologies Limited dba dotMobi
838        "mobily", // mobily GreenTech Consultancy Company W.L.L.
839        "moda", // moda United TLD Holdco Ltd.
840        "moe", // moe Interlink Co., Ltd.
841        "moi", // moi Amazon Registry Services, Inc.
842        "mom", // mom Uniregistry, Corp.
843        "monash", // monash Monash University
844        "money", // money Outer McCook, LLC
845        "montblanc", // montblanc Richemont DNS Inc.
846        "mormon", // mormon IRI Domain Management, LLC (&quot;Applicant&quot;)
847        "mortgage", // mortgage United TLD Holdco, Ltd
848        "moscow", // moscow Foundation for Assistance for Internet Technologies and Infrastructure Development (FAITID)
849        "motorcycles", // motorcycles DERMotorcycles, LLC
850        "mov", // mov Charleston Road Registry Inc.
851        "movie", // movie New Frostbite, LLC
852        "movistar", // movistar Telefónica S.A.
853        "mtn", // mtn MTN Dubai Limited
854        "mtpc", // mtpc Mitsubishi Tanabe Pharma Corporation
855        "mtr", // mtr MTR Corporation Limited
856        "museum", // museum Museum Domain Management Association
857        "mutual", // mutual Northwestern Mutual MU TLD Registry, LLC
858        "mutuelle", // mutuelle Fédération Nationale de la Mutualité Française
859        "nadex", // nadex Nadex Domains, Inc
860        "nagoya", // nagoya GMO Registry, Inc.
861        "name", // name VeriSign Information Services, Inc.
862        "natura", // natura NATURA COSMÉTICOS S.A.
863        "navy", // navy United TLD Holdco Ltd.
864        "nec", // nec NEC Corporation
865        "net", // net VeriSign Global Registry Services
866        "netbank", // netbank COMMONWEALTH BANK OF AUSTRALIA
867        "netflix", // netflix Netflix, Inc.
868        "network", // network Trixy Manor, LLC
869        "neustar", // neustar NeuStar, Inc.
870        "new", // new Charleston Road Registry Inc.
871        "news", // news United TLD Holdco Ltd.
872        "next", // next Next plc
873        "nextdirect", // nextdirect Next plc
874        "nexus", // nexus Charleston Road Registry Inc.
875        "ngo", // ngo Public Interest Registry
876        "nhk", // nhk Japan Broadcasting Corporation (NHK)
877        "nico", // nico DWANGO Co., Ltd.
878        "nikon", // nikon NIKON CORPORATION
879        "ninja", // ninja United TLD Holdco Ltd.
880        "nissan", // nissan NISSAN MOTOR CO., LTD.
881        "nissay", // nissay Nippon Life Insurance Company
882        "nokia", // nokia Nokia Corporation
883        "northwesternmutual", // northwesternmutual Northwestern Mutual Registry, LLC
884        "norton", // norton Symantec Corporation
885        "nowruz", // nowruz Asia Green IT System Bilgisayar San. ve Tic. Ltd. Sti.
886        "nowtv", // nowtv Starbucks (HK) Limited
887        "nra", // nra NRA Holdings Company, INC.
888        "nrw", // nrw Minds + Machines GmbH
889        "ntt", // ntt NIPPON TELEGRAPH AND TELEPHONE CORPORATION
890        "nyc", // nyc The City of New York by and through the New York City Department of Information Technology &amp; Telecommunications
891        "obi", // obi OBI Group Holding SE &amp; Co. KGaA
892        "office", // office Microsoft Corporation
893        "okinawa", // okinawa BusinessRalliart inc.
894        "olayan", // olayan Crescent Holding GmbH
895        "olayangroup", // olayangroup Crescent Holding GmbH
896        "ollo", // ollo Dish DBS Corporation
897        "omega", // omega The Swatch Group Ltd
898        "one", // one One.com A/S
899        "ong", // ong Public Interest Registry
900        "onl", // onl I-REGISTRY Ltd., Niederlassung Deutschland
901        "online", // online DotOnline Inc.
902        "ooo", // ooo INFIBEAM INCORPORATION LIMITED
903        "oracle", // oracle Oracle Corporation
904        "orange", // orange Orange Brand Services Limited
905        "org", // org Public Interest Registry (PIR)
906        "organic", // organic Afilias Limited
907        "origins", // origins The Estée Lauder Companies Inc.
908        "osaka", // osaka Interlink Co., Ltd.
909        "otsuka", // otsuka Otsuka Holdings Co., Ltd.
910        "ott", // ott Dish DBS Corporation
911        "ovh", // ovh OVH SAS
912        "page", // page Charleston Road Registry Inc.
913        "pamperedchef", // pamperedchef The Pampered Chef, Ltd.
914        "panerai", // panerai Richemont DNS Inc.
915        "paris", // paris City of Paris
916        "pars", // pars Asia Green IT System Bilgisayar San. ve Tic. Ltd. Sti.
917        "partners", // partners Magic Glen, LLC
918        "parts", // parts Sea Goodbye, LLC
919        "party", // party Blue Sky Registry Limited
920        "passagens", // passagens Travel Reservations SRL
921        "pccw", // pccw PCCW Enterprises Limited
922        "pet", // pet Afilias plc
923        "pharmacy", // pharmacy National Association of Boards of Pharmacy
924        "philips", // philips Koninklijke Philips N.V.
925        "photo", // photo Uniregistry, Corp.
926        "photography", // photography Sugar Glen, LLC
927        "photos", // photos Sea Corner, LLC
928        "physio", // physio PhysBiz Pty Ltd
929        "piaget", // piaget Richemont DNS Inc.
930        "pics", // pics Uniregistry, Corp.
931        "pictet", // pictet Pictet Europe S.A.
932        "pictures", // pictures Foggy Sky, LLC
933        "pid", // pid Top Level Spectrum, Inc.
934        "pin", // pin Amazon Registry Services, Inc.
935        "ping", // ping Ping Registry Provider, Inc.
936        "pink", // pink Afilias Limited
937        "pioneer", // pioneer Pioneer Corporation
938        "pizza", // pizza Foggy Moon, LLC
939        "place", // place Snow Galley, LLC
940        "play", // play Charleston Road Registry Inc.
941        "playstation", // playstation Sony Computer Entertainment Inc.
942        "plumbing", // plumbing Spring Tigers, LLC
943        "plus", // plus Sugar Mill, LLC
944        "pohl", // pohl Deutsche Vermögensberatung Aktiengesellschaft DVAG
945        "poker", // poker Afilias Domains No. 5 Limited
946        "porn", // porn ICM Registry PN LLC
947        "post", // post Universal Postal Union
948        "praxi", // praxi Praxi S.p.A.
949        "press", // press DotPress Inc.
950        "pro", // pro Registry Services Corporation dba RegistryPro
951        "prod", // prod Charleston Road Registry Inc.
952        "productions", // productions Magic Birch, LLC
953        "prof", // prof Charleston Road Registry Inc.
954        "progressive", // progressive Progressive Casualty Insurance Company
955        "promo", // promo Afilias plc
956        "properties", // properties Big Pass, LLC
957        "property", // property Uniregistry, Corp.
958        "protection", // protection XYZ.COM LLC
959        "pub", // pub United TLD Holdco Ltd.
960        "pwc", // pwc PricewaterhouseCoopers LLP
961        "qpon", // qpon dotCOOL, Inc.
962        "quebec", // quebec PointQuébec Inc
963        "quest", // quest Quest ION Limited
964        "racing", // racing Premier Registry Limited
965        "read", // read Amazon Registry Services, Inc.
966        "realestate", // realestate dotRealEstate LLC
967        "realtor", // realtor Real Estate Domains LLC
968        "realty", // realty Fegistry, LLC
969        "recipes", // recipes Grand Island, LLC
970        "red", // red Afilias Limited
971        "redstone", // redstone Redstone Haute Couture Co., Ltd.
972        "redumbrella", // redumbrella Travelers TLD, LLC
973        "rehab", // rehab United TLD Holdco Ltd.
974        "reise", // reise Foggy Way, LLC
975        "reisen", // reisen New Cypress, LLC
976        "reit", // reit National Association of Real Estate Investment Trusts, Inc.
977        "ren", // ren Beijing Qianxiang Wangjing Technology Development Co., Ltd.
978        "rent", // rent XYZ.COM LLC
979        "rentals", // rentals Big Hollow,LLC
980        "repair", // repair Lone Sunset, LLC
981        "report", // report Binky Glen, LLC
982        "republican", // republican United TLD Holdco Ltd.
983        "rest", // rest Punto 2012 Sociedad Anonima Promotora de Inversion de Capital Variable
984        "restaurant", // restaurant Snow Avenue, LLC
985        "review", // review dot Review Limited
986        "reviews", // reviews United TLD Holdco, Ltd.
987        "rexroth", // rexroth Robert Bosch GMBH
988        "rich", // rich I-REGISTRY Ltd., Niederlassung Deutschland
989        "richardli", // richardli Pacific Century Asset Management (HK) Limited
990        "ricoh", // ricoh Ricoh Company, Ltd.
991        "rio", // rio Empresa Municipal de Informática SA - IPLANRIO
992        "rip", // rip United TLD Holdco Ltd.
993        "rocher", // rocher Ferrero Trading Lux S.A.
994        "rocks", // rocks United TLD Holdco, LTD.
995        "rodeo", // rodeo Top Level Domain Holdings Limited
996        "room", // room Amazon Registry Services, Inc.
997        "rsvp", // rsvp Charleston Road Registry Inc.
998        "ruhr", // ruhr regiodot GmbH &amp; Co. KG
999        "run", // run Snow Park, LLC
1000        "rwe", // rwe RWE AG
1001        "ryukyu", // ryukyu BusinessRalliart inc.
1002        "saarland", // saarland dotSaarland GmbH
1003        "safe", // safe Amazon Registry Services, Inc.
1004        "safety", // safety Safety Registry Services, LLC.
1005        "sakura", // sakura SAKURA Internet Inc.
1006        "sale", // sale United TLD Holdco, Ltd
1007        "salon", // salon Outer Orchard, LLC
1008        "samsung", // samsung SAMSUNG SDS CO., LTD
1009        "sandvik", // sandvik Sandvik AB
1010        "sandvikcoromant", // sandvikcoromant Sandvik AB
1011        "sanofi", // sanofi Sanofi
1012        "sap", // sap SAP AG
1013        "sapo", // sapo PT Comunicacoes S.A.
1014        "sarl", // sarl Delta Orchard, LLC
1015        "sas", // sas Research IP LLC
1016        "saxo", // saxo Saxo Bank A/S
1017        "sbi", // sbi STATE BANK OF INDIA
1018        "sbs", // sbs SPECIAL BROADCASTING SERVICE CORPORATION
1019        "sca", // sca SVENSKA CELLULOSA AKTIEBOLAGET SCA (publ)
1020        "scb", // scb The Siam Commercial Bank Public Company Limited (&quot;SCB&quot;)
1021        "schaeffler", // schaeffler Schaeffler Technologies AG &amp; Co. KG
1022        "schmidt", // schmidt SALM S.A.S.
1023        "scholarships", // scholarships Scholarships.com, LLC
1024        "school", // school Little Galley, LLC
1025        "schule", // schule Outer Moon, LLC
1026        "schwarz", // schwarz Schwarz Domains und Services GmbH &amp; Co. KG
1027        "science", // science dot Science Limited
1028        "scor", // scor SCOR SE
1029        "scot", // scot Dot Scot Registry Limited
1030        "seat", // seat SEAT, S.A. (Sociedad Unipersonal)
1031        "security", // security XYZ.COM LLC
1032        "seek", // seek Seek Limited
1033        "select", // select iSelect Ltd
1034        "sener", // sener Sener Ingeniería y Sistemas, S.A.
1035        "services", // services Fox Castle, LLC
1036        "seven", // seven Seven West Media Ltd
1037        "sew", // sew SEW-EURODRIVE GmbH &amp; Co KG
1038        "sex", // sex ICM Registry SX LLC
1039        "sexy", // sexy Uniregistry, Corp.
1040        "sfr", // sfr Societe Francaise du Radiotelephone - SFR
1041        "sharp", // sharp Sharp Corporation
1042        "shaw", // shaw Shaw Cablesystems G.P.
1043        "shell", // shell Shell Information Technology International Inc
1044        "shia", // shia Asia Green IT System Bilgisayar San. ve Tic. Ltd. Sti.
1045        "shiksha", // shiksha Afilias Limited
1046        "shoes", // shoes Binky Galley, LLC
1047        "shop", // shop GMO Registry, Inc.
1048        "shouji", // shouji QIHOO 360 TECHNOLOGY CO. LTD.
1049        "show", // show Snow Beach, LLC
1050        "shriram", // shriram Shriram Capital Ltd.
1051        "sina", // sina Sina Corporation
1052        "singles", // singles Fern Madison, LLC
1053        "site", // site DotSite Inc.
1054        "ski", // ski STARTING DOT LIMITED
1055        "skin", // skin L&#39;Oréal
1056        "sky", // sky Sky International AG
1057        "skype", // skype Microsoft Corporation
1058        "smile", // smile Amazon Registry Services, Inc.
1059        "sncf", // sncf SNCF (Société Nationale des Chemins de fer Francais)
1060        "soccer", // soccer Foggy Shadow, LLC
1061        "social", // social United TLD Holdco Ltd.
1062        "softbank", // softbank SoftBank Group Corp.
1063        "software", // software United TLD Holdco, Ltd
1064        "sohu", // sohu Sohu.com Limited
1065        "solar", // solar Ruby Town, LLC
1066        "solutions", // solutions Silver Cover, LLC
1067        "song", // song Amazon EU S.à r.l.
1068        "sony", // sony Sony Corporation
1069        "soy", // soy Charleston Road Registry Inc.
1070        "space", // space DotSpace Inc.
1071        "spiegel", // spiegel SPIEGEL-Verlag Rudolf Augstein GmbH &amp; Co. KG
1072        "spot", // spot Amazon Registry Services, Inc.
1073        "spreadbetting", // spreadbetting DOTSPREADBETTING REGISTRY LTD
1074        "srl", // srl InterNetX Corp.
1075        "stada", // stada STADA Arzneimittel AG
1076        "star", // star Star India Private Limited
1077        "starhub", // starhub StarHub Limited
1078        "statebank", // statebank STATE BANK OF INDIA
1079        "statefarm", // statefarm State Farm Mutual Automobile Insurance Company
1080        "statoil", // statoil Statoil ASA
1081        "stc", // stc Saudi Telecom Company
1082        "stcgroup", // stcgroup Saudi Telecom Company
1083        "stockholm", // stockholm Stockholms kommun
1084        "storage", // storage Self Storage Company LLC
1085        "store", // store DotStore Inc.
1086        "stream", // stream dot Stream Limited
1087        "studio", // studio United TLD Holdco Ltd.
1088        "study", // study OPEN UNIVERSITIES AUSTRALIA PTY LTD
1089        "style", // style Binky Moon, LLC
1090        "sucks", // sucks Vox Populi Registry Ltd.
1091        "supplies", // supplies Atomic Fields, LLC
1092        "supply", // supply Half Falls, LLC
1093        "support", // support Grand Orchard, LLC
1094        "surf", // surf Top Level Domain Holdings Limited
1095        "surgery", // surgery Tin Avenue, LLC
1096        "suzuki", // suzuki SUZUKI MOTOR CORPORATION
1097        "swatch", // swatch The Swatch Group Ltd
1098        "swiss", // swiss Swiss Confederation
1099        "sydney", // sydney State of New South Wales, Department of Premier and Cabinet
1100        "symantec", // symantec Symantec Corporation
1101        "systems", // systems Dash Cypress, LLC
1102        "tab", // tab Tabcorp Holdings Limited
1103        "taipei", // taipei Taipei City Government
1104        "talk", // talk Amazon Registry Services, Inc.
1105        "taobao", // taobao Alibaba Group Holding Limited
1106        "tatamotors", // tatamotors Tata Motors Ltd
1107        "tatar", // tatar Limited Liability Company "Coordination Center of Regional Domain of Tatarstan Republic"
1108        "tattoo", // tattoo Uniregistry, Corp.
1109        "tax", // tax Storm Orchard, LLC
1110        "taxi", // taxi Pine Falls, LLC
1111        "tci", // tci Asia Green IT System Bilgisayar San. ve Tic. Ltd. Sti.
1112        "team", // team Atomic Lake, LLC
1113        "tech", // tech Dot Tech LLC
1114        "technology", // technology Auburn Falls, LLC
1115        "tel", // tel Telnic Ltd.
1116        "telecity", // telecity TelecityGroup International Limited
1117        "telefonica", // telefonica Telefónica S.A.
1118        "temasek", // temasek Temasek Holdings (Private) Limited
1119        "tennis", // tennis Cotton Bloom, LLC
1120        "teva", // teva Teva Pharmaceutical Industries Limited
1121        "thd", // thd Homer TLC, Inc.
1122        "theater", // theater Blue Tigers, LLC
1123        "theatre", // theatre XYZ.COM LLC
1124        "tickets", // tickets Accent Media Limited
1125        "tienda", // tienda Victor Manor, LLC
1126        "tiffany", // tiffany Tiffany and Company
1127        "tips", // tips Corn Willow, LLC
1128        "tires", // tires Dog Edge, LLC
1129        "tirol", // tirol punkt Tirol GmbH
1130        "tmall", // tmall Alibaba Group Holding Limited
1131        "today", // today Pearl Woods, LLC
1132        "tokyo", // tokyo GMO Registry, Inc.
1133        "tools", // tools Pioneer North, LLC
1134        "top", // top Jiangsu Bangning Science &amp; Technology Co.,Ltd.
1135        "toray", // toray Toray Industries, Inc.
1136        "toshiba", // toshiba TOSHIBA Corporation
1137        "total", // total Total SA
1138        "tours", // tours Sugar Station, LLC
1139        "town", // town Koko Moon, LLC
1140        "toyota", // toyota TOYOTA MOTOR CORPORATION
1141        "toys", // toys Pioneer Orchard, LLC
1142        "trade", // trade Elite Registry Limited
1143        "trading", // trading DOTTRADING REGISTRY LTD
1144        "training", // training Wild Willow, LLC
1145        "travel", // travel Tralliance Registry Management Company, LLC.
1146        "travelers", // travelers Travelers TLD, LLC
1147        "travelersinsurance", // travelersinsurance Travelers TLD, LLC
1148        "trust", // trust Artemis Internet Inc
1149        "trv", // trv Travelers TLD, LLC
1150        "tube", // tube Latin American Telecom LLC
1151        "tui", // tui TUI AG
1152        "tunes", // tunes Amazon Registry Services, Inc.
1153        "tushu", // tushu Amazon Registry Services, Inc.
1154        "tvs", // tvs T V SUNDRAM IYENGAR  &amp; SONS PRIVATE LIMITED
1155        "ubs", // ubs UBS AG
1156        "unicom", // unicom China United Network Communications Corporation Limited
1157        "university", // university Little Station, LLC
1158        "uno", // uno Dot Latin LLC
1159        "uol", // uol UBN INTERNET LTDA.
1160        "ups", // ups UPS Market Driver, Inc.
1161        "vacations", // vacations Atomic Tigers, LLC
1162        "vana", // vana Lifestyle Domain Holdings, Inc.
1163        "vegas", // vegas Dot Vegas, Inc.
1164        "ventures", // ventures Binky Lake, LLC
1165        "verisign", // verisign VeriSign, Inc.
1166        "versicherung", // versicherung dotversicherung-registry GmbH
1167        "vet", // vet United TLD Holdco, Ltd
1168        "viajes", // viajes Black Madison, LLC
1169        "video", // video United TLD Holdco, Ltd
1170        "vig", // vig VIENNA INSURANCE GROUP AG Wiener Versicherung Gruppe
1171        "viking", // viking Viking River Cruises (Bermuda) Ltd.
1172        "villas", // villas New Sky, LLC
1173        "vin", // vin Holly Shadow, LLC
1174        "vip", // vip Minds + Machines Group Limited
1175        "virgin", // virgin Virgin Enterprises Limited
1176        "vision", // vision Koko Station, LLC
1177        "vista", // vista Vistaprint Limited
1178        "vistaprint", // vistaprint Vistaprint Limited
1179        "viva", // viva Saudi Telecom Company
1180        "vlaanderen", // vlaanderen DNS.be vzw
1181        "vodka", // vodka Top Level Domain Holdings Limited
1182        "volkswagen", // volkswagen Volkswagen Group of America Inc.
1183        "vote", // vote Monolith Registry LLC
1184        "voting", // voting Valuetainment Corp.
1185        "voto", // voto Monolith Registry LLC
1186        "voyage", // voyage Ruby House, LLC
1187        "vuelos", // vuelos Travel Reservations SRL
1188        "wales", // wales Nominet UK
1189        "walter", // walter Sandvik AB
1190        "wang", // wang Zodiac Registry Limited
1191        "wanggou", // wanggou Amazon Registry Services, Inc.
1192        "warman", // warman Weir Group IP Limited
1193        "watch", // watch Sand Shadow, LLC
1194        "watches", // watches Richemont DNS Inc.
1195        "weather", // weather The Weather Channel, LLC
1196        "weatherchannel", // weatherchannel The Weather Channel, LLC
1197        "webcam", // webcam dot Webcam Limited
1198        "weber", // weber Saint-Gobain Weber SA
1199        "website", // website DotWebsite Inc.
1200        "wed", // wed Atgron, Inc.
1201        "wedding", // wedding Top Level Domain Holdings Limited
1202        "weibo", // weibo Sina Corporation
1203        "weir", // weir Weir Group IP Limited
1204        "whoswho", // whoswho Who&#39;s Who Registry
1205        "wien", // wien punkt.wien GmbH
1206        "wiki", // wiki Top Level Design, LLC
1207        "williamhill", // williamhill William Hill Organization Limited
1208        "win", // win First Registry Limited
1209        "windows", // windows Microsoft Corporation
1210        "wine", // wine June Station, LLC
1211        "wme", // wme William Morris Endeavor Entertainment, LLC
1212        "wolterskluwer", // wolterskluwer Wolters Kluwer N.V.
1213        "work", // work Top Level Domain Holdings Limited
1214        "works", // works Little Dynamite, LLC
1215        "world", // world Bitter Fields, LLC
1216        "wtc", // wtc World Trade Centers Association, Inc.
1217        "wtf", // wtf Hidden Way, LLC
1218        "xbox", // xbox Microsoft Corporation
1219        "xerox", // xerox Xerox DNHC LLC
1220        "xihuan", // xihuan QIHOO 360 TECHNOLOGY CO. LTD.
1221        "xin", // xin Elegant Leader Limited
1222        "xn--11b4c3d", // कॉम VeriSign Sarl
1223        "xn--1ck2e1b", // セール Amazon Registry Services, Inc.
1224        "xn--1qqw23a", // 佛山 Guangzhou YU Wei Information Technology Co., Ltd.
1225        "xn--30rr7y", // 慈善 Excellent First Limited
1226        "xn--3bst00m", // 集团 Eagle Horizon Limited
1227        "xn--3ds443g", // 在线 TLD REGISTRY LIMITED
1228        "xn--3pxu8k", // 点看 VeriSign Sarl
1229        "xn--42c2d9a", // คอม VeriSign Sarl
1230        "xn--45q11c", // 八卦 Zodiac Scorpio Limited
1231        "xn--4gbrim", // موقع Suhub Electronic Establishment
1232        "xn--55qw42g", // 公益 China Organizational Name Administration Center
1233        "xn--55qx5d", // 公司 Computer Network Information Center of Chinese Academy of Sciences (China Internet Network Information Center)
1234        "xn--5tzm5g", // 网站 Global Website TLD Asia Limited
1235        "xn--6frz82g", // 移动 Afilias Limited
1236        "xn--6qq986b3xl", // 我爱你 Tycoon Treasure Limited
1237        "xn--80adxhks", // москва Foundation for Assistance for Internet Technologies and Infrastructure Development (FAITID)
1238        "xn--80asehdb", // онлайн CORE Association
1239        "xn--80aswg", // сайт CORE Association
1240        "xn--8y0a063a", // 联通 China United Network Communications Corporation Limited
1241        "xn--9dbq2a", // קום VeriSign Sarl
1242        "xn--9et52u", // 时尚 RISE VICTORY LIMITED
1243        "xn--9krt00a", // 微博 Sina Corporation
1244        "xn--b4w605ferd", // 淡马锡 Temasek Holdings (Private) Limited
1245        "xn--bck1b9a5dre4c", // ファッション Amazon Registry Services, Inc.
1246        "xn--c1avg", // орг Public Interest Registry
1247        "xn--c2br7g", // नेट VeriSign Sarl
1248        "xn--cck2b3b", // ストア Amazon Registry Services, Inc.
1249        "xn--cg4bki", // 삼성 SAMSUNG SDS CO., LTD
1250        "xn--czr694b", // 商标 HU YI GLOBAL INFORMATION RESOURCES(HOLDING) COMPANY.HONGKONG LIMITED
1251        "xn--czrs0t", // 商店 Wild Island, LLC
1252        "xn--czru2d", // 商城 Zodiac Aquarius Limited
1253        "xn--d1acj3b", // дети The Foundation for Network Initiatives “The Smart Internet”
1254        "xn--eckvdtc9d", // ポイント Amazon Registry Services, Inc.
1255        "xn--efvy88h", // 新闻 Xinhua News Agency Guangdong Branch 新华通讯社广东分社
1256        "xn--estv75g", // 工行 Industrial and Commercial Bank of China Limited
1257        "xn--fct429k", // 家電 Amazon Registry Services, Inc.
1258        "xn--fhbei", // كوم VeriSign Sarl
1259        "xn--fiq228c5hs", // 中文网 TLD REGISTRY LIMITED
1260        "xn--fiq64b", // 中信 CITIC Group Corporation
1261        "xn--fjq720a", // 娱乐 Will Bloom, LLC
1262        "xn--flw351e", // 谷歌 Charleston Road Registry Inc.
1263        "xn--fzys8d69uvgm", // 電訊盈科 PCCW Enterprises Limited
1264        "xn--g2xx48c", // 购物 Minds + Machines Group Limited
1265        "xn--gckr3f0f", // クラウド Amazon Registry Services, Inc.
1266        "xn--hxt814e", // 网店 Zodiac Libra Limited
1267        "xn--i1b6b1a6a2e", // संगठन Public Interest Registry
1268        "xn--imr513n", // 餐厅 HU YI GLOBAL INFORMATION RESOURCES (HOLDING) COMPANY. HONGKONG LIMITED
1269        "xn--io0a7i", // 网络 Computer Network Information Center of Chinese Academy of Sciences (China Internet Network Information Center)
1270        "xn--j1aef", // ком VeriSign Sarl
1271        "xn--jlq61u9w7b", // 诺基亚 Nokia Corporation
1272        "xn--jvr189m", // 食品 Amazon Registry Services, Inc.
1273        "xn--kcrx77d1x4a", // 飞利浦 Koninklijke Philips N.V.
1274        "xn--kpu716f", // 手表 Richemont DNS Inc.
1275        "xn--kput3i", // 手机 Beijing RITT-Net Technology Development Co., Ltd
1276        "xn--mgba3a3ejt", // ارامكو Aramco Services Company
1277        "xn--mgba7c0bbn0a", // العليان Crescent Holding GmbH
1278        "xn--mgbab2bd", // بازار CORE Association
1279        "xn--mgbb9fbpob", // موبايلي GreenTech Consultancy Company W.L.L.
1280        "xn--mgbca7dzdo", // ابوظبي Abu Dhabi Systems and Information Centre
1281        "xn--mgbt3dhd", // همراه Asia Green IT System Bilgisayar San. ve Tic. Ltd. Sti.
1282        "xn--mk1bu44c", // 닷컴 VeriSign Sarl
1283        "xn--mxtq1m", // 政府 Net-Chinese Co., Ltd.
1284        "xn--ngbc5azd", // شبكة International Domain Registry Pty. Ltd.
1285        "xn--ngbe9e0a", // بيتك Kuwait Finance House
1286        "xn--nqv7f", // 机构 Public Interest Registry
1287        "xn--nqv7fs00ema", // 组织机构 Public Interest Registry
1288        "xn--nyqy26a", // 健康 Stable Tone Limited
1289        "xn--p1acf", // рус Rusnames Limited
1290        "xn--pbt977c", // 珠宝 Richemont DNS Inc.
1291        "xn--pssy2u", // 大拿 VeriSign Sarl
1292        "xn--q9jyb4c", // みんな Charleston Road Registry Inc.
1293        "xn--qcka1pmc", // グーグル Charleston Road Registry Inc.
1294        "xn--rhqv96g", // 世界 Stable Tone Limited
1295        "xn--rovu88b", // 書籍 Amazon EU S.à r.l.
1296        "xn--ses554g", // 网址 KNET Co., Ltd
1297        "xn--t60b56a", // 닷넷 VeriSign Sarl
1298        "xn--tckwe", // コム VeriSign Sarl
1299        "xn--unup4y", // 游戏 Spring Fields, LLC
1300        "xn--vermgensberater-ctb", // VERMöGENSBERATER Deutsche Vermögensberatung Aktiengesellschaft DVAG
1301        "xn--vermgensberatung-pwb", // VERMöGENSBERATUNG Deutsche Vermögensberatung Aktiengesellschaft DVAG
1302        "xn--vhquv", // 企业 Dash McCook, LLC
1303        "xn--vuq861b", // 信息 Beijing Tele-info Network Technology Co., Ltd.
1304        "xn--w4r85el8fhu5dnra", // 嘉里大酒店 Kerry Trading Co. Limited
1305        "xn--w4rs40l", // 嘉里 Kerry Trading Co. Limited
1306        "xn--xhq521b", // 广东 Guangzhou YU Wei Information Technology Co., Ltd.
1307        "xn--zfr164b", // 政务 China Organizational Name Administration Center
1308        "xperia", // xperia Sony Mobile Communications AB
1309        "xxx", // xxx ICM Registry LLC
1310        "xyz", // xyz XYZ.COM LLC
1311        "yachts", // yachts DERYachts, LLC
1312        "yahoo", // yahoo Yahoo! Domain Services Inc.
1313        "yamaxun", // yamaxun Amazon Registry Services, Inc.
1314        "yandex", // yandex YANDEX, LLC
1315        "yodobashi", // yodobashi YODOBASHI CAMERA CO.,LTD.
1316        "yoga", // yoga Top Level Domain Holdings Limited
1317        "yokohama", // yokohama GMO Registry, Inc.
1318        "you", // you Amazon Registry Services, Inc.
1319        "youtube", // youtube Charleston Road Registry Inc.
1320        "yun", // yun QIHOO 360 TECHNOLOGY CO. LTD.
1321        "zappos", // zappos Amazon Registry Service, Inc.
1322        "zara", // zara Industria de Diseño Textil, S.A. (INDITEX, S.A.)
1323        "zero", // zero Amazon Registry Services, Inc.
1324        "zip", // zip Charleston Road Registry Inc.
1325        "zone", // zone Outer Falls, LLC
1326        "zuerich", // zuerich Kanton Zürich (Canton of Zurich)
1327    };
1328
1329    // WARNING: this array MUST be sorted, otherwise it cannot be searched reliably using binary search
1330    private static final String[] COUNTRY_CODE_TLDS = new String[] {
1331        "ac",                 // Ascension Island
1332        "ad",                 // Andorra
1333        "ae",                 // United Arab Emirates
1334        "af",                 // Afghanistan
1335        "ag",                 // Antigua and Barbuda
1336        "ai",                 // Anguilla
1337        "al",                 // Albania
1338        "am",                 // Armenia
1339        //"an",               // Netherlands Antilles (retired)
1340        "ao",                 // Angola
1341        "aq",                 // Antarctica
1342        "ar",                 // Argentina
1343        "as",                 // American Samoa
1344        "at",                 // Austria
1345        "au",                 // Australia (includes Ashmore and Cartier Islands and Coral Sea Islands)
1346        "aw",                 // Aruba
1347        "ax",                 // Åland
1348        "az",                 // Azerbaijan
1349        "ba",                 // Bosnia and Herzegovina
1350        "bb",                 // Barbados
1351        "bd",                 // Bangladesh
1352        "be",                 // Belgium
1353        "bf",                 // Burkina Faso
1354        "bg",                 // Bulgaria
1355        "bh",                 // Bahrain
1356        "bi",                 // Burundi
1357        "bj",                 // Benin
1358        "bm",                 // Bermuda
1359        "bn",                 // Brunei Darussalam
1360        "bo",                 // Bolivia
1361        "br",                 // Brazil
1362        "bs",                 // Bahamas
1363        "bt",                 // Bhutan
1364        "bv",                 // Bouvet Island
1365        "bw",                 // Botswana
1366        "by",                 // Belarus
1367        "bz",                 // Belize
1368        "ca",                 // Canada
1369        "cc",                 // Cocos (Keeling) Islands
1370        "cd",                 // Democratic Republic of the Congo (formerly Zaire)
1371        "cf",                 // Central African Republic
1372        "cg",                 // Republic of the Congo
1373        "ch",                 // Switzerland
1374        "ci",                 // Côte d'Ivoire
1375        "ck",                 // Cook Islands
1376        "cl",                 // Chile
1377        "cm",                 // Cameroon
1378        "cn",                 // China, mainland
1379        "co",                 // Colombia
1380        "cr",                 // Costa Rica
1381        "cu",                 // Cuba
1382        "cv",                 // Cape Verde
1383        "cw",                 // Curaçao
1384        "cx",                 // Christmas Island
1385        "cy",                 // Cyprus
1386        "cz",                 // Czech Republic
1387        "de",                 // Germany
1388        "dj",                 // Djibouti
1389        "dk",                 // Denmark
1390        "dm",                 // Dominica
1391        "do",                 // Dominican Republic
1392        "dz",                 // Algeria
1393        "ec",                 // Ecuador
1394        "ee",                 // Estonia
1395        "eg",                 // Egypt
1396        "er",                 // Eritrea
1397        "es",                 // Spain
1398        "et",                 // Ethiopia
1399        "eu",                 // European Union
1400        "fi",                 // Finland
1401        "fj",                 // Fiji
1402        "fk",                 // Falkland Islands
1403        "fm",                 // Federated States of Micronesia
1404        "fo",                 // Faroe Islands
1405        "fr",                 // France
1406        "ga",                 // Gabon
1407        "gb",                 // Great Britain (United Kingdom)
1408        "gd",                 // Grenada
1409        "ge",                 // Georgia
1410        "gf",                 // French Guiana
1411        "gg",                 // Guernsey
1412        "gh",                 // Ghana
1413        "gi",                 // Gibraltar
1414        "gl",                 // Greenland
1415        "gm",                 // The Gambia
1416        "gn",                 // Guinea
1417        "gp",                 // Guadeloupe
1418        "gq",                 // Equatorial Guinea
1419        "gr",                 // Greece
1420        "gs",                 // South Georgia and the South Sandwich Islands
1421        "gt",                 // Guatemala
1422        "gu",                 // Guam
1423        "gw",                 // Guinea-Bissau
1424        "gy",                 // Guyana
1425        "hk",                 // Hong Kong
1426        "hm",                 // Heard Island and McDonald Islands
1427        "hn",                 // Honduras
1428        "hr",                 // Croatia (Hrvatska)
1429        "ht",                 // Haiti
1430        "hu",                 // Hungary
1431        "id",                 // Indonesia
1432        "ie",                 // Ireland (Éire)
1433        "il",                 // Israel
1434        "im",                 // Isle of Man
1435        "in",                 // India
1436        "io",                 // British Indian Ocean Territory
1437        "iq",                 // Iraq
1438        "ir",                 // Iran
1439        "is",                 // Iceland
1440        "it",                 // Italy
1441        "je",                 // Jersey
1442        "jm",                 // Jamaica
1443        "jo",                 // Jordan
1444        "jp",                 // Japan
1445        "ke",                 // Kenya
1446        "kg",                 // Kyrgyzstan
1447        "kh",                 // Cambodia (Khmer)
1448        "ki",                 // Kiribati
1449        "km",                 // Comoros
1450        "kn",                 // Saint Kitts and Nevis
1451        "kp",                 // North Korea
1452        "kr",                 // South Korea
1453        "kw",                 // Kuwait
1454        "ky",                 // Cayman Islands
1455        "kz",                 // Kazakhstan
1456        "la",                 // Laos (currently being marketed as the official domain for Los Angeles)
1457        "lb",                 // Lebanon
1458        "lc",                 // Saint Lucia
1459        "li",                 // Liechtenstein
1460        "lk",                 // Sri Lanka
1461        "lr",                 // Liberia
1462        "ls",                 // Lesotho
1463        "lt",                 // Lithuania
1464        "lu",                 // Luxembourg
1465        "lv",                 // Latvia
1466        "ly",                 // Libya
1467        "ma",                 // Morocco
1468        "mc",                 // Monaco
1469        "md",                 // Moldova
1470        "me",                 // Montenegro
1471        "mg",                 // Madagascar
1472        "mh",                 // Marshall Islands
1473        "mk",                 // Republic of Macedonia
1474        "ml",                 // Mali
1475        "mm",                 // Myanmar
1476        "mn",                 // Mongolia
1477        "mo",                 // Macau
1478        "mp",                 // Northern Mariana Islands
1479        "mq",                 // Martinique
1480        "mr",                 // Mauritania
1481        "ms",                 // Montserrat
1482        "mt",                 // Malta
1483        "mu",                 // Mauritius
1484        "mv",                 // Maldives
1485        "mw",                 // Malawi
1486        "mx",                 // Mexico
1487        "my",                 // Malaysia
1488        "mz",                 // Mozambique
1489        "na",                 // Namibia
1490        "nc",                 // New Caledonia
1491        "ne",                 // Niger
1492        "nf",                 // Norfolk Island
1493        "ng",                 // Nigeria
1494        "ni",                 // Nicaragua
1495        "nl",                 // Netherlands
1496        "no",                 // Norway
1497        "np",                 // Nepal
1498        "nr",                 // Nauru
1499        "nu",                 // Niue
1500        "nz",                 // New Zealand
1501        "om",                 // Oman
1502        "pa",                 // Panama
1503        "pe",                 // Peru
1504        "pf",                 // French Polynesia With Clipperton Island
1505        "pg",                 // Papua New Guinea
1506        "ph",                 // Philippines
1507        "pk",                 // Pakistan
1508        "pl",                 // Poland
1509        "pm",                 // Saint-Pierre and Miquelon
1510        "pn",                 // Pitcairn Islands
1511        "pr",                 // Puerto Rico
1512        "ps",                 // Palestinian territories (PA-controlled West Bank and Gaza Strip)
1513        "pt",                 // Portugal
1514        "pw",                 // Palau
1515        "py",                 // Paraguay
1516        "qa",                 // Qatar
1517        "re",                 // Réunion
1518        "ro",                 // Romania
1519        "rs",                 // Serbia
1520        "ru",                 // Russia
1521        "rw",                 // Rwanda
1522        "sa",                 // Saudi Arabia
1523        "sb",                 // Solomon Islands
1524        "sc",                 // Seychelles
1525        "sd",                 // Sudan
1526        "se",                 // Sweden
1527        "sg",                 // Singapore
1528        "sh",                 // Saint Helena
1529        "si",                 // Slovenia
1530        "sj",                 // Svalbard and Jan Mayen Islands Not in use (Norwegian dependencies; see .no)
1531        "sk",                 // Slovakia
1532        "sl",                 // Sierra Leone
1533        "sm",                 // San Marino
1534        "sn",                 // Senegal
1535        "so",                 // Somalia
1536        "sr",                 // Suriname
1537        "st",                 // São Tomé and Príncipe
1538        "su",                 // Soviet Union (deprecated)
1539        "sv",                 // El Salvador
1540        "sx",                 // Sint Maarten
1541        "sy",                 // Syria
1542        "sz",                 // Swaziland
1543        "tc",                 // Turks and Caicos Islands
1544        "td",                 // Chad
1545        "tf",                 // French Southern and Antarctic Lands
1546        "tg",                 // Togo
1547        "th",                 // Thailand
1548        "tj",                 // Tajikistan
1549        "tk",                 // Tokelau
1550        "tl",                 // East Timor (deprecated old code)
1551        "tm",                 // Turkmenistan
1552        "tn",                 // Tunisia
1553        "to",                 // Tonga
1554        //"tp",               // East Timor (Retired)
1555        "tr",                 // Turkey
1556        "tt",                 // Trinidad and Tobago
1557        "tv",                 // Tuvalu
1558        "tw",                 // Taiwan, Republic of China
1559        "tz",                 // Tanzania
1560        "ua",                 // Ukraine
1561        "ug",                 // Uganda
1562        "uk",                 // United Kingdom
1563        "us",                 // United States of America
1564        "uy",                 // Uruguay
1565        "uz",                 // Uzbekistan
1566        "va",                 // Vatican City State
1567        "vc",                 // Saint Vincent and the Grenadines
1568        "ve",                 // Venezuela
1569        "vg",                 // British Virgin Islands
1570        "vi",                 // U.S. Virgin Islands
1571        "vn",                 // Vietnam
1572        "vu",                 // Vanuatu
1573        "wf",                 // Wallis and Futuna
1574        "ws",                 // Samoa (formerly Western Samoa)
1575        "xn--3e0b707e", // 한국 KISA (Korea Internet &amp; Security Agency)
1576        "xn--45brj9c", // ভারত National Internet Exchange of India
1577        "xn--80ao21a", // қаз Association of IT Companies of Kazakhstan
1578        "xn--90a3ac", // срб Serbian National Internet Domain Registry (RNIDS)
1579        "xn--90ais", // ??? Reliable Software Inc.
1580        "xn--clchc0ea0b2g2a9gcd", // சிங்கப்பூர் Singapore Network Information Centre (SGNIC) Pte Ltd
1581        "xn--d1alf", // мкд Macedonian Academic Research Network Skopje
1582        "xn--e1a4c", // ею EURid vzw/asbl
1583        "xn--fiqs8s", // 中国 China Internet Network Information Center
1584        "xn--fiqz9s", // 中國 China Internet Network Information Center
1585        "xn--fpcrj9c3d", // భారత్ National Internet Exchange of India
1586        "xn--fzc2c9e2c", // ලංකා LK Domain Registry
1587        "xn--gecrj9c", // ભારત National Internet Exchange of India
1588        "xn--h2brj9c", // भारत National Internet Exchange of India
1589        "xn--j1amh", // укр Ukrainian Network Information Centre (UANIC), Inc.
1590        "xn--j6w193g", // 香港 Hong Kong Internet Registration Corporation Ltd.
1591        "xn--kprw13d", // 台湾 Taiwan Network Information Center (TWNIC)
1592        "xn--kpry57d", // 台灣 Taiwan Network Information Center (TWNIC)
1593        "xn--l1acc", // мон Datacom Co.,Ltd
1594        "xn--lgbbat1ad8j", // الجزائر CERIST
1595        "xn--mgb9awbf", // عمان Telecommunications Regulatory Authority (TRA)
1596        "xn--mgba3a4f16a", // ایران Institute for Research in Fundamental Sciences (IPM)
1597        "xn--mgbaam7a8h", // امارات Telecommunications Regulatory Authority (TRA)
1598        "xn--mgbayh7gpa", // الاردن National Information Technology Center (NITC)
1599        "xn--mgbbh1a71e", // بھارت National Internet Exchange of India
1600        "xn--mgbc0a9azcg", // المغرب Agence Nationale de Réglementation des Télécommunications (ANRT)
1601        "xn--mgberp4a5d4ar", // السعودية Communications and Information Technology Commission
1602        "xn--mgbpl2fh", // ????? Sudan Internet Society
1603        "xn--mgbtx2b", // عراق Communications and Media Commission (CMC)
1604        "xn--mgbx4cd0ab", // مليسيا MYNIC Berhad
1605        "xn--mix891f", // 澳門 Bureau of Telecommunications Regulation (DSRT)
1606        "xn--node", // გე Information Technologies Development Center (ITDC)
1607        "xn--o3cw4h", // ไทย Thai Network Information Center Foundation
1608        "xn--ogbpf8fl", // سورية National Agency for Network Services (NANS)
1609        "xn--p1ai", // рф Coordination Center for TLD RU
1610        "xn--pgbs0dh", // تونس Agence Tunisienne d&#39;Internet
1611        "xn--qxam", // ελ ICS-FORTH GR
1612        "xn--s9brj9c", // ਭਾਰਤ National Internet Exchange of India
1613        "xn--wgbh1c", // مصر National Telecommunication Regulatory Authority - NTRA
1614        "xn--wgbl6a", // قطر Communications Regulatory Authority
1615        "xn--xkc2al3hye2a", // இலங்கை LK Domain Registry
1616        "xn--xkc2dl3a5ee0h", // இந்தியா National Internet Exchange of India
1617        "xn--y9a3aq", // ??? Internet Society
1618        "xn--yfro4i67o", // 新加坡 Singapore Network Information Centre (SGNIC) Pte Ltd
1619        "xn--ygbi2ammx", // فلسطين Ministry of Telecom &amp; Information Technology (MTIT)
1620        "ye",                 // Yemen
1621        "yt",                 // Mayotte
1622        "za",                 // South Africa
1623        "zm",                 // Zambia
1624        "zw",                 // Zimbabwe
1625    };
1626
1627    // WARNING: this array MUST be sorted, otherwise it cannot be searched reliably using binary search
1628    private static final String[] LOCAL_TLDS = new String[] {
1629       "localdomain",         // Also widely used as localhost.localdomain
1630       "localhost",           // RFC2606 defined
1631    };
1632
1633    // Additional arrays to supplement or override the built in ones.
1634    // The PLUS arrays are valid keys, the MINUS arrays are invalid keys
1635
1636    /*
1637     * This field is used to detect whether the getInstance has been called.
1638     * After this, the method updateTLDOverride is not allowed to be called.
1639     * This field does not need to be volatile since it is only accessed from
1640     * synchronized methods.
1641     */
1642    private static boolean inUse;
1643
1644    /*
1645     * These arrays are mutable, but they don't need to be volatile.
1646     * They can only be updated by the updateTLDOverride method, and any readers must get an instance
1647     * using the getInstance methods which are all (now) synchronised.
1648     */
1649    // WARNING: this array MUST be sorted, otherwise it cannot be searched reliably using binary search
1650    private static volatile String[] countryCodeTLDsPlus = EMPTY_STRING_ARRAY;
1651
1652    // WARNING: this array MUST be sorted, otherwise it cannot be searched reliably using binary search
1653    private static volatile String[] genericTLDsPlus = EMPTY_STRING_ARRAY;
1654
1655    // WARNING: this array MUST be sorted, otherwise it cannot be searched reliably using binary search
1656    private static volatile String[] countryCodeTLDsMinus = EMPTY_STRING_ARRAY;
1657
1658    // WARNING: this array MUST be sorted, otherwise it cannot be searched reliably using binary search
1659    private static volatile String[] genericTLDsMinus = EMPTY_STRING_ARRAY;
1660
1661    /**
1662     * enum used by {@link DomainValidator#updateTLDOverride(ArrayType, String[])}
1663     * to determine which override array to update / fetch
1664     * @since 1.5.0
1665     * @since 1.5.1 made public and added read-only array references
1666     */
1667    public enum ArrayType {
1668        /** Update (or get a copy of) the GENERIC_TLDS_PLUS table containing additonal generic TLDs */
1669        GENERIC_PLUS,
1670        /** Update (or get a copy of) the GENERIC_TLDS_MINUS table containing deleted generic TLDs */
1671        GENERIC_MINUS,
1672        /** Update (or get a copy of) the COUNTRY_CODE_TLDS_PLUS table containing additonal country code TLDs */
1673        COUNTRY_CODE_PLUS,
1674        /** Update (or get a copy of) the COUNTRY_CODE_TLDS_MINUS table containing deleted country code TLDs */
1675        COUNTRY_CODE_MINUS,
1676        /** Get a copy of the generic TLDS table */
1677        GENERIC_RO,
1678        /** Get a copy of the country code table */
1679        COUNTRY_CODE_RO,
1680        /** Get a copy of the infrastructure table */
1681        INFRASTRUCTURE_RO,
1682        /** Get a copy of the local table */
1683        LOCAL_RO
1684    }
1685
1686    // For use by unit test code only
1687    static synchronized void clearTLDOverrides() {
1688        inUse = false;
1689        countryCodeTLDsPlus = EMPTY_STRING_ARRAY;
1690        countryCodeTLDsMinus = EMPTY_STRING_ARRAY;
1691        genericTLDsPlus = EMPTY_STRING_ARRAY;
1692        genericTLDsMinus = EMPTY_STRING_ARRAY;
1693    }
1694
1695    /**
1696     * Update one of the TLD override arrays.
1697     * This must only be done at program startup, before any instances are accessed using getInstance.
1698     * <p>
1699     * For example:
1700     * <p>
1701     * <code>DomainValidator.updateTLDOverride(ArrayType.GENERIC_PLUS, new String[]{"apache"})}</code>
1702     * <p>
1703     * To clear an override array, provide an empty array.
1704     *
1705     * @param table the table to update, see {@link DomainValidator.ArrayType}
1706     * Must be one of the following
1707     * <ul>
1708     * <li>COUNTRY_CODE_MINUS</li>
1709     * <li>COUNTRY_CODE_PLUS</li>
1710     * <li>GENERIC_MINUS</li>
1711     * <li>GENERIC_PLUS</li>
1712     * </ul>
1713     * @param tlds the array of TLDs, must not be null
1714     * @throws IllegalStateException if the method is called after getInstance
1715     * @throws IllegalArgumentException if one of the read-only tables is requested
1716     * @since 1.5.0
1717     */
1718    public static synchronized void updateTLDOverride(ArrayType table, String[] tlds) {
1719        if (inUse) {
1720            throw new IllegalStateException("Can only invoke this method before calling getInstance");
1721        }
1722        String[] copy = new String[tlds.length];
1723        // Comparisons are always done with lower-case entries
1724        for (int i = 0; i < tlds.length; i++) {
1725            copy[i] = tlds[i].toLowerCase(Locale.ENGLISH);
1726        }
1727        Arrays.sort(copy);
1728        switch(table) {
1729        case COUNTRY_CODE_MINUS:
1730            countryCodeTLDsMinus = copy;
1731            break;
1732        case COUNTRY_CODE_PLUS:
1733            countryCodeTLDsPlus = copy;
1734            break;
1735        case GENERIC_MINUS:
1736            genericTLDsMinus = copy;
1737            break;
1738        case GENERIC_PLUS:
1739            genericTLDsPlus = copy;
1740            break;
1741        case COUNTRY_CODE_RO:
1742        case GENERIC_RO:
1743        case INFRASTRUCTURE_RO:
1744        case LOCAL_RO:
1745            throw new IllegalArgumentException("Cannot update the table: " + table);
1746        default:
1747            throw new IllegalArgumentException("Unexpected enum value: " + table);
1748        }
1749    }
1750
1751    /**
1752     * Get a copy of the internal array.
1753     * @param table the array type (any of the enum values)
1754     * @return a copy of the array
1755     * @throws IllegalArgumentException if the table type is unexpected (should not happen)
1756     * @since 1.5.1
1757     */
1758    public static String[] getTLDEntries(ArrayType table) {
1759        final String[] array;
1760        switch(table) {
1761        case COUNTRY_CODE_MINUS:
1762            array = countryCodeTLDsMinus;
1763            break;
1764        case COUNTRY_CODE_PLUS:
1765            array = countryCodeTLDsPlus;
1766            break;
1767        case GENERIC_MINUS:
1768            array = genericTLDsMinus;
1769            break;
1770        case GENERIC_PLUS:
1771            array = genericTLDsPlus;
1772            break;
1773        case GENERIC_RO:
1774            array = GENERIC_TLDS;
1775            break;
1776        case COUNTRY_CODE_RO:
1777            array = COUNTRY_CODE_TLDS;
1778            break;
1779        case INFRASTRUCTURE_RO:
1780            array = INFRASTRUCTURE_TLDS;
1781            break;
1782        case LOCAL_RO:
1783            array = LOCAL_TLDS;
1784            break;
1785        default:
1786            throw new IllegalArgumentException("Unexpected enum value: " + table);
1787        }
1788        return Arrays.copyOf(array, array.length); // clone the array
1789    }
1790
1791    /**
1792     * Converts potentially Unicode input to punycode.
1793     * If conversion fails, returns the original input.
1794     *
1795     * @param input the string to convert, not null
1796     * @return converted input, or original input if conversion fails
1797     */
1798    // Needed by UrlValidator
1799    static String unicodeToASCII(String input) {
1800        if (isOnlyASCII(input)) { // skip possibly expensive processing
1801            return input;
1802        }
1803        try {
1804            final String ascii = IDN.toASCII(input);
1805            if (IDNBUGHOLDER.IDN_TOASCII_PRESERVES_TRAILING_DOTS) {
1806                return ascii;
1807            }
1808            final int length = input.length();
1809            if (length == 0) { // check there is a last character
1810                return input;
1811            }
1812            // RFC3490 3.1. 1)
1813            //            Whenever dots are used as label separators, the following
1814            //            characters MUST be recognized as dots: U+002E (full stop), U+3002
1815            //            (ideographic full stop), U+FF0E (fullwidth full stop), U+FF61
1816            //            (halfwidth ideographic full stop).
1817            char lastChar = input.charAt(length-1); // fetch original last char
1818            switch(lastChar) {
1819                case '\u002E': // "." full stop
1820                case '\u3002': // ideographic full stop
1821                case '\uFF0E': // fullwidth full stop
1822                case '\uFF61': // halfwidth ideographic full stop
1823                    return ascii + '.'; // restore the missing stop
1824                default:
1825                    return ascii;
1826            }
1827        } catch (IllegalArgumentException e) { // input is not valid
1828            return input;
1829        }
1830    }
1831
1832    private static class IDNBUGHOLDER {
1833        private static boolean keepsTrailingDot() {
1834            final String input = "a."; // must be a valid name
1835            return input.equals(IDN.toASCII(input));
1836        }
1837
1838        private static final boolean IDN_TOASCII_PRESERVES_TRAILING_DOTS = keepsTrailingDot();
1839    }
1840
1841    /*
1842     * Check if input contains only ASCII
1843     * Treats null as all ASCII
1844     */
1845    private static boolean isOnlyASCII(String input) {
1846        if (input == null) {
1847            return true;
1848        }
1849        for (int i = 0; i < input.length(); i++) {
1850            if (input.charAt(i) > 0x7F) { // CHECKSTYLE IGNORE MagicNumber
1851                return false;
1852            }
1853        }
1854        return true;
1855    }
1856
1857    /**
1858     * Check if a sorted array contains the specified key
1859     *
1860     * @param sortedArray the array to search
1861     * @param key the key to find
1862     * @return {@code true} if the array contains the key
1863     */
1864    private static boolean arrayContains(String[] sortedArray, String key) {
1865        return Arrays.binarySearch(sortedArray, key) >= 0;
1866    }
1867}