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