23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 |
25 |
26 package com.sun.jndi.ldap; |
26 package com.sun.jndi.ldap; |
27 |
27 |
|
28 import java.util.Locale; |
28 import java.util.Arrays; // JDK 1.2 |
29 import java.util.Arrays; // JDK 1.2 |
29 import java.io.OutputStream; |
30 import java.io.OutputStream; |
30 import javax.naming.ldap.Control; |
31 import javax.naming.ldap.Control; |
31 import java.lang.reflect.Method; |
32 import java.lang.reflect.Method; |
32 import javax.net.SocketFactory; |
33 import javax.net.SocketFactory; |
69 final public static boolean debug = false; |
70 final public static boolean debug = false; |
70 |
71 |
71 ClientId(int version, String hostname, int port, String protocol, |
72 ClientId(int version, String hostname, int port, String protocol, |
72 Control[] bindCtls, OutputStream trace, String socketFactory) { |
73 Control[] bindCtls, OutputStream trace, String socketFactory) { |
73 this.version = version; |
74 this.version = version; |
74 this.hostname = hostname.toLowerCase(); // ignore case |
75 this.hostname = hostname.toLowerCase(Locale.ENGLISH); // ignore case |
75 this.port = port; |
76 this.port = port; |
76 this.protocol = protocol; |
77 this.protocol = protocol; |
77 this.bindCtls = (bindCtls != null ? bindCtls.clone() : null); |
78 this.bindCtls = (bindCtls != null ? bindCtls.clone() : null); |
78 this.trace = trace; |
79 this.trace = trace; |
79 // |
80 // |
81 // |
82 // |
82 this.socketFactory = socketFactory; |
83 this.socketFactory = socketFactory; |
83 if ((socketFactory != null) && |
84 if ((socketFactory != null) && |
84 !socketFactory.equals(LdapCtx.DEFAULT_SSL_FACTORY)) { |
85 !socketFactory.equals(LdapCtx.DEFAULT_SSL_FACTORY)) { |
85 try { |
86 try { |
86 Class<?> socketFactoryClass = Obj.helper.loadClass(socketFactory); |
87 Class<?> socketFactoryClass = |
|
88 Obj.helper.loadClass(socketFactory); |
87 Class<?> objClass = Class.forName("java.lang.Object"); |
89 Class<?> objClass = Class.forName("java.lang.Object"); |
88 this.sockComparator = socketFactoryClass.getMethod( |
90 this.sockComparator = socketFactoryClass.getMethod( |
89 "compare", new Class<?>[]{objClass, objClass}); |
91 "compare", new Class<?>[]{objClass, objClass}); |
90 Method getDefault = |
92 Method getDefault = socketFactoryClass.getMethod( |
91 socketFactoryClass.getMethod("getDefault", new Class<?>[]{}); |
93 "getDefault", new Class<?>[]{}); |
92 this.factory = (SocketFactory) getDefault.invoke(null, new Object[]{}); |
94 this.factory = |
|
95 (SocketFactory)getDefault.invoke(null, new Object[]{}); |
93 } catch (Exception e) { |
96 } catch (Exception e) { |
94 // Ignore it here, the same exceptions are/will be handled by |
97 // Ignore it here, the same exceptions are/will be handled by |
95 // LdapPoolManager and Connection classes. |
98 // LdapPoolManager and Connection classes. |
96 if (debug) { |
99 if (debug) { |
97 System.out.println("ClientId received an exception"); |
100 System.out.println("ClientId received an exception"); |