billbarker 2003/06/04 22:16:25 Modified: util/java/org/apache/tomcat/util/net/jsse JSSEImplementation.java Added: util/java/org/apache/tomcat/util/net/jsse JSSE13Factory.java JSSE14Factory.java JSSEFactory.java Log: Yet another re-factoring to support JSSE 1.1.x better. Removing the introspection from the per-connection, and moving it into a Factory method (that depends on the JVM version). Revision Changes Path 1.7 +24 -45 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.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- JSSEImplementation.java 27 Apr 2003 05:28:55 -0000 1.6 +++ JSSEImplementation.java 5 Jun 2003 05:16:25 -0000 1.7 @@ -65,8 +65,6 @@ import org.apache.tomcat.util.net.ServerSocketFactory; import java.io.*; import java.net.*; -import java.lang.reflect.Constructor; -import javax.net.ssl.SSLSocket; /* JSSEImplementation: @@ -77,18 +75,33 @@ public class JSSEImplementation extends SSLImplementation { - static final String JSSE14SocketFactory = - "org.apache.tomcat.util.net.jsse.JSSE14SocketFactory"; - static final String JSSE14Support = - "org.apache.tomcat.util.net.jsse.JSSE14Support"; + static final String JSSE14Factory = + "org.apache.tomcat.util.net.jsse.JSSE14Factory"; + static final String JSSE13Factory = + "org.apache.tomcat.util.net.jsse.JSSE13Support"; static final String SSLSocketClass = "javax.net.ssl.SSLSocket"; static org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory.getLog(JSSEImplementation.class); + private JSSEFactory factory; + public JSSEImplementation() throws ClassNotFoundException { // Check to see if JSSE is floating around somewhere - Class.forName("javax.net.ssl.SSLServerSocketFactory"); + Class.forName(SSLSocketClass); + if( JdkCompat.isJava14() ) { + try { + Class factcl = Class.forName(JSSE14Factory); + factory = (JSSEFactory)factcl.newInstance(); + } catch(Exception ex) { + factory = new JSSE13Factory(); + if(logger.isDebugEnabled()) { + logger.debug("Error getting factory: " + JSSE14Factory, ex); + } + } + } else { + factory = new JSSE13Factory(); + } } @@ -96,47 +109,13 @@ return "JSSE"; } - public ServerSocketFactory getServerSocketFactory() - { - ServerSocketFactory ssf = null; - if( JdkCompat.isJava14() ) { - try { - Class ssfCl = Class.forName(JSSE14SocketFactory); - ssf =(ServerSocketFactory)ssfCl.newInstance(); - } catch(Exception ex) { - if(logger.isDebugEnabled()) - logger.debug("Error finding " + JSSE14SocketFactory, ex); - ssf = new JSSESocketFactory(); - } - } else { - ssf = new JSSESocketFactory(); - } + public ServerSocketFactory getServerSocketFactory() { + ServerSocketFactory ssf = factory.getSocketFactory(); return ssf; } - public SSLSupport getSSLSupport(Socket s) - { - SSLSupport ssls = null; - if( JdkCompat.isJava14() ) { - try { - Class sslsCl = Class.forName(JSSE14Support); - Class [] cparams = new Class[1]; - cparams[0] = Class.forName(SSLSocketClass); - Constructor sslc = sslsCl.getConstructor(cparams); - Object [] params = new Object[1]; - params[0] = s; - ssls = (SSLSupport)sslc.newInstance(params); - } catch(Exception ex) { - if(logger.isDebugEnabled()) - logger.debug("Unable to get " + JSSE14Support, ex); - ssls = new JSSESupport((SSLSocket)s); - } - } else { - ssls = new JSSESupport((SSLSocket)s); - } + public SSLSupport getSSLSupport(Socket s) { + SSLSupport ssls = factory.getSSLSupport(s); return ssls; } - - - } 1.1 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/jsse/JSSE13Factory.java Index: JSSE13Factory.java =================================================================== /* * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * [Additional notices, if required by prior licensing conditions] * */ package org.apache.tomcat.util.net.jsse; import java.net.Socket; import javax.net.ssl.SSLSocket; import org.apache.tomcat.util.net.SSLSupport; import org.apache.tomcat.util.net.ServerSocketFactory; /** * Implementation class for JSSEFactory for JSSE 1.0.x (that is an extension * to the 1.3 JVM). * * @author Bill Barker */ class JSSE13Factory implements JSSEFactory { JSSE13Factory() { } public ServerSocketFactory getSocketFactory() { return new JSSESocketFactory(); } public SSLSupport getSSLSupport(Socket socket) { return new JSSESupport((SSLSocket)socket); } } 1.1 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/jsse/JSSE14Factory.java Index: JSSE14Factory.java =================================================================== /* * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * [Additional notices, if required by prior licensing conditions] * */ package org.apache.tomcat.util.net.jsse; import java.net.Socket; import javax.net.ssl.SSLSocket; import org.apache.tomcat.util.net.SSLSupport; import org.apache.tomcat.util.net.ServerSocketFactory; /** * Implementation class for JSSEFactory for JSSE 1.1.x (that ships with the * 1.4 JVM). * * @author Bill Barker */ class JSSE14Factory implements JSSEFactory { JSSE14Factory() { } public ServerSocketFactory getSocketFactory() { return new JSSE14SocketFactory(); } public SSLSupport getSSLSupport(Socket socket) { return new JSSE14Support((SSLSocket)socket); } } 1.1 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/jsse/JSSEFactory.java Index: JSSEFactory.java =================================================================== /* * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * [Additional notices, if required by prior licensing conditions] * */ package org.apache.tomcat.util.net.jsse; import java.net.Socket; import org.apache.tomcat.util.net.SSLSupport; import org.apache.tomcat.util.net.ServerSocketFactory; /** * Factory interface to construct components based on the JSSE version * in use. * * @author Bill Barker */ interface JSSEFactory { /** * Returns the ServerSocketFactory to use. */ public ServerSocketFactory getSocketFactory(); /** * returns the SSLSupport attached to this socket. */ public SSLSupport getSSLSupport(Socket socket); };
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]