Author: markt
Date: Mon Jan 11 13:48:24 2016
New Revision: 1724024

URL: http://svn.apache.org/viewvc?rev=1724024&view=rev
Log:
Factory method for default instance is overly flexible. Simplify.
Add some Javadoc.

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/net/LocalStrings.properties
    tomcat/trunk/java/org/apache/tomcat/util/net/SSLImplementation.java

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/LocalStrings.properties
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/LocalStrings.properties?rev=1724024&r1=1724023&r2=1724024&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/LocalStrings.properties 
(original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/LocalStrings.properties Mon 
Jan 11 13:48:24 2016
@@ -121,3 +121,5 @@ sslHostConfig.certificateVerificationInv
 sslHostConfig.certificate.notype=Multiple certificates were specified and at 
least one is missing the required attribute type
 sslHostConfig.mismatch=The property [{0}] was set on the SSLHostConfig named 
[{1}] and is for connectors of type [{2}] but the SSLHostConfig is being used 
with a connector of type [{3}]
 sslHostConfig.prefix_missing=The protocol [{0}] was added to the list of 
protocols on the SSLHostConfig named [{1}]. Check if a +/- prefix is missing.
+
+sslImplementation.cnfe= Unable to create SSLImplementation for class [{0}]

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/SSLImplementation.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SSLImplementation.java?rev=1724024&r1=1724023&r2=1724024&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/SSLImplementation.java 
(original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/SSLImplementation.java Mon Jan 
11 13:48:24 2016
@@ -21,37 +21,42 @@ import javax.net.ssl.SSLSession;
 
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.net.jsse.JSSEImplementation;
+import org.apache.tomcat.util.res.StringManager;
 
-/* SSLImplementation:
-
- Abstract factory and base class for all SSL implementations.
-
- @author EKR
+/**
+ * Provides a factory and base implementation for the Tomcat specific mechanism
+ * that allows alternative SSL/TLS implementations to be used without requiring
+ * the implementation of a full JSSE provider.
  */
 public abstract class SSLImplementation {
-    private static final Log logger = 
LogFactory.getLog(SSLImplementation.class);
 
-    // The default implementations in our search path
-    private static final String JSSEImplementationClass =
-        "org.apache.tomcat.util.net.jsse.JSSEImplementation";
-
-    private static final String[] implementations = { JSSEImplementationClass 
};
-
-    public static SSLImplementation getInstance() throws 
ClassNotFoundException {
-        for (int i = 0; i < implementations.length; i++) {
-            try {
-                SSLImplementation impl = getInstance(implementations[i]);
-                return impl;
-            } catch (Exception e) {
-                if (logger.isTraceEnabled())
-                    logger.trace("Error creating " + implementations[i], e);
-            }
-        }
+    private static final Log logger = 
LogFactory.getLog(SSLImplementation.class);
+    private static final StringManager sm = 
StringManager.getManager(SSLImplementation.class);
 
-        // If we can't instantiate any of these
-        throw new ClassNotFoundException("Can't find any SSL implementation");
+    /**
+     * Obtain an instance (not a singleton) of the default implementation.
+     * Currently, this is the standard JSSE implementation that ships as part 
of
+     * the JRE. Tomcat also provides an OpenSSL based implementation.
+     *
+     * @return The default implementation
+     */
+    public static SSLImplementation getInstance() {
+        return new JSSEImplementation();
     }
 
+
+    /**
+     * Obtain an instance (not a singleton) of the implementation with the 
given
+     * class name.
+     *
+     * @param className The class name of the required implementation
+     *
+     * @return An instance of the required implementation
+     *
+     * @throws ClassNotFoundException If an instance of the requested class
+     *         cannot be created
+     */
     public static SSLImplementation getInstance(String className)
             throws ClassNotFoundException {
         if (className == null)
@@ -61,12 +66,15 @@ public abstract class SSLImplementation
             Class<?> clazz = Class.forName(className);
             return (SSLImplementation) clazz.newInstance();
         } catch (Exception e) {
-            if (logger.isDebugEnabled())
-                logger.debug("Error loading SSL Implementation " + className, 
e);
-            throw new ClassNotFoundException("Error loading SSL Implementation 
" + className, e);
+            String msg = sm.getString("sslImplementation.cnfe", className);
+            if (logger.isDebugEnabled()) {
+                logger.debug(msg, e);
+            }
+            throw new ClassNotFoundException(msg, e);
         }
     }
 
+
     public abstract String getImplementationName();
 
     public abstract SSLSupport getSSLSupport(SSLSession session);



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to