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