author | mullan |
Tue, 14 Nov 2017 09:15:12 -0500 | |
changeset 47745 | e6e6ed17abbe |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
43541
9aeb1de77a63
8173827: Remove forRemoval=true from several deprecated security APIs
mullan
parents:
39334
diff
changeset
|
2 |
* Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package java.security.acl; |
|
27 |
||
28 |
import java.util.Enumeration; |
|
29 |
import java.security.Principal; |
|
30 |
||
31 |
/** |
|
32 |
* Interface representing an Access Control List (ACL). An Access |
|
33 |
* Control List is a data structure used to guard access to |
|
34 |
* resources.<p> |
|
35 |
* |
|
36 |
* An ACL can be thought of as a data structure with multiple ACL |
|
37 |
* entries. Each ACL entry, of interface type AclEntry, contains a |
|
38 |
* set of permissions associated with a particular principal. (A |
|
39 |
* principal represents an entity such as an individual user or a |
|
40 |
* group). Additionally, each ACL entry is specified as being either |
|
41 |
* positive or negative. If positive, the permissions are to be |
|
42 |
* granted to the associated principal. If negative, the permissions |
|
43 |
* are to be denied.<p> |
|
44 |
* |
|
21334 | 45 |
* The ACL Entries in each ACL observe the following rules: |
2 | 46 |
* |
47 |
* <ul> <li>Each principal can have at most one positive ACL entry and |
|
48 |
* one negative entry; that is, multiple positive or negative ACL |
|
49 |
* entries are not allowed for any principal. Each entry specifies |
|
50 |
* the set of permissions that are to be granted (if positive) or |
|
21334 | 51 |
* denied (if negative). |
2 | 52 |
* |
53 |
* <li>If there is no entry for a particular principal, then the |
|
21334 | 54 |
* principal is considered to have a null (empty) permission set. |
2 | 55 |
* |
56 |
* <li>If there is a positive entry that grants a principal a |
|
57 |
* particular permission, and a negative entry that denies the |
|
58 |
* principal the same permission, the result is as though the |
|
21334 | 59 |
* permission was never granted or denied. |
2 | 60 |
* |
61 |
* <li>Individual permissions always override permissions of the |
|
62 |
* group(s) to which the individual belongs. That is, individual |
|
63 |
* negative permissions (specific denial of permissions) override the |
|
64 |
* groups' positive permissions. And individual positive permissions |
|
21334 | 65 |
* override the groups' negative permissions. |
2 | 66 |
* |
67 |
* </ul> |
|
68 |
* |
|
18579
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
69 |
* The {@code java.security.acl } package provides the |
2 | 70 |
* interfaces to the ACL and related data structures (ACL entries, |
29100
56267f38f743
8072663: Remove the sun.security.acl package which is not used in the JDK
juh
parents:
28773
diff
changeset
|
71 |
* groups, permissions, etc.).<p> |
2 | 72 |
* |
18579
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
73 |
* The {@code java.security.acl.Acl } interface extends the |
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
74 |
* {@code java.security.acl.Owner } interface. The Owner |
2 | 75 |
* interface is used to maintain a list of owners for each ACL. Only |
76 |
* owners are allowed to modify an ACL. For example, only an owner can |
|
18579
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
77 |
* call the ACL's {@code addEntry} method to add a new ACL entry |
2 | 78 |
* to the ACL. |
79 |
* |
|
80 |
* @see java.security.acl.AclEntry |
|
81 |
* @see java.security.acl.Owner |
|
82 |
* @see java.security.acl.Acl#getPermissions |
|
83 |
* |
|
84 |
* @author Satish Dharmaraj |
|
45434
4582657c7260
8181082: class-level since tag issues in java.base & java.datatransfer module
mli
parents:
43541
diff
changeset
|
85 |
* @since 1.1 |
29377
d3f457ce9c48
8073430: Deprecate security APIs that have been superseded
juh
parents:
29100
diff
changeset
|
86 |
* |
47745
e6e6ed17abbe
8175094: Mark the deprecated java.security.acl APIs with forRemoval=true
mullan
parents:
47216
diff
changeset
|
87 |
* @deprecated This class is deprecated and subject to removal in a future |
e6e6ed17abbe
8175094: Mark the deprecated java.security.acl APIs with forRemoval=true
mullan
parents:
47216
diff
changeset
|
88 |
* version of Java SE. It has been replaced by {@code java.security.Policy} |
e6e6ed17abbe
8175094: Mark the deprecated java.security.acl APIs with forRemoval=true
mullan
parents:
47216
diff
changeset
|
89 |
* and related classes since 1.2. |
2 | 90 |
*/ |
91 |
||
47745
e6e6ed17abbe
8175094: Mark the deprecated java.security.acl APIs with forRemoval=true
mullan
parents:
47216
diff
changeset
|
92 |
@Deprecated(since="9", forRemoval=true) |
e6e6ed17abbe
8175094: Mark the deprecated java.security.acl APIs with forRemoval=true
mullan
parents:
47216
diff
changeset
|
93 |
@SuppressWarnings("removal") |
2 | 94 |
public interface Acl extends Owner { |
95 |
||
96 |
/** |
|
97 |
* Sets the name of this ACL. |
|
98 |
* |
|
99 |
* @param caller the principal invoking this method. It must be an |
|
100 |
* owner of this ACL. |
|
101 |
* |
|
102 |
* @param name the name to be given to this ACL. |
|
103 |
* |
|
104 |
* @exception NotOwnerException if the caller principal |
|
105 |
* is not an owner of this ACL. |
|
106 |
* |
|
107 |
* @see #getName |
|
108 |
*/ |
|
109 |
public void setName(Principal caller, String name) |
|
110 |
throws NotOwnerException; |
|
111 |
||
112 |
/** |
|
113 |
* Returns the name of this ACL. |
|
114 |
* |
|
115 |
* @return the name of this ACL. |
|
116 |
* |
|
117 |
* @see #setName |
|
118 |
*/ |
|
119 |
public String getName(); |
|
120 |
||
121 |
/** |
|
122 |
* Adds an ACL entry to this ACL. An entry associates a principal |
|
123 |
* (e.g., an individual or a group) with a set of |
|
124 |
* permissions. Each principal can have at most one positive ACL |
|
125 |
* entry (specifying permissions to be granted to the principal) |
|
126 |
* and one negative ACL entry (specifying permissions to be |
|
127 |
* denied). If there is already an ACL entry of the same type |
|
128 |
* (negative or positive) already in the ACL, false is returned. |
|
129 |
* |
|
130 |
* @param caller the principal invoking this method. It must be an |
|
131 |
* owner of this ACL. |
|
132 |
* |
|
133 |
* @param entry the ACL entry to be added to this ACL. |
|
134 |
* |
|
135 |
* @return true on success, false if an entry of the same type |
|
136 |
* (positive or negative) for the same principal is already |
|
137 |
* present in this ACL. |
|
138 |
* |
|
139 |
* @exception NotOwnerException if the caller principal |
|
140 |
* is not an owner of this ACL. |
|
141 |
*/ |
|
142 |
public boolean addEntry(Principal caller, AclEntry entry) |
|
143 |
throws NotOwnerException; |
|
144 |
||
145 |
/** |
|
146 |
* Removes an ACL entry from this ACL. |
|
147 |
* |
|
148 |
* @param caller the principal invoking this method. It must be an |
|
149 |
* owner of this ACL. |
|
150 |
* |
|
151 |
* @param entry the ACL entry to be removed from this ACL. |
|
152 |
* |
|
153 |
* @return true on success, false if the entry is not part of this ACL. |
|
154 |
* |
|
155 |
* @exception NotOwnerException if the caller principal is not |
|
156 |
* an owner of this Acl. |
|
157 |
*/ |
|
158 |
public boolean removeEntry(Principal caller, AclEntry entry) |
|
159 |
throws NotOwnerException; |
|
160 |
||
161 |
/** |
|
162 |
* Returns an enumeration for the set of allowed permissions for the |
|
163 |
* specified principal (representing an entity such as an individual or |
|
164 |
* a group). This set of allowed permissions is calculated as |
|
21334 | 165 |
* follows: |
2 | 166 |
* |
167 |
* <ul> |
|
168 |
* |
|
169 |
* <li>If there is no entry in this Access Control List for the |
|
21334 | 170 |
* specified principal, an empty permission set is returned. |
2 | 171 |
* |
172 |
* <li>Otherwise, the principal's group permission sets are determined. |
|
173 |
* (A principal can belong to one or more groups, where a group is a |
|
174 |
* group of principals, represented by the Group interface.) |
|
175 |
* The group positive permission set is the union of all |
|
176 |
* the positive permissions of each group that the principal belongs to. |
|
177 |
* The group negative permission set is the union of all |
|
178 |
* the negative permissions of each group that the principal belongs to. |
|
179 |
* If there is a specific permission that occurs in both |
|
180 |
* the positive permission set and the negative permission set, |
|
181 |
* it is removed from both.<p> |
|
182 |
* |
|
183 |
* The individual positive and negative permission sets are also |
|
184 |
* determined. The positive permission set contains the permissions |
|
185 |
* specified in the positive ACL entry (if any) for the principal. |
|
186 |
* Similarly, the negative permission set contains the permissions |
|
187 |
* specified in the negative ACL entry (if any) for the principal. |
|
188 |
* The individual positive (or negative) permission set is considered |
|
189 |
* to be null if there is not a positive (negative) ACL entry for the |
|
190 |
* principal in this ACL.<p> |
|
191 |
* |
|
192 |
* The set of permissions granted to the principal is then calculated |
|
193 |
* using the simple rule that individual permissions always override |
|
194 |
* the group permissions. That is, the principal's individual negative |
|
195 |
* permission set (specific denial of permissions) overrides the group |
|
196 |
* positive permission set, and the principal's individual positive |
|
197 |
* permission set overrides the group negative permission set. |
|
198 |
* |
|
199 |
* </ul> |
|
200 |
* |
|
201 |
* @param user the principal whose permission set is to be returned. |
|
202 |
* |
|
203 |
* @return the permission set specifying the permissions the principal |
|
204 |
* is allowed. |
|
205 |
*/ |
|
206 |
public Enumeration<Permission> getPermissions(Principal user); |
|
207 |
||
208 |
/** |
|
209 |
* Returns an enumeration of the entries in this ACL. Each element in |
|
210 |
* the enumeration is of type AclEntry. |
|
211 |
* |
|
212 |
* @return an enumeration of the entries in this ACL. |
|
213 |
*/ |
|
214 |
public Enumeration<AclEntry> entries(); |
|
215 |
||
216 |
/** |
|
217 |
* Checks whether or not the specified principal has the specified |
|
218 |
* permission. If it does, true is returned, otherwise false is returned. |
|
219 |
* |
|
220 |
* More specifically, this method checks whether the passed permission |
|
221 |
* is a member of the allowed permission set of the specified principal. |
|
222 |
* The allowed permission set is determined by the same algorithm as is |
|
18579
b678846778ad
8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents:
5506
diff
changeset
|
223 |
* used by the {@code getPermissions} method. |
2 | 224 |
* |
225 |
* @param principal the principal, assumed to be a valid authenticated |
|
226 |
* Principal. |
|
227 |
* |
|
228 |
* @param permission the permission to be checked for. |
|
229 |
* |
|
230 |
* @return true if the principal has the specified permission, false |
|
231 |
* otherwise. |
|
232 |
* |
|
233 |
* @see #getPermissions |
|
234 |
*/ |
|
235 |
public boolean checkPermission(Principal principal, Permission permission); |
|
236 |
||
237 |
/** |
|
238 |
* Returns a string representation of the |
|
239 |
* ACL contents. |
|
240 |
* |
|
241 |
* @return a string representation of the ACL contents. |
|
242 |
*/ |
|
243 |
public String toString(); |
|
244 |
} |