1 26 27 package org.objectweb.jonas.security.auth; 28 29 import java.io.Serializable ; 30 import java.security.Principal ; 31 import java.security.acl.Group ; 32 import java.util.Enumeration ; 33 import java.util.Vector ; 34 35 40 public class JGroup implements Group , Serializable { 41 42 43 46 private String name = null; 47 48 51 private Vector members = null; 52 53 54 58 public JGroup(String name) { 59 this.name = name; 60 this.members = new Vector (); 61 62 } 63 64 69 public boolean equals(Object another) { 70 if (!(another instanceof Group )) { 71 return false; 72 } 73 return name.equals(((Group ) another).getName()); 75 } 76 77 81 public String toString() { 82 return "Principal[" + name + "]"; 83 } 84 85 86 90 public int hashCode() { 91 return name.hashCode(); 92 } 93 94 98 public String getName() { 99 return name; 100 } 101 102 107 public boolean addMember(Principal user) { 108 if (isMember(user)) { 109 return false; 110 } 111 members.add(user); 113 return true; 114 } 115 116 121 public boolean removeMember(Principal user) { 122 if (!isMember(user)) { 123 return false; 124 } 125 members.remove(user); 127 return true; 128 } 129 130 131 136 public boolean isMember(Principal member) { 137 return members.contains(member); 138 } 139 140 141 145 public Enumeration members() { 146 return members.elements(); 147 } 148 149 } 150 | Popular Tags |