glenn 01/01/23 14:02:38
Modified: catalina/src/share/org/apache/catalina/startup
ContextConfig.java
Log:
Implement SecurityManager
Revision Changes Path
1.38 +4 -124
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java
Index: ContextConfig.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- ContextConfig.java 2001/01/23 05:05:51 1.37
+++ ContextConfig.java 2001/01/23 22:02:36 1.38
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v
1.37 2001/01/23 05:05:51 remm Exp $
- * $Revision: 1.37 $
- * $Date: 2001/01/23 05:05:51 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v
1.38 2001/01/23 22:02:36 glenn Exp $
+ * $Revision: 1.38 $
+ * $Date: 2001/01/23 22:02:36 $
*
* ====================================================================
*
@@ -68,7 +68,6 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
-import java.io.FilePermission;
import java.io.InputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
@@ -76,12 +75,6 @@
import java.net.JarURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
-import java.security.CodeSource;
-import java.security.Permission;
-import java.security.Permissions;
-import java.security.PermissionCollection;
-import java.security.Policy;
-import java.security.ProtectionDomain;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.MissingResourceException;
@@ -118,7 +111,7 @@
* of that Context, and the associated defined servlets.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.37 $ $Date: 2001/01/23 05:05:51 $
+ * @version $Revision: 1.38 $ $Date: 2001/01/23 22:02:36 $
*/
public final class ContextConfig
@@ -766,116 +759,6 @@
/**
- * Configure permissions for this web application if we are running
- * under the control of a security manager.
- */
- private void permissionsConfig() {
-
- // Has a security manager been installed?
- SecurityManager securityManager = System.getSecurityManager();
- if (securityManager == null)
- return;
-
- // Refresh the standard policy permissions
- if (debug >= 1)
- log("Retrieving global policy permissions");
- Policy policy = Policy.getPolicy();
- policy.refresh();
-
- // Accumulate the common permissions we will add to all code sources
- if (debug >= 1)
- log("Building common permissions to add");
- ServletContext servletContext = context.getServletContext();
- Permissions commonPerms = new Permissions();
- URL baseURL = null;
- try {
- baseURL = servletContext.getResource("/");
- if (debug >= 1)
- log(" baseURL=" + baseURL.toString());
- } catch (MalformedURLException e) {
- log("permissionsConfig.baseURL", e);
- }
- String baseFile = baseURL.toString();
- if (baseFile.startsWith("file://")) // FIXME - file dependency
- baseFile = baseFile.substring(7);
- else if (baseFile.startsWith("file:"))
- baseFile = baseFile.substring(5);
- if (baseFile.endsWith("/"))
- baseFile += "-";
- else
- baseFile += "/-";
- commonPerms.add(new FilePermission(baseFile, "read"));
- File workDir = (File)
- context.getServletContext().getAttribute(Globals.WORK_DIR_ATTR);
- try {
- commonPerms.add(new FilePermission(workDir.getCanonicalPath() +
- "/-",
- "read,write,delete"));
- } catch (IOException e) {
- log("permissionsConfig.filePerm", e);
- }
- if (debug >= 1)
- log(" commonPerms=" + commonPerms.toString());
-
- // Build a CodeSource representing our document root code base
- if (debug >= 1)
- log("Building document root code source");
- URL docURL = null;
- try {
- docURL = servletContext.getResource("/WEB-INF");
- if (debug >= 1)
- log(" docURL=" + docURL.toString());
- } catch (MalformedURLException e) {
- log("permissionsConfig.docURL", e);
- }
- CodeSource docSource = new CodeSource(docURL, null);
- if (debug >= 1)
- log(" docSource=" + docSource.toString());
-
- // Generate the Permissions for the document root code base
- if (debug >= 1)
- log("Building document root permissions");
- PermissionCollection docPerms = policy.getPermissions(docSource);
- Enumeration docAdds = commonPerms.elements();
- while (docAdds.hasMoreElements())
- docPerms.add((Permission) docAdds.nextElement());
- if (debug >= 1)
- log(" docPerms=" + docPerms);
-
- // Generate the ProtectionDomain for the document root code base
- if (debug >= 1)
- log("Building document root protection domain");
- ProtectionDomain docPD = new ProtectionDomain(docSource, docPerms);
- if (debug >= 1)
- log(" docPD=" + docPD.toString());
-
- // Build a CodeSource representing our work directory code base
- if (debug >= 1)
- log("Building work directory code source");
- URL workURL = null;
- try {
- workURL = new URL("file", null, workDir.getCanonicalPath());
- if (debug >= 1)
- log(" workURL=" + workURL.toString());
- } catch (IOException e) {
- log("permissionsConfig.workURL", e);
- }
- CodeSource workSource = new CodeSource(workURL, null);
-
- // Generate the Permissions for the work directory code base
- if (debug >= 1)
- log("Building work directory permissions");
- PermissionCollection workPerms = policy.getPermissions(workSource);
- Enumeration workAdds = commonPerms.elements();
- while (workAdds.hasMoreElements())
- workPerms.add((Permission) workAdds.nextElement());
- if (debug >= 1)
- log(" workPerms=" + workPerms);
-
- }
-
-
- /**
* Process a "start" event for this Context.
*/
private void start() {
@@ -883,9 +766,6 @@
if (debug > 0)
log(sm.getString("contextConfig.start"));
ok = true;
-
- // Configure the Permissions for this Context (if necessary)
- // permissionsConfig(); // FIXME - Method not finished yet
// Process the default and application web.xml files
XmlMapper mapper = createWebMapper();
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]