src/share/classes/com/sun/jndi/ldap/ServiceLocator.java

Print this page
rev 10430 : imported patch typos


  45 class ServiceLocator {
  46 
  47     private static final String SRV_RR = "SRV";
  48 
  49     private static final String[] SRV_RR_ATTR = new String[]{SRV_RR};
  50 
  51     private static final Random random = new Random();
  52 
  53     private ServiceLocator() {
  54     }
  55 
  56     /**
  57      * Maps a distinguished name (RFC 2253) to a fully qualified domain name.
  58      * Processes a sequence of RDNs having a DC attribute.
  59      * The special RDN "DC=." denotes the root of the domain tree.
  60      * Multi-valued RDNs, non-DC attributes, binary-valued attributes and the
  61      * RDN "DC=." all reset the domain name and processing continues.
  62      *
  63      * @param dn A string distinguished name (RFC 2253).
  64      * @return A domain name or null if none can be derived.
  65      * @throw InvalidNameException If the distinugished name is invalid.
  66      */
  67     static String mapDnToDomainName(String dn) throws InvalidNameException {
  68         if (dn == null) {
  69             return null;
  70         }
  71         StringBuilder domain = new StringBuilder();
  72         LdapName ldapName = new LdapName(dn);
  73 
  74         // process RDNs left-to-right
  75         //List<Rdn> rdnList = ldapName.getRdns();
  76 
  77         List<Rdn> rdnList = ldapName.getRdns();
  78         for (int i = rdnList.size() - 1; i >= 0; i--) {
  79             //Rdn rdn = rdnList.get(i);
  80             Rdn rdn = rdnList.get(i);
  81 
  82             // single-valued RDN with a DC attribute
  83             if ((rdn.size() == 1) &&
  84                 ("dc".equalsIgnoreCase(rdn.getType()) )) {
  85                 Object attrval = rdn.getValue();




  45 class ServiceLocator {
  46 
  47     private static final String SRV_RR = "SRV";
  48 
  49     private static final String[] SRV_RR_ATTR = new String[]{SRV_RR};
  50 
  51     private static final Random random = new Random();
  52 
  53     private ServiceLocator() {
  54     }
  55 
  56     /**
  57      * Maps a distinguished name (RFC 2253) to a fully qualified domain name.
  58      * Processes a sequence of RDNs having a DC attribute.
  59      * The special RDN "DC=." denotes the root of the domain tree.
  60      * Multi-valued RDNs, non-DC attributes, binary-valued attributes and the
  61      * RDN "DC=." all reset the domain name and processing continues.
  62      *
  63      * @param dn A string distinguished name (RFC 2253).
  64      * @return A domain name or null if none can be derived.
  65      * @throw InvalidNameException If the distinguished name is invalid.
  66      */
  67     static String mapDnToDomainName(String dn) throws InvalidNameException {
  68         if (dn == null) {
  69             return null;
  70         }
  71         StringBuilder domain = new StringBuilder();
  72         LdapName ldapName = new LdapName(dn);
  73 
  74         // process RDNs left-to-right
  75         //List<Rdn> rdnList = ldapName.getRdns();
  76 
  77         List<Rdn> rdnList = ldapName.getRdns();
  78         for (int i = rdnList.size() - 1; i >= 0; i--) {
  79             //Rdn rdn = rdnList.get(i);
  80             Rdn rdn = rdnList.get(i);
  81 
  82             // single-valued RDN with a DC attribute
  83             if ((rdn.size() == 1) &&
  84                 ("dc".equalsIgnoreCase(rdn.getType()) )) {
  85                 Object attrval = rdn.getValue();