Acl.java 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /* Acl.java -- An access control list
  2. Copyright (C) 1998 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package java.security.acl;
  32. import java.security.Principal;
  33. import java.util.Enumeration;
  34. /**
  35. * A Java access control list (ACL) is a group of individual ACL entries.
  36. * These entries consist of a <code>Principal</code> and a list of
  37. * permissions this <code>Principal</code> is either granted or denied.
  38. * A given <code>Principal</code> can have at most one positive ACL entry
  39. * (i.e., one that grants permissions) and one negative ACL entry (i.e., one
  40. * that denies permissions). If a given permission is both granted and
  41. * denied, the ACL treats it as if it were never granted or denied. If
  42. * both a <code>Principal</code> and a <code>Group</code> to which the
  43. * <code>Principal</code> belongs have an ACL entry, the permissions for
  44. * the individual <code>Principal</code> take precedence over the
  45. * permissions of the <code>Group</code> if there is a conflict.
  46. * <p>
  47. * Additionally, the ACL interface extends the <code>Owner</code> interface
  48. * and so an ACL has owners. Actions which modify the ACL are restricted
  49. * to owners.
  50. *
  51. * @version 0.0
  52. *
  53. * @author Aaron M. Renn (arenn@urbanophile.com)
  54. */
  55. public interface Acl extends Owner
  56. {
  57. /**
  58. * This method returns the name of this ACL.
  59. *
  60. * @return The name of this ACL
  61. */
  62. String getName();
  63. /**
  64. * This method sets the name of the ACL
  65. *
  66. * @param caller The <code>Principal</code> requesting the action.
  67. * @param name The new name for this ACL.
  68. *
  69. * @exception NotOwnerException If the caller is not an owner of this ACL.
  70. */
  71. void setName(Principal caller, String name)
  72. throws NotOwnerException;
  73. /**
  74. * This method adds the specified entry to the ACL
  75. *
  76. * @param caller The <code>Principal</code> requesting the addition
  77. * @param entry The ACL entry to add
  78. *
  79. * @return <code>true</code> if the entry was added, <code>false</code>
  80. * if there is already an entry of the same type for the
  81. * <code>Principal</code>.
  82. *
  83. * @exception NotOwnerException If the caller is not an owner of this ACL.
  84. */
  85. boolean addEntry(Principal caller, AclEntry entry)
  86. throws NotOwnerException;
  87. /**
  88. * This method delets the specified entry from the ACL
  89. *
  90. * @param caller The <code>Principal</code> requesting the deletion.
  91. * @param entry The ACL entry to delete
  92. *
  93. * @return <code>true</code> if the entry was deleted, or <code>false</code>
  94. * if this entry was not part of the ACL to begin with
  95. *
  96. * @exception NotOwnerException If the caller is not an owner of this ACL.
  97. */
  98. boolean removeEntry(Principal caller, AclEntry entry)
  99. throws NotOwnerException;
  100. /**
  101. * This method returns a list of all the entries in the ACL as an
  102. * <code>Enumeration</code>.
  103. *
  104. * @return An enumeration of the ACL entries
  105. */
  106. Enumeration<AclEntry> entries();
  107. /**
  108. * This method tests whether or not the specified <code>Principal</code>
  109. * has the specified <code>Permission</code>
  110. *
  111. * @param user The <code>Principal</code> to test
  112. * @param perm The <code>Permission</code> to test for
  113. *
  114. * @return <code>true</code> if the user has been granted the permission,
  115. * <code>false</code> otherwise
  116. */
  117. boolean checkPermission(Principal user, Permission perm);
  118. /**
  119. * This method returns a list of <code>Permission</code>'s that are granted
  120. * to a particular <code>Principal</code>. This includes any permissions
  121. * that are granted to <code>Group</code>'s to which the <code>Principal</code>
  122. * belongs unless they are overridden by a negative ACL. This permission
  123. * list is returned as an <code>Enumeration</code>.
  124. *
  125. * @param user The <code>Principal</code> to retrieve permissions for.
  126. *
  127. * @return A list of permissions for the <code>Principal</code>.
  128. */
  129. Enumeration<Permission> getPermissions(Principal user);
  130. /**
  131. * This method returns the ACL as a <code>String</code>
  132. *
  133. * @return A <code>String</code> representation of this ACL
  134. */
  135. String toString();
  136. }