tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r899420 - in /tomcat/trunk/java/org/apache/catalina: security/SecurityClassLoad.java session/StandardSession.java
Date Thu, 14 Jan 2010 21:33:58 GMT
Author: markt
Date: Thu Jan 14 21:33:58 2010
New Revision: 899420

URL: http://svn.apache.org/viewvc?rev=899420&view=rev
Log:
Fix TCK failures with security manager due to fix for bug 47774

Modified:
    tomcat/trunk/java/org/apache/catalina/security/SecurityClassLoad.java
    tomcat/trunk/java/org/apache/catalina/session/StandardSession.java

Modified: tomcat/trunk/java/org/apache/catalina/security/SecurityClassLoad.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/security/SecurityClassLoad.java?rev=899420&r1=899419&r2=899420&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/security/SecurityClassLoad.java (original)
+++ tomcat/trunk/java/org/apache/catalina/security/SecurityClassLoad.java Thu Jan 14 21:33:58
2010
@@ -99,6 +99,8 @@
         loader.loadClass
             (basePackage + "session.StandardSession");
         loader.loadClass
+            (basePackage + "session.StandardSession$PrivilegedSetTccl");
+        loader.loadClass
             (basePackage +
              "session.StandardSession$1");
         loader.loadClass

Modified: tomcat/trunk/java/org/apache/catalina/session/StandardSession.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/session/StandardSession.java?rev=899420&r1=899419&r2=899420&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/session/StandardSession.java (original)
+++ tomcat/trunk/java/org/apache/catalina/session/StandardSession.java Thu Jan 14 21:33:58
2010
@@ -710,8 +710,14 @@
             if (context.getLoader() != null &&
                     context.getLoader().getClassLoader() != null) {
                 oldTccl = Thread.currentThread().getContextClassLoader();
-                Thread.currentThread().setContextClassLoader(
-                        context.getLoader().getClassLoader());
+                if (Globals.IS_SECURITY_ENABLED) {
+                    PrivilegedAction<Void> pa = new PrivilegedSetTccl(
+                            context.getLoader().getClassLoader());
+                    AccessController.doPrivileged(pa);
+                } else {
+                    Thread.currentThread().setContextClassLoader(
+                            context.getLoader().getClassLoader());
+                }
             }
             try {
                 Object listeners[] = context.getApplicationLifecycleListeners();
@@ -747,7 +753,13 @@
                 }
             } finally {
                 if (oldTccl != null) {
-                    Thread.currentThread().setContextClassLoader(oldTccl);
+                    if (Globals.IS_SECURITY_ENABLED) {
+                        PrivilegedAction<Void> pa =
+                            new PrivilegedSetTccl(oldTccl);
+                        AccessController.doPrivileged(pa);
+                    } else {
+                        Thread.currentThread().setContextClassLoader(oldTccl);
+                    }
                 }
             }
 
@@ -1732,6 +1744,21 @@
     }
 
 
+    private static class PrivilegedSetTccl
+    implements PrivilegedAction<Void> {
+
+        private ClassLoader cl;
+
+        PrivilegedSetTccl(ClassLoader cl) {
+            this.cl = cl;
+        }
+
+        public Void run() {
+            Thread.currentThread().setContextClassLoader(cl);
+            return null;
+        }
+    }
+
 }
 
 



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


Mime
View raw message