[jboss-cvs] JBossAS SVN: r83514 - in projects/security/security-jboss-sx/trunk/jbosssx/src: test/java/org/jboss/test/security/helpers and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jan 27 15:17:37 EST 2009


Author: anil.saldhana at jboss.com
Date: 2009-01-27 15:17:37 -0500 (Tue, 27 Jan 2009)
New Revision: 83514

Modified:
   projects/security/security-jboss-sx/trunk/jbosssx/src/main/java/org/jboss/security/plugins/javaee/EJBAuthorizationHelper.java
   projects/security/security-jboss-sx/trunk/jbosssx/src/test/java/org/jboss/test/security/helpers/EJBAuthorizationHelperUnitTestCase.java
Log:
SECURITY-349: flag error when caller subject and caller run-as both are null

Modified: projects/security/security-jboss-sx/trunk/jbosssx/src/main/java/org/jboss/security/plugins/javaee/EJBAuthorizationHelper.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx/src/main/java/org/jboss/security/plugins/javaee/EJBAuthorizationHelper.java	2009-01-27 19:56:54 UTC (rev 83513)
+++ projects/security/security-jboss-sx/trunk/jbosssx/src/main/java/org/jboss/security/plugins/javaee/EJBAuthorizationHelper.java	2009-01-27 20:17:37 UTC (rev 83514)
@@ -74,8 +74,8 @@
          throw new IllegalArgumentException("EJB CodeSource is null");
       if(contextID == null)
          throw new IllegalArgumentException("ContextID is null");
-      if(callerSubject == null)
-         throw new IllegalArgumentException("callerSubject is null"); 
+      if(callerSubject == null && callerRunAs == null)
+         throw new IllegalArgumentException("Either callerSubject or callerRunAs should be non-null"); 
 
       AuthorizationManager am = securityContext.getAuthorizationManager();
       if(am == null)

Modified: projects/security/security-jboss-sx/trunk/jbosssx/src/test/java/org/jboss/test/security/helpers/EJBAuthorizationHelperUnitTestCase.java
===================================================================
--- projects/security/security-jboss-sx/trunk/jbosssx/src/test/java/org/jboss/test/security/helpers/EJBAuthorizationHelperUnitTestCase.java	2009-01-27 19:56:54 UTC (rev 83513)
+++ projects/security/security-jboss-sx/trunk/jbosssx/src/test/java/org/jboss/test/security/helpers/EJBAuthorizationHelperUnitTestCase.java	2009-01-27 20:17:37 UTC (rev 83514)
@@ -108,6 +108,36 @@
       assertFalse("InvalidAuthz", result);
    }
    
+   public void testRequiredParameters() throws Exception
+   {
+      Principal ejbPrincipal = new SimplePrincipal("AuthenticatedPrincipal");
+      Subject callerSubject = new Subject();
+      callerSubject.getPrincipals().add(ejbPrincipal); 
+
+      RoleGroup roleGroup = SecurityTestUtil.getRoleGroup(new String[]{"villain"});
+        
+      //Add good roles to the context
+      sc.getUtil().setRoles(roleGroup);
+      
+      try
+      { 
+         eah.authorize("TestEJB", 
+               DummyClass.class.getMethod("someMethod", new Class[0]), 
+               ejbPrincipal, 
+               "void someMethod",  
+               this.getClass().getProtectionDomain().getCodeSource(), 
+               null, 
+               null, 
+               "ejb.jar", 
+               methodRoleGroup);
+         fail("Either subject or caller runas needs to be passed");
+      }
+      catch(IllegalArgumentException iae)
+      {
+         //pass
+      }
+   }
+   
    /**
     * Dummy Class just to get a Method instance
     * by calling DummyClass.class.getMethod()




More information about the jboss-cvs-commits mailing list