29 * NullPointerException 30 * @run main/othervm ComURLNulls 31 * 32 * SunJSSE does not support dynamic system properties, no way to re-use 33 * system properties in samevm/agentvm mode. 34 * @author Brad Wetmore 35 */ 36 37 import java.net.*; 38 import java.io.*; 39 import javax.net.ssl.*; 40 import com.sun.net.ssl.HttpsURLConnection; 41 import com.sun.net.ssl.HostnameVerifier; 42 43 /* 44 * Tests that the com null argument changes made it in ok. 45 */ 46 47 public class ComURLNulls { 48 49 public static void main(String[] args) throws Exception { 50 HostnameVerifier reservedHV = 51 HttpsURLConnection.getDefaultHostnameVerifier(); 52 try { 53 System.setProperty("java.protocol.handler.pkgs", 54 "com.sun.net.ssl.internal.www.protocol"); 55 /** 56 * This test does not establish any connection to the specified 57 * URL, hence a dummy URL is used. 58 */ 59 URL foobar = new URL("https://example.com/"); 60 61 HttpsURLConnection urlc = 62 (HttpsURLConnection) foobar.openConnection(); 63 64 try { 65 urlc.getCipherSuite(); 66 } catch (IllegalStateException e) { 67 System.out.print("Caught proper exception: "); 68 System.out.println(e.getMessage()); 69 } 70 71 try { 72 urlc.getServerCertificateChain(); 73 } catch (IllegalStateException e) { 74 System.out.print("Caught proper exception: "); | 29 * NullPointerException 30 * @run main/othervm ComURLNulls 31 * 32 * SunJSSE does not support dynamic system properties, no way to re-use 33 * system properties in samevm/agentvm mode. 34 * @author Brad Wetmore 35 */ 36 37 import java.net.*; 38 import java.io.*; 39 import javax.net.ssl.*; 40 import com.sun.net.ssl.HttpsURLConnection; 41 import com.sun.net.ssl.HostnameVerifier; 42 43 /* 44 * Tests that the com null argument changes made it in ok. 45 */ 46 47 public class ComURLNulls { 48 49 private static class ComSunHTTPSHandlerFactory implements URLStreamHandlerFactory { 50 private static String SUPPORTED_PROTOCOL = "https"; 51 52 public URLStreamHandler createURLStreamHandler(String protocol) { 53 if (!protocol.equalsIgnoreCase(SUPPORTED_PROTOCOL)) 54 return null; 55 56 return new com.sun.net.ssl.internal.www.protocol.https.Handler(); 57 } 58 } 59 60 public static void main(String[] args) throws Exception { 61 HostnameVerifier reservedHV = 62 HttpsURLConnection.getDefaultHostnameVerifier(); 63 try { 64 URL.addURLStreamHandlerFactory(new ComSunHTTPSHandlerFactory()); 65 66 /** 67 * This test does not establish any connection to the specified 68 * URL, hence a dummy URL is used. 69 */ 70 URL foobar = new URL("https://example.com/"); 71 72 HttpsURLConnection urlc = 73 (HttpsURLConnection) foobar.openConnection(); 74 75 try { 76 urlc.getCipherSuite(); 77 } catch (IllegalStateException e) { 78 System.out.print("Caught proper exception: "); 79 System.out.println(e.getMessage()); 80 } 81 82 try { 83 urlc.getServerCertificateChain(); 84 } catch (IllegalStateException e) { 85 System.out.print("Caught proper exception: "); |