There is a static way of providing SocketFactory to InitialLdapContext:
env.put("java.naming.ldap.factory.socket", MySocketFactory.class.getName());
new InitialLdapContext(env, null);
But is there some way to provide the instance itself instead of its class name? My socket factory is parameterized with the input stream of trusted certificate and there can be configured many instances of InitialLdapContext with different trusted certificates. BTW this will run in OSGi environment.
Thanks in advance.
Inspecting source of com.sun.jndi.ldap.Connection.createSocket(String, int, String, int)
I can see that there is unfortunately no way to do this. It is sad that so many Java core APIs have that bad design.
The solution might be to use different implementation:
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