1 /*
2  * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
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
7  * published by the Free Software Foundation.  Oracle designates this
8  * particular file as subject to the "Classpath" exception as provided
9  * by Oracle in the LICENSE file that accompanied this code.
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  *
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.
24  */
25 
26 package java.security.acl;
27 
28 import java.util.Enumeration;
29 import java.security.Principal;
30 
31 /**
32  * This is the interface used for representing one entry in an Access
33  * Control List (ACL).<p>
34  *
35  * An ACL can be thought of as a data structure with multiple ACL entry
36  * objects. Each ACL entry object contains a set of permissions associated
37  * with a particular principal. (A principal represents an entity such as
38  * an individual user or a group). Additionally, each ACL entry is specified
39  * as being either positive or negative. If positive, the permissions are
40  * to be granted to the associated principal. If negative, the permissions
41  * are to be denied. Each principal can have at most one positive ACL entry
42  * and one negative entry; that is, multiple positive or negative ACL
43  * entries are not allowed for any principal.
44  *
45  * Note: ACL entries are by default positive. An entry becomes a
46  * negative entry only if the
47  * {@link #setNegativePermissions() setNegativePermissions}
48  * method is called on it.
49  *
50  * @see java.security.acl.Acl
51  *
52  * @author      Satish Dharmaraj
53  * @since 1.1
54  *
55  * @deprecated This class is deprecated and subject to removal in a future
56  *     version of Java SE. It has been replaced by {@code java.security.Policy}
57  *     and related classes since 1.2.
58  */
59 @Deprecated(since="9", forRemoval=true)
60 @SuppressWarnings("removal")
61 public interface AclEntry extends Cloneable {
62 
63     /**
64      * Specifies the principal for which permissions are granted or denied
65      * by this ACL entry. If a principal was already set for this ACL entry,
66      * false is returned, otherwise true is returned.
67      *
68      * @param user the principal to be set for this entry.
69      *
70      * @return true if the principal is set, false if there was
71      * already a principal set for this entry.
72      *
73      * @see #getPrincipal
74      */
setPrincipal(Principal user)75     public boolean setPrincipal(Principal user);
76 
77     /**
78      * Returns the principal for which permissions are granted or denied by
79      * this ACL entry. Returns null if there is no principal set for this
80      * entry yet.
81      *
82      * @return the principal associated with this entry.
83      *
84      * @see #setPrincipal
85      */
getPrincipal()86     public Principal getPrincipal();
87 
88     /**
89      * Sets this ACL entry to be a negative one. That is, the associated
90      * principal (e.g., a user or a group) will be denied the permission set
91      * specified in the entry.
92      *
93      * Note: ACL entries are by default positive. An entry becomes a
94      * negative entry only if this {@code setNegativePermissions}
95      * method is called on it.
96      */
setNegativePermissions()97     public void setNegativePermissions();
98 
99     /**
100      * Returns true if this is a negative ACL entry (one denying the
101      * associated principal the set of permissions in the entry), false
102      * otherwise.
103      *
104      * @return true if this is a negative ACL entry, false if it's not.
105      */
isNegative()106     public boolean isNegative();
107 
108     /**
109      * Adds the specified permission to this ACL entry. Note: An entry can
110      * have multiple permissions.
111      *
112      * @param permission the permission to be associated with
113      * the principal in this entry.
114      *
115      * @return true if the permission was added, false if the
116      * permission was already part of this entry's permission set.
117      */
addPermission(Permission permission)118     public boolean addPermission(Permission permission);
119 
120     /**
121      * Removes the specified permission from this ACL entry.
122      *
123      * @param permission the permission to be removed from this entry.
124      *
125      * @return true if the permission is removed, false if the
126      * permission was not part of this entry's permission set.
127      */
removePermission(Permission permission)128     public boolean removePermission(Permission permission);
129 
130     /**
131      * Checks if the specified permission is part of the
132      * permission set in this entry.
133      *
134      * @param permission the permission to be checked for.
135      *
136      * @return true if the permission is part of the
137      * permission set in this entry, false otherwise.
138      */
checkPermission(Permission permission)139     public boolean checkPermission(Permission permission);
140 
141     /**
142      * Returns an enumeration of the permissions in this ACL entry.
143      *
144      * @return an enumeration of the permissions in this ACL entry.
145      */
permissions()146     public Enumeration<Permission> permissions();
147 
148     /**
149      * Returns a string representation of the contents of this ACL entry.
150      *
151      * @return a string representation of the contents.
152      */
toString()153     public String toString();
154 
155     /**
156      * Clones this ACL entry.
157      *
158      * @return a clone of this ACL entry.
159      */
clone()160     public Object clone();
161 }
162