1 7 8 package javax.naming.ldap; 9 10 import javax.naming.*; 11 import javax.naming.directory.*; 12 13 import java.util.Hashtable ; 14 15 72 73 public class InitialLdapContext extends InitialDirContext implements LdapContext { 74 private static final String 75 BIND_CONTROLS_PROPERTY = "java.naming.ldap.control.connect"; 76 77 84 public InitialLdapContext() throws NamingException { 85 super(null); 86 } 87 88 113 public InitialLdapContext(Hashtable <?,?> environment, 114 Control [] connCtls) 115 throws NamingException { 116 super(true); 118 Hashtable env = (environment == null) 120 ? new Hashtable (11) 121 : (Hashtable )environment.clone(); 122 123 if (connCtls != null) { 126 Control [] copy = new Control [connCtls.length]; 127 System.arraycopy(connCtls, 0, copy, 0, connCtls.length); 128 env.put(BIND_CONTROLS_PROPERTY, copy); 129 } 130 env.put("java.naming.ldap.version", "3"); 132 133 init(env); 135 } 136 137 145 private LdapContext getDefaultLdapInitCtx() throws NamingException{ 146 Context answer = getDefaultInitCtx(); 147 148 if (!(answer instanceof LdapContext )) { 149 if (answer == null) { 150 throw new NoInitialContextException(); 151 } else { 152 throw new NotContextException( 153 "Not an instance of LdapContext"); 154 } 155 } 156 return (LdapContext )answer; 157 } 158 159 162 public ExtendedResponse extendedOperation(ExtendedRequest request) 163 throws NamingException { 164 return getDefaultLdapInitCtx().extendedOperation(request); 165 } 166 167 public LdapContext newInstance(Control [] reqCtls) 168 throws NamingException { 169 return getDefaultLdapInitCtx().newInstance(reqCtls); 170 } 171 172 public void reconnect(Control [] connCtls) throws NamingException { 173 getDefaultLdapInitCtx().reconnect(connCtls); 174 } 175 176 public Control [] getConnectControls() throws NamingException { 177 return getDefaultLdapInitCtx().getConnectControls(); 178 } 179 180 public void setRequestControls(Control [] requestControls) 181 throws NamingException { 182 getDefaultLdapInitCtx().setRequestControls(requestControls); 183 } 184 185 public Control [] getRequestControls() throws NamingException { 186 return getDefaultLdapInitCtx().getRequestControls(); 187 } 188 189 public Control [] getResponseControls() throws NamingException { 190 return getDefaultLdapInitCtx().getResponseControls(); 191 } 192 } 193 | Popular Tags |