-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
1.4.2, 5.0
-
generic
-
solaris_9
2004/11/30 11:00 ###@###.### --
There is discrepency between calls to get() and toString(). Given the following test program (also attached to this bug):
------------------------------------------------------------
//import com.sun.jndi.ldap.*; // for v1.4.2 and v1.5.0
import java.util.*;
import javax.naming.*;
import javax.naming.ldap.*; // for v1.5.0 only
public class NameTest {
public static void main(String[] argumentList) throws NamingException {
Name cName1 = null;
Name cName2 = null;
Name cName3 = null;
Name cName4 = null;
Name lName1 = null;
Properties properties = new Properties();
String dn = "cn=A\\\\B, cn=testRoot";
properties.setProperty("jndi.syntax.direction", "left_to_right");
properties.setProperty("jndi.syntax.separator", "/");
properties.setProperty("jndi.syntax.ignorecase", "true");
properties.setProperty("jndi.syntax.escape", "\\");
cName1 = new CompositeName().add(dn);
cName2 = new CompositeName(dn);
cName3 = new CompoundName("", properties).add(dn);
cName4 = new CompoundName(dn, properties);
lName1 = new LdapName(dn);
for (int i = 0; i < cName1.size(); i++) {
System.out.println("cName1: " + cName1.get(i));
}
System.out.println("cName1: " + cName1.toString());
for (int i = 0; i < cName2.size(); i++) {
System.out.println("cName2: " + cName2.get(i));
}
System.out.println("cName2: " + cName2.toString());
for (int i = 0; i < cName3.size(); i++) {
System.out.println("cName3: " + cName3.get(i));
}
System.out.println("cName3: " + cName3.toString());
for (int i = 0; i < cName4.size(); i++) {
System.out.println("cName4: " + cName4.get(i));
}
System.out.println("cName4: " + cName4.toString());
for (int i = 0; i < lName1.size(); i++) {
System.out.println("lName1: " + lName1.get(i));
}
System.out.println("lName1: " + lName1.toString());
}
}
------------------------------------------------------------
the results on JDK v1.4.2 and v1.5.0 are:
1. Using com.sun.jndi.ldap.LdapName (JDK v1.4.2 and JDK v1.5.0)
JDK v1.4.2_04 -
cName1: cn=A\\B, cn=testRoot
cName1: cn=A\\\B, cn=testRoot *
cName2: cn=A\B, cn=testRoot *
cName2: cn=A\B, cn=testRoot *
cName3: cn=A\\B, cn=testRoot
cName3: cn=A\\\B, cn=testRoot *
cName4: cn=A\B, cn=testRoot *
cName4: cn=A\B, cn=testRoot *
lName1: cn=testRoot
lName1: cn=A\\B
lName1: cn=A\\B, cn=testRoot
JDK v1.5.0_00 -
cName1: cn=A\\B, cn=testRoot
cName1: cn=A\\\B, cn=testRoot *
cName2: cn=A\B, cn=testRoot *
cName2: cn=A\B, cn=testRoot *
cName3: cn=A\\B, cn=testRoot
cName3: cn=A\\\B, cn=testRoot *
cName4: cn=A\B, cn=testRoot *
cName4: cn=A\B, cn=testRoot *
lName1: cn=testRoot
lName1: cn=A\\B
lName1: cn=A\\B, cn=testRoot
2. Using javax.naming.ldap.LdapName (JDK v1.5.0 only)
JDK v1.5.0_00 -
cName1: cn=A\\B, cn=testRoot
cName1: cn=A\\\B, cn=testRoot *
cName2: cn=A\B, cn=testRoot *
cName2: cn=A\B, cn=testRoot *
cName3: cn=A\\B, cn=testRoot
cName3: cn=A\\\B, cn=testRoot *
cName4: cn=A\B, cn=testRoot *
cName4: cn=A\B, cn=testRoot *
lName1: cn=testRoot
lName1: cn=A\\B
lName1: cn=A\\B, cn=testRoot
The only time it can produce the correct output is when we are using "cn=A\\B, cn=testRoot" as DN.
There is discrepency between calls to get() and toString(). Given the following test program (also attached to this bug):
------------------------------------------------------------
//import com.sun.jndi.ldap.*; // for v1.4.2 and v1.5.0
import java.util.*;
import javax.naming.*;
import javax.naming.ldap.*; // for v1.5.0 only
public class NameTest {
public static void main(String[] argumentList) throws NamingException {
Name cName1 = null;
Name cName2 = null;
Name cName3 = null;
Name cName4 = null;
Name lName1 = null;
Properties properties = new Properties();
String dn = "cn=A\\\\B, cn=testRoot";
properties.setProperty("jndi.syntax.direction", "left_to_right");
properties.setProperty("jndi.syntax.separator", "/");
properties.setProperty("jndi.syntax.ignorecase", "true");
properties.setProperty("jndi.syntax.escape", "\\");
cName1 = new CompositeName().add(dn);
cName2 = new CompositeName(dn);
cName3 = new CompoundName("", properties).add(dn);
cName4 = new CompoundName(dn, properties);
lName1 = new LdapName(dn);
for (int i = 0; i < cName1.size(); i++) {
System.out.println("cName1: " + cName1.get(i));
}
System.out.println("cName1: " + cName1.toString());
for (int i = 0; i < cName2.size(); i++) {
System.out.println("cName2: " + cName2.get(i));
}
System.out.println("cName2: " + cName2.toString());
for (int i = 0; i < cName3.size(); i++) {
System.out.println("cName3: " + cName3.get(i));
}
System.out.println("cName3: " + cName3.toString());
for (int i = 0; i < cName4.size(); i++) {
System.out.println("cName4: " + cName4.get(i));
}
System.out.println("cName4: " + cName4.toString());
for (int i = 0; i < lName1.size(); i++) {
System.out.println("lName1: " + lName1.get(i));
}
System.out.println("lName1: " + lName1.toString());
}
}
------------------------------------------------------------
the results on JDK v1.4.2 and v1.5.0 are:
1. Using com.sun.jndi.ldap.LdapName (JDK v1.4.2 and JDK v1.5.0)
JDK v1.4.2_04 -
cName1: cn=A\\B, cn=testRoot
cName1: cn=A\\\B, cn=testRoot *
cName2: cn=A\B, cn=testRoot *
cName2: cn=A\B, cn=testRoot *
cName3: cn=A\\B, cn=testRoot
cName3: cn=A\\\B, cn=testRoot *
cName4: cn=A\B, cn=testRoot *
cName4: cn=A\B, cn=testRoot *
lName1: cn=testRoot
lName1: cn=A\\B
lName1: cn=A\\B, cn=testRoot
JDK v1.5.0_00 -
cName1: cn=A\\B, cn=testRoot
cName1: cn=A\\\B, cn=testRoot *
cName2: cn=A\B, cn=testRoot *
cName2: cn=A\B, cn=testRoot *
cName3: cn=A\\B, cn=testRoot
cName3: cn=A\\\B, cn=testRoot *
cName4: cn=A\B, cn=testRoot *
cName4: cn=A\B, cn=testRoot *
lName1: cn=testRoot
lName1: cn=A\\B
lName1: cn=A\\B, cn=testRoot
2. Using javax.naming.ldap.LdapName (JDK v1.5.0 only)
JDK v1.5.0_00 -
cName1: cn=A\\B, cn=testRoot
cName1: cn=A\\\B, cn=testRoot *
cName2: cn=A\B, cn=testRoot *
cName2: cn=A\B, cn=testRoot *
cName3: cn=A\\B, cn=testRoot
cName3: cn=A\\\B, cn=testRoot *
cName4: cn=A\B, cn=testRoot *
cName4: cn=A\B, cn=testRoot *
lName1: cn=testRoot
lName1: cn=A\\B
lName1: cn=A\\B, cn=testRoot
The only time it can produce the correct output is when we are using "cn=A\\B, cn=testRoot" as DN.
- relates to
-
JDK-6201615 LDAP Service Provider does not parse LDAP names with escape characters ('\') properly.
- Closed
-
JDK-4894089 DN containing four backslashes in Java is retrieved with three backslashes
- Closed