This content has been marked as final.
Show 1 reply
-
1. Re: JNDI over HTTPS
benoitx Aug 2, 2005 11:47 AM (in response to triplem)We had to add some code...
System.out.println("Connect HTTPS"); Properties prop = System.getProperties(); prop.put("java.naming.factory.initial","org.jboss.naming.HttpNamingContextFactory"); prop.put("org.jboss.security.ignoreHttpsHost","true"); final int newPort = ConsoleMenu.getInt("Enter the port (current:" + 8443 +")", 8443); prop.put("java.naming.provider.url","https://"+host+":"+newPort+"/invoker/JNDIFactory"); // Create a trust manager that does not validate certificate chains TrustManager[] trustAllCerts = new TrustManager[]{ new X509TrustManager() { public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } public void checkClientTrusted( java.security.cert.X509Certificate[] certs, String authType) { } public void checkServerTrusted( java.security.cert.X509Certificate[] certs, String authType) { } } }; // Install the all-trusting trust manager try { SSLContext sc = SSLContext.getInstance("SSL"); sc.init(null, trustAllCerts, new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); } catch (Exception e) { } RefDataProviderHome home; try { System.err.println("About to connect to JNDI HTTPS"); InitialContext context = new InitialContext(prop); final Object objref = context.lookup("RefDataProviderBean"); EJBHome anEJBHome = (EJBHome) PortableRemoteObject .narrow(objref, RefDataProviderHome.class); ...
Hope this helps!
Benoti