ssl - SpringLdap 2 over ldaps -
i've followed interesting webinar springldap , i'm planning migrate current ldap interface springldap. haven't seen easy way connect ldaps server. in current implementation had like:
string nexttoken = stcc.nexttoken(); properties envp = initializeenv(nexttoken, userpassword); try { ldapcontext ctx = new initialldapcontext(envp, null); //system.out.println(nexttoken + " validation"); return ctx; }
and
private properties initializeenv(string username, string userpassword) throws ioexception { properties envp = new properties(); envp.setproperty(context.initial_context_factory, "com.sun.jndi.ldap.ldapctxfactory"); envp.put(context.provider_url, (string) properties.get("ldap.server.url")); if (username != null) envp.setproperty(context.security_principal, username); if (userpassword != null) envp.setproperty(context.security_credentials, userpassword); envp.setproperty(context.security_authentication, "simple"); envp.setproperty("java.naming.security.protocol", "ssl"); envp.setproperty("com.sun.jndi.ldap.connect.pool", "true"); envp.put("java.naming.ldap.factory.socket", "org.mycompany.ldap.custsslsocketfactory"); return envp;
}
and more:
public emblsslsocketfactory() { try { sslcontext ctx = sslcontext.getinstance("tls"); ctx.init(null, new trustmanager[] { new dummytrustmanager() }, new securerandom()); socketfactory = ctx.getsocketfactory(); } catch (exception ex) { ex.printstacktrace(system.err); /* handle exception */ }
}
which equivalent (and possibly easier) way such authentication on tls spring-ldap 2?
thanks
Comments
Post a Comment