Java Code Examples for javax.naming.ldap.Rdn#size()
The following examples show how to use
javax.naming.ldap.Rdn#size() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServiceLocator.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Maps a distinguished name (RFC 2253) to a fully qualified domain name. * Processes a sequence of RDNs having a DC attribute. * The special RDN "DC=." denotes the root of the domain tree. * Multi-valued RDNs, non-DC attributes, binary-valued attributes and the * RDN "DC=." all reset the domain name and processing continues. * * @param dn A string distinguished name (RFC 2253). * @return A domain name or null if none can be derived. * @throw InvalidNameException If the distinugished name is invalid. */ static String mapDnToDomainName(String dn) throws InvalidNameException { if (dn == null) { return null; } StringBuffer domain = new StringBuffer(); LdapName ldapName = new LdapName(dn); // process RDNs left-to-right //List<Rdn> rdnList = ldapName.getRdns(); List<Rdn> rdnList = ldapName.getRdns(); for (int i = rdnList.size() - 1; i >= 0; i--) { //Rdn rdn = rdnList.get(i); Rdn rdn = rdnList.get(i); // single-valued RDN with a DC attribute if ((rdn.size() == 1) && ("dc".equalsIgnoreCase(rdn.getType()) )) { Object attrval = rdn.getValue(); if (attrval instanceof String) { if (attrval.equals(".") || (domain.length() == 1 && domain.charAt(0) == '.')) { domain.setLength(0); // reset (when current or previous // RDN value is "DC=.") } if (domain.length() > 0) { domain.append('.'); } domain.append(attrval); } else { domain.setLength(0); // reset (when binary-valued attribute) } } else { domain.setLength(0); // reset (when multi-valued RDN or non-DC) } } return (domain.length() != 0) ? domain.toString() : null; }
Example 2
Source File: ServiceLocator.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Maps a distinguished name (RFC 2253) to a fully qualified domain name. * Processes a sequence of RDNs having a DC attribute. * The special RDN "DC=." denotes the root of the domain tree. * Multi-valued RDNs, non-DC attributes, binary-valued attributes and the * RDN "DC=." all reset the domain name and processing continues. * * @param dn A string distinguished name (RFC 2253). * @return A domain name or null if none can be derived. * @throw InvalidNameException If the distinugished name is invalid. */ static String mapDnToDomainName(String dn) throws InvalidNameException { if (dn == null) { return null; } StringBuffer domain = new StringBuffer(); LdapName ldapName = new LdapName(dn); // process RDNs left-to-right //List<Rdn> rdnList = ldapName.getRdns(); List<Rdn> rdnList = ldapName.getRdns(); for (int i = rdnList.size() - 1; i >= 0; i--) { //Rdn rdn = rdnList.get(i); Rdn rdn = rdnList.get(i); // single-valued RDN with a DC attribute if ((rdn.size() == 1) && ("dc".equalsIgnoreCase(rdn.getType()) )) { Object attrval = rdn.getValue(); if (attrval instanceof String) { if (attrval.equals(".") || (domain.length() == 1 && domain.charAt(0) == '.')) { domain.setLength(0); // reset (when current or previous // RDN value is "DC=.") } if (domain.length() > 0) { domain.append('.'); } domain.append(attrval); } else { domain.setLength(0); // reset (when binary-valued attribute) } } else { domain.setLength(0); // reset (when multi-valued RDN or non-DC) } } return (domain.length() != 0) ? domain.toString() : null; }
Example 3
Source File: ServiceLocator.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Maps a distinguished name (RFC 2253) to a fully qualified domain name. * Processes a sequence of RDNs having a DC attribute. * The special RDN "DC=." denotes the root of the domain tree. * Multi-valued RDNs, non-DC attributes, binary-valued attributes and the * RDN "DC=." all reset the domain name and processing continues. * * @param dn A string distinguished name (RFC 2253). * @return A domain name or null if none can be derived. * @throw InvalidNameException If the distinugished name is invalid. */ static String mapDnToDomainName(String dn) throws InvalidNameException { if (dn == null) { return null; } StringBuffer domain = new StringBuffer(); LdapName ldapName = new LdapName(dn); // process RDNs left-to-right //List<Rdn> rdnList = ldapName.getRdns(); List<Rdn> rdnList = ldapName.getRdns(); for (int i = rdnList.size() - 1; i >= 0; i--) { //Rdn rdn = rdnList.get(i); Rdn rdn = rdnList.get(i); // single-valued RDN with a DC attribute if ((rdn.size() == 1) && ("dc".equalsIgnoreCase(rdn.getType()) )) { Object attrval = rdn.getValue(); if (attrval instanceof String) { if (attrval.equals(".") || (domain.length() == 1 && domain.charAt(0) == '.')) { domain.setLength(0); // reset (when current or previous // RDN value is "DC=.") } if (domain.length() > 0) { domain.append('.'); } domain.append(attrval); } else { domain.setLength(0); // reset (when binary-valued attribute) } } else { domain.setLength(0); // reset (when multi-valued RDN or non-DC) } } return (domain.length() != 0) ? domain.toString() : null; }
Example 4
Source File: ServiceLocator.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Maps a distinguished name (RFC 2253) to a fully qualified domain name. * Processes a sequence of RDNs having a DC attribute. * The special RDN "DC=." denotes the root of the domain tree. * Multi-valued RDNs, non-DC attributes, binary-valued attributes and the * RDN "DC=." all reset the domain name and processing continues. * * @param dn A string distinguished name (RFC 2253). * @return A domain name or null if none can be derived. * @throw InvalidNameException If the distinugished name is invalid. */ static String mapDnToDomainName(String dn) throws InvalidNameException { if (dn == null) { return null; } StringBuffer domain = new StringBuffer(); LdapName ldapName = new LdapName(dn); // process RDNs left-to-right //List<Rdn> rdnList = ldapName.getRdns(); List<Rdn> rdnList = ldapName.getRdns(); for (int i = rdnList.size() - 1; i >= 0; i--) { //Rdn rdn = rdnList.get(i); Rdn rdn = rdnList.get(i); // single-valued RDN with a DC attribute if ((rdn.size() == 1) && ("dc".equalsIgnoreCase(rdn.getType()) )) { Object attrval = rdn.getValue(); if (attrval instanceof String) { if (attrval.equals(".") || (domain.length() == 1 && domain.charAt(0) == '.')) { domain.setLength(0); // reset (when current or previous // RDN value is "DC=.") } if (domain.length() > 0) { domain.append('.'); } domain.append(attrval); } else { domain.setLength(0); // reset (when binary-valued attribute) } } else { domain.setLength(0); // reset (when multi-valued RDN or non-DC) } } return (domain.length() != 0) ? domain.toString() : null; }
Example 5
Source File: ServiceLocator.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Maps a distinguished name (RFC 2253) to a fully qualified domain name. * Processes a sequence of RDNs having a DC attribute. * The special RDN "DC=." denotes the root of the domain tree. * Multi-valued RDNs, non-DC attributes, binary-valued attributes and the * RDN "DC=." all reset the domain name and processing continues. * * @param dn A string distinguished name (RFC 2253). * @return A domain name or null if none can be derived. * @throw InvalidNameException If the distinugished name is invalid. */ static String mapDnToDomainName(String dn) throws InvalidNameException { if (dn == null) { return null; } StringBuffer domain = new StringBuffer(); LdapName ldapName = new LdapName(dn); // process RDNs left-to-right //List<Rdn> rdnList = ldapName.getRdns(); List<Rdn> rdnList = ldapName.getRdns(); for (int i = rdnList.size() - 1; i >= 0; i--) { //Rdn rdn = rdnList.get(i); Rdn rdn = rdnList.get(i); // single-valued RDN with a DC attribute if ((rdn.size() == 1) && ("dc".equalsIgnoreCase(rdn.getType()) )) { Object attrval = rdn.getValue(); if (attrval instanceof String) { if (attrval.equals(".") || (domain.length() == 1 && domain.charAt(0) == '.')) { domain.setLength(0); // reset (when current or previous // RDN value is "DC=.") } if (domain.length() > 0) { domain.append('.'); } domain.append(attrval); } else { domain.setLength(0); // reset (when binary-valued attribute) } } else { domain.setLength(0); // reset (when multi-valued RDN or non-DC) } } return (domain.length() != 0) ? domain.toString() : null; }
Example 6
Source File: ServiceLocator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Maps a distinguished name (RFC 2253) to a fully qualified domain name. * Processes a sequence of RDNs having a DC attribute. * The special RDN "DC=." denotes the root of the domain tree. * Multi-valued RDNs, non-DC attributes, binary-valued attributes and the * RDN "DC=." all reset the domain name and processing continues. * * @param dn A string distinguished name (RFC 2253). * @return A domain name or null if none can be derived. * @throws InvalidNameException If the distinguished name is invalid. */ static String mapDnToDomainName(String dn) throws InvalidNameException { if (dn == null) { return null; } StringBuilder domain = new StringBuilder(); LdapName ldapName = new LdapName(dn); // process RDNs left-to-right //List<Rdn> rdnList = ldapName.getRdns(); List<Rdn> rdnList = ldapName.getRdns(); for (int i = rdnList.size() - 1; i >= 0; i--) { //Rdn rdn = rdnList.get(i); Rdn rdn = rdnList.get(i); // single-valued RDN with a DC attribute if ((rdn.size() == 1) && ("dc".equalsIgnoreCase(rdn.getType()) )) { Object attrval = rdn.getValue(); if (attrval instanceof String) { if (attrval.equals(".") || (domain.length() == 1 && domain.charAt(0) == '.')) { domain.setLength(0); // reset (when current or previous // RDN value is "DC=.") } if (domain.length() > 0) { domain.append('.'); } domain.append(attrval); } else { domain.setLength(0); // reset (when binary-valued attribute) } } else { domain.setLength(0); // reset (when multi-valued RDN or non-DC) } } return (domain.length() != 0) ? domain.toString() : null; }
Example 7
Source File: ServiceLocator.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Maps a distinguished name (RFC 2253) to a fully qualified domain name. * Processes a sequence of RDNs having a DC attribute. * The special RDN "DC=." denotes the root of the domain tree. * Multi-valued RDNs, non-DC attributes, binary-valued attributes and the * RDN "DC=." all reset the domain name and processing continues. * * @param dn A string distinguished name (RFC 2253). * @return A domain name or null if none can be derived. * @throw InvalidNameException If the distinugished name is invalid. */ static String mapDnToDomainName(String dn) throws InvalidNameException { if (dn == null) { return null; } StringBuffer domain = new StringBuffer(); LdapName ldapName = new LdapName(dn); // process RDNs left-to-right //List<Rdn> rdnList = ldapName.getRdns(); List<Rdn> rdnList = ldapName.getRdns(); for (int i = rdnList.size() - 1; i >= 0; i--) { //Rdn rdn = rdnList.get(i); Rdn rdn = rdnList.get(i); // single-valued RDN with a DC attribute if ((rdn.size() == 1) && ("dc".equalsIgnoreCase(rdn.getType()) )) { Object attrval = rdn.getValue(); if (attrval instanceof String) { if (attrval.equals(".") || (domain.length() == 1 && domain.charAt(0) == '.')) { domain.setLength(0); // reset (when current or previous // RDN value is "DC=.") } if (domain.length() > 0) { domain.append('.'); } domain.append(attrval); } else { domain.setLength(0); // reset (when binary-valued attribute) } } else { domain.setLength(0); // reset (when multi-valued RDN or non-DC) } } return (domain.length() != 0) ? domain.toString() : null; }
Example 8
Source File: ServiceLocator.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Maps a distinguished name (RFC 2253) to a fully qualified domain name. * Processes a sequence of RDNs having a DC attribute. * The special RDN "DC=." denotes the root of the domain tree. * Multi-valued RDNs, non-DC attributes, binary-valued attributes and the * RDN "DC=." all reset the domain name and processing continues. * * @param dn A string distinguished name (RFC 2253). * @return A domain name or null if none can be derived. * @throw InvalidNameException If the distinugished name is invalid. */ static String mapDnToDomainName(String dn) throws InvalidNameException { if (dn == null) { return null; } StringBuffer domain = new StringBuffer(); LdapName ldapName = new LdapName(dn); // process RDNs left-to-right //List<Rdn> rdnList = ldapName.getRdns(); List<Rdn> rdnList = ldapName.getRdns(); for (int i = rdnList.size() - 1; i >= 0; i--) { //Rdn rdn = rdnList.get(i); Rdn rdn = rdnList.get(i); // single-valued RDN with a DC attribute if ((rdn.size() == 1) && ("dc".equalsIgnoreCase(rdn.getType()) )) { Object attrval = rdn.getValue(); if (attrval instanceof String) { if (attrval.equals(".") || (domain.length() == 1 && domain.charAt(0) == '.')) { domain.setLength(0); // reset (when current or previous // RDN value is "DC=.") } if (domain.length() > 0) { domain.append('.'); } domain.append(attrval); } else { domain.setLength(0); // reset (when binary-valued attribute) } } else { domain.setLength(0); // reset (when multi-valued RDN or non-DC) } } return (domain.length() != 0) ? domain.toString() : null; }
Example 9
Source File: ServiceLocator.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Maps a distinguished name (RFC 2253) to a fully qualified domain name. * Processes a sequence of RDNs having a DC attribute. * The special RDN "DC=." denotes the root of the domain tree. * Multi-valued RDNs, non-DC attributes, binary-valued attributes and the * RDN "DC=." all reset the domain name and processing continues. * * @param dn A string distinguished name (RFC 2253). * @return A domain name or null if none can be derived. * @throw InvalidNameException If the distinugished name is invalid. */ static String mapDnToDomainName(String dn) throws InvalidNameException { if (dn == null) { return null; } StringBuffer domain = new StringBuffer(); LdapName ldapName = new LdapName(dn); // process RDNs left-to-right //List<Rdn> rdnList = ldapName.getRdns(); List<Rdn> rdnList = ldapName.getRdns(); for (int i = rdnList.size() - 1; i >= 0; i--) { //Rdn rdn = rdnList.get(i); Rdn rdn = rdnList.get(i); // single-valued RDN with a DC attribute if ((rdn.size() == 1) && ("dc".equalsIgnoreCase(rdn.getType()) )) { Object attrval = rdn.getValue(); if (attrval instanceof String) { if (attrval.equals(".") || (domain.length() == 1 && domain.charAt(0) == '.')) { domain.setLength(0); // reset (when current or previous // RDN value is "DC=.") } if (domain.length() > 0) { domain.append('.'); } domain.append(attrval); } else { domain.setLength(0); // reset (when binary-valued attribute) } } else { domain.setLength(0); // reset (when multi-valued RDN or non-DC) } } return (domain.length() != 0) ? domain.toString() : null; }
Example 10
Source File: ServiceLocator.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Maps a distinguished name (RFC 2253) to a fully qualified domain name. * Processes a sequence of RDNs having a DC attribute. * The special RDN "DC=." denotes the root of the domain tree. * Multi-valued RDNs, non-DC attributes, binary-valued attributes and the * RDN "DC=." all reset the domain name and processing continues. * * @param dn A string distinguished name (RFC 2253). * @return A domain name or null if none can be derived. * @throw InvalidNameException If the distinugished name is invalid. */ static String mapDnToDomainName(String dn) throws InvalidNameException { if (dn == null) { return null; } StringBuffer domain = new StringBuffer(); LdapName ldapName = new LdapName(dn); // process RDNs left-to-right //List<Rdn> rdnList = ldapName.getRdns(); List<Rdn> rdnList = ldapName.getRdns(); for (int i = rdnList.size() - 1; i >= 0; i--) { //Rdn rdn = rdnList.get(i); Rdn rdn = rdnList.get(i); // single-valued RDN with a DC attribute if ((rdn.size() == 1) && ("dc".equalsIgnoreCase(rdn.getType()) )) { Object attrval = rdn.getValue(); if (attrval instanceof String) { if (attrval.equals(".") || (domain.length() == 1 && domain.charAt(0) == '.')) { domain.setLength(0); // reset (when current or previous // RDN value is "DC=.") } if (domain.length() > 0) { domain.append('.'); } domain.append(attrval); } else { domain.setLength(0); // reset (when binary-valued attribute) } } else { domain.setLength(0); // reset (when multi-valued RDN or non-DC) } } return (domain.length() != 0) ? domain.toString() : null; }
Example 11
Source File: ServiceLocator.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Maps a distinguished name (RFC 2253) to a fully qualified domain name. * Processes a sequence of RDNs having a DC attribute. * The special RDN "DC=." denotes the root of the domain tree. * Multi-valued RDNs, non-DC attributes, binary-valued attributes and the * RDN "DC=." all reset the domain name and processing continues. * * @param dn A string distinguished name (RFC 2253). * @return A domain name or null if none can be derived. * @throw InvalidNameException If the distinugished name is invalid. */ static String mapDnToDomainName(String dn) throws InvalidNameException { if (dn == null) { return null; } StringBuffer domain = new StringBuffer(); LdapName ldapName = new LdapName(dn); // process RDNs left-to-right //List<Rdn> rdnList = ldapName.getRdns(); List<Rdn> rdnList = ldapName.getRdns(); for (int i = rdnList.size() - 1; i >= 0; i--) { //Rdn rdn = rdnList.get(i); Rdn rdn = rdnList.get(i); // single-valued RDN with a DC attribute if ((rdn.size() == 1) && ("dc".equalsIgnoreCase(rdn.getType()) )) { Object attrval = rdn.getValue(); if (attrval instanceof String) { if (attrval.equals(".") || (domain.length() == 1 && domain.charAt(0) == '.')) { domain.setLength(0); // reset (when current or previous // RDN value is "DC=.") } if (domain.length() > 0) { domain.append('.'); } domain.append(attrval); } else { domain.setLength(0); // reset (when binary-valued attribute) } } else { domain.setLength(0); // reset (when multi-valued RDN or non-DC) } } return (domain.length() != 0) ? domain.toString() : null; }
Example 12
Source File: ServiceLocator.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Maps a distinguished name (RFC 2253) to a fully qualified domain name. * Processes a sequence of RDNs having a DC attribute. * The special RDN "DC=." denotes the root of the domain tree. * Multi-valued RDNs, non-DC attributes, binary-valued attributes and the * RDN "DC=." all reset the domain name and processing continues. * * @param dn A string distinguished name (RFC 2253). * @return A domain name or null if none can be derived. * @throw InvalidNameException If the distinugished name is invalid. */ static String mapDnToDomainName(String dn) throws InvalidNameException { if (dn == null) { return null; } StringBuffer domain = new StringBuffer(); LdapName ldapName = new LdapName(dn); // process RDNs left-to-right //List<Rdn> rdnList = ldapName.getRdns(); List<Rdn> rdnList = ldapName.getRdns(); for (int i = rdnList.size() - 1; i >= 0; i--) { //Rdn rdn = rdnList.get(i); Rdn rdn = rdnList.get(i); // single-valued RDN with a DC attribute if ((rdn.size() == 1) && ("dc".equalsIgnoreCase(rdn.getType()) )) { Object attrval = rdn.getValue(); if (attrval instanceof String) { if (attrval.equals(".") || (domain.length() == 1 && domain.charAt(0) == '.')) { domain.setLength(0); // reset (when current or previous // RDN value is "DC=.") } if (domain.length() > 0) { domain.append('.'); } domain.append(attrval); } else { domain.setLength(0); // reset (when binary-valued attribute) } } else { domain.setLength(0); // reset (when multi-valued RDN or non-DC) } } return (domain.length() != 0) ? domain.toString() : null; }
Example 13
Source File: ServiceLocator.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * Maps a distinguished name (RFC 2253) to a fully qualified domain name. * Processes a sequence of RDNs having a DC attribute. * The special RDN "DC=." denotes the root of the domain tree. * Multi-valued RDNs, non-DC attributes, binary-valued attributes and the * RDN "DC=." all reset the domain name and processing continues. * * @param dn A string distinguished name (RFC 2253). * @return A domain name or null if none can be derived. * @throw InvalidNameException If the distinugished name is invalid. */ static String mapDnToDomainName(String dn) throws InvalidNameException { if (dn == null) { return null; } StringBuffer domain = new StringBuffer(); LdapName ldapName = new LdapName(dn); // process RDNs left-to-right //List<Rdn> rdnList = ldapName.getRdns(); List<Rdn> rdnList = ldapName.getRdns(); for (int i = rdnList.size() - 1; i >= 0; i--) { //Rdn rdn = rdnList.get(i); Rdn rdn = rdnList.get(i); // single-valued RDN with a DC attribute if ((rdn.size() == 1) && ("dc".equalsIgnoreCase(rdn.getType()) )) { Object attrval = rdn.getValue(); if (attrval instanceof String) { if (attrval.equals(".") || (domain.length() == 1 && domain.charAt(0) == '.')) { domain.setLength(0); // reset (when current or previous // RDN value is "DC=.") } if (domain.length() > 0) { domain.append('.'); } domain.append(attrval); } else { domain.setLength(0); // reset (when binary-valued attribute) } } else { domain.setLength(0); // reset (when multi-valued RDN or non-DC) } } return (domain.length() != 0) ? domain.toString() : null; }
Example 14
Source File: LdapUtils.java From spring-ldap with Apache License 2.0 | 5 votes |
/** * Get the value of the Rdn at the requested index in the supplied Name. * * @param name the Name to work on. * @param index The 0-based index of the rdn value to retrieve. Must be in the range [0,size()). * @return the value of the rdn at the requested index. * @throws IndexOutOfBoundsException if index is outside the specified range. * @since 2.0 */ public static Object getValue(Name name, int index) { Assert.notNull(name, "name must not be null"); LdapName ldapName = returnOrConstructLdapNameFromName(name); Rdn rdn = ldapName.getRdn(index); if(rdn.size() > 1) { LOGGER.warn("Rdn at position " + index + " of dn '" + name + "' is multi-value - returned value is not to be trusted. " + "Consider using name-based getValue method instead"); } return rdn.getValue(); }