[jboss-cvs] JBossAS SVN: r58216 - trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Nov 8 17:27:45 EST 2006


Author: anil.saldhana at jboss.com
Date: 2006-11-08 17:27:44 -0500 (Wed, 08 Nov 2006)
New Revision: 58216

Modified:
   trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/DeployerConfig.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployer.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployment.java
Log:
handle the optional xacml policy file in wars

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/DeployerConfig.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/DeployerConfig.java	2006-11-08 22:27:28 UTC (rev 58215)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/DeployerConfig.java	2006-11-08 22:27:44 UTC (rev 58216)
@@ -21,6 +21,8 @@
  */
 package org.jboss.web.tomcat.tc6.deployers; 
 
+import java.net.URL;
+
 import javax.management.ObjectName;
  
 import org.jboss.security.plugins.JaasSecurityManagerServiceMBean;
@@ -127,6 +129,8 @@
    /** The service used to flush authentication cache on session invalidation. */
    private JaasSecurityManagerServiceMBean secMgrService;  
    
+   private URL xacmlPolicyURL = null;
+   
    public ClassLoader getServiceClassLoader()
    {
       return serviceClassLoader;
@@ -348,5 +352,15 @@
    public void setFilteredPackages(String[] filteredPackages)
    {
       this.filteredPackages = filteredPackages;
-   }  
+   }
+
+   public URL getXacmlPolicyURL() 
+   {
+	  return xacmlPolicyURL;
+   }
+
+   public void setXacmlPolicyURL(URL xacmlPolicyURL) 
+   {
+	 this.xacmlPolicyURL = xacmlPolicyURL;
+   }   
 }

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployer.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployer.java	2006-11-08 22:27:28 UTC (rev 58215)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployer.java	2006-11-08 22:27:44 UTC (rev 58216)
@@ -47,6 +47,7 @@
 import org.jboss.security.plugins.JaasSecurityManagerServiceMBean;
 import org.jboss.system.server.Server;
 import org.jboss.system.server.ServerImplMBean;
+import org.jboss.virtual.VirtualFile;
 import org.jboss.web.deployers.AbstractWarDeployer;
 import org.jboss.web.deployers.AbstractWarDeployment;
 import org.jboss.web.tomcat.security.HttpServletRequestPolicyContextHandler;
@@ -747,6 +748,12 @@
       config.setAllowSelfPrivilegedWebApps(this.allowSelfPrivilegedWebApps); 
       config.setSecurityManagerService(this.secMgrService);
       config.setFilteredPackages(filteredPackages);
+      
+      //Check if there are any xacml policy files
+      VirtualFile vf = unit.getMetaDataFile("jboss-xacml-policy.xml");
+      if(vf != null)
+    	  config.setXacmlPolicyURL(vf.toURL());
+      
       deployment.setServer(super.getServer());
       deployment.init(config);
 
@@ -763,7 +770,7 @@
       ic.processMetadata();
       JmxDependencyPolicy dependencyPolicy = (JmxDependencyPolicy)ic.getDependencyPolicy();
       metadata.setDepends(dependencyPolicy.getDependencies(metadata.getDepends()));
-      */
+      */  
       return deployment;
    }
    
@@ -779,5 +786,5 @@
       MBeanServer server = MBeanServerLocator.locateJBoss();
       if (server != null)
          server.unregisterMBean(OBJECT_NAME);
-   }
+   } 
 }

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployment.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployment.java	2006-11-08 22:27:28 UTC (rev 58215)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/deployers/TomcatDeployment.java	2006-11-08 22:27:44 UTC (rev 58216)
@@ -73,13 +73,8 @@
    /**
     * The name of the war level context configuration descriptor
     */
-   private static final String CONTEXT_CONFIG_FILE = "WEB-INF/context.xml";
+   private static final String CONTEXT_CONFIG_FILE = "WEB-INF/context.xml"; 
 
-   /**
-    * Optional XACML Policy File
-    */
-   private static final String XACML_POLICY_FILE = "WEB-INF/jboss-xacml-policy.xml";
-
    private DeployerConfig config;
    private String[] javaVMs = { " jboss.management.local:J2EEServer=Local,j2eeType=JVM,name=localhost" };
    private String serverName = "jboss";
@@ -395,25 +390,18 @@
          // Associate the Context Id with the Security Domain
          String contextID = metaData.getJaccContextID();
 
-         // Check if xacml policy is available
-         URL xacmlPolicyFile = null;
-         try
+         //Check if an xacml policy file is present
+         URL xacmlPolicyFile = this.config.getXacmlPolicyURL();
+         if (xacmlPolicyFile != null)
          {
-            xacmlPolicyFile = this.findXACMLFile(url);
-            if (xacmlPolicyFile != null)
-            {
-               AuthorizationManager authzmgr = org.jboss.security.Util
-                     .getAuthorizationManager(secDomain);
-               if (authzmgr instanceof PolicyRegistration)
-               {
-                  PolicyRegistration xam = (PolicyRegistration) authzmgr;
-                  xam.registerPolicy(contextID, xacmlPolicyFile);
-               }
-            }
-         } catch (IOException ioe)
-         {
-            // Ignore
-         }
+        	 AuthorizationManager authzmgr = org.jboss.security.Util
+        	 .getAuthorizationManager(secDomain);
+        	 if (authzmgr instanceof PolicyRegistration)
+        	 {
+        		 PolicyRegistration xam = (PolicyRegistration) authzmgr;
+        		 xam.registerPolicy(contextID, xacmlPolicyFile);
+        	 }
+         }  
       }
 
       log.debug("Initialized: " + webApp + " " + objectName);
@@ -598,27 +586,6 @@
          zipFile.close();
       }
       return result;
-   }
+   } 
 
-   /**
-    * Locate a XACMl Policy file packaged in the war
-    * 
-    * @param warURL
-    * @return
-    * @throws IOException
-    */
-   private URL findXACMLFile(URL warURL) throws IOException
-   {
-      URL result = null;
-      // See if the warUrl is a dir or a file
-      File warFile = new File(warURL.getFile());
-      if (warURL.getProtocol().equals("file") && warFile.isDirectory() == true)
-      {
-         File webDD = new File(warFile, XACML_POLICY_FILE);
-         if (webDD.exists() == true)
-            result = webDD.toURL();
-      }
-      return result;
-   }
-
 }




More information about the jboss-cvs-commits mailing list