@@ -0,0 +1,1556 @@
+package org.xdi.model.security;%0D%0A%0D%0Aimport java.io.Serializable;%0D%0Aimport java.security.Principal;%0D%0Aimport java.security.acl.Group;%0D%0Aimport java.util.Collections;%0D%0Aimport java.util.Enumeration;%0D%0Aimport java.util.HashSet;%0D%0Aimport java.util.Set;%0D%0A%0D%0A/**%0D%0A * Implementation of the Group interface, used for holding roles etc.%0D%0A */%0D%0Apublic class SimpleGroup implements Group, Serializable %7B%0D%0A%0D%0A%09private static final long serialVersionUID = 391089759338334557L;%0D%0A%0D%0A%09/**%0D%0A%09 * The name of the group%0D%0A%09 */%0D%0A%09private String name;%0D%0A%0D%0A%09/**%0D%0A%09 * The members of this group%0D%0A%09 */%0D%0A%09private Set%3CPrincipal%3E members = new HashSet%3CPrincipal%3E();%0D%0A%0D%0A%09public SimpleGroup(String name) %7B%0D%0A%09%09this.name = name;%0D%0A%09%7D%0D%0A%0D%0A%09public boolean addMember(Principal user) %7B%0D%0A%09%09return members.add(user);%0D%0A%09%7D%0D%0A%0D%0A%09public boolean isMember(Principal member) %7B%0D%0A%09%09if (members.contains(member)) %7B%0D%0A%09%09%09return true;%0D%0A%09%09%7D else %7B%0D%0A%09%09%09for (Principal m : members) %7B%0D%0A%09%09%09%09if (m instanceof Group && ((Group) m).isMember(member)) %7B%0D%0A%09%09%09%09%09return true;%0D%0A%09%09%09%09%7D%0D%0A%09%09%09%7D%0D%0A%09%09%7D%0D%0A%09%09return false;%0D%0A%09%7D%0D%0A%0D%0A%09public Enumeration%3C? extends Principal%3E members() %7B%0D%0A%09%09return Collections.enumeration(members);%0D%0A%09%7D%0D%0A%0D%0A%09public boolean removeMember(Principal user) %7B%0D%0A%09%09return members.remove(user);%0D%0A%09%7D%0D%0A%0D%0A%09public String getName() %7B%0D%0A%09%09return name;%0D%0A%09%7D%0D%0A%0D%0A%09@Override%0D%0A%09public boolean equals(Object obj) %7B%0D%0A%09%09if (obj instanceof SimpleGroup) %7B%0D%0A%09%09%09SimpleGroup other = (SimpleGroup) obj;%0D%0A%09%09%09return other.name.equals(name);%0D%0A%09%09%7D else %7B%0D%0A%09%09%09return false;%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%0D%0A%09@Override%0D%0A%09public int hashCode() %7B%0D%0A%09%09return name.hashCode();%0D%0A%09%7D%0D%0A%7D%0D%0A

Add SimpleGroup