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?
JNDI does for LDAP what JDBC does for Oracle -- it provides a standard API for interacting with naming and directory services using a service provider interface (SPI), which is analogous to an JDBC driver. LDAP is a standard way to provide access to directory information.
Both the JNDI and LDAP models define a hierarchical namespace in which you name objects. Each object in the namespace may have attributes that can be used to search for the object. At this high level, the two models are similar, so it is not surprising that the JNDI maps well to the LDAP.
String url = "ldap://localhost:389" ; That specifies URL of a LDAP server which is running on local host and is listening on the default port number 389 - a well known port number of the Lightweight Directory Access Protocol.
These naming and directory services are supported by JNDI: Lightweight Directory Access Protocol (LDAP) Corba Object Services (COS) Naming Service. RMI Registry.
Actually thread local is only way to solve this I found so far. I posted my solution here:
jndi LDAPS custom HostnameVerifier and TrustManager
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");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With