jdk/test/sun/net/www/protocol/https/NewImpl/ComHTTPSConnection.java
changeset 29097 01a70c01f5a1
parent 23052 241885315119
child 29615 b0057b63b4e7
equal deleted inserted replaced
29096:e91fff38083a 29097:01a70c01f5a1
   186              sslSocket.close();
   186              sslSocket.close();
   187              serverReady = false;
   187              serverReady = false;
   188         }
   188         }
   189     }
   189     }
   190 
   190 
       
   191     private static class ComSunHTTPSHandlerFactory implements URLStreamHandlerFactory {
       
   192         private static String SUPPORTED_PROTOCOL = "https";
       
   193 
       
   194         public URLStreamHandler createURLStreamHandler(String protocol) {
       
   195             if (!protocol.equalsIgnoreCase(SUPPORTED_PROTOCOL))
       
   196                 return null;
       
   197 
       
   198             return new com.sun.net.ssl.internal.www.protocol.https.Handler();
       
   199         }
       
   200     }
       
   201 
   191     /*
   202     /*
   192      * Define the client side of the test.
   203      * Define the client side of the test.
   193      *
   204      *
   194      * If the server prematurely exits, serverReady will be set to true
   205      * If the server prematurely exits, serverReady will be set to true
   195      * to avoid infinite hangs.
   206      * to avoid infinite hangs.
   203         }
   214         }
   204 
   215 
   205         HostnameVerifier reservedHV =
   216         HostnameVerifier reservedHV =
   206             HttpsURLConnection.getDefaultHostnameVerifier();
   217             HttpsURLConnection.getDefaultHostnameVerifier();
   207         try {
   218         try {
   208             System.setProperty("java.protocol.handler.pkgs",
   219             URL.setURLStreamHandlerFactory(new ComSunHTTPSHandlerFactory());
   209                 "com.sun.net.ssl.internal.www.protocol");
       
   210             HttpsURLConnection.setDefaultHostnameVerifier(new NameVerifier());
   220             HttpsURLConnection.setDefaultHostnameVerifier(new NameVerifier());
   211 
   221 
   212             URL url = new URL("https://" + "localhost:" + serverPort +
   222             URL url = new URL("https://" + "localhost:" + serverPort +
   213                                     "/etc/hosts");
   223                                     "/etc/hosts");
   214             URLConnection urlc = url.openConnection();
   224             URLConnection urlc = url.openConnection();