FileDocCategorySizeDatePackage
GroupImpl.javaAPI DocAndroid 1.5 API3575Wed May 06 22:41:06 BST 2009org.apache.harmony.security.tests.support.acl

GroupImpl

public class GroupImpl extends Object implements java.security.acl.Group
Additional class for verification Group interface

Fields Summary
private Vector
groupMembers
private String
group
Constructors Summary
public GroupImpl(String s)

        groupMembers = new Vector(50, 100);
        group = s;
    
Methods Summary
public booleanaddMember(java.security.Principal principal)

        if(groupMembers.contains(principal))
            return false;
        if(group.equals(principal.toString())) {
            throw new IllegalArgumentException();
        } else {
            groupMembers.addElement(principal);
            return true;
        }
    
public booleanequals(java.lang.Object obj)

        if(this == obj)
            return true;
        if(!(obj instanceof Group)) {
            return false;
        } else {
            Group group1 = (Group)obj;
            return group.equals(group1.toString());
        }
    
public booleanequals(java.security.acl.Group group1)

        return equals(group1);
    
public java.lang.StringgetName()

        return group;
    
public inthashCode()

        return group.hashCode();
    
public booleanisMember(java.security.Principal principal)

        if(groupMembers.contains(principal)) {
            return true;
        } else {
            Vector vector = new Vector(10);
            return isMemberRecurse(principal, vector);
        }
    
booleanisMemberRecurse(java.security.Principal principal, java.util.Vector vector)

        for(Enumeration enumeration = members(); enumeration.hasMoreElements();) {
            boolean flag = false;
            Principal principal1 = (Principal)enumeration.nextElement();
            if(principal1.equals(principal))
                return true;
            if(principal1 instanceof GroupImpl) {
                GroupImpl groupimpl = (GroupImpl)principal1;
                vector.addElement(this);
                if(!vector.contains(groupimpl))
                    flag = groupimpl.isMemberRecurse(principal, vector);
            } else if(principal1 instanceof Group) {
                Group group1 = (Group)principal1;
                if(!vector.contains(group1)) flag = group1.isMember(principal);
            } 
            if(flag) return flag;
        }
        return false;
    
public java.util.Enumerationmembers()

        return groupMembers.elements();
    
public booleanremoveMember(java.security.Principal principal)

        return groupMembers.removeElement(principal);
    
public java.lang.StringtoString()

        return group;