User: starksm 
  Date: 01/06/12 01:03:33

  Modified:    src/main/org/jboss/security SimpleGroup.java
  Removed:     src/main/org/jboss/security EJBSecurityManager.java
                        RealmMapping.java SecurityAssociation.java
                        SecurityProxy.java SecurityProxyFactory.java
                        SubjectSecurityManager.java
  Log:
  Add special check for membership of AnybodyPrincipal and NobodyPrincipal
  types to SimpleGroup.isMember
  
  Move the security related files that make up the JBoss security plugin
  interface back to the jboss module as it should build without the
  JBossSX implementation
  
  Revision  Changes    Path
  1.2       +18 -9     jbosssx/src/main/org/jboss/security/SimpleGroup.java
  
  Index: SimpleGroup.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbosssx/src/main/org/jboss/security/SimpleGroup.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SimpleGroup.java  2001/03/05 09:53:27     1.1
  +++ SimpleGroup.java  2001/06/12 08:03:33     1.2
  @@ -15,8 +15,8 @@
   import java.util.Iterator;
   import java.util.HashMap;
   
  -/** An implementation of Group that manages a collection of
  -Principal objects based on their getName() values. This class
  +/** An implementation of Group that manages a collection of Principal
  +objects based on their hashCode() and equals() methods. This class
   is not thread safe.
   
   @author [EMAIL PROTECTED]
  @@ -38,16 +38,18 @@
        */
       public boolean addMember(Principal user)
       {
  -        String key = user.getName();
  -        boolean isMember = members.containsKey(key);
  +        boolean isMember = members.containsKey(user);
           if( isMember == false )
  -            members.put(key, user);
  +            members.put(user, user);
           return isMember == false;
       }
       /** Returns true if the passed principal is a member of the group.
           This method does a recursive search, so if a principal belongs to a
           group which is a member of this group, true is returned.
   
  +        A special check is made to see if the member is an instance of
  +        org.jboss.security.AnybodyPrincipal or org.jboss.security.NobodyPrincipal
  +        since these classes do not hash to meaningful values.
       @param member the principal whose membership is to be checked.
       @return true if the principal is a member of this group,
           false otherwise.
  @@ -55,9 +57,17 @@
       public boolean isMember(Principal member)
       {
           // First see if there is a key with the member name
  -        String key = member.getName();
  -        boolean isMember = members.containsKey(key);
  +        boolean isMember = members.containsKey(member);
           if( isMember == false )
  +        {   // Check the AnybodyPrincipal & NobodyPrincipal special cases
  +            isMember = (member instanceof org.jboss.security.AnybodyPrincipal);
  +            if( isMember == false )
  +            {
  +                if( member instanceof org.jboss.security.NobodyPrincipal )
  +                return false;
  +            }
  +        }
  +        if( isMember == false )
           {   // Check any Groups for membership
               Collection values = members.values();
               Iterator iter = values.iterator();
  @@ -91,8 +101,7 @@
       */
       public boolean removeMember(Principal user)
       {
  -        String key = user.getName();
  -        Object prev = members.remove(key);
  +        Object prev = members.remove(user);
           return prev != null;
       }
   }
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to