Uploaded image for project: 'BlueJ'
  1. BlueJ
  2. BLUEJ-314

InitialDirContext(env) fails in bluej environment but works in eclipse

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Medium
    • Resolution: Cannot Reproduce
    • Affects Version/s: 3.0.3
    • Fix Version/s: 3.0.6
    • Component/s: Execution

      Description

      ==
      bluej fails when attempting to execute the last line on this code snippet.

      DirContext ctx = new InitialDirContext(env);

      Yet this same code works when run outside bluej at dos prompt (java ldap) and also within eclipse.
      ==

      import javax.naming.*;
      import javax.naming.directory.*;
      import java.util.Hashtable;
      import java.util.Properties;
      import java.security.Security;
      import java.io.UnsupportedEncodingException;
      import java.util.Hashtable;
      import java.lang.*;

      :
      :

      Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
      Properties env = new Properties();
      env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
      env.put(Context.SECURITY_PROTOCOL, "ssl");

      env.put(Context.SECURITY_AUTHENTICATION, "simple");
      env.put(Context.PROVIDER_URL, "ldap://127.0.0.1:636/");
      env.put(Context.SECURITY_PRINCIPAL, "cn=testuser, o=users");
      env.put(Context.SECURITY_CREDENTIALS, "password");

      DirContext ctx = new InitialDirContext(env);

      ==============
      Java stak dump

      ==============
      javax.naming.CommunicationException: simple bind failed: 147.252.80.40:636 [exception is javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target|Root]
      at com.sun.jndi.ldap.LdapClient.authenticate(LdapClient.java:197)
      at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2694)
      at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:293)
      at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:175)
      at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:193)
      at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:136)
      at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:66)
      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
      at javax.naming.InitialContext.init(InitialContext.java:223)
      at javax.naming.InitialContext.<init>(InitialContext.java:197)
      at javax.naming.directory.InitialDirContext.<init>(InitialDirContext.java:82)
      at ldap.main(ldap.java:36)
      at +SHELL1.run(+SHELL1.java:6)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at bluej.runtime.ExecServer$3.run(ExecServer.java:774)
      Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
      at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1623)
      at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:198)
      at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:192)
      at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1074)
      at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:128)
      at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:529)
      at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:465)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:884)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1120)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:744)
      at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:75)
      at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
      at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
      at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
      at com.sun.jndi.ldap.Connection.run(Connection.java:808)
      at java.lang.Thread.run(Thread.java:619)
      Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
      at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:325)
      at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:219)
      at sun.security.validator.Validator.validate(Validator.java:218)
      at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:126)
      at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:209)
      at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:249)
      at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1053)
      ... 12 more
      Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
      at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:174)
      at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:238)
      at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:320)
      ... 18 more

      =====

      Is this a bug , or am I missing something with bluej setup!

      Thanks
      Liam

        Attachments

          Activity

            People

            • Assignee:
              davmac Davin McCall
              Reporter:
              external External via trac
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: