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