1 25 26 package org.objectweb.easybeans.security.struct; 27 28 import java.io.Serializable ; 29 import java.security.Principal ; 30 import java.security.acl.Group ; 31 import java.util.Enumeration ; 32 import java.util.Vector ; 33 34 39 public class JGroup implements Group , Serializable { 40 41 44 private static final long serialVersionUID = 7035827226889396034L; 45 46 49 private String groupName = null; 50 51 54 private Vector <Principal > members = null; 55 56 60 public JGroup(final String groupName) { 61 this.groupName = groupName; 62 this.members = new Vector <Principal >(); 63 } 64 65 73 @Override 74 public boolean equals(final Object another) { 75 if (!(another instanceof Group )) { 76 return false; 77 } 78 return groupName.equals(((Group ) another).getName()); 80 } 81 82 86 @Override 87 public String toString() { 88 return "Principal[" + groupName + "]"; 89 } 90 91 95 @Override 96 public int hashCode() { 97 return groupName.hashCode(); 98 } 99 100 104 public String getName() { 105 return groupName; 106 } 107 108 114 public boolean addMember(final Principal user) { 115 if (isMember(user)) { 116 return false; 117 } 118 members.add(user); 120 return true; 121 } 122 123 129 public boolean removeMember(final Principal user) { 130 if (!isMember(user)) { 131 return false; 132 } 133 members.remove(user); 135 return true; 136 } 137 138 145 public boolean isMember(final Principal member) { 146 return members.contains(member); 147 } 148 149 155 public Enumeration <? extends Principal > members() { 156 return members.elements(); 157 } 158 159 } 160 | Popular Tags |