The answer you entered to the math problem is incorrect.
Vijay (not verified)
Wed, 1969-12-31 20:00
Hi Mike,
Thanks because of your code I was able to gain some knowledge about SSL. But when I tried implementing custom socket factory as you mentioned I received an error which says "The error is 10.233.8.21:636". Could you help me out in figuring out whats wrong over here.
I am pasting the code of my method below and custom socket factory class which is just copy of your BlindSSLSocketFactoryTest.java
Hi Mike,
Thanks because of your code I was able to gain some knowledge about SSL. But when I tried implementing custom socket factory as you mentioned I received an error which says "The error is 10.233.8.21:636". Could you help me out in figuring out whats wrong over here.
I am pasting the code of my method below and custom socket factory class which is just copy of your BlindSSLSocketFactoryTest.java
==========================authenticate method==================
public DirContext authenticate(String principle, String password) throws Exception
{
// connect to , authenticate and return directory context
Debug.out("principle: "+principle);
Debug.out("password: "+password);
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldaps://10.241.14.122:636");
env.put("java.naming.ldap.factory.socket", SecureSSLSocketFactory.class.getName());
env.put(Context.SECURITY_AUTHENTICATION,"simple");
env.put(Context.SECURITY_PRINCIPAL,principle);
env.put(Context.SECURITY_CREDENTIALS,password);
DirContext ctx = new InitialDirContext(env);
return ctx
}
===========================================================
===================SecureSSLSocketFactory=====================
public class SecureSSLSocketFactory extends SocketFactory
{
private static SocketFactory blindFactory = null;
static
{
TrustManager[] blindTrustMan = new TrustManager[]
{
new X509TrustManager()
{
public X509Certificate[] getAcceptedIssuers() { return null; }
public void checkClientTrusted(X509Certificate[] c, String a) { }
public void checkServerTrusted(X509Certificate[] c, String a) { }
}
};
}
public static SocketFactory getDefault()
{
return new SecureSSLSocketFactory();
}
public Socket createSocket(String arg0, int arg1) throws IOException,UnknownHostException
{
return blindFactory.createSocket(arg0, arg1);
}
public Socket createSocket(InetAddress arg0, int arg1) throws IOException
{
return blindFactory.createSocket(arg0, arg1);
}
public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3) throws IOException, UnknownHostException
{
return blindFactory.createSocket(arg0, arg1, arg2, arg3);
}
public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2,int arg3) throws IOException
{
return blindFactory.createSocket(arg0, arg1, arg2, arg3);
}
}
===========================================================