test/sun/net/www/protocol/https/NewImpl/ComHostnameVerifier.java

Print this page

        

@@ -184,10 +184,21 @@
              sslSocket.close();
              serverReady = false;
         }
     }
 
+    private static class ComSunHTTPSHandlerFactory implements URLStreamHandlerFactory {
+        private static String SUPPORTED_PROTOCOL = "https";
+
+        public URLStreamHandler createURLStreamHandler(String protocol) {
+            if (!protocol.equalsIgnoreCase(SUPPORTED_PROTOCOL))
+                return null;
+
+            return new com.sun.net.ssl.internal.www.protocol.https.Handler();
+        }
+    }
+
     /*
      * Define the client side of the test.
      *
      * If the server prematurely exits, serverReady will be set to true
      * to avoid infinite hangs.

@@ -198,12 +209,11 @@
          */
         while (!serverReady) {
             Thread.sleep(50);
         }
 
-        System.setProperty("java.protocol.handler.pkgs",
-            "com.sun.net.ssl.internal.www.protocol");
+        URL.addURLStreamHandlerFactory(new ComSunHTTPSHandlerFactory());
 
         System.setProperty("https.cipherSuites",
                 "SSL_DH_anon_WITH_3DES_EDE_CBC_SHA");
 
         // use the default hostname verifier