1 /* 2 * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.security.acl; 27 28 import java.util.Enumeration; 29 import java.security.Principal; 30 31 /** 32 * This interface is used to represent a group of principals. (A principal 33 * represents an entity such as an individual user or a company). <p> 34 * 35 * Note that Group extends Principal. Thus, either a Principal or a Group can 36 * be passed as an argument to methods containing a Principal parameter. For 37 * example, you can add either a Principal or a Group to a Group object by 38 * calling the object's {@code addMember} method, passing it the 39 * Principal or Group. 40 * 41 * @author Satish Dharmaraj 42 */ 43 public interface Group extends Principal { 44 45 /** 46 * Adds the specified member to the group. 47 * 48 * @param user the principal to add to this group. 49 * 50 * @return true if the member was successfully added, 51 * false if the principal was already a member. 52 */ addMember(Principal user)53 public boolean addMember(Principal user); 54 55 /** 56 * Removes the specified member from the group. 57 * 58 * @param user the principal to remove from this group. 59 * 60 * @return true if the principal was removed, or 61 * false if the principal was not a member. 62 */ removeMember(Principal user)63 public boolean removeMember(Principal user); 64 65 /** 66 * Returns true if the passed principal is a member of the group. 67 * This method does a recursive search, so if a principal belongs to a 68 * group which is a member of this group, true is returned. 69 * 70 * @param member the principal whose membership is to be checked. 71 * 72 * @return true if the principal is a member of this group, 73 * false otherwise. 74 */ isMember(Principal member)75 public boolean isMember(Principal member); 76 77 78 /** 79 * Returns an enumeration of the members in the group. 80 * The returned objects can be instances of either Principal 81 * or Group (which is a subclass of Principal). 82 * 83 * @return an enumeration of the group members. 84 */ members()85 public Enumeration<? extends Principal> members(); 86 87 } 88