1. /*
  2. * @(#)Group.java 1.17 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.security.acl;
  8. import java.util.Enumeration;
  9. import java.security.Principal;
  10. /**
  11. * This interface is used to represent a group of principals. (A principal
  12. * represents an entity such as an individual user or a company). <p>
  13. *
  14. * Note that Group extends Principal. Thus, either a Principal or a Group can
  15. * be passed as an argument to methods containing a Principal parameter. For
  16. * example, you can add either a Principal or a Group to a Group object by
  17. * calling the object's <code>addMember</code> method, passing it the
  18. * Principal or Group.
  19. *
  20. * @author Satish Dharmaraj
  21. */
  22. public interface Group extends Principal {
  23. /**
  24. * Adds the specified member to the group.
  25. *
  26. * @param user the principal to add to this group.
  27. *
  28. * @return true if the member was successfully added,
  29. * false if the principal was already a member.
  30. */
  31. public boolean addMember(Principal user);
  32. /**
  33. * Removes the specified member from the group.
  34. *
  35. * @param user the principal to remove from this group.
  36. *
  37. * @return true if the principal was removed, or
  38. * false if the principal was not a member.
  39. */
  40. public boolean removeMember(Principal user);
  41. /**
  42. * Returns true if the passed principal is a member of the group.
  43. * This method does a recursive search, so if a principal belongs to a
  44. * group which is a member of this group, true is returned.
  45. *
  46. * @param member the principal whose membership is to be checked.
  47. *
  48. * @return true if the principal is a member of this group,
  49. * false otherwise.
  50. */
  51. public boolean isMember(Principal member);
  52. /**
  53. * Returns an enumeration of the members in the group.
  54. * The returned objects can be instances of either Principal
  55. * or Group (which is a subclass of Principal).
  56. *
  57. * @return an enumeration of the group members.
  58. */
  59. public Enumeration members();
  60. }