1. /*
  2. * @(#)AclEntry.java 1.13 01/11/29
  3. *
  4. * Copyright 2002 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 is the interface used for representing one entry in an Access
  12. * Control List (ACL).<p>
  13. *
  14. * An ACL can be thought of as a data structure with multiple ACL entry
  15. * objects. Each ACL entry object contains a set of permissions associated
  16. * with a particular principal. (A principal represents an entity such as
  17. * an individual user or a group). Additionally, each ACL entry is specified
  18. * as being either positive or negative. If positive, the permissions are
  19. * to be granted to the associated principal. If negative, the permissions
  20. * are to be denied. Each principal can have at most one positive ACL entry
  21. * and one negative entry; that is, multiple positive or negative ACL
  22. * entries are not allowed for any principal.
  23. *
  24. * Note: ACL entries are by default positive. An entry becomes a
  25. * negative entry only if the
  26. * {@link setNegativePermissions() setNegativePermissions}
  27. * method is called on it.
  28. *
  29. * @see java.security.acl.Acl
  30. *
  31. * @author Satish Dharmaraj
  32. */
  33. public interface AclEntry extends Cloneable {
  34. /**
  35. * Specifies the principal for which permissions are granted or denied
  36. * by this ACL entry. If a principal was already set for this ACL entry,
  37. * false is returned, otherwise true is returned.
  38. *
  39. * @param user the principal to be set for this entry.
  40. *
  41. * @return true if the principal is set, false if there was
  42. * already a principal set for this entry.
  43. */
  44. public boolean setPrincipal(Principal user);
  45. /**
  46. * Returns the principal for which permissions are granted or denied by
  47. * this ACL entry. Returns null if there is no principal set for this
  48. * entry yet.
  49. *
  50. * @return the principal associated with this entry.
  51. */
  52. public Principal getPrincipal();
  53. /**
  54. * Sets this ACL entry to be a negative one. That is, the associated
  55. * principal (e.g., a user or a group) will be denied the permission set
  56. * specified in the entry.
  57. *
  58. * Note: ACL entries are by default positive. An entry becomes a
  59. * negative entry only if this <code>setNegativePermissions</code>
  60. * method is called on it.
  61. */
  62. public void setNegativePermissions();
  63. /**
  64. * Returns true if this is a negative ACL entry (one denying the
  65. * associated principal the set of permissions in the entry), false
  66. * otherwise.
  67. *
  68. * @return true if this is a negative ACL entry, false if it's not.
  69. */
  70. public boolean isNegative();
  71. /**
  72. * Adds the specified permission to this ACL entry. Note: An entry can
  73. * have multiple permissions.
  74. *
  75. * @param permission the permission to be associated with
  76. * the principal in this entry.
  77. *
  78. * @return true if the permission was added, false if the
  79. * permission was already part of this entry's permission set.
  80. */
  81. public boolean addPermission(Permission permission);
  82. /**
  83. * Removes the specified permission from this ACL entry.
  84. *
  85. * @param permission the permission to be removed from this entry.
  86. *
  87. * @return true if the permission is removed, false if the
  88. * permission was not part of this entry's permission set.
  89. */
  90. public boolean removePermission(Permission permission);
  91. /**
  92. * Checks if the specified permission is part of the
  93. * permission set in this entry.
  94. *
  95. * @param permission the permission to be checked for.
  96. *
  97. * @return true if the permission is part of the
  98. * permission set in this entry, false otherwise.
  99. */
  100. public boolean checkPermission(Permission permission);
  101. /**
  102. * Returns an enumeration of the permissions in this ACL entry.
  103. *
  104. * @return an enumeration of the permissions in this ACL entry.
  105. */
  106. public Enumeration permissions();
  107. /**
  108. * Returns a string representation of the contents of this ACL entry.
  109. *
  110. * @return a string representation of the contents.
  111. */
  112. public String toString();
  113. /**
  114. * Clones this ACL entry.
  115. *
  116. * @return a clone of this ACL entry.
  117. */
  118. public Object clone();
  119. }