Source for java.security.acl.Acl

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