Author: remm
Date: Fri Apr 21 04:04:05 2006
New Revision: 395849

URL: http://svn.apache.org/viewcvs?rev=395849&view=rev
Log:
- Remove pre 1.5 compatibility code, which is not used anymore as the new APIs 
require and use 
  JDK 1.5+. I hope I didn't make any mistake merging the SSL code.

Removed:
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/compat/Jdk14Compat.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/compat/JdkCompat.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/jsse/JSSE13Factory.java
    
tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/jsse/JSSE13SocketFactory.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/jsse/JSSE14Factory.java
    
tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/jsse/JSSE14SocketFactory.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/jsse/JSSE14Support.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/jsse/JSSE15Factory.java
    
tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/jsse/JSSE15SocketFactory.java
Modified:
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Response.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardContext.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoader.java
    
tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/DefaultContextMBean.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/GroupMBean.java
    
tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/MemoryUserDatabaseMBean.java
    
tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/NamingResourcesMBean.java
    
tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/StandardContextMBean.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/UserMBean.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/valves/ErrorReportValve.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/valves/RequestFilterValve.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/jsse/JSSEFactory.java
    
tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/jsse/JSSEImplementation.java
    
tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/jsse/JSSESupport.java

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Response.java
URL: 
http://svn.apache.org/viewcvs/tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Response.java?rev=395849&r1=395848&r2=395849&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Response.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Response.java Fri 
Apr 21 04:04:05 2006
@@ -40,17 +40,16 @@
 import org.apache.catalina.Context;
 import org.apache.catalina.Session;
 import org.apache.catalina.Wrapper;
+import org.apache.catalina.security.SecurityUtil;
 import org.apache.catalina.util.CharsetMapper;
 import org.apache.catalina.util.DateTool;
 import org.apache.catalina.util.StringManager;
-import org.apache.catalina.security.SecurityUtil;
 import org.apache.tomcat.util.buf.CharChunk;
 import org.apache.tomcat.util.buf.UEncoder;
 import org.apache.tomcat.util.http.FastHttpDateFormat;
 import org.apache.tomcat.util.http.MimeHeaders;
 import org.apache.tomcat.util.http.ServerCookie;
 import org.apache.tomcat.util.net.URL;
-import org.apache.tomcat.util.compat.JdkCompat;
 
 /**
  * Wrapper object for the Coyote response.
@@ -80,12 +79,6 @@
 
 
     /**
-     * JDK compatibility support
-     */
-    private static final JdkCompat jdkCompat = JdkCompat.getJdkCompat();
-
-
-    /**
      * Descriptive information about this Response implementation.
      */
     protected static final String info =
@@ -1477,7 +1470,7 @@
                         } catch (PrivilegedActionException pae){
                             IllegalArgumentException iae =
                                 new IllegalArgumentException(location);
-                            jdkCompat.chainException(iae, pae.getException());
+                            iae.initCause(pae.getException());
                             throw iae;
                         }
                     } else {
@@ -1490,7 +1483,7 @@
             } catch (IOException e) {
                 IllegalArgumentException iae =
                     new IllegalArgumentException(location);
-                jdkCompat.chainException(iae, e);
+                iae.initCause(e);
                 throw iae;
             }
 

Modified: 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardContext.java
URL: 
http://svn.apache.org/viewcvs/tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardContext.java?rev=395849&r1=395848&r2=395849&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardContext.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardContext.java Fri 
Apr 21 04:04:05 2006
@@ -97,7 +97,6 @@
 import org.apache.naming.resources.FileDirContext;
 import org.apache.naming.resources.ProxyDirContext;
 import org.apache.naming.resources.WARDirContext;
-import org.apache.tomcat.util.compat.JdkCompat;
 import org.apache.tomcat.util.modeler.Registry;
 
 /**
@@ -140,12 +139,6 @@
      */
     private static final String info =
         "org.apache.catalina.core.StandardContext/1.0";
-
-
-    /**
-     * JDK compatibility support
-     */
-    private static final JdkCompat jdkCompat = JdkCompat.getJdkCompat();
 
 
     /**

Modified: 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoader.java
URL: 
http://svn.apache.org/viewcvs/tomcat/tc6.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoader.java?rev=395849&r1=395848&r2=395849&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoader.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoader.java 
Fri Apr 21 04:04:05 2006
@@ -62,7 +62,6 @@
 import org.apache.naming.resources.Resource;
 import org.apache.naming.resources.ResourceAttributes;
 import org.apache.tomcat.util.IntrospectionUtils;
-import org.apache.tomcat.util.compat.JdkCompat;
 
 /**
  * Specialized web application class loader.
@@ -142,11 +141,6 @@
         "javax.servlet.Servlet"                     // Servlet API
     };
 
-    /** 
-     * Jdk Compatibility Support.
-     */
-    protected static JdkCompat jdkCompat = JdkCompat.getJdkCompat();
-
     /**
      * Set of package names which are not allowed to be loaded from a webapp
      * class loader without delegating first.
@@ -548,7 +542,7 @@
         } catch (MalformedURLException e) {
             IllegalArgumentException iae = new IllegalArgumentException
                 ("Invalid repository: " + repository); 
-            jdkCompat.chainException(iae, e);
+            iae.initCause(e);
             throw iae;
         }
 
@@ -2300,7 +2294,14 @@
     protected URL getURI(File file)
         throws MalformedURLException {
 
-        return jdkCompat.getURI(file);
+        File realFile = file;
+        try {
+            realFile = realFile.getCanonicalFile();
+        } catch (IOException e) {
+            // Ignore
+        }
+
+        return realFile.toURI().toURL();
 
     }
 

Modified: 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/DefaultContextMBean.java
URL: 
http://svn.apache.org/viewcvs/tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/DefaultContextMBean.java?rev=395849&r1=395848&r2=395849&view=diff
==============================================================================
--- 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/DefaultContextMBean.java 
(original)
+++ 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/DefaultContextMBean.java 
Fri Apr 21 04:04:05 2006
@@ -28,7 +28,6 @@
 import org.apache.catalina.deploy.ContextResource;
 import org.apache.catalina.deploy.ContextResourceLink;
 import org.apache.catalina.deploy.NamingResources;
-import org.apache.tomcat.util.compat.JdkCompat;
 import org.apache.tomcat.util.modeler.BaseModelMBean;
 import org.apache.tomcat.util.modeler.ManagedBean;
 import org.apache.tomcat.util.modeler.Registry;
@@ -64,15 +63,6 @@
     }
     
 
-    // ----------------------------------------------------- Class Variables
-
-
-    /**
-     * JDK compatibility support
-     */
-    private static final JdkCompat jdkCompat = JdkCompat.getJdkCompat();
-
-
     // ----------------------------------------------------- Instance Variables
     
     
@@ -116,7 +106,7 @@
             } catch (MalformedObjectNameException e) {
                 IllegalArgumentException iae = new IllegalArgumentException
                     ("Cannot create object name for environment " + envs[i]);
-                jdkCompat.chainException(iae, e);
+                iae.initCause(e);
                 throw iae;
             }
         }
@@ -141,7 +131,7 @@
             } catch (MalformedObjectNameException e) {
                 IllegalArgumentException iae = new IllegalArgumentException
                     ("Cannot create object name for resource " + resources[i]);
-                jdkCompat.chainException(iae, e);
+                iae.initCause(e);
                 throw iae;
             }
         }
@@ -166,7 +156,7 @@
             } catch (MalformedObjectNameException e) {
                 IllegalArgumentException iae = new IllegalArgumentException
                     ("Cannot create object name for resource " + links[i]);
-                jdkCompat.chainException(iae, e);
+                iae.initCause(e);
                 throw iae;
             }
         }

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/GroupMBean.java
URL: 
http://svn.apache.org/viewcvs/tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/GroupMBean.java?rev=395849&r1=395848&r2=395849&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/GroupMBean.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/GroupMBean.java Fri 
Apr 21 04:04:05 2006
@@ -29,7 +29,6 @@
 import org.apache.catalina.Group;
 import org.apache.catalina.Role;
 import org.apache.catalina.User;
-import org.apache.tomcat.util.compat.JdkCompat;
 import org.apache.tomcat.util.modeler.BaseModelMBean;
 import org.apache.tomcat.util.modeler.ManagedBean;
 import org.apache.tomcat.util.modeler.Registry;
@@ -65,15 +64,6 @@
     }
 
 
-    // ----------------------------------------------------- Class Variables
-
-
-    /**
-     * JDK compatibility support
-     */
-    private static final JdkCompat jdkCompat = JdkCompat.getJdkCompat();
-
-
     // ----------------------------------------------------- Instance Variables
 
 
@@ -117,7 +107,7 @@
             } catch (MalformedObjectNameException e) {
                 IllegalArgumentException iae = new IllegalArgumentException
                     ("Cannot create object name for role " + role);
-                jdkCompat.chainException(iae, e);
+                iae.initCause(e);
                 throw iae;
             }
         }
@@ -144,7 +134,7 @@
             } catch (MalformedObjectNameException e) {
                 IllegalArgumentException iae = new IllegalArgumentException
                     ("Cannot create object name for user " + user);
-                jdkCompat.chainException(iae, e);
+                iae.initCause(e);
                 throw iae;
             }
         }

Modified: 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/MemoryUserDatabaseMBean.java
URL: 
http://svn.apache.org/viewcvs/tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/MemoryUserDatabaseMBean.java?rev=395849&r1=395848&r2=395849&view=diff
==============================================================================
--- 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/MemoryUserDatabaseMBean.java
 (original)
+++ 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/MemoryUserDatabaseMBean.java
 Fri Apr 21 04:04:05 2006
@@ -19,16 +19,17 @@
 
 import java.util.ArrayList;
 import java.util.Iterator;
-import javax.management.MalformedObjectNameException;
+
 import javax.management.MBeanException;
 import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 import javax.management.RuntimeOperationsException;
+
 import org.apache.catalina.Group;
 import org.apache.catalina.Role;
 import org.apache.catalina.User;
 import org.apache.catalina.UserDatabase;
-import org.apache.tomcat.util.compat.JdkCompat;
 import org.apache.tomcat.util.modeler.BaseModelMBean;
 import org.apache.tomcat.util.modeler.ManagedBean;
 import org.apache.tomcat.util.modeler.Registry;
@@ -64,15 +65,6 @@
     }
 
 
-    // ----------------------------------------------------- Class Variables
-
-
-    /**
-     * JDK compatibility support
-     */
-    private static final JdkCompat jdkCompat = JdkCompat.getJdkCompat();
-
-
     // ----------------------------------------------------- Instance Variables
 
 
@@ -188,7 +180,7 @@
         } catch (Exception e) {
             IllegalArgumentException iae = new IllegalArgumentException
                 ("Exception creating group " + group + " MBean");
-            jdkCompat.chainException(iae, e);
+            iae.initCause(e);
             throw iae;
         }
         return (findGroup(groupname));
@@ -211,7 +203,7 @@
         } catch (Exception e) {
             IllegalArgumentException iae = new IllegalArgumentException
                 ("Exception creating role " + role + " MBean");
-            jdkCompat.chainException(iae, e);
+            iae.initCause(e);
             throw iae;
         }
         return (findRole(rolename));
@@ -236,7 +228,7 @@
         } catch (Exception e) {
             IllegalArgumentException iae = new IllegalArgumentException
                 ("Exception creating user " + user + " MBean");
-            jdkCompat.chainException(iae, e);
+            iae.initCause(e);
             throw iae;
         }
         return (findUser(username));
@@ -264,7 +256,7 @@
         } catch (MalformedObjectNameException e) {
             IllegalArgumentException iae = new IllegalArgumentException
                 ("Cannot create object name for group " + group);
-            jdkCompat.chainException(iae, e);
+            iae.initCause(e);
             throw iae;
         }
 
@@ -291,7 +283,7 @@
         } catch (MalformedObjectNameException e) {
             IllegalArgumentException iae = new IllegalArgumentException
                 ("Cannot create object name for role " + role);
-            jdkCompat.chainException(iae, e);
+            iae.initCause(e);
             throw iae;
         }
 
@@ -318,7 +310,7 @@
         } catch (MalformedObjectNameException e) {
             IllegalArgumentException iae = new IllegalArgumentException
                 ("Cannot create object name for user " + user);
-            jdkCompat.chainException(iae, e);
+            iae.initCause(e);
             throw iae;
         }
 
@@ -343,7 +335,7 @@
         } catch (Exception e) {
             IllegalArgumentException iae = new IllegalArgumentException
                 ("Exception destroying group " + group + " MBean");
-            jdkCompat.chainException(iae, e);
+            iae.initCause(e);
             throw iae;
         }
 
@@ -368,7 +360,7 @@
         } catch (Exception e) {
             IllegalArgumentException iae = new IllegalArgumentException
                 ("Exception destroying role " + role + " MBean");
-            jdkCompat.chainException(iae, e);
+            iae.initCause(e);
             throw iae;
         }
 
@@ -393,7 +385,7 @@
         } catch (Exception e) {
             IllegalArgumentException iae = new IllegalArgumentException
                 ("Exception destroying user " + user + " MBean");
-            jdkCompat.chainException(iae, e);
+            iae.initCause(e);
             throw iae;
         }
 

Modified: 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/NamingResourcesMBean.java
URL: 
http://svn.apache.org/viewcvs/tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/NamingResourcesMBean.java?rev=395849&r1=395848&r2=395849&view=diff
==============================================================================
--- 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/NamingResourcesMBean.java 
(original)
+++ 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/NamingResourcesMBean.java 
Fri Apr 21 04:04:05 2006
@@ -27,7 +27,6 @@
 import org.apache.catalina.deploy.ContextResource;
 import org.apache.catalina.deploy.ContextResourceLink;
 import org.apache.catalina.deploy.NamingResources;
-import org.apache.tomcat.util.compat.JdkCompat;
 import org.apache.tomcat.util.modeler.BaseModelMBean;
 import org.apache.tomcat.util.modeler.ManagedBean;
 import org.apache.tomcat.util.modeler.Registry;
@@ -63,15 +62,6 @@
     }
 
 
-    // ----------------------------------------------------- Class Variables
-
-
-    /**
-     * JDK compatibility support
-     */
-    private static final JdkCompat jdkCompat = JdkCompat.getJdkCompat();
-
-
     // ----------------------------------------------------- Instance Variables
     
     /**
@@ -105,7 +95,7 @@
             } catch (MalformedObjectNameException e) {
                 IllegalArgumentException iae = new IllegalArgumentException
                     ("Cannot create object name for environment " + envs[i]);
-                jdkCompat.chainException(iae, e);
+                iae.initCause(e);
                 throw iae;
             }
         }
@@ -131,7 +121,7 @@
             } catch (MalformedObjectNameException e) {
                 IllegalArgumentException iae = new IllegalArgumentException
                     ("Cannot create object name for resource " + resources[i]);
-                jdkCompat.chainException(iae, e);
+                iae.initCause(e);
                 throw iae;
             }
         }
@@ -157,7 +147,7 @@
             } catch (MalformedObjectNameException e) {
                 IllegalArgumentException iae = new IllegalArgumentException
                     ("Cannot create object name for resource " + 
resourceLinks[i]);
-                jdkCompat.chainException(iae, e);
+                iae.initCause(e);
                 throw iae;
             }
         }

Modified: 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/StandardContextMBean.java
URL: 
http://svn.apache.org/viewcvs/tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/StandardContextMBean.java?rev=395849&r1=395848&r2=395849&view=diff
==============================================================================
--- 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/StandardContextMBean.java 
(original)
+++ 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/StandardContextMBean.java 
Fri Apr 21 04:04:05 2006
@@ -28,7 +28,6 @@
 import org.apache.catalina.deploy.ContextResource;
 import org.apache.catalina.deploy.ContextResourceLink;
 import org.apache.catalina.deploy.NamingResources;
-import org.apache.tomcat.util.compat.JdkCompat;
 import org.apache.tomcat.util.modeler.BaseModelMBean;
 import org.apache.tomcat.util.modeler.ManagedBean;
 import org.apache.tomcat.util.modeler.Registry;
@@ -64,15 +63,6 @@
     }
     
 
-    // ----------------------------------------------------- Class Variables
-
-
-    /**
-     * JDK compatibility support
-     */
-    private static final JdkCompat jdkCompat = JdkCompat.getJdkCompat();
-
-
     // ----------------------------------------------------- Instance Variables
     
     
@@ -125,7 +115,7 @@
             } catch (MalformedObjectNameException e) {
                 IllegalArgumentException iae = new IllegalArgumentException
                     ("Cannot create object name for environment " + envs[i]);
-                jdkCompat.chainException(iae, e);
+                iae.initCause(e);
                 throw iae;
             }
         }
@@ -150,7 +140,7 @@
             } catch (MalformedObjectNameException e) {
                 IllegalArgumentException iae = new IllegalArgumentException
                     ("Cannot create object name for resource " + resources[i]);
-                jdkCompat.chainException(iae, e);
+                iae.initCause(e);
                 throw iae;
             }
         }
@@ -175,7 +165,7 @@
             } catch (MalformedObjectNameException e) {
                 IllegalArgumentException iae = new IllegalArgumentException
                     ("Cannot create object name for resource " + links[i]);
-                jdkCompat.chainException(iae, e);
+                iae.initCause(e);
                 throw iae;
             }
         }

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/UserMBean.java
URL: 
http://svn.apache.org/viewcvs/tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/UserMBean.java?rev=395849&r1=395848&r2=395849&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/UserMBean.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/mbeans/UserMBean.java Fri Apr 
21 04:04:05 2006
@@ -29,7 +29,6 @@
 import org.apache.catalina.Group;
 import org.apache.catalina.Role;
 import org.apache.catalina.User;
-import org.apache.tomcat.util.compat.JdkCompat;
 import org.apache.tomcat.util.modeler.BaseModelMBean;
 import org.apache.tomcat.util.modeler.ManagedBean;
 import org.apache.tomcat.util.modeler.Registry;
@@ -65,15 +64,6 @@
     }
 
 
-    // ----------------------------------------------------- Class Variables
-
-
-    /**
-     * JDK compatibility support
-     */
-    private static final JdkCompat jdkCompat = JdkCompat.getJdkCompat();
-
-
     // ----------------------------------------------------- Instance Variables
 
 
@@ -117,7 +107,7 @@
             } catch (MalformedObjectNameException e) {
                 IllegalArgumentException iae = new IllegalArgumentException
                     ("Cannot create object name for group " + group);
-                jdkCompat.chainException(iae, e);
+                iae.initCause(e);
                 throw iae;
             }
         }
@@ -144,7 +134,7 @@
             } catch (MalformedObjectNameException e) {
                 IllegalArgumentException iae = new IllegalArgumentException
                     ("Cannot create object name for role " + role);
-                jdkCompat.chainException(iae, e);
+                iae.initCause(e);
                 throw iae;
             }
         }

Modified: 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/valves/ErrorReportValve.java
URL: 
http://svn.apache.org/viewcvs/tomcat/tc6.0.x/trunk/java/org/apache/catalina/valves/ErrorReportValve.java?rev=395849&r1=395848&r2=395849&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/valves/ErrorReportValve.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/valves/ErrorReportValve.java 
Fri Apr 21 04:04:05 2006
@@ -33,7 +33,6 @@
 import org.apache.catalina.util.ServerInfo;
 import org.apache.catalina.util.StringManager;
 import org.apache.tomcat.util.IntrospectionUtils;
-import org.apache.tomcat.util.compat.JdkCompat;
 
 /**
  * <p>Implementation of a Valve that outputs HTML error pages.</p>
@@ -220,8 +219,7 @@
 
         if (throwable != null) {
 
-            String stackTrace = JdkCompat.getJdkCompat()
-                .getPartialServletStackTrace(throwable);
+            String stackTrace = getPartialServletStackTrace(throwable);
             sb.append("<p><b>");
             sb.append(sm.getString("errorReportValve.exception"));
             sb.append("</b> <pre>");
@@ -229,8 +227,7 @@
             sb.append("</pre></p>");
 
             while (rootCause != null) {
-                stackTrace = JdkCompat.getJdkCompat()
-                    .getPartialServletStackTrace(rootCause);
+                stackTrace = getPartialServletStackTrace(rootCause);
                 sb.append("<p><b>");
                 sb.append(sm.getString("errorReportValve.rootCause"));
                 sb.append("</b> <pre>");
@@ -280,5 +277,30 @@
         
     }
 
+
+    /**
+     * Print out a partial servlet stack trace (truncating at the last 
+     * occurrence of javax.servlet.).
+     */
+    protected String getPartialServletStackTrace(Throwable t) {
+        StringBuffer trace = new StringBuffer();
+        trace.append(t.toString()).append('\n');
+        StackTraceElement[] elements = t.getStackTrace();
+        int pos = elements.length;
+        for (int i = 0; i < elements.length; i++) {
+            if ((elements[i].getClassName().startsWith
+                 ("org.apache.catalina.core.ApplicationFilterChain"))
+                && (elements[i].getMethodName().equals("internalDoFilter"))) {
+                pos = i;
+            }
+        }
+        for (int i = 0; i < pos; i++) {
+            if (!(elements[i].getClassName().startsWith
+                  ("org.apache.catalina.core."))) {
+                trace.append('\t').append(elements[i].toString()).append('\n');
+            }
+        }
+        return trace.toString();
+    }
 
 }

Modified: 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/valves/RequestFilterValve.java
URL: 
http://svn.apache.org/viewcvs/tomcat/tc6.0.x/trunk/java/org/apache/catalina/valves/RequestFilterValve.java?rev=395849&r1=395848&r2=395849&view=diff
==============================================================================
--- 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/valves/RequestFilterValve.java 
(original)
+++ 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/valves/RequestFilterValve.java 
Fri Apr 21 04:04:05 2006
@@ -29,7 +29,6 @@
 import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
 import org.apache.catalina.util.StringManager;
-import org.apache.tomcat.util.compat.JdkCompat;
 
 /**
  * Implementation of a Valve that performs filtering based on comparing the
@@ -73,12 +72,6 @@
 
 
     /**
-     * JDK compatibility support
-     */
-    private static final JdkCompat jdkCompat = JdkCompat.getJdkCompat();
-
-
-    /**
      * The descriptive information related to this implementation.
      */
     private static final String info =
@@ -234,7 +227,7 @@
             } catch (PatternSyntaxException e) {
                 IllegalArgumentException iae = new IllegalArgumentException
                     (sm.getString("requestFilterValve.syntax", pattern));
-                jdkCompat.chainException(iae, e);
+                iae.initCause(e);
                 throw iae;
             }
             list = list.substring(comma + 1);

Modified: 
tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/jsse/JSSEFactory.java
URL: 
http://svn.apache.org/viewcvs/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/jsse/JSSEFactory.java?rev=395849&r1=395848&r2=395849&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/jsse/JSSEFactory.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/jsse/JSSEFactory.java 
Fri Apr 21 04:04:05 2006
@@ -17,6 +17,9 @@
 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;
 
@@ -27,16 +30,20 @@
  * @author Bill Barker
  */
 
-interface JSSEFactory {
+public class JSSEFactory {
 
     /**
      * Returns the ServerSocketFactory to use.
      */
-    public ServerSocketFactory getSocketFactory();
+    public ServerSocketFactory getSocketFactory() {
+        return new JSSESocketFactory();
+    }
 
     /**
      * returns the SSLSupport attached to this socket.
      */
-    public SSLSupport getSSLSupport(Socket socket);
+    public SSLSupport getSSLSupport(Socket socket) {
+        return new JSSESupport((SSLSocket)socket);
+    }
 
 };

Modified: 
tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/jsse/JSSEImplementation.java
URL: 
http://svn.apache.org/viewcvs/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/jsse/JSSEImplementation.java?rev=395849&r1=395848&r2=395849&view=diff
==============================================================================
--- 
tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/jsse/JSSEImplementation.java
 (original)
+++ 
tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/jsse/JSSEImplementation.java
 Fri Apr 21 04:04:05 2006
@@ -18,7 +18,6 @@
 
 import java.net.Socket;
 
-import org.apache.tomcat.util.compat.JdkCompat;
 import org.apache.tomcat.util.net.SSLImplementation;
 import org.apache.tomcat.util.net.SSLSupport;
 import org.apache.tomcat.util.net.ServerSocketFactory;
@@ -32,12 +31,6 @@
         
 public class JSSEImplementation extends SSLImplementation
 {
-    static final String JSSE15Factory =
-       "org.apache.tomcat.util.net.jsse.JSSE15Factory";
-    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 = 
@@ -48,27 +41,7 @@
     public JSSEImplementation() throws ClassNotFoundException {
         // Check to see if JSSE is floating around somewhere
         Class.forName(SSLSocketClass);
-        if( JdkCompat.isJava15() ) {
-            try {
-                Class factcl = Class.forName(JSSE15Factory);
-                factory = (JSSEFactory)factcl.newInstance();
-            } catch(Exception ex) {
-                if(logger.isDebugEnabled())
-                    logger.debug("Error getting factory: " + JSSE15Factory, 
ex);
-            }
-        }
-        if(factory == null && JdkCompat.isJava14() ) {
-            try {
-                Class factcl = Class.forName(JSSE14Factory);
-                factory = (JSSEFactory)factcl.newInstance();
-            } catch(Exception ex) {
-                if(logger.isDebugEnabled()) {
-                    logger.debug("Error getting factory: " + JSSE14Factory, 
ex);
-                }
-            }
-        } if(factory == null) {
-            factory = new JSSE13Factory();
-        }
+        factory = new JSSEFactory();
     }
 
 

Modified: 
tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java
URL: 
http://svn.apache.org/viewcvs/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java?rev=395849&r1=395848&r2=395849&view=diff
==============================================================================
--- 
tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java
 (original)
+++ 
tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java
 Fri Apr 21 04:04:05 2006
@@ -26,12 +26,34 @@
 import java.net.Socket;
 import java.net.SocketException;
 import java.security.KeyStore;
+import java.security.SecureRandom;
+import java.security.cert.CRL;
+import java.security.cert.CRLException;
+import java.security.cert.CertPathParameters;
+import java.security.cert.CertStore;
+import java.security.cert.CertStoreParameters;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.CollectionCertStoreParameters;
+import java.security.cert.PKIXBuilderParameters;
+import java.security.cert.X509CertSelector;
+import java.util.Collection;
 import java.util.Vector;
 
+import javax.net.ssl.CertPathTrustManagerParameters;
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.ManagerFactoryParameters;
+import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLException;
 import javax.net.ssl.SSLServerSocket;
 import javax.net.ssl.SSLServerSocketFactory;
 import javax.net.ssl.SSLSocket;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactory;
+import javax.net.ssl.X509KeyManager;
+
+import org.apache.tomcat.util.res.StringManager;
 
 /*
   1. Make the JSSE's jars available, either as an installed
@@ -49,10 +71,15 @@
  * @author Costin Manolache
  * @author Stefan Freyr Stefansson
  * @author EKR -- renamed to JSSESocketFactory
+ * @author Jan Luehe
+ * @author Bill Barker
  */
-public abstract class JSSESocketFactory
-    extends org.apache.tomcat.util.net.ServerSocketFactory
-{
+public class JSSESocketFactory
+    extends org.apache.tomcat.util.net.ServerSocketFactory {
+
+    private static StringManager sm =
+        StringManager.getManager("org.apache.tomcat.util.net.jsse.res");
+
     // defaults
     static String defaultProtocol = "TLS";
     static String defaultAlgorithm = "SunX509";
@@ -68,7 +95,17 @@
     protected String clientAuth = "false";
     protected SSLServerSocketFactory sslProxy = null;
     protected String[] enabledCiphers;
-   
+
+    /**
+     * Flag to state that we require client authentication.
+     */
+    protected boolean requireClientAuth = false;
+
+    /**
+     * Flag to state that we would like client authentication.
+     */
+    protected boolean wantClientAuth    = false;
+
 
     public JSSESocketFactory () {
     }
@@ -303,12 +340,214 @@
 
     /**
      * Reads the keystore and initializes the SSL socket factory.
-     *
-     * Place holder method to initialize the KeyStore, etc.
      */
-    abstract void init() throws IOException ;
+    void init() throws IOException {
+        try {
 
-    /*
+            String clientAuthStr = (String) attributes.get("clientauth");
+            if("true".equalsIgnoreCase(clientAuthStr) ||
+               "yes".equalsIgnoreCase(clientAuthStr)) {
+                requireClientAuth = true;
+            } else if("want".equalsIgnoreCase(clientAuthStr)) {
+                wantClientAuth = true;
+            }
+
+            // SSL protocol variant (e.g., TLS, SSL v3, etc.)
+            String protocol = (String) attributes.get("protocol");
+            if (protocol == null) {
+                protocol = defaultProtocol;
+            }
+
+            // Certificate encoding algorithm (e.g., SunX509)
+            String algorithm = (String) attributes.get("algorithm");
+            if (algorithm == null) {
+                algorithm = defaultAlgorithm;
+            }
+
+            String keystoreType = (String) attributes.get("keystoreType");
+            if (keystoreType == null) {
+                keystoreType = defaultKeystoreType;
+            }
+
+        String trustAlgorithm = (String)attributes.get("truststoreAlgorithm");
+        if( trustAlgorithm == null ) {
+        trustAlgorithm = algorithm;
+        }
+            // Create and init SSLContext
+            SSLContext context = SSLContext.getInstance(protocol); 
+            context.init(getKeyManagers(keystoreType, algorithm,
+                                        (String) attributes.get("keyAlias")),
+                         getTrustManagers(keystoreType, trustAlgorithm),
+                         new SecureRandom());
+
+            // create proxy
+            sslProxy = context.getServerSocketFactory();
+
+            // Determine which cipher suites to enable
+            String requestedCiphers = (String)attributes.get("ciphers");
+            enabledCiphers = getEnabledCiphers(requestedCiphers,
+                                               
sslProxy.getSupportedCipherSuites());
+
+        } catch(Exception e) {
+            if( e instanceof IOException )
+                throw (IOException)e;
+            throw new IOException(e.getMessage());
+        }
+    }
+
+    /**
+     * Gets the initialized key managers.
+     */
+    protected KeyManager[] getKeyManagers(String keystoreType,
+                                          String algorithm,
+                                          String keyAlias)
+                throws Exception {
+
+        KeyManager[] kms = null;
+
+        String keystorePass = getKeystorePassword();
+
+        KeyStore ks = getKeystore(keystoreType, keystorePass);
+        if (keyAlias != null && !ks.isKeyEntry(keyAlias)) {
+            throw new IOException(sm.getString("jsse.alias_no_key_entry", 
keyAlias));
+        }
+
+        KeyManagerFactory kmf = KeyManagerFactory.getInstance(algorithm);
+        kmf.init(ks, keystorePass.toCharArray());
+
+        kms = kmf.getKeyManagers();
+        if (keyAlias != null) {
+            if (JSSESocketFactory.defaultKeystoreType.equals(keystoreType)) {
+                keyAlias = keyAlias.toLowerCase();
+            }
+            for(int i=0; i<kms.length; i++) {
+                kms[i] = new JSSEKeyManager((X509KeyManager)kms[i], keyAlias);
+            }
+        }
+
+        return kms;
+    }
+
+    /**
+     * Gets the intialized trust managers.
+     */
+    protected TrustManager[] getTrustManagers(String keystoreType, String 
algorithm)
+        throws Exception {
+        if (attributes.get("truststoreAlgorithm") == null) {
+            // in 1.5, the Trust default isn't the same as the Key default.
+            algorithm = TrustManagerFactory.getDefaultAlgorithm();
+        }
+        String crlf = (String) attributes.get("crlFile");
+        
+        TrustManager[] tms = null;
+        
+        String truststoreType = (String) attributes.get("truststoreType");
+        if (truststoreType == null) {
+            truststoreType = keystoreType;
+        }
+        KeyStore trustStore = getTrustStore(truststoreType);
+        if (trustStore != null) {
+            if (crlf == null) {
+                TrustManagerFactory tmf = 
TrustManagerFactory.getInstance(algorithm);
+                tmf.init(trustStore);
+                tms = tmf.getTrustManagers();
+            } else {
+                TrustManagerFactory tmf = 
TrustManagerFactory.getInstance(algorithm);
+                CertPathParameters params = getParameters(algorithm, crlf, 
trustStore);
+                ManagerFactoryParameters mfp = new 
CertPathTrustManagerParameters(params);
+                tmf.init(mfp);
+                tms = tmf.getTrustManagers();
+            }
+        }
+        
+        return tms;
+    }
+    
+    /**
+     * Return the initialization parameters for the TrustManager.
+     * Currently, only the default <code>PKIX</code> is supported.
+     * 
+     * @param algorithm The algorithm to get parameters for.
+     * @param crlf The path to the CRL file.
+     * @param trustStore The configured TrustStore.
+     * @return The parameters including the CRLs and TrustStore.
+     */
+    protected CertPathParameters getParameters(String algorithm, 
+                                                String crlf, 
+                                                KeyStore trustStore)
+        throws Exception {
+        CertPathParameters params = null;
+        if("PKIX".equalsIgnoreCase(algorithm)) {
+            PKIXBuilderParameters xparams = new 
PKIXBuilderParameters(trustStore, 
+                                                                     new 
X509CertSelector());
+            Collection crls = getCRLs(crlf);
+            CertStoreParameters csp = new CollectionCertStoreParameters(crls);
+            CertStore store = CertStore.getInstance("Collection", csp);
+            xparams.addCertStore(store);
+            xparams.setRevocationEnabled(true);
+            String trustLength = (String)attributes.get("trustMaxCertLength");
+            if(trustLength != null) {
+                try {
+                    xparams.setMaxPathLength(Integer.parseInt(trustLength));
+                } catch(Exception ex) {
+                    log.warn("Bad maxCertLength: "+trustLength);
+                }
+            }
+
+            params = xparams;
+        } else {
+            throw new CRLException("CRLs not supported for type: "+algorithm);
+        }
+        return params;
+    }
+
+
+    /**
+     * Load the collection of CRLs.
+     * 
+     */
+    protected Collection<? extends CRL> getCRLs(String crlf) 
+        throws IOException, CRLException, CertificateException {
+
+        File crlFile = new File(crlf);
+        if( !crlFile.isAbsolute() ) {
+            crlFile = new File(System.getProperty("catalina.base"), crlf);
+        }
+        Collection<? extends CRL> crls = null;
+        InputStream is = null;
+        try {
+            CertificateFactory cf = CertificateFactory.getInstance("X.509");
+            is = new FileInputStream(crlFile);
+            crls = cf.generateCRLs(is);
+        } catch(IOException iex) {
+            throw iex;
+        } catch(CRLException crle) {
+            throw crle;
+        } catch(CertificateException ce) {
+            throw ce;
+        } finally { 
+            if(is != null) {
+                try{
+                    is.close();
+                } catch(Exception ex) {
+                }
+            }
+        }
+        return crls;
+    }
+
+    /**
+     * Set the SSL protocol variants to be enabled.
+     * @param socket the SSLServerSocket.
+     * @param protocols the protocols to use.
+     */
+    protected void setEnabledProtocols(SSLServerSocket socket, String 
[]protocols){
+        if (protocols != null) {
+            socket.setEnabledProtocols(protocols);
+        }
+    }
+
+    /**
      * Determines the SSL protocol variants to be enabled.
      *
      * @param socket The socket to get supported list from.
@@ -318,16 +557,70 @@
      * @return Array of SSL protocol variants to be enabled, or null if none of
      * the requested protocol variants are supported
      */
-    abstract protected String[] getEnabledProtocols(SSLServerSocket socket,
-                                                    String requestedProtocols);
+    protected String[] getEnabledProtocols(SSLServerSocket socket,
+                                           String requestedProtocols){
+        String[] supportedProtocols = socket.getSupportedProtocols();
 
-    /**
-     * Set the SSL protocol variants to be enabled.
-     * @param socket the SSLServerSocket.
-     * @param protocols the protocols to use.
-     */
-    abstract protected void setEnabledProtocols(SSLServerSocket socket, 
-                                            String [] protocols);
+        String[] enabledProtocols = null;
+
+        if (requestedProtocols != null) {
+            Vector vec = null;
+            String protocol = requestedProtocols;
+            int index = requestedProtocols.indexOf(',');
+            if (index != -1) {
+                int fromIndex = 0;
+                while (index != -1) {
+                    protocol = requestedProtocols.substring(fromIndex, 
index).trim();
+                    if (protocol.length() > 0) {
+                        /*
+                         * Check to see if the requested protocol is among the
+                         * supported protocols, i.e., may be enabled
+                         */
+                        for (int i=0; supportedProtocols != null
+                                     && i<supportedProtocols.length; i++) {
+                            if (supportedProtocols[i].equals(protocol)) {
+                                if (vec == null) {
+                                    vec = new Vector();
+                                }
+                                vec.addElement(protocol);
+                                break;
+                            }
+                        }
+                    }
+                    fromIndex = index+1;
+                    index = requestedProtocols.indexOf(',', fromIndex);
+                } // while
+                protocol = requestedProtocols.substring(fromIndex);
+            }
+
+            if (protocol != null) {
+                protocol = protocol.trim();
+                if (protocol.length() > 0) {
+                    /*
+                     * Check to see if the requested protocol is among the
+                     * supported protocols, i.e., may be enabled
+                     */
+                    for (int i=0; supportedProtocols != null
+                                 && i<supportedProtocols.length; i++) {
+                        if (supportedProtocols[i].equals(protocol)) {
+                            if (vec == null) {
+                                vec = new Vector();
+                            }
+                            vec.addElement(protocol);
+                            break;
+                        }
+                    }
+                }
+            }           
+
+            if (vec != null) {
+                enabledProtocols = new String[vec.size()];
+                vec.copyInto(enabledProtocols);
+            }
+        }
+
+        return enabledProtocols;
+    }
 
     /**
      * Configure Client authentication for this version of JSSE.  The
@@ -335,7 +628,13 @@
      * versions of JSSE will treat 'want' as 'false'.
      * @param socket the SSLServerSocket
      */
-    abstract protected void configureClientAuth(SSLServerSocket socket);
+    protected void configureClientAuth(SSLServerSocket socket){
+        if (wantClientAuth){
+            socket.setWantClientAuth(wantClientAuth);
+        } else {
+            socket.setNeedClientAuth(requireClientAuth);
+        }
+    }
 
     /**
      * Configure Client authentication for this version of JSSE.  The
@@ -343,7 +642,10 @@
      * versions of JSSE will treat 'want' as 'false'.
      * @param socket the SSLSocket
      */
-    abstract protected void configureClientAuth(SSLSocket socket);
+    protected void configureClientAuth(SSLSocket socket){
+        // Per JavaDocs: SSLSockets returned from 
+        // SSLServerSocket.accept() inherit this setting.
+    }
     
     /**
      * Configures the given SSL server socket with the requested cipher suites,

Modified: 
tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/jsse/JSSESupport.java
URL: 
http://svn.apache.org/viewcvs/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/jsse/JSSESupport.java?rev=395849&r1=395848&r2=395849&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/jsse/JSSESupport.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/jsse/JSSESupport.java 
Fri Apr 21 04:04:05 2006
@@ -18,8 +18,14 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
+import java.io.InputStream;
+import java.net.SocketException;
+import java.security.cert.Certificate;
 import java.security.cert.CertificateFactory;
 
+import javax.net.ssl.HandshakeCompletedEvent;
+import javax.net.ssl.HandshakeCompletedListener;
+import javax.net.ssl.SSLException;
 import javax.net.ssl.SSLSession;
 import javax.net.ssl.SSLSocket;
 import javax.security.cert.X509Certificate;
@@ -41,14 +47,17 @@
 */
 
 class JSSESupport implements SSLSupport {
+    
     private static org.apache.commons.logging.Log log =
-       org.apache.commons.logging.LogFactory.getLog(JSSESupport.class);
+        org.apache.commons.logging.LogFactory.getLog(JSSESupport.class);
 
     protected SSLSocket ssl;
 
+    Listener listener = new Listener();
 
     JSSESupport(SSLSocket sock){
         ssl=sock;
+        sock.addHandshakeCompletedListener(listener);
     }
 
     public String getCipherSuite() throws IOException {
@@ -64,41 +73,44 @@
         return getPeerCertificateChain(false);
     }
 
-    protected java.security.cert.X509Certificate [] 
-       getX509Certificates(SSLSession session) throws IOException {
-        X509Certificate jsseCerts[] = null;
-    try{
-           jsseCerts = session.getPeerCertificateChain();
-    } catch (Throwable ex){
-       // Get rid of the warning in the logs when no Client-Cert is
-       // available
+    protected java.security.cert.X509Certificate [] 
getX509Certificates(SSLSession session) 
+        throws IOException {
+        Certificate [] certs=null;
+        try {
+            certs = session.getPeerCertificates();
+        } catch( Throwable t ) {
+            log.debug("Error getting client certs",t);
+            return null;
+        }
+        if( certs==null ) return null;
+        
+        java.security.cert.X509Certificate [] x509Certs = 
+            new java.security.cert.X509Certificate[certs.length];
+        for(int i=0; i < certs.length; i++) {
+            if (certs[i] instanceof java.security.cert.X509Certificate ) {
+                // always currently true with the JSSE 1.1.x
+                x509Certs[i] = (java.security.cert.X509Certificate) certs[i];
+            } else {
+                try {
+                    byte [] buffer = certs[i].getEncoded();
+                    CertificateFactory cf =
+                        CertificateFactory.getInstance("X.509");
+                    ByteArrayInputStream stream =
+                        new ByteArrayInputStream(buffer);
+                    x509Certs[i] = (java.security.cert.X509Certificate) 
cf.generateCertificate(stream);
+                } catch(Exception ex) { 
+                    log.info("Error translating cert " + certs[i], ex);
+                    return null;
+                }
+            }
+            if(log.isTraceEnabled())
+                log.trace("Cert #" + i + " = " + x509Certs[i]);
+        }
+        if(x509Certs.length < 1)
+            return null;
+        return x509Certs;
     }
 
-       if(jsseCerts == null)
-           jsseCerts = new X509Certificate[0];
-       java.security.cert.X509Certificate [] x509Certs =
-           new java.security.cert.X509Certificate[jsseCerts.length];
-       for (int i = 0; i < x509Certs.length; i++) {
-           try {
-               byte buffer[] = jsseCerts[i].getEncoded();
-               CertificateFactory cf =
-                   CertificateFactory.getInstance("X.509");
-               ByteArrayInputStream stream =
-                   new ByteArrayInputStream(buffer);
-               x509Certs[i] = (java.security.cert.X509Certificate)
-                   cf.generateCertificate(stream);
-               if(log.isTraceEnabled())
-                   log.trace("Cert #" + i + " = " + x509Certs[i]);
-           } catch(Exception ex) {
-               log.info("Error translating " + jsseCerts[i], ex);
-               return null;
-           }
-       }
-       
-       if ( x509Certs.length < 1 )
-           return null;
-       return x509Certs;
-    }
     public Object[] getPeerCertificateChain(boolean force)
         throws IOException {
         // Look up the current SSLSession
@@ -124,9 +136,41 @@
     }
 
     protected void handShake() throws IOException {
-        ssl.setNeedClientAuth(true);
+        if( ssl.getWantClientAuth() ) {
+            log.debug("No client cert sent for want");
+        } else {
+            ssl.setNeedClientAuth(true);
+        }
+
+        InputStream in = ssl.getInputStream();
+        int oldTimeout = ssl.getSoTimeout();
+        ssl.setSoTimeout(1000);
+        byte[] b = new byte[0];
+        listener.reset();
         ssl.startHandshake();
+        int maxTries = 60; // 60 * 1000 = example 1 minute time out
+        for (int i = 0; i < maxTries; i++) {
+        if(log.isTraceEnabled())
+            log.trace("Reading for try #" +i);
+            try {
+                int x = in.read(b);
+            } catch(SSLException sslex) {
+                log.info("SSL Error getting client Certs",sslex);
+                throw sslex;
+            } catch (IOException e) {
+                // ignore - presumably the timeout
+            }
+            if (listener.completed) {
+                break;
+            }
+        }
+        ssl.setSoTimeout(oldTimeout);
+        if (listener.completed == false) {
+            throw new SocketException("SSL Cert handshake timeout");
+        }
+
     }
+
     /**
      * Copied from <code>org.apache.catalina.valves.CertificateValve</code>
      */
@@ -173,6 +217,16 @@
         return buf.toString();
     }
 
+
+    private static class Listener implements HandshakeCompletedListener {
+        volatile boolean completed = false;
+        public void handshakeCompleted(HandshakeCompletedEvent event) {
+            completed = true;
+        }
+        void reset() {
+            completed = false;
+        }
+    }
 
 }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to