geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r209985 - in /geronimo/trunk/specs/j2ee-jacc/src: java/javax/security/jacc/EJBMethodPermission.java test/javax/security/jacc/EJBMethodPermissionTest.java
Date Sun, 10 Jul 2005 03:22:22 GMT
Author: djencks
Date: Sat Jul  9 20:22:20 2005
New Revision: 209985

URL: http://svn.apache.org/viewcvs?rev=209985&view=rev
Log:
GERONIMO-661 unchecked EJBMethodPermissions do not work

Modified:
    geronimo/trunk/specs/j2ee-jacc/src/java/javax/security/jacc/EJBMethodPermission.java
    geronimo/trunk/specs/j2ee-jacc/src/test/javax/security/jacc/EJBMethodPermissionTest.java

Modified: geronimo/trunk/specs/j2ee-jacc/src/java/javax/security/jacc/EJBMethodPermission.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/specs/j2ee-jacc/src/java/javax/security/jacc/EJBMethodPermission.java?rev=209985&r1=209984&r2=209985&view=diff
==============================================================================
--- geronimo/trunk/specs/j2ee-jacc/src/java/javax/security/jacc/EJBMethodPermission.java (original)
+++ geronimo/trunk/specs/j2ee-jacc/src/java/javax/security/jacc/EJBMethodPermission.java Sat
Jul  9 20:22:20 2005
@@ -250,7 +250,7 @@
             if (methodParams == null) {
                 if (methodInterface == null) {
                     if (methodName == null) {
-                        actions = ",,";
+                        actions = "";
                     } else {
 
                         actions = methodName;

Modified: geronimo/trunk/specs/j2ee-jacc/src/test/javax/security/jacc/EJBMethodPermissionTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/specs/j2ee-jacc/src/test/javax/security/jacc/EJBMethodPermissionTest.java?rev=209985&r1=209984&r2=209985&view=diff
==============================================================================
--- geronimo/trunk/specs/j2ee-jacc/src/test/javax/security/jacc/EJBMethodPermissionTest.java
(original)
+++ geronimo/trunk/specs/j2ee-jacc/src/test/javax/security/jacc/EJBMethodPermissionTest.java
Sat Jul  9 20:22:20 2005
@@ -26,6 +26,10 @@
 import junit.framework.TestCase;
 
 import java.lang.reflect.Method;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
 
 /**
  *
@@ -47,36 +51,54 @@
     /*
      * Testing EJBMethodPermission(java.lang.String, java.lang.String)
      */
-    public void testConstructorStringString() {
+    public void testConstructorStringString() throws Exception {
 
         // methodSpec ::= null
         EJBMethodPermission permission = new EJBMethodPermission("foo", null);
+        doTestSerialization(permission);
 
         // methodSpec ::= methodNameSpec
         permission = new EJBMethodPermission("foo", "");
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "cat");
+        doTestSerialization(permission);
 
         // methodSpec ::= methodNameSpec comma methodInterface
         permission = new EJBMethodPermission("foo", ",ServiceEndpoint");
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "cat,ServiceEndpoint");
+        doTestSerialization(permission);
 
         // methodSpec ::= methodNameSpec comma methodInterfaceSpec comma methodParamsSpec
         permission = new EJBMethodPermission("foo", ",,");
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "cat,,");
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", ",Home,");
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "cat,Home,");
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", ",,a,b,c,d");
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "cat,,a,b,c,d");
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", ",Home,a,b,c,d");
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "cat,Home,a,b,c,d");
+        doTestSerialization(permission);
 
 
         // methodInterface ::= "Home" | "LocalHome" | "Remote" | "Local" | "ServiceEndpoint"
         permission = new EJBMethodPermission("foo", "cat,Home,a,b,c,d");
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "cat,LocalHome,a,b,c,d");
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "cat,Remote,a,b,c,d");
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "cat,Local,a,b,c,d");
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "cat,ServiceEndpoint,a,b,c,d");
+        doTestSerialization(permission);
 
         assertEquals(permission.getName(), "foo");
         assertEquals(permission.getActions(), "cat,ServiceEndpoint,a,b,c,d");
@@ -118,7 +140,7 @@
         }
     }
 
-    public void testImpliesStringString() {
+    public void testImpliesStringString() throws Exception {
         EJBMethodPermission permissionFooEEE = new EJBMethodPermission("foo", "");
         EJBMethodPermission permissionFooMIP = new EJBMethodPermission("foo", "cat,LocalHome,a,b,c,d");
         EJBMethodPermission permissionBarEEE = new EJBMethodPermission("bar", "");
@@ -150,41 +172,66 @@
         assertTrue(permissionFooEI.implies(permissionFooEIE));
 
         assertFalse(permissionFooEEE.hashCode() == permissionBarEEE.hashCode());
+
+        doTestSerialization(permissionFooEEE);
+        doTestSerialization(permissionFooMIP);
+        doTestSerialization(permissionBarEEE);
+        doTestSerialization(permissionFooEIP);
+        doTestSerialization(permissionFooEIE);
+        doTestSerialization(permissionFooEI);
     }
 
     /*
      * Testing EJBMethodPermission(String, String, String, String[])
      */
-    public void testConstructorStringStringStringStringArray() {
+    public void testConstructorStringStringStringStringArray() throws Exception {
 
         // methodSpec ::= null
         EJBMethodPermission permission = new EJBMethodPermission("foo", null, null, null);
+        doTestSerialization(permission);
 
         // methodSpec ::= methodNameSpec
         permission = new EJBMethodPermission("foo", "", "", null);
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "cat", "", null);
+        doTestSerialization(permission);
 
         // methodSpec ::= methodNameSpec comma methodInterface
         permission = new EJBMethodPermission("foo", "", "ServiceEndpoint", null);
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "cat", "ServiceEndpoint", null);
+        doTestSerialization(permission);
 
         // methodSpec ::= methodNameSpec comma methodInterfaceSpec comma methodParamsSpec
         permission = new EJBMethodPermission("foo", "", "", new String[]{});
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "cat", "", new String[]{});
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "", "Home", new String[]{});
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "cat", "Home", new String[] {});
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "", "", new String[] { "a", "b", "c",
"d" });
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "cat", "", new String[] { "a", "b", "c",
"d" });
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "", "Home", new String[] { "a", "b",
"c", "d" });
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "cat", "Home", new String[] { "a", "b",
"c", "d" });
+        doTestSerialization(permission);
 
 
         // methodInterface ::= "Home" | "LocalHome" | "Remote" | "Local" | "ServiceEndpoint"
         permission = new EJBMethodPermission("foo", "cat", "Home", new String[] { "a", "b",
"c", "d" });
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "cat", "LocalHome", new String[] { "a",
"b", "c", "d" });
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "cat", "Remote", new String[] { "a",
"b", "c", "d" });
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "cat", "Local", new String[] { "a", "b",
"c", "d" });
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "cat", "ServiceEndpoint", new String[]
{ "a", "b", "c", "d" });
+        doTestSerialization(permission);
 
         assertEquals(permission.getName(), "foo");
         assertEquals(permission.getActions(), "cat,ServiceEndpoint,a,b,c,d");
@@ -198,7 +245,7 @@
         }
     }
 
-    public void testImpliesStringStringStringStringArray() {
+    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 permissionBarEEE = new EJBMethodPermission("bar", "", "", new
String[] {});
@@ -230,23 +277,37 @@
         assertTrue(permissionFooEI.implies(permissionFooEIE));
 
         assertFalse(permissionFooEEE.hashCode() == permissionBarEEE.hashCode());
+
+        doTestSerialization(permissionFooEEE);
+        doTestSerialization(permissionFooMIP);
+        doTestSerialization(permissionBarEEE);
+        doTestSerialization(permissionFooEIP);
+        doTestSerialization(permissionFooEIE);
+        doTestSerialization(permissionFooEI);
     }
 
     /*
      * Testing EJBMethodPermission(String, String, Method)
      */
-    public void testConstructorStringStringMethod() {
+    public void testConstructorStringStringMethod() throws Exception {
 
         EJBMethodPermission permission = new EJBMethodPermission("foo", "ServiceEndpoint",
method);
-
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", null, method);
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "", method);
+        doTestSerialization(permission);
 
         permission = new EJBMethodPermission("foo", "Home", method);
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "LocalHome", method);
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "Remote", method);
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "Local", method);
+        doTestSerialization(permission);
         permission = new EJBMethodPermission("foo", "ServiceEndpoint", method);
+        doTestSerialization(permission);
 
         assertEquals(permission.getName(), "foo");
         assertEquals(permission.getActions(), "cat,ServiceEndpoint,java.lang.Integer,java.lang.Float,java.lang.Long,java.lang.Double");
@@ -260,6 +321,17 @@
     }
 
     public void testImpliesStringStringMethod() {
+    }
+
+    private void doTestSerialization(EJBMethodPermission permission) throws Exception {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream oos = new ObjectOutputStream(baos);
+        oos.writeObject(permission);
+        oos.flush();
+        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+        ObjectInputStream ois = new ObjectInputStream(bais);
+        Object o = ois.readObject();
+        assertEquals("Permission did not serialize correctly", permission, o);
     }
 
     class TestClass {



Mime
View raw message