[jboss-cvs] JBossAS SVN: r57432 - branches/JEE5_TCK/server/src/main/org/jboss/web

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Oct 4 18:31:13 EDT 2006


Author: anil.saldhana at jboss.com
Date: 2006-10-04 18:31:08 -0400 (Wed, 04 Oct 2006)
New Revision: 57432

Modified:
   branches/JEE5_TCK/server/src/main/org/jboss/web/WebPermissionMapping.java
Log:
JBAS-3326:Jacc 1.1 spec: add the ! permissions

Modified: branches/JEE5_TCK/server/src/main/org/jboss/web/WebPermissionMapping.java
===================================================================
--- branches/JEE5_TCK/server/src/main/org/jboss/web/WebPermissionMapping.java	2006-10-04 18:09:06 UTC (rev 57431)
+++ branches/JEE5_TCK/server/src/main/org/jboss/web/WebPermissionMapping.java	2006-10-04 22:31:08 UTC (rev 57432)
@@ -148,7 +148,8 @@
       Iterator iter = patternMap.values().iterator();
       while( iter.hasNext() )
       {
-         PatternInfo info = (PatternInfo) iter.next();
+         PatternInfo info = (PatternInfo) iter.next(); 
+         
          String qurl = info.getQualifiedPattern();
          if( info.isOverriden == true )
          {
@@ -166,6 +167,13 @@
                httpMethods, null);
             pc.addToExcludedPolicy(wrp);
             pc.addToExcludedPolicy(wudp);
+            
+            //!(excluded methods)  [JACC 1.1]
+            String excludedString = "!" + getCommaSeparatedString(httpMethods);
+            WebResourcePermission wrp1 = new WebResourcePermission(info.pattern, excludedString);
+            WebUserDataPermission wudp1 = new WebUserDataPermission(info.pattern,excludedString);
+            pc.addToUncheckedPolicy(wrp1);
+            pc.addToUncheckedPolicy(wudp1); 
          }
 
          // Create the role permissions
@@ -179,16 +187,20 @@
             methods.toArray(httpMethods);
             WebResourcePermission wrp = new WebResourcePermission(qurl, httpMethods);
             pc.addToRole(role, wrp);
+            
+            //JACC 1.1: create !(httpmethods) in unchecked perms
+            WebResourcePermission wrpUnchecked = new WebResourcePermission(info.pattern, 
+                          "!" + getCommaSeparatedString(httpMethods));
+            pc.addToUncheckedPolicy(wrpUnchecked);
          }
 
          // Create the unchecked permissions
-         String[] missingHttpMethods = info.getMissingMethods();
+         String[] missingHttpMethods = info.getMissingMethods(); 
          if( missingHttpMethods.length > 0 )
          {
             // Create the unchecked permissions WebResourcePermissions
             WebResourcePermission wrp = new WebResourcePermission(qurl, missingHttpMethods);
-            pc.addToUncheckedPolicy(wrp);
-
+            pc.addToUncheckedPolicy(wrp);  
          }
 
          // Create the unchecked permissions WebUserDataPermissions
@@ -202,6 +214,21 @@
             methods.toArray(httpMethods);
             WebUserDataPermission wudp = new WebUserDataPermission(qurl, httpMethods, transport);
             pc.addToUncheckedPolicy(wudp);
+            
+            //If the transport is "NONE", then add an exlusive WebUserDataPermission
+            //with the url pattern and null
+            if(transport.equals("NONE"))
+            {
+               WebUserDataPermission wudp1 = new WebUserDataPermission(info.pattern, null);
+               pc.addToUncheckedPolicy(wudp1);
+            } 
+            else
+            {
+               //JACC 1.1: Transport is CONFIDENTIAL/INTEGRAL, add a !(http methods)
+               WebUserDataPermission wudpNonNull = new WebUserDataPermission(info.pattern, 
+                     "!" + getCommaSeparatedString(httpMethods));
+               pc.addToUncheckedPolicy(wudpNonNull);
+            }
          }
       }
 
@@ -260,6 +287,20 @@
          pc.addToRole(role, wrrp);  
       } 
    }
+   
+   static String getCommaSeparatedString(String[] str)
+   {
+      int len = str.length; 
+      Arrays.sort(str);
+      
+      StringBuilder buf = new StringBuilder();
+      for(int i = 0; i < len ; i++)
+      {
+         if(i > 0) buf.append(",");
+         buf.append(str[i]);
+      }
+      return buf.toString();
+   }
 
    /**
     * Determine the url-pattern type
@@ -591,7 +632,7 @@
             httpMethods = WebSecurityMetaData.getMissingHttpMethods(allMethods);
          }
          return httpMethods;
-      }
+      } 
 
       /**
        * Add the qualifying pattern. If info is a prefix pattern that matches
@@ -672,7 +713,7 @@
             isExtensionFor = pattern.regionMatches(1, other.pattern, offset, length);
          }
          return isExtensionFor;
-      }
+      } 
 
       public String toString()
       {




More information about the jboss-cvs-commits mailing list