JDK 11 jdk.naming.dns.jmod - Naming DNS Module

JDK 11 jdk.naming.dns.jmod is the JMOD file for JDK 11 Naming DNS module.

JDK 11 Naming DNS module compiled class files are stored in \fyicenter\jdk-11.0.1\jmods\jdk.naming.dns.jmod.

JDK 11 Naming DNS module compiled class files are also linked and stored in the \fyicenter\jdk-11.0.1\lib\modules JImage file.

JDK 11 Naming DNS module source code files are stored in \fyicenter\jdk-11.0.1\lib\src.zip\jdk.naming.dns.

You can click and view the content of each source code file in the list below.

✍: FYIcenter

com/sun/jndi/dns/Resolver.java

/*
 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */

package com.sun.jndi.dns;


import javax.naming.*;


/**
 * The Resolver class performs DNS client operations in support of DnsContext.
 *
 * <p> Every DnsName instance passed to or returned from a method of
 * this class should be fully-qualified and contain a root label (an
 * empty component at position 0).
 *
 * @author Scott Seligman
 */

class Resolver {

    private DnsClient dnsClient;
    private int timeout;                // initial timeout on UDP queries in ms
    private int retries;                // number of UDP retries


    /*
     * Constructs a new Resolver given its servers and timeout parameters.
     * Each server is of the form "server[:port]".
     * IPv6 literal host names include delimiting brackets.
     * There must be at least one server.
     * "timeout" is the initial timeout interval (in ms) for UDP queries,
     * and "retries" gives the number of retries per server.
     */
    Resolver(String[] servers, int timeout, int retries)
            throws NamingException {
        this.timeout = timeout;
        this.retries = retries;
        dnsClient = new DnsClient(servers, timeout, retries);
    }

    public void close() {
        dnsClient.close();
        dnsClient = null;
    }


    /*
     * Queries resource records of a particular class and type for a
     * given domain name.
     * Useful values of rrclass are ResourceRecord.[Q]CLASS_xxx.
     * Useful values of rrtype are ResourceRecord.[Q]TYPE_xxx.
     * If recursion is true, recursion is requested on the query.
     * If auth is true, only authoritative responses are accepted.
     */
    ResourceRecords query(DnsName fqdn, int rrclass, int rrtype,
                          boolean recursion, boolean auth)
            throws NamingException {
        return dnsClient.query(fqdn, rrclass, rrtype, recursion, auth);
    }

    /*
     * Queries all resource records of a zone given its domain name and class.
     * If recursion is true, recursion is requested on the query to find
     * the name server (and also on the zone transfer, but it won't matter).
     */
    ResourceRecords queryZone(DnsName zone, int rrclass, boolean recursion)
            throws NamingException {

        DnsClient cl =
            new DnsClient(findNameServers(zone, recursion), timeout, retries);
        try {
            return cl.queryZone(zone, rrclass, recursion);
        } finally {
            cl.close();
        }
    }

    /*
     * Finds the zone of a given domain name.  The method is to look
     * for the first SOA record on the path from the given domain to
     * the root.  This search may be partially bypassed if the zone's
     * SOA record is received in the authority section of a response.
     * If recursion is true, recursion is requested on any queries.
     */
    DnsName findZoneName(DnsName fqdn, int rrclass, boolean recursion)
            throws NamingException {

        fqdn = (DnsName) fqdn.clone();
        while (fqdn.size() > 1) {       // while below root
            ResourceRecords rrs = null;
            try {
                rrs = query(fqdn, rrclass, ResourceRecord.TYPE_SOA,
                            recursion, false);
            } catch (NameNotFoundException e) {
                throw e;
            } catch (NamingException e) {
                // Ignore error and keep searching up the tree.
            }
            if (rrs != null) {
                if (rrs.answer.size() > 0) {    // found zone's SOA
                    return fqdn;
                }
                // Look for an SOA record giving the zone's top node.
                for (int i = 0; i < rrs.authority.size(); i++) {
                    ResourceRecord rr = rrs.authority.elementAt(i);
                    if (rr.getType() == ResourceRecord.TYPE_SOA) {
                        DnsName zone = rr.getName();
                        if (fqdn.endsWith(zone)) {
                            return zone;
                        }
                    }
                }
            }
            fqdn.remove(fqdn.size() - 1);       // one step rootward
        }
        return fqdn;                    // no SOA found below root, so
                                        // return root
    }

    /*
     * Finds a zone's SOA record.  Returns null if no SOA is found (in
     * which case "zone" is not actually a zone).
     * If recursion is true, recursion is requested on the query.
     */
     ResourceRecord findSoa(DnsName zone, int rrclass, boolean recursion)
            throws NamingException {

        ResourceRecords rrs = query(zone, rrclass, ResourceRecord.TYPE_SOA,
                                    recursion, false);
        for (int i = 0; i < rrs.answer.size(); i++) {
            ResourceRecord rr = rrs.answer.elementAt(i);
            if (rr.getType() == ResourceRecord.TYPE_SOA) {
                return rr;
            }
        }
        return null;
    }

    /*
     * Finds the name servers of a zone.  {@code zone} is a fully-qualified
     * domain name at the top of a zone.
     * If recursion is true, recursion is requested on the query.
     */
    private String[] findNameServers(DnsName zone, boolean recursion)
            throws NamingException {

        // %%% As an optimization, could look in authority section of
        // findZoneName() response first.
        ResourceRecords rrs =
            query(zone, ResourceRecord.CLASS_INTERNET, ResourceRecord.TYPE_NS,
                  recursion, false);
        String[] ns = new String[rrs.answer.size()];
        for (int i = 0; i < ns.length; i++) {
            ResourceRecord rr = rrs.answer.elementAt(i);
            if (rr.getType() != ResourceRecord.TYPE_NS) {
                throw new CommunicationException("Corrupted DNS message");
            }
            ns[i] = (String) rr.getRdata();

            // Server name will be passed to InetAddress.getByName(), which
            // may not be able to handle a trailing dot.
            // assert ns[i].endsWith(".");
            ns[i] = ns[i].substring(0, ns[i].length() - 1);
        }
        return ns;
    }
}

com/sun/jndi/dns/Resolver.java

 

JDK 11 jdk.naming.rmi.jmod - Naming RMI Module

JDK 11 jdk.management.jfr.jmod - Management JFR Module

Download and Use JDK 11

⇑⇑ FAQ for JDK (Java Development Kit)

2020-06-21, 1534👍, 0💬