Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > LDAP over SSL

Reply
Thread Tools

LDAP over SSL

 
 
John Smith
Guest
Posts: n/a
 
      07-22-2003
I'm trying to make a ldap connection using SSL well I'm not sure why I am
getting the following message. If anyone could help me out.

==============
command prompt
==============
Starting to execute
Binding...
javax.naming.CommunicationException: pitt-auth-07.srv.cssd.pitt.edu:636.
Root exception is java.net
..SocketException: Default SSL context init failed: null
at javax.net.ssl.DefaultSSLSocketFactory.createSocket (DashoA6275)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39
)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl
..java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.sun.jndi.ldap.Connection.createSocket(Connecti on.java:311)
at com.sun.jndi.ldap.Connection.<init>(Connection.jav a:181)
at com.sun.jndi.ldap.LdapClient.<init>(LdapClient.jav a:119)
at com.sun.jndi.ldap.LdapClient.getInstance(LdapClien t.java:166
at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:255 6)
at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:275)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapC txFactory.java:173)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(Ldap CtxFactory.java:191)
at
com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstanc e(LdapCtxFactory.java:136)
at
com.sun.jndi.ldap.LdapCtxFactory.getInitialContext (LdapCtxFactory.java:66)
at javax.naming.spi.NamingManager.getInitialContext(N amingManager.java:662)
at javax.naming.InitialContext.getDefaultInitCtx(Init ialContext.java:243)
at javax.naming.InitialContext.init(InitialContext.ja va:219)
at javax.naming.InitialContext.<init>(InitialContext. java:195)
at
javax.naming.directory.InitialDirContext.<init>(In itialDirContext.java:80)
at LDAPConn.bindAs(LDAPConn.java:45)
at LDAPConn.main(LDAPConn.java:66)
Fininished....!

==========
code snip
==========
public void bindAs ( String principal, String credentials, String baseDN) {
env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");

env.put(Context.SECURITY_AUTHENTICATION, "simple");

env.put(Context.REFERRAL, "ignore");
env.put(Context.SECURITY_PROTOCOL, "ssl");
//THE LOCATION OF THE CACERTS MUST BE SPECIFIED
java.security.Security.addProvider(new
com.sun.net.ssl.internal.ssl.Provider());
System.setProperty("javax.net.ssl.keyStore",
"c:\\j2sdk1.4.0_01\\jre\\lib\\security\\cacert s");
System.setProperty("javax.net.ssl.trustStore",
"c:\\j2sdk1.4.0_01\\jre\\lib\\security\\cacert s");
System.setProperty("javax.net.ssl.trustStoreType", "jks");
env.put(Context.PROVIDER_URL, baseDN );
env.put(Context.SECURITY_PRINCIPAL, principal);
env.put(Context.SECURITY_CREDENTIALS, credentials);
DirContext ctx = null;
try {
ctx = new InitialDirContext(env);
System.out.println("bind Successful...");
ctx.close();
} catch(AuthenticationException aex) {
System.out.println("Invalid userid or password... Please try again");
} catch (Exception ex) {
ex.printStackTrace();
}

} // bindAs


public static void main(String[] args) {
String principal = "user name";
String credentials = "password";
String baseDN = "ldap://ldaphost:636";
System.out.println("Starting to execute");
LDAPConn testUser = new LDAPConn();
System.out.println("Binding...");
testUser.bindAs( principal, credentials, baseDN );
System.out.println( "Fininished....!");
} // main


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VOIP over VPN over TCP over WAP over 3G Theo Markettos UK VOIP 2 02-14-2008 03:27 PM
AD over SSL using Net/LDAP? Amos Ruby 0 05-10-2007 10:58 PM
Need to wrtie LDAP class to *answer* LDAP queries. junk1@davidbevan.co.uk Java 1 02-21-2006 09:59 PM
FTPS ( FTP over SSL) Problem with Python's builtin SSL Robert Python 2 06-10-2004 10:27 AM
FTP over SSL vs FTP over SSH someone Java 1 04-25-2004 03:30 PM



Advertisments