How to pass arguments to an LDAP custom socket fac

2019-04-07 13:00发布

I'm using JNDI to make LDAP connections. Example:

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");
...

I need to pass parameters at run time to the CustomSocketFactory. Specifically a reference to a client certificate.

How can I do this? I could use thread local storage.

Is there a better way?

标签: java ldap jndi
2条回答
祖国的老花朵
2楼-- · 2019-04-07 13:18

Actually thread local is only way to solve this I found so far. I posted my solution here:

jndi LDAPS custom HostnameVerifier and TrustManager

查看更多
forever°为你锁心
3楼-- · 2019-04-07 13:35

I think that you may be looking for something like this:

env.put("javax.net.ssl.keyStore", keystorePath);
//Where keystorePath is the path to the Keys file resource

env.put("javax.net.ssl.keyStorePassword", "password");
查看更多
登录 后发表回答