[jboss-cvs] JBossAS SVN: r81257 - projects/integration/trunk/jboss-classloading-spi/src/main/java/org/jboss/classloading/spi.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Nov 18 17:46:42 EST 2008
Author: anil.saldhana at jboss.com
Date: 2008-11-18 17:46:42 -0500 (Tue, 18 Nov 2008)
New Revision: 81257
Added:
projects/integration/trunk/jboss-classloading-spi/src/main/java/org/jboss/classloading/spi/SecurityActions.java
Modified:
projects/integration/trunk/jboss-classloading-spi/src/main/java/org/jboss/classloading/spi/DelegatingClassLoader.java
Log:
JBAS-6209: DelegatingClassLoader needs to have getParent() in priv block
Modified: projects/integration/trunk/jboss-classloading-spi/src/main/java/org/jboss/classloading/spi/DelegatingClassLoader.java
===================================================================
--- projects/integration/trunk/jboss-classloading-spi/src/main/java/org/jboss/classloading/spi/DelegatingClassLoader.java 2008-11-18 22:37:39 UTC (rev 81256)
+++ projects/integration/trunk/jboss-classloading-spi/src/main/java/org/jboss/classloading/spi/DelegatingClassLoader.java 2008-11-18 22:46:42 UTC (rev 81257)
@@ -27,6 +27,7 @@
* DelegatingClassLoader.
*
* @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author anil.saldhana at redhat.com
* @version $Revision: 1.1 $
*/
public class DelegatingClassLoader extends ClassLoader
@@ -81,7 +82,14 @@
clazz = super.loadClass(name, resolve);
// We should really let the parent decide to do that
else
- clazz = getParent().loadClass(name);
+ {
+ if(System.getSecurityManager() == null)
+ clazz = getParent().loadClass(name);
+ else
+ {
+ clazz = SecurityActions.getParentClassLoader(this).loadClass(name);
+ }
+ }
}
// Do we need to resolve the class?
@@ -103,8 +111,13 @@
resource = super.getResource(name);
// We should really let the parent decide to do that
else
- resource = getParent().getResource(name);
+ {
+ if(System.getSecurityManager() == null)
+ resource = getParent().getResource(name);
+ else
+ resource = SecurityActions.getParentClassLoader(this).getResource(name);
+ }
}
- return resource;
- }
+ return resource;
+ }
}
Added: projects/integration/trunk/jboss-classloading-spi/src/main/java/org/jboss/classloading/spi/SecurityActions.java
===================================================================
--- projects/integration/trunk/jboss-classloading-spi/src/main/java/org/jboss/classloading/spi/SecurityActions.java (rev 0)
+++ projects/integration/trunk/jboss-classloading-spi/src/main/java/org/jboss/classloading/spi/SecurityActions.java 2008-11-18 22:46:42 UTC (rev 81257)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.classloading.spi;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * Privileged Blocks
+ * @author Anil.Saldhana at redhat.com
+ * @since Nov 18, 2008
+ */
+class SecurityActions
+{
+ static ClassLoader getParentClassLoader(final ClassLoader cl)
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+ {
+ public ClassLoader run()
+ {
+ return cl.getParent();
+ }
+ });
+ }
+}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list