2362N/A * Copyright (c) 2002, 2003, 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 * This class discovers the location of LDAP services by querying DNS. 0N/A * Maps a distinguished name (RFC 2253) to a fully qualified domain name. 0N/A * Processes a sequence of RDNs having a DC attribute. 0N/A * The special RDN "DC=." denotes the root of the domain tree. 0N/A * Multi-valued RDNs, non-DC attributes, binary-valued attributes and the 0N/A * RDN "DC=." all reset the domain name and processing continues. 0N/A * @param dn A string distinguished name (RFC 2253). 0N/A * @return A domain name or null if none can be derived. 0N/A * @throw InvalidNameException If the distinugished name is invalid. 0N/A // process RDNs left-to-right 0N/A //List<Rdn> rdnList = ldapName.getRdns(); 0N/A //Rdn rdn = rdnList.get(i); 0N/A // single-valued RDN with a DC attribute 0N/A // RDN value is "DC=.") 0N/A * Locates the LDAP service for a given domain. 0N/A * Queries DNS for a list of LDAP Service Location Records (SRV) for a 0N/A * given domain name. 0N/A * @param domainName A string domain name. 0N/A * @param environment The possibly null environment of the context. 0N/A * @return An ordered list of hostports for the LDAP service or null if 0N/A * the service has not been located. 0N/A // Create the DNS context using NamingManager rather than using 0N/A // the initial context constructor. This avoids having the initial 0N/A // context constructor call itself (when processing the URL 0N/A // argument in the getAttributes call). 0N/A return null;
// cannot create a DNS context 0N/A // create the service records 0N/A // Sort the service records in ascending order of their 0N/A // priority value. For records with equal priority, move 0N/A // those with weight 0 to the top of the list. 0N/A // extract the host and port number from each service record 0N/A * Extract hosts and port numbers from a list of SRV records. 0N/A * An array of hostports is returned or null if none were found. 0N/A // find the head and tail of the list of records having the same 0N/A // select hostports from the sublist 0N/A * Randomly select a service record in the range [head, tail] and return 0N/A * its hostport value. Follows the algorithm in RFC 2782. 0N/A // compute the running sum for records between head and tail 0N/A // If all records have zero weight, select first available one; 0N/A // otherwise, randomly select a record according to its weight 0N/A * This class holds a DNS service (SRV) record. 0N/A * Creates a service record object from a string record. 0N/A * DNS supplies the string record in the following format: 0N/A * <Priority> " " <Weight> " " <Port> " " <Host> 0N/A * Sort records in ascending order of priority value. For records with 0N/A * equal priority move those with weight 0 to the top of the list. 0N/A return 1;
// this > that 0N/A return -
1;
// this < that 0N/A return -
1;
// this < that 0N/A return 1;
// this > that 0N/A return 0;
// this == that