blob: 02dab70051ee9f97d20e01e016c258b7e97c89e8 [file] [log] [blame]
The Android Open Source Projectb5de22c2012-04-01 00:00:00 -07001/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18package java.security.acl;
19
20import java.security.Principal;
21import java.util.Enumeration;
22
23/**
24 * The <i>Access Control List Entry</i> interface definition.
25 * <p>
26 * An {@code AclEntry} is a list of the {@link Permission}s that are
27 * granted (<i>positive</i>) or denied (<i>negative</i>) to a {@link Principal}.
28 */
29public interface AclEntry extends Cloneable {
30
31 /**
32 * Set the principal for this ACL entry.
33 * <p>
34 * The principal for an ACL entry can only be set once.
35 *
36 * @param user
37 * the principal for this ACL entry.
38 * @return {@code true} on success, {@code false} if there is a principal already set for
39 * this entry.
40 */
41 boolean setPrincipal(Principal user);
42
43 /**
44 * Returns the principal of this ACL entry.
45 *
46 * @return the principal of this ACL entry, or null if none is set.
47 */
48 Principal getPrincipal();
49
50 /**
51 * Sets this ACL entry to be <i>negative</i>.
52 * <p>
53 * The permissions in this ACL entry will be denied to the principal
54 * associated with this entry.
55 * <p>
56 * Note: An ACL entry is <i>positive</i> by default and can only become
57 * <i>negative</i> by calling this method.
58 */
59 void setNegativePermissions();
60
61 /**
62 * Returns whether this ACL entry is <i>negative</i>.
63 *
64 * @return {@code true} if this ACL entry is negative, {@code false} if it's positive.
65 */
66 boolean isNegative();
67
68 /**
69 * Adds the specified permission to this ACL entry.
70 *
71 * @param permission
72 * the permission to be added.
73 * @return {@code true} if the specified permission is added, {@code false} if the
74 * permission was already in this entry.
75 */
76 boolean addPermission(Permission permission);
77
78 /**
79 * Removes the specified permission from this ACL entry.
80 *
81 * @param permission
82 * the permission to be removed.
83 * @return {@code true} if the permission is removed, {@code false} if the permission was
84 * not in this entry.
85 */
86 boolean removePermission(Permission permission);
87
88 /**
89 * Checks whether the specified permission is in this ACL entry.
90 *
91 * @param permission
92 * the permission to check.
93 * @return {@code true} if the permission is in this entry, otherwise {@code false}.
94 */
95 boolean checkPermission(Permission permission);
96
97 /**
98 * Returns the list of permissions of this ACL entry.
99 *
100 * @return the list of permissions of this ACL entry,
101 */
102 Enumeration<Permission> permissions();
103
104 /**
105 * Returns the string representation of this ACL entry.
106 *
107 * @return the string representation of this ACL entry.
108 */
109 String toString();
110
111 /**
112 * Clones this ACL entry instance.
113 *
114 * @return a copy of this entry.
115 */
116 Object clone();
117
118}