OSDN Git Service

4e776f50cc0d7419849116d32276fef73bdf3531
[pf3gnuchains/gcc-fork.git] / libjava / java / security / acl / Acl.java
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., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 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   public abstract 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   public abstract 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> if there is already an entry of the same type for the <code>Principal</code>.
92    *
93    * @exception NotOwnerException If the caller is not an owner of this ACL.
94    */
95   public abstract boolean addEntry(Principal caller, AclEntry entry) 
96     throws NotOwnerException;
97
98   /**
99    * This method delets the specified entry from the ACL
100    *
101    * @param caller The <code>Principal</code> requesting the deletion.
102    * @param entry The ACL entry to delete
103    *
104    * @return <code>true</code> if the entry was deleted, or <code>false</code> if this entry was not part of the ACL to begin with
105    *
106    * @exception NotOwnerException If the caller is not an owner of this ACL.
107    */
108   public abstract boolean removeEntry(Principal caller, AclEntry entry)
109     throws NotOwnerException;
110
111   /**
112    * This method returns a list of all the entries in the ACL as an
113    * <code>Enumeration</code>.
114    *
115    * @return An enumeration of the ACL entries
116    */
117   public abstract Enumeration entries();
118
119   /**
120    * This method tests whether or not the specified <code>Principal</code>
121    * has the specified <code>Permission</code>
122    *
123    * @param user The <code>Principal</code> to test
124    * @param perm The <code>Permission</code> to test for
125    *
126    * @return <code>true</code> if the user has been granted the permission, <code>false</code> otherwise
127    */
128   public abstract boolean checkPermission(Principal user, Permission perm);
129
130   /**
131    * This method returns a list of <code>Permission</code>'s that are granted
132    * to a particular <code>Principal</code>.  This includes any permissions
133    * that are granted to <code>Group</code>'s to which the <code>Principal</code>
134    * belongs unless they are overridden by a negative ACL.  This permission
135    * list is returned as an <code>Enumeration</code>.
136    *
137    * @param user The <code>Principal</code> to retrieve permissions for.
138    *
139    * @return A list of permissions for the <code>Principal</code>.
140    */
141   public abstract Enumeration getPermissions(Principal user);
142
143   /**
144    * This method returns the ACL as a <code>String</code>
145    *
146    * @return A <code>String</code> representation of this ACL
147    */
148   public abstract String toString();
149 }