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