billbarker 2003/03/14 23:00:07 Modified: util/java/org/apache/tomcat/util/net/jsse JSSE14SocketFactory.java JSSEImplementation.java Log: catch the tabs before the tab police nab me ;-). Revision Changes Path 1.2 +75 -75 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/jsse/JSSE14SocketFactory.java Index: JSSE14SocketFactory.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/jsse/JSSE14SocketFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- JSSE14SocketFactory.java 15 Mar 2003 06:55:21 -0000 1.1 +++ JSSE14SocketFactory.java 15 Mar 2003 07:00:07 -0000 1.2 @@ -96,90 +96,90 @@ public class JSSE14SocketFactory extends JSSESocketFactory { public JSSE14SocketFactory () { - super(); + super(); } // -------------------- Internal methods /** Read the keystore, init the SSL socket factory */ void initProxy() throws IOException { - try { + try { - // Please don't change the name of the attribute - other - // software may depend on it ( j2ee for sure ) - String keystoreFile=(String)attributes.get("keystore"); - if( keystoreFile==null) keystoreFile=defaultKeystoreFile; - - keystoreType=(String)attributes.get("keystoreType"); - if( keystoreType==null) keystoreType=defaultKeystoreType; - - //determine whether we want client authentication - // the presence of the attribute enables client auth - String clientAuthStr=(String)attributes.get("clientauth"); - if(clientAuthStr != null){ - if(clientAuthStr.equals("true")){ - clientAuth=true; - } else if(clientAuthStr.equals("false")) { - clientAuth=false; - } else { - throw new IOException("Invalid value '" + - clientAuthStr + - "' for 'clientauth' parameter:"); - } - } - - String keyPass=(String)attributes.get("keypass"); - if( keyPass==null) keyPass=defaultKeyPass; - - String keystorePass=(String)attributes.get("keystorePass"); - if( keystorePass==null) keystorePass=keyPass; - - //protocol for the SSL ie - TLS, SSL v3 etc. - String protocol = (String)attributes.get("protocol"); - if(protocol == null) protocol = defaultProtocol; - - //Algorithm used to encode the certificate ie - SunX509 - String algorithm = (String)attributes.get("algorithm"); - if(algorithm == null) algorithm = defaultAlgorithm; - - // You can't use ssl without a server certificate. - // Create a KeyStore ( to get server certs ) - KeyStore kstore = initKeyStore( keystoreFile, keystorePass ); - - SSLContext context = SSLContext.getInstance(protocol); //SSL - - // Key manager will extract the server key - KeyManagerFactory kmf = KeyManagerFactory.getInstance(algorithm); - kmf.init( kstore, keyPass.toCharArray()); - - // set up TrustManager - TrustManager[] tm = null; - String trustStoreFile = System.getProperty("javax.net.ssl.trustStore"); - String trustStorePassword = - System.getProperty("javax.net.ssl.trustStorePassword"); - if ( trustStoreFile != null && trustStorePassword != null ){ - KeyStore trustStore = - initKeyStore( trustStoreFile, trustStorePassword); + // Please don't change the name of the attribute - other + // software may depend on it ( j2ee for sure ) + String keystoreFile=(String)attributes.get("keystore"); + if( keystoreFile==null) keystoreFile=defaultKeystoreFile; + + keystoreType=(String)attributes.get("keystoreType"); + if( keystoreType==null) keystoreType=defaultKeystoreType; + + //determine whether we want client authentication + // the presence of the attribute enables client auth + String clientAuthStr=(String)attributes.get("clientauth"); + if(clientAuthStr != null){ + if(clientAuthStr.equals("true")){ + clientAuth=true; + } else if(clientAuthStr.equals("false")) { + clientAuth=false; + } else { + throw new IOException("Invalid value '" + + clientAuthStr + + "' for 'clientauth' parameter:"); + } + } + + String keyPass=(String)attributes.get("keypass"); + if( keyPass==null) keyPass=defaultKeyPass; + + String keystorePass=(String)attributes.get("keystorePass"); + if( keystorePass==null) keystorePass=keyPass; + + //protocol for the SSL ie - TLS, SSL v3 etc. + String protocol = (String)attributes.get("protocol"); + if(protocol == null) protocol = defaultProtocol; - TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509"); + //Algorithm used to encode the certificate ie - SunX509 + String algorithm = (String)attributes.get("algorithm"); + if(algorithm == null) algorithm = defaultAlgorithm; + + // You can't use ssl without a server certificate. + // Create a KeyStore ( to get server certs ) + KeyStore kstore = initKeyStore( keystoreFile, keystorePass ); + + SSLContext context = SSLContext.getInstance(protocol); //SSL + + // Key manager will extract the server key + KeyManagerFactory kmf = KeyManagerFactory.getInstance(algorithm); + kmf.init( kstore, keyPass.toCharArray()); + + // set up TrustManager + TrustManager[] tm = null; + String trustStoreFile = System.getProperty("javax.net.ssl.trustStore"); + String trustStorePassword = + System.getProperty("javax.net.ssl.trustStorePassword"); + if ( trustStoreFile != null && trustStorePassword != null ){ + KeyStore trustStore = + initKeyStore( trustStoreFile, trustStorePassword); + + TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509"); - tmf.init(trustStore); - tm = tmf.getTrustManagers(); - } - - // init context with the key managers - context.init(kmf.getKeyManagers(), tm, - new java.security.SecureRandom()); - - // create proxy - sslProxy = context.getServerSocketFactory(); - - return; - } catch(Exception e) { - if( e instanceof IOException ) - throw (IOException)e; - throw new IOException(e.getMessage()); - } + tmf.init(trustStore); + tm = tmf.getTrustManagers(); + } + + // init context with the key managers + context.init(kmf.getKeyManagers(), tm, + new java.security.SecureRandom()); + + // create proxy + sslProxy = context.getServerSocketFactory(); + + return; + } catch(Exception e) { + if( e instanceof IOException ) + throw (IOException)e; + throw new IOException(e.getMessage()); + } } } 1.3 +17 -17 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/jsse/JSSEImplementation.java Index: JSSEImplementation.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/jsse/JSSEImplementation.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- JSSEImplementation.java 15 Mar 2003 06:55:21 -0000 1.2 +++ JSSEImplementation.java 15 Mar 2003 07:00:07 -0000 1.3 @@ -73,14 +73,14 @@ @author EKR */ - + public class JSSEImplementation extends SSLImplementation { static final String JSSE14SocketFactory = - "org.apache.tomcat.net.jsse.JSSE11SocketFactory"; + "org.apache.tomcat.net.jsse.JSSE11SocketFactory"; public JSSEImplementation() throws ClassNotFoundException { - // Check to see if JSSE is floating around somewhere - Class.forName("javax.net.ssl.SSLServerSocketFactory"); + // Check to see if JSSE is floating around somewhere + Class.forName("javax.net.ssl.SSLServerSocketFactory"); } @@ -90,23 +90,23 @@ public ServerSocketFactory getServerSocketFactory() { - ServerSocketFactory ssf = null; - if( JdkCompat.isJava14() ) { - try { - Class ssfCl = Class.forName(JSSE14SocketFactory); - ssf =(ServerSocketFactory)ssfCl.newInstance(); - } catch(Exception ex) { - ssf = new JSSESocketFactory(); - } - } else { - ssf = new JSSESocketFactory(); - } - return ssf; + ServerSocketFactory ssf = null; + if( JdkCompat.isJava14() ) { + try { + Class ssfCl = Class.forName(JSSE14SocketFactory); + ssf =(ServerSocketFactory)ssfCl.newInstance(); + } catch(Exception ex) { + ssf = new JSSESocketFactory(); + } + } else { + ssf = new JSSESocketFactory(); + } + return ssf; } public SSLSupport getSSLSupport(Socket s) { - return new JSSESupport((SSLSocket)s); + return new JSSESupport((SSLSocket)s); }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]