Reputation: 3219
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.
Upvotes: 5
Views: 663
Reputation: 3219
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:
Upvotes: 2