I'm looking for a way to connect to an LDAP Server over SSL from Java in a scenario where you can have multiple users, each one with its own truststore (Basically each user is an application deployed on a Java application server). I think it should be possible to connect to LDAPs using a Custom SSL Connection Factory. Something like this:
Hashtable env = new Hashtable();
env.put(DirContext.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(DirContext.PROVIDER_URL, url );
env.put(DirContext.SECURITY_AUTHENTICATION, "simple");
env.put(DirContext.SECURITY_PRINCIPAL, principal);
env.put(DirContext.SECURITY_CREDENTIALS, credentials);
env.put("java.naming.ldap.factory.socket", "MySSLSocketFactory");
However, if the property "java.naming.ldap.factory.socket" is set at JVM level, I believe each applicaton will overwrite the current SSL Factory. On the other hand, I'd need to have a distinct SSLSocketFactory for each user. Is it possible? Thanks