code: private TimedDirContext createDirContext(Hashtable<String, Object> env, long createTimestamp) throws NamingException {
  
          /*
           * Check if the credential is a protected string. It will be unprotected if this is an anonymous bind
           */
          Object o = env.get(Context.SECURITY_CREDENTIALS);
          if (o instanceof ProtectedString) {
              // Reset the bindPassword to simple string.
              ProtectedString sps = (ProtectedString) env.get(Context.SECURITY_CREDENTIALS);
              String password = sps == null ? "" : new String(sps.getChars());
              String decodedPassword = PasswordUtil.passwordDecode(password.trim());
              env.put(Context.SECURITY_CREDENTIALS, decodedPassword);
          }
  
          SSLUtilImpl sslUtil = new SSLUtilImpl();
          Properties currentSSLProps = sslUtil.getSSLPropertiesOnThread();
          try {
              if (iSSLAlias != null) {
                  try {
                      sslUtil.setSSLAlias(iSSLAlias, env);
                  } catch (Exception ssle) {
                      throw new NamingException(ssle.getMessage());
                  }
              }
  
              /*
               * Set the classloader so that a class in the package can be loaded by JNDI
               */
              ClassLoader origCL = getContextClassLoader();
              setContextClassLoader(getClass());
              try {
                  TimedDirContext ctx = new TimedDirContext(env, getConnectionRequestControls(), createTimestamp);
                  String newURL = getProviderURL(ctx);
                  // Set the active URL if context pool is disabled,
                  // otherwise active URL will be set when pool is refreshed
                  if (!iContextPoolEnabled)
                      if (!newURL.equalsIgnoreCase(getActiveURL()))
                          setActiveURL(newURL);
  
                  return ctx;
              } finally {
                  setContextClassLoader(origCL);
              }
          } finally {
              sslUtil.setSSLPropertiesOnThread(currentSSLProps);
          }
      }
docs: Create a directory context.
  
  @param env The JNDI environment to create the context with.
  @param createTimestamp The timestamp to use as the creation timestamp for the {@link TimedDirContext}.
  @return The {@link TimedDirContext}.
  @throws NamingException If there was an issue binding to the LDAP server.