home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 April / DPPCPRO0499.ISO / April / Notes / 50b2wic.exe / DATA1.CAB / NotesProgramFilesJavaSupport / rt.jar / sun / security / acl / GroupImpl.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-23  |  1.8 KB  |  91 lines

  1. package sun.security.acl;
  2.  
  3. import java.security.Principal;
  4. import java.security.acl.Group;
  5. import java.util.Enumeration;
  6. import java.util.Vector;
  7.  
  8. public class GroupImpl implements Group {
  9.    private Vector groupMembers = new Vector(50, 100);
  10.    private String group;
  11.  
  12.    public GroupImpl(String var1) {
  13.       this.group = var1;
  14.    }
  15.  
  16.    public boolean addMember(Principal var1) {
  17.       if (this.groupMembers.contains(var1)) {
  18.          return false;
  19.       } else if (this.group.equals(var1.toString())) {
  20.          throw new IllegalArgumentException();
  21.       } else {
  22.          this.groupMembers.addElement(var1);
  23.          return true;
  24.       }
  25.    }
  26.  
  27.    public boolean removeMember(Principal var1) {
  28.       return this.groupMembers.removeElement(var1);
  29.    }
  30.  
  31.    public Enumeration members() {
  32.       return this.groupMembers.elements();
  33.    }
  34.  
  35.    public boolean equals(Group var1) {
  36.       return this.group.equals(var1.toString());
  37.    }
  38.  
  39.    public String toString() {
  40.       return this.group;
  41.    }
  42.  
  43.    public int hashCode() {
  44.       return this.group.hashCode();
  45.    }
  46.  
  47.    public boolean isMember(Principal var1) {
  48.       if (this.groupMembers.contains(var1)) {
  49.          return true;
  50.       } else {
  51.          Vector var2 = new Vector(10);
  52.          return this.isMemberRecurse(var1, var2);
  53.       }
  54.    }
  55.  
  56.    public String getName() {
  57.       return this.group;
  58.    }
  59.  
  60.    boolean isMemberRecurse(Principal var1, Vector var2) {
  61.       Enumeration var3 = this.members();
  62.  
  63.       while(var3.hasMoreElements()) {
  64.          boolean var4 = false;
  65.          Principal var5 = (Principal)var3.nextElement();
  66.          if (var5.equals(var1)) {
  67.             return true;
  68.          }
  69.  
  70.          if (var5 instanceof GroupImpl) {
  71.             GroupImpl var6 = (GroupImpl)var5;
  72.             var2.addElement(this);
  73.             if (!var2.contains(var6)) {
  74.                var4 = var6.isMemberRecurse(var1, var2);
  75.             }
  76.          } else if (var5 instanceof Group) {
  77.             Group var7 = (Group)var5;
  78.             if (!var2.contains(var7)) {
  79.                var4 = var7.isMember(var1);
  80.             }
  81.          }
  82.  
  83.          if (var4) {
  84.             return var4;
  85.          }
  86.       }
  87.  
  88.       return false;
  89.    }
  90. }
  91.