remm 01/07/30 17:30:28
Modified: catalina/src/share/org/apache/catalina/loader
WebappClassLoader.java
Log:
- The system policy file is now refreshed in the CL constructor, since it's more
likely to succeed here (in getPermissions, it could end up failing a check
on SecurityPermission getPolicy). An alternatie would be to wrap inside a
PA, but that change should allow it to work without a PA.
- If Policy.getPolicy fails, the access control exception is caught and ignored,
since
the policy reloading feature is optional, and shouldn't break things.
Revision Changes Path
1.12 +31 -16
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java
Index: WebappClassLoader.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- WebappClassLoader.java 2001/07/22 21:23:17 1.11
+++ WebappClassLoader.java 2001/07/31 00:30:28 1.12
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java,v
1.11 2001/07/22 21:23:17 remm Exp $
- * $Revision: 1.11 $
- * $Date: 2001/07/22 21:23:17 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java,v
1.12 2001/07/31 00:30:28 remm Exp $
+ * $Revision: 1.12 $
+ * $Date: 2001/07/31 00:30:28 $
*
* ====================================================================
*
@@ -123,7 +123,7 @@
*
* @author Remy Maucherat
* @author Craig R. McClanahan
- * @version $Revision: 1.11 $ $Date: 2001/07/22 21:23:17 $
+ * @version $Revision: 1.12 $ $Date: 2001/07/31 00:30:28 $
*/
public class WebappClassLoader
extends URLClassLoader
@@ -162,6 +162,10 @@
system = getSystemClassLoader();
securityManager = System.getSecurityManager();
+ if (securityManager != null) {
+ refreshPolicy();
+ }
+
}
@@ -177,6 +181,10 @@
system = getSystemClassLoader();
securityManager = System.getSecurityManager();
+ if (securityManager != null) {
+ refreshPolicy();
+ }
+
}
@@ -315,12 +323,6 @@
/**
- * Flag that the security policy has been refreshed from file.
- */
- private boolean policy_refresh = false;
-
-
- /**
* The parent class loader.
*/
private ClassLoader parent = null;
@@ -1276,12 +1278,6 @@
*/
protected PermissionCollection getPermissions(CodeSource codeSource) {
- if (!policy_refresh) {
- // Refresh the security policies
- Policy policy = Policy.getPolicy();
- policy.refresh();
- policy_refresh = true;
- }
String codeUrl = codeSource.getLocation().toString();
PermissionCollection pc;
if ((pc = (PermissionCollection)loaderPC.get(codeUrl)) == null) {
@@ -1702,6 +1698,25 @@
return entry.loadedClass;
}
return (null); // FIXME - findLoadedResource()
+
+ }
+
+
+ /**
+ * Refresh the system policy file, to pick up eventual changes.
+ */
+ protected void refreshPolicy() {
+
+ try {
+ // The policy file may have been modified to adjust
+ // permissions, so we're reloading it when loading or
+ // reloading a Context
+ Policy policy = Policy.getPolicy();
+ policy.refresh();
+ } catch (AccessControlException e) {
+ // Some policy files may restrict this, even for the core,
+ // so this exception is ignored
+ }
}