geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r787163 - in /geronimo/specs/trunk/geronimo-jacc_1.1_spec/src: main/java/javax/security/jacc/EJBMethodPermission.java main/java/javax/security/jacc/HTTPMethodSpec.java test/java/javax/security/jacc/EJBMethodPermissionTest.java
Date Mon, 22 Jun 2009 08:30:18 GMT
Author: djencks
Date: Mon Jun 22 08:30:18 2009
New Revision: 787163

URL: http://svn.apache.org/viewvc?rev=787163&view=rev
Log:
GERONIMO-4587 fix EJBMethodPermission construction problem when a method param is an array,
patch (slightly modified) from Shawn Jiang

Modified:
    geronimo/specs/trunk/geronimo-jacc_1.1_spec/src/main/java/javax/security/jacc/EJBMethodPermission.java
    geronimo/specs/trunk/geronimo-jacc_1.1_spec/src/main/java/javax/security/jacc/HTTPMethodSpec.java
    geronimo/specs/trunk/geronimo-jacc_1.1_spec/src/test/java/javax/security/jacc/EJBMethodPermissionTest.java

Modified: geronimo/specs/trunk/geronimo-jacc_1.1_spec/src/main/java/javax/security/jacc/EJBMethodPermission.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jacc_1.1_spec/src/main/java/javax/security/jacc/EJBMethodPermission.java?rev=787163&r1=787162&r2=787163&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jacc_1.1_spec/src/main/java/javax/security/jacc/EJBMethodPermission.java
(original)
+++ geronimo/specs/trunk/geronimo-jacc_1.1_spec/src/main/java/javax/security/jacc/EJBMethodPermission.java
Mon Jun 22 08:30:18 2009
@@ -48,9 +48,9 @@
     private static String[] methodInterfaces;
 
     static {
-        String newMethodInterfaces = (String) AccessController.doPrivileged(new
-                PrivilegedAction() {
-                    public Object run() {
+        String newMethodInterfaces = AccessController.doPrivileged(new
+                PrivilegedAction<String>() {
+                    public String run() {
                         return System.getProperty(NEW_METHOD_INTERFACES);
                     }
                 });
@@ -162,8 +162,8 @@
                             checkMethodInterface(tokens[1]);
                             if (tokens[2].indexOf(',') > -1) {
                                 String[] test = tokens[2].split(",", -1);
-                                for (int i = 0; i < test.length; i++) {
-                                    if (test[i].length() == 0) throw new IllegalArgumentException("Invalid
type name");
+                                for (String aTest : test) {
+                                    if (aTest.length() == 0) throw new IllegalArgumentException("Invalid
type name");
                                 }
                             }
 
@@ -189,7 +189,7 @@
             } else {
                 if (methodParamsArray[0] == null || methodParamsArray[0].length() == 0) throw
new IllegalArgumentException("Invalid type name");
 
-                StringBuffer buffer = new StringBuffer(methodParamsArray[0]);
+                StringBuilder buffer = new StringBuilder(methodParamsArray[0]);
                 for (int i = 1; i < methodParamsArray.length; i++) {
                     if (methodParamsArray[i] == null || methodParamsArray[i].length() ==
0) throw new IllegalArgumentException("Invalid type name");
 
@@ -212,10 +212,10 @@
             if (paramTypes.length == 0) {
                 methodParams = "";
             } else {
-                StringBuffer buffer = new StringBuffer(paramTypes[0].getName());
+                StringBuilder buffer = new StringBuilder(paramTypes[0].getName());
                 for (int i = 1; i < paramTypes.length; i++) {
                     buffer.append(",");
-                    buffer.append(paramTypes[i].getName());
+                    getName(paramTypes[i], buffer);
                 }
                 methodParams = buffer.toString();
             }
@@ -223,6 +223,16 @@
             initActions();
         }
 
+        private static void getName(Class<?> paramType, StringBuilder buffer){
+            if(paramType.isArray()){
+                getName(paramType.getComponentType(), buffer);
+                buffer.append("[]");
+            }else{
+                buffer.append(paramType.getName());
+            }
+        }
+
+
         public boolean equals(MethodSpec spec) {
             return implies(spec) && spec.implies(this);
         }
@@ -313,7 +323,7 @@
 
         private LinkedList collection = new LinkedList();
         private HashMap permissions = new HashMap();
-        private static final String WILDCARD = new String("$WILDCARD");
+        private static final String WILDCARD = "$WILDCARD";
 
         /**
          * Adds a permission object to the current collection of permission objects.

Modified: geronimo/specs/trunk/geronimo-jacc_1.1_spec/src/main/java/javax/security/jacc/HTTPMethodSpec.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jacc_1.1_spec/src/main/java/javax/security/jacc/HTTPMethodSpec.java?rev=787163&r1=787162&r2=787163&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jacc_1.1_spec/src/main/java/javax/security/jacc/HTTPMethodSpec.java
(original)
+++ geronimo/specs/trunk/geronimo-jacc_1.1_spec/src/main/java/javax/security/jacc/HTTPMethodSpec.java
Mon Jun 22 08:30:18 2009
@@ -232,7 +232,7 @@
                 actions = "";
             } else {
                 boolean first = true;
-                StringBuffer buffer = new StringBuffer();
+                StringBuilder buffer = new StringBuilder();
                 if (isExcluded) {
                     buffer.append("!");
                 }

Modified: geronimo/specs/trunk/geronimo-jacc_1.1_spec/src/test/java/javax/security/jacc/EJBMethodPermissionTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jacc_1.1_spec/src/test/java/javax/security/jacc/EJBMethodPermissionTest.java?rev=787163&r1=787162&r2=787163&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jacc_1.1_spec/src/test/java/javax/security/jacc/EJBMethodPermissionTest.java
(original)
+++ geronimo/specs/trunk/geronimo-jacc_1.1_spec/src/test/java/javax/security/jacc/EJBMethodPermissionTest.java
Mon Jun 22 08:30:18 2009
@@ -41,7 +41,7 @@
 
     public void setUp() {
         try {
-            method = TestClass.class.getDeclaredMethod("cat", new Class[] { Integer.class,
Float.class, Long.class, Double.class });
+            method = TestClass.class.getDeclaredMethod("cat", new Class[] { Integer.class,
Float.class, Long.class, Double.class,int[].class });
         } catch (NoSuchMethodException e) {
             e.printStackTrace();  //To change body of catch statement use Options | File
Templates.
         } catch (SecurityException e) {
@@ -79,35 +79,35 @@
         doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "cat,Home,");
         doTestSerialization(permission);
-        permission = new EJBMethodPermission("foo", ",,a,b,c,d");
+        permission = new EJBMethodPermission("foo", ",,a,b,c,d,e");
         doTestSerialization(permission);
-        permission = new EJBMethodPermission("foo", "cat,,a,b,c,d");
+        permission = new EJBMethodPermission("foo", "cat,,a,b,c,d,e");
         doTestSerialization(permission);
-        permission = new EJBMethodPermission("foo", ",Home,a,b,c,d");
+        permission = new EJBMethodPermission("foo", ",Home,a,b,c,d,e");
         doTestSerialization(permission);
-        permission = new EJBMethodPermission("foo", "cat,Home,a,b,c,d");
+        permission = new EJBMethodPermission("foo", "cat,Home,a,b,c,d,e");
         doTestSerialization(permission);
 
 
         // methodInterface ::= "Home" | "LocalHome" | "Remote" | "Local" | "ServiceEndpoint"
-        permission = new EJBMethodPermission("foo", "cat,Home,a,b,c,d");
+        permission = new EJBMethodPermission("foo", "cat,Home,a,b,c,d,e");
         doTestSerialization(permission);
-        permission = new EJBMethodPermission("foo", "cat,LocalHome,a,b,c,d");
+        permission = new EJBMethodPermission("foo", "cat,LocalHome,a,b,c,d,e");
         doTestSerialization(permission);
-        permission = new EJBMethodPermission("foo", "cat,Remote,a,b,c,d");
+        permission = new EJBMethodPermission("foo", "cat,Remote,a,b,c,d,e");
         doTestSerialization(permission);
-        permission = new EJBMethodPermission("foo", "cat,Local,a,b,c,d");
+        permission = new EJBMethodPermission("foo", "cat,Local,a,b,c,d,e");
         doTestSerialization(permission);
-        permission = new EJBMethodPermission("foo", "cat,ServiceEndpoint,a,b,c,d");
+        permission = new EJBMethodPermission("foo", "cat,ServiceEndpoint,a,b,c,d,e");
         doTestSerialization(permission);
 
         assertEquals(permission.getName(), "foo");
-        assertEquals(permission.getActions(), "cat,ServiceEndpoint,a,b,c,d");
+        assertEquals(permission.getActions(), "cat,ServiceEndpoint,a,b,c,d,e");
 
 
         // bad methodInterface
         try {
-            permission = new EJBMethodPermission("foo", "cat,Interface,a,b,c,d");
+            permission = new EJBMethodPermission("foo", "cat,Interface,a,b,c,d,e");
             fail("Bad method interface");
         } catch(IllegalArgumentException iae) {
         }
@@ -143,9 +143,9 @@
 
     public void testImpliesStringString() throws Exception {
         EJBMethodPermission permissionFooEEE = new EJBMethodPermission("foo", "");
-        EJBMethodPermission permissionFooMIP = new EJBMethodPermission("foo", "cat,LocalHome,a,b,c,d");
+        EJBMethodPermission permissionFooMIP = new EJBMethodPermission("foo", "cat,LocalHome,a,b,c,d,e");
         EJBMethodPermission permissionBarEEE = new EJBMethodPermission("bar", "");
-        EJBMethodPermission permissionFooEIP = new EJBMethodPermission("foo", ",LocalHome,a,b,c,d");
+        EJBMethodPermission permissionFooEIP = new EJBMethodPermission("foo", ",LocalHome,a,b,c,d,e");
         EJBMethodPermission permissionFooEIE = new EJBMethodPermission("foo", ",LocalHome,");
         EJBMethodPermission permissionFooEI  = new EJBMethodPermission("foo", ",LocalHome");
 
@@ -212,35 +212,35 @@
         doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "cat", "Home", new String[] {});
         doTestSerialization(permission);
-        permission = new EJBMethodPermission("foo", "", "", new String[] { "a", "b", "c",
"d" });
+        permission = new EJBMethodPermission("foo", "", "", new String[] { "a", "b", "c",
"d", "e"});
         doTestSerialization(permission);
-        permission = new EJBMethodPermission("foo", "cat", "", new String[] { "a", "b", "c",
"d" });
+        permission = new EJBMethodPermission("foo", "cat", "", new String[] { "a", "b", "c",
"d", "e"});
         doTestSerialization(permission);
-        permission = new EJBMethodPermission("foo", "", "Home", new String[] { "a", "b",
"c", "d" });
+        permission = new EJBMethodPermission("foo", "", "Home", new String[] { "a", "b",
"c", "d", "e"});
         doTestSerialization(permission);
-        permission = new EJBMethodPermission("foo", "cat", "Home", new String[] { "a", "b",
"c", "d" });
+        permission = new EJBMethodPermission("foo", "cat", "Home", new String[] { "a", "b",
"c", "d", "e"});
         doTestSerialization(permission);
 
 
         // methodInterface ::= "Home" | "LocalHome" | "Remote" | "Local" | "ServiceEndpoint"
-        permission = new EJBMethodPermission("foo", "cat", "Home", new String[] { "a", "b",
"c", "d" });
+        permission = new EJBMethodPermission("foo", "cat", "Home", new String[] { "a", "b",
"c", "d", "e"});
         doTestSerialization(permission);
-        permission = new EJBMethodPermission("foo", "cat", "LocalHome", new String[] { "a",
"b", "c", "d" });
+        permission = new EJBMethodPermission("foo", "cat", "LocalHome", new String[] { "a",
"b", "c", "d", "e"});
         doTestSerialization(permission);
-        permission = new EJBMethodPermission("foo", "cat", "Remote", new String[] { "a",
"b", "c", "d" });
+        permission = new EJBMethodPermission("foo", "cat", "Remote", new String[] { "a",
"b", "c", "d", "e"});
         doTestSerialization(permission);
-        permission = new EJBMethodPermission("foo", "cat", "Local", new String[] { "a", "b",
"c", "d" });
+        permission = new EJBMethodPermission("foo", "cat", "Local", new String[] { "a", "b",
"c", "d", "e"});
         doTestSerialization(permission);
-        permission = new EJBMethodPermission("foo", "cat", "ServiceEndpoint", new String[]
{ "a", "b", "c", "d" });
+        permission = new EJBMethodPermission("foo", "cat", "ServiceEndpoint", new String[]
{ "a", "b", "c", "d", "e"});
         doTestSerialization(permission);
 
         assertEquals(permission.getName(), "foo");
-        assertEquals(permission.getActions(), "cat,ServiceEndpoint,a,b,c,d");
+        assertEquals(permission.getActions(), "cat,ServiceEndpoint,a,b,c,d,e");
 
 
         // bad methodInterface
         try {
-            permission = new EJBMethodPermission("foo", "cat", "Interface", new String[]
{ "a", "b", "c", "d" });
+            permission = new EJBMethodPermission("foo", "cat", "Interface", new String[]
{ "a", "b", "c", "d", "e"});
             fail("Bad method interface");
         } catch(IllegalArgumentException iae) {
         }
@@ -248,9 +248,9 @@
 
     public void testImpliesStringStringStringStringArray() throws Exception {
         EJBMethodPermission permissionFooEEE = new EJBMethodPermission("foo", "", "", null);
-        EJBMethodPermission permissionFooMIP = new EJBMethodPermission("foo", "cat", "LocalHome",
new String[] { "a", "b", "c", "d" });
+        EJBMethodPermission permissionFooMIP = new EJBMethodPermission("foo", "cat", "LocalHome",
new String[] { "a", "b", "c", "d", "e"});
         EJBMethodPermission permissionBarEEE = new EJBMethodPermission("bar", "", "", new
String[] {});
-        EJBMethodPermission permissionFooEIP = new EJBMethodPermission("foo", "", "LocalHome",
new String[] { "a", "b", "c", "d" });
+        EJBMethodPermission permissionFooEIP = new EJBMethodPermission("foo", "", "LocalHome",
new String[] { "a", "b", "c", "d", "e"});
         EJBMethodPermission permissionFooEIE = new EJBMethodPermission("foo", "", "LocalHome",
new String[] {});
         EJBMethodPermission permissionFooEI  = new EJBMethodPermission("foo", "", "LocalHome",
null);
 
@@ -311,7 +311,7 @@
         doTestSerialization(permission);
 
         assertEquals(permission.getName(), "foo");
-        assertEquals(permission.getActions(), "cat,ServiceEndpoint,java.lang.Integer,java.lang.Float,java.lang.Long,java.lang.Double");
+        assertEquals(permission.getActions(), "cat,ServiceEndpoint,java.lang.Integer,java.lang.Float,java.lang.Long,java.lang.Double,int[]");
 
         // Parameter method must not be null
         try {
@@ -336,9 +336,10 @@
     }
 
     class TestClass {
-        public Object cat(Integer a, Float b, Long c, Double d) {
+        public Object cat(Integer a, Float b, Long c, Double d, int[] e) {
             return null;
         }
+       
     }
 }
 



Mime
View raw message