- 论坛徽章:
- 0
|
String path = "C:/tmp/testJNDI/sslkey.keystore";
boolean isSsl = true;
//dynamically set JSSE as a security provider
//Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
//dynamically set the property that JSSE uses to identify
//the keystore that holds trusted root certificates
System.setProperty("javax.net.ssl.trustStore", path);
// Set up the environment for creating the initial context
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" ;
if (!isSsl)
{
env.put(Context.PROVIDER_URL, "ldap://testhost:389/dc=domain,dc=com" ;
}
else
{
env.put(Context.PROVIDER_URL, "ldap://testhost:636/dc=domain,dc=com" ;
env.put(Context.SECURITY_PROTOCOL, "ssl" ;
}
System.err.println("Using SSL = " + isSsl);
// Authenticate
env.put(Context.SECURITY_AUTHENTICATION, "simple" ;
env.put(Context.SECURITY_PRINCIPAL,
"uid=testUser,ou=people,dc=domain,dc=com" ;
env.put(Context.SECURITY_CREDENTIALS, "password" ;
sslkey.keystore 怎么生成??有那为高手知道请指教指教!!! |
|