2362N/A * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * A DnsContext is a directory context representing a DNS node. 0N/A * @author Scott Seligman 0N/A // with a root (empty) label at position 0 0N/A private boolean envShared;
// true if environment is possibly shared 0N/A // and so must be copied on write 0N/A // another? see composeName() 0N/A private int timeout;
// initial timeout on UDP queries in ms 0N/A // Timeouts for UDP queries use exponential backoff: each retry 0N/A // is for twice as long as the last. The following constants set 0N/A // the defaults for the initial timeout (in ms) and the number of 0N/A // retries, and name the environment properties used to override 0N/A // The resource record type and class to use for lookups, and the 0N/A // property used to modify them 0N/A // Property used to disallow recursion on queries 0N/A // ANY == ResourceRecord.QCLASS_STAR == ResourceRecord.QTYPE_STAR 0N/A // The zone tree used for list operations 0N/A * Returns a DNS context for a given domain and servers. 0N/A * Each server is of the form "server[:port]". 0N/A * IPv6 literal host names include delimiting brackets. 0N/A * There must be at least one server. 0N/A * The environment must not be null; it is cloned before being stored. 0N/A * Returns a clone of a DNS context, just like DnsContext(DnsContext) 0N/A * but with a different domain name and with parentIsDns set to true. 0N/A * Returns a clone of a DNS context. The context's modifiable 0N/A * private state is independent of the original's (so closing one 0N/A * context, for example, won't close the other). The two contexts 0N/A * share <tt>environment</tt>, but it's copy-on-write so there's 0N/A //---------- Environment operations 0N/A * Override default with a noncloning version. 0N/A * Update PROVIDER_URL property. Call this only when environment 0N/A * is not being shared. 0N/A // assert !envShared; 0N/A * Read environment properties and set parameters. 0N/A //---------- Naming operations 0N/A // clone for parallelism 0N/A "Problem generating object using object factory");
0N/A //---------- Directory operations 0N/A //---------- Name-related operations 0N/A // Any name that's not a CompositeName is assumed to be a DNS 0N/A // compound name. Convert each to a DnsName for syntax checking. 0N/A // Each of prefix and name is now either a DnsName or a CompositeName. 0N/A // If we have two DnsNames, simply join them together. 0N/A // Wrap compound names in composite names. 0N/A // Let toolkit do the work at namespace boundaries. 0N/A //---------- Helper methods 0N/A * Resolver is not created until needed, to allow time for updates 0N/A * to the environment. 0N/A * Returns the fully-qualified domain name of a name given 0N/A * relative to this context. Result includes a root label (an 0N/A * empty component at position 0). 0N/A // Be overly generous and allow root label if we're in root domain. 0N/A * Converts resource records to an attribute set. Only resource 0N/A * records in the answer section are used, and only those that 0N/A * match the classes and types in cts (see classAndTypeMatch() 0N/A * for matching rules). 0N/A * Returns true if rrclass and rrtype match some element of cts. 0N/A * A match occurs if corresponding classes and types are equal, 0N/A * or if the array value is ANY. If cts is null, then any class 0N/A * Returns the attribute ID for a resource record given its class 0N/A * and type. If the record is in the internet class, the 0N/A * corresponding attribute ID is the record's type name (or the 0N/A * integer type value if the name is not known). If the record is 0N/A * not in the internet class, the class name (or integer class 0N/A * value) is prepended to the attribute ID, separated by a space. 0N/A * A class or type value of ANY represents an indeterminate class 0N/A * or type, and is represented within the attribute ID by "*". 0N/A * For example, the attribute ID "IN *" represents 0N/A * any type in the internet class, and "* NS" represents an NS 0N/A * record of any class. 0N/A * Returns the class and type values corresponding to an attribute 0N/A * ID. An indeterminate class or type is represented by ANY. See 0N/A * toAttrId() for the format of attribute IDs. 0N/A * @throws InvalidAttributeIdentifierException 0N/A * if class or type is unknown 0N/A "Attribute ID cannot be empty");
0N/A * Returns an array of the classes and types corresponding to a 0N/A * set of attribute IDs. See toAttrId() for the format of 0N/A * attribute IDs, and classAndTypeMatch() for the format of the 0N/A * Returns the most restrictive resource record class and type 0N/A * that may be used to query for records matching cts. 0N/A * See classAndTypeMatch() for matching rules. 0N/A // Query all records. 0N/A // No records are requested, but we need to ask for something. 0N/A //---------- Support for list operations 0N/A * Synchronization notes: 0N/A * Any access to zoneTree that walks the tree, whether it modifies 0N/A * the tree or not, is synchronized on zoneTree. 0N/A * [%%% Note: a read/write lock would allow increased concurrency.] 0N/A * The depth of a ZoneNode can thereafter be accessed without 0N/A * further synchronization. Access to other fields and methods 0N/A * should be synchronized on the node itself. 0N/A * A zone's contents is a NameNode tree that, once created, is never 0N/A * modified. The only synchronization needed is to ensure that it 0N/A * gets flushed into shared memory after being created, which is 0N/A * accomplished by ZoneNode.populate(). The contents are accessed 0N/A * via a soft reference, so a ZoneNode may be seen to be populated 0N/A * one moment and unpopulated the next. 0N/A * Returns the node in the zone tree corresponding to a 0N/A * fully-qualified domain name. If the desired portion of the 0N/A * tree has not yet been populated or has been outdated, a zone 0N/A * transfer is done to populate the tree. 0N/A // Find deepest related zone in zone tree. 0N/A dprint(
"Deepest related zone in zone tree: " +
0N/A // If fqdn is in znode's zone, is not at a zone cut, and 0N/A // is current, we're done. 0N/A // Zone was modified while we were examining it. 0N/A // All bets are off. 0N/A // Cache miss... do it the expensive way. 0N/A // Find fqdn's zone and add it to the tree. 0N/A // If znode is now populated we know -- because the first half of 0N/A // getNodeName() didn't find it -- that it was populated by another 0N/A // thread during this method call. Assume then that it's current. 0N/A // Desired node should now be in znode's populated zone. Find it. 0N/A "DNS error: node not found in its own zone");
0N/A dprint(
"Found node in newly-populated zone");
0N/A * Does a zone transfer to [re]populate a zone in the zone tree. 0N/A * Returns the zone's new contents. 0N/A // assert Thread.holdsLock(znode); 0N/A * Determine if a ZoneNode's data is current. 0N/A * We base this on a comparison between the cached serial 0N/A * number and the latest SOA record. 0N/A * If there is no SOA record, znode is not (or is no longer) a zone: 0N/A * depopulate znode and return false. 0N/A * Since this method may perform a network operation, it is best 0N/A * to call it with znode unlocked. Caller must then note that the 0N/A * result may be outdated by the time this method returns. 0N/A // former version: return !znode.isExpired(); 0N/A //---------- Debugging 0N/A * A pairing of a resource record class and a resource record type. 0N/A * A value of ANY in either field represents an indeterminate value. 0N/A * Nodes that have children or that are zone cuts are returned with 0N/A * classname DirContext. Other nodes are returned with classname 0N/A * Object even though they are DirContexts as well, since this might 0N/A * make the namespace easier to browse. 1538N/A * ctx will be set to null when no longer needed by the enumeration. 0N/A ?
"javax.naming.directory.DirContext" 0N/A :
"java.lang.Object";
0N/A "javax.naming.NamingException was thrown: " +
0N/A * An enumeration of Bindings. 0N/A // Finalizer not needed since it's safe to leave ctx unclosed. 0N/A// protected void finalize() { 0N/A // Clone ctx to create the child context. 0N/A "Problem generating object using object factory");