[jboss-cvs] JBossAS SVN: r69098 - in projects/security/security-jboss-sx/trunk/identity/src: tests/org/jboss/test/identity/impl and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jan 17 18:14:41 EST 2008


Author: anil.saldhana at jboss.com
Date: 2008-01-17 18:14:40 -0500 (Thu, 17 Jan 2008)
New Revision: 69098

Added:
   projects/security/security-jboss-sx/trunk/identity/src/tests/org/jboss/test/identity/impl/RoleGroupUnitTestCase.java
Modified:
   projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleRole.java
Log:
take care of anybody role

Modified: projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleRole.java
===================================================================
--- projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleRole.java	2008-01-17 22:45:47 UTC (rev 69097)
+++ projects/security/security-jboss-sx/trunk/identity/src/main/org/jboss/security/identity/plugins/SimpleRole.java	2008-01-17 23:14:40 UTC (rev 69098)
@@ -38,6 +38,8 @@
 {
    private static final long serialVersionUID = 1L;
    private String roleName;
+   
+   public static final String ANYBODY = "<ANYBODY>";
 
    public SimpleRole(String roleName)
    {
@@ -60,7 +62,11 @@
    public boolean containsAll(Role anotherRole)
    {
       if(anotherRole.getType() == RoleType.simple)
-         return roleName.equals(anotherRole.getRoleName());
+      {
+         if(ANYBODY.equals(roleName))
+            return true;
+         return roleName.equals(anotherRole.getRoleName()); 
+      }
       return false; 
    }
 

Added: projects/security/security-jboss-sx/trunk/identity/src/tests/org/jboss/test/identity/impl/RoleGroupUnitTestCase.java
===================================================================
--- projects/security/security-jboss-sx/trunk/identity/src/tests/org/jboss/test/identity/impl/RoleGroupUnitTestCase.java	                        (rev 0)
+++ projects/security/security-jboss-sx/trunk/identity/src/tests/org/jboss/test/identity/impl/RoleGroupUnitTestCase.java	2008-01-17 23:14:40 UTC (rev 69098)
@@ -0,0 +1,63 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2007, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.test.identity.impl;
+
+import org.jboss.security.identity.plugins.SimpleRole;
+import org.jboss.security.identity.plugins.SimpleRoleGroup;
+
+import junit.framework.TestCase;
+
+//$Id$
+
+/**
+ *  Test complex RoleGroup situations
+ *  @author Anil.Saldhana at redhat.com
+ *  @since  Jan 17, 2008 
+ *  @version $Revision$
+ */
+public class RoleGroupUnitTestCase extends TestCase
+{
+
+   public void testAnybodyRole()
+   {
+      SimpleRoleGroup srg = new SimpleRoleGroup("Roles");
+      srg.addRole(new SimpleRole(SimpleRole.ANYBODY));
+      assertTrue(srg.containsRole(new SimpleRole("AnyRole")));
+   }
+   
+   
+   public void testNestedRoles()
+   {
+      SimpleRoleGroup srg = new SimpleRoleGroup("nested");
+      srg.addRole(new SimpleRole("aRole"));
+      srg.addRole(new SimpleRole("bRole"));
+      
+      SimpleRoleGroup methodRoles = new SimpleRoleGroup("Roles");
+      methodRoles.addRole(srg);
+      
+      //Create user role now
+      SimpleRoleGroup userRole = new SimpleRoleGroup("Roles");
+      userRole.addRole(new SimpleRole("aRole"));
+      methodRoles.containsAtleastOneRole(userRole); 
+   }
+
+}




More information about the jboss-cvs-commits mailing list