1 5 48 49 package com.oreilly.servlet; 50 51 import java.io.*; 52 import java.net.*; 53 import java.util.*; 54 import java.security.Security ; 55 import java.security.Provider ; 56 57 83 public class HttpsMessage extends com.oreilly.servlet.HttpMessage 84 { 85 86 static boolean m_bStreamHandlerSet = false; 88 89 96 public HttpsMessage(String szURL) throws Exception 97 { 98 super(null); 99 if( !m_bStreamHandlerSet ) 102 { 103 String szVendor = System.getProperty("java.vendor"); 104 String szVersion = System.getProperty("java.version"); 105 Double dVersion = new Double (szVersion.substring(0, 3)); 107 108 if( -1 < szVendor.indexOf("Microsoft") ) 110 { 111 try 112 { 113 Class clsFactory = Class.forName("com.ms.net.wininet.WininetStreamHandlerFactory" ); 114 if ( null != clsFactory) 115 URL.setURLStreamHandlerFactory((URLStreamHandlerFactory)clsFactory.newInstance()); 116 } 117 catch( ClassNotFoundException cfe ) 118 { 119 throw new Exception ("Unable to load the Microsoft SSL stream handler. Check classpath." + cfe.toString()); 120 } 121 catch( Error err ){m_bStreamHandlerSet = true;} 124 } 125 else if( 1.2 <= dVersion.doubleValue() ) 127 { 128 System.getProperties().put("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol"); 129 try 130 { 131 Class clsFactory = Class.forName("com.sun.net.ssl.internal.ssl.Provider"); 134 if( (null != clsFactory) && (null == Security.getProvider("SunJSSE")) ) 135 Security.addProvider((Provider )clsFactory.newInstance()); 136 } 137 catch( ClassNotFoundException cfe ) 138 { 139 throw new Exception ("Unable to load the JSSE SSL stream handler. Check classpath." + cfe.toString()); 140 } 141 } 142 143 m_bStreamHandlerSet = true; 144 } 145 146 super.servlet = new URL(szURL); 147 } 148 } 149 | Popular Tags |