src/share/classes/javax/naming/ldap/InitialLdapContext.java

Print this page




 112      * save references to them, but may save a clone or copy.
 113      * Caller should not modify mutable keys and values in
 114      * <tt>environment</tt> after it has been passed to the constructor.
 115      *
 116      * <p> <tt>connCtls</tt> is used as the underlying context instance's
 117      * connection request controls.  See the class description
 118      * for details.
 119      *
 120      * @param environment
 121      *          environment used to create the initial DirContext.
 122      *          Null indicates an empty environment.
 123      * @param connCtls
 124      *          connection request controls for the initial context.
 125      *          If null, no connection request controls are used.
 126      *
 127      * @throws  NamingException if a naming exception is encountered
 128      *
 129      * @see #reconnect
 130      * @see LdapContext#reconnect
 131      */

 132     public InitialLdapContext(Hashtable<?,?> environment,
 133                               Control[] connCtls)
 134             throws NamingException {
 135         super(true); // don't initialize yet
 136 
 137         // Clone environment since caller owns it.
 138         Hashtable env = (environment == null)
 139             ? new Hashtable(11)
 140             : (Hashtable)environment.clone();
 141 
 142         // Put connect controls into environment.  Copy them first since
 143         // caller owns the array.
 144         if (connCtls != null) {
 145             Control[] copy = new Control[connCtls.length];
 146             System.arraycopy(connCtls, 0, copy, 0, connCtls.length);
 147             env.put(BIND_CONTROLS_PROPERTY, copy);
 148         }
 149         // set version to LDAPv3
 150         env.put("java.naming.ldap.version", "3");
 151 
 152         // Initialize with updated environment
 153         init(env);
 154     }
 155 
 156     /**
 157      * Retrieves the initial LDAP context.
 158      *
 159      * @return The non-null cached initial context.
 160      * @exception NotContextException If the initial context is not an




 112      * save references to them, but may save a clone or copy.
 113      * Caller should not modify mutable keys and values in
 114      * <tt>environment</tt> after it has been passed to the constructor.
 115      *
 116      * <p> <tt>connCtls</tt> is used as the underlying context instance's
 117      * connection request controls.  See the class description
 118      * for details.
 119      *
 120      * @param environment
 121      *          environment used to create the initial DirContext.
 122      *          Null indicates an empty environment.
 123      * @param connCtls
 124      *          connection request controls for the initial context.
 125      *          If null, no connection request controls are used.
 126      *
 127      * @throws  NamingException if a naming exception is encountered
 128      *
 129      * @see #reconnect
 130      * @see LdapContext#reconnect
 131      */
 132     @SuppressWarnings("unchecked")
 133     public InitialLdapContext(Hashtable<?,?> environment,
 134                               Control[] connCtls)
 135             throws NamingException {
 136         super(true); // don't initialize yet
 137 
 138         // Clone environment since caller owns it.
 139         Hashtable<Object,Object> env = (environment == null)
 140             ? new Hashtable<>(11)
 141             : (Hashtable<Object,Object>)environment.clone();
 142 
 143         // Put connect controls into environment.  Copy them first since
 144         // caller owns the array.
 145         if (connCtls != null) {
 146             Control[] copy = new Control[connCtls.length];
 147             System.arraycopy(connCtls, 0, copy, 0, connCtls.length);
 148             env.put(BIND_CONTROLS_PROPERTY, copy);
 149         }
 150         // set version to LDAPv3
 151         env.put("java.naming.ldap.version", "3");
 152 
 153         // Initialize with updated environment
 154         init(env);
 155     }
 156 
 157     /**
 158      * Retrieves the initial LDAP context.
 159      *
 160      * @return The non-null cached initial context.
 161      * @exception NotContextException If the initial context is not an