title: How to pass arguments to an LDAP custom socket factory with JNDI?
body: <p>I'm using JNDI to make LDAP connections. Example:</p>
  
  <pre><code>Hashtable env = new Hashtable();
  env.put(Context.PROVIDER_URL, LDAPS_URL);
  env.put(Context.SECURITY_AUTHENTICATION, "EXTERNAL");
  env.put("java.naming.ldap.factory.socket", "ldaptest.CustomSocketFactory");
  ...
  </code></pre>
  
  <p>I need to pass parameters at run time to the CustomSocketFactory. Specifically a reference to a client certificate.</p>
  
  <p>How can I do this?
  I could use thread local storage.</p>
  
  <p>Is there a better way?</p>