AclEntry.java 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /* AclEntry.java -- An entry in an ACL 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. * This interface models an entry in an access control list (ACL). Java
  36. * ACL's consist of a list of entries, where each consists of a
  37. * <code>Principal</code> and a list of <code>Permission</code>'s which
  38. * have been granted to that <code>Principal</code>. An ACL can also
  39. * be <em>negative</em>, which indicates that the list of
  40. * <code>Permission</code>'s is a list of permissions that are <em>not</em>
  41. * granted to the <code>Principal</code>. A <code>Principal</code> can
  42. * have at most one regular (or positive) ACL entry and one negative
  43. * ACL entry.
  44. *
  45. * @version 0.0
  46. *
  47. * @author Aaron M. Renn (arenn@urbanophile.com)
  48. */
  49. public interface AclEntry extends Cloneable
  50. {
  51. /**
  52. * This method returns the <code>Principal</code> associated with this
  53. * ACL entry.
  54. *
  55. * @return The <code>Principal</code> for this ACL entry
  56. */
  57. Principal getPrincipal();
  58. /**
  59. * This method sets ths <code>Principal</code> associated with this
  60. * ACL entry. This operation will only succeed if there is not already
  61. * a <code>Principal</code> assigned.
  62. *
  63. * @param user The <code>Principal</code> for this ACL entry
  64. *
  65. * @return <code>true</code> if the <code>Principal</code> was successfully set or <code>false</code> if this entry already has a <code>Principal</code>.
  66. */
  67. boolean setPrincipal(Principal user);
  68. /**
  69. * This method sets this ACL entry to be a <em>negative</em> entry, indicating
  70. * that it contains a list of permissions that are <em>not</em> granted
  71. * to the entry's <code>Principal</code>. Note that there is no way to
  72. * undo this operation.
  73. */
  74. void setNegativePermissions();
  75. /**
  76. * This method tests whether or not this ACL entry is a negative entry or not.
  77. *
  78. * @return <code>true</code> if this ACL entry is negative, <code>false</code> otherwise
  79. */
  80. boolean isNegative();
  81. /**
  82. * This method adds the specified permission to this ACL entry.
  83. *
  84. * @param permission The <code>Permission</code> to add
  85. *
  86. * @return <code>true</code> if the permission was added or <code>false</code> if it was already set for this entry
  87. */
  88. boolean addPermission(Permission permission);
  89. /**
  90. * This method deletes the specified permission to this ACL entry.
  91. *
  92. * @param perm The <code>Permission</code> to delete from this ACL entry.
  93. *
  94. * @return <code>true</code> if the permission was successfully deleted or <code>false</code> if the permission was not part of this ACL to begin with
  95. */
  96. boolean removePermission(Permission perm);
  97. /**
  98. * This method tests whether or not the specified permission is associated
  99. * with this ACL entry.
  100. *
  101. * @param permission The <code>Permission</code> to test
  102. *
  103. * @return <code>true</code> if this permission is associated with this entry or <code>false</code> otherwise
  104. */
  105. boolean checkPermission(Permission permission);
  106. /**
  107. * This method returns a list of all <code>Permission</code> objects
  108. * associated with this ACL entry as an <code>Enumeration</code>.
  109. *
  110. * @return A list of permissions for this ACL entry
  111. */
  112. Enumeration<Permission> permissions();
  113. /**
  114. * This method returns this object as a <code>String</code>.
  115. *
  116. * @return A <code>String</code> representation of this object
  117. */
  118. String toString();
  119. /**
  120. * This method returns a clone of this ACL entry
  121. *
  122. * @return A clone of this ACL entry
  123. */
  124. Object clone();
  125. }