KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fulcrum > security > util > AccessControlList


1 package org.apache.fulcrum.security.util;
2
3 /* ====================================================================
4  * The Apache Software License, Version 1.1
5  *
6  * Copyright (c) 2001 The Apache Software Foundation. All rights
7  * reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in
18  * the documentation and/or other materials provided with the
19  * distribution.
20  *
21  * 3. The end-user documentation included with the redistribution,
22  * if any, must include the following acknowledgment:
23  * "This product includes software developed by the
24  * Apache Software Foundation (http://www.apache.org/)."
25  * Alternately, this acknowledgment may appear in the software itself,
26  * if and wherever such third-party acknowledgments normally appear.
27  *
28  * 4. The names "Apache" and "Apache Software Foundation" and
29  * "Apache Turbine" must not be used to endorse or promote products
30  * derived from this software without prior written permission. For
31  * written permission, please contact apache@apache.org.
32  *
33  * 5. Products derived from this software may not be called "Apache",
34  * "Apache Turbine", nor may "Apache" appear in their name, without
35  * prior written permission of the Apache Software Foundation.
36  *
37  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
38  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
39  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
40  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
41  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
43  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
44  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
45  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
47  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
48  * SUCH DAMAGE.
49  * ====================================================================
50  *
51  * This software consists of voluntary contributions made by many
52  * individuals on behalf of the Apache Software Foundation. For more
53  * information on the Apache Software Foundation, please see
54  * <http://www.apache.org/>.
55  */

56
57 import java.io.Serializable JavaDoc;
58
59 import org.apache.fulcrum.security.entity.Group;
60 import org.apache.fulcrum.security.entity.Permission;
61 import org.apache.fulcrum.security.entity.Role;
62
63
64 /**
65  * This interface describes a control class that makes it
66  * easy to find out if a particular User has a given Permission.
67  * It also determines if a User has a a particular Role.
68  *
69  * @author <a HREF="mailto:jmcnally@collab.net">John D. McNally</a>
70  * @author <a HREF="mailto:bmclaugh@algx.net">Brett McLaughlin</a>
71  * @author <a HREF="mailto:greg@shwoop.com">Greg Ritter</a>
72  * @author <a HREF="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
73  * @author <a HREF="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
74  * @author <a HREF="mailto:marco@intermeta.de">Marco Kn&uuml;ttel</a>
75  * @version $Id: AccessControlList.java,v 1.1 2004/11/12 10:25:42 epugh Exp $
76  */

77 public interface AccessControlList
78   extends Serializable JavaDoc
79 {
80     /** The default Session key for the Access Control List */
81     public static final java.lang.String JavaDoc SESSION_KEY = "turbine.AccessControlList";
82
83     /**
84      * Retrieves a set of Roles an user is assigned in a Group.
85      *
86      * @param group the Group
87      * @return the set of Roles this user has within the Group.
88      */

89     RoleSet getRoles(Group group);
90
91     /**
92      * Retrieves a set of Roles an user is assigned in the global Group.
93      *
94      * @return the set of Roles this user has within the global Group.
95      */

96     RoleSet getRoles();
97
98     /**
99      * Retrieves a set of Permissions an user is assigned in a Group.
100      *
101      * @param group the Group
102      * @return the set of Permissions this user has within the Group.
103      */

104     PermissionSet getPermissions(Group group);
105
106     /**
107      * Retrieves a set of Permissions an user is assigned in the global Group.
108      *
109      * @return the set of Permissions this user has within the global Group.
110      */

111     PermissionSet getPermissions();
112
113     /**
114      * Checks if the user is assigned a specific Role in the Group.
115      *
116      * @param role the Role
117      * @param group the Group
118      * @return <code>true</code> if the user is assigned the Role in the Group.
119      */

120     boolean hasRole(Role role, Group group);
121
122     /**
123      * Checks if the user is assigned a specific Role in any of the given
124      * Groups
125      *
126      * @param role the Role
127      * @param groupset a Groupset
128      * @return <code>true</code> if the user is assigned the Role in any of
129      * the given Groups.
130      */

131     boolean hasRole(Role role, GroupSet groupset);
132
133     /**
134      * Checks if the user is assigned a specific Role in the Group.
135      *
136      * @param role the Role
137      * @param group the Group
138      * @return <code>true</code> if the user is assigned the Role in the Group.
139      */

140     boolean hasRole(String JavaDoc role, String JavaDoc group);
141
142     /**
143      * Checks if the user is assigned a specifie Role in any of the given
144      * Groups
145      *
146      * @param rolename the name of the Role
147      * @param groupset a Groupset
148      * @return <code>true</code> if the user is assigned the Role in any of
149      * the given Groups.
150      */

151     boolean hasRole(String JavaDoc rolename, GroupSet groupset);
152
153     /**
154      * Checks if the user is assigned a specific Role in the global Group.
155      *
156      * @param role the Role
157      * @return <code>true</code> if the user is assigned the Role in the global Group.
158      */

159     boolean hasRole(Role role);
160
161     /**
162      * Checks if the user is assigned a specific Role in the global Group.
163      *
164      * @param role the Role
165      * @return <code>true</code> if the user is assigned the Role in the global Group.
166      */

167     boolean hasRole(String JavaDoc role);
168
169     /**
170      * Checks if the user is assigned a specific Permission in the Group.
171      *
172      * @param permission the Permission
173      * @param group the Group
174      * @return <code>true</code> if the user is assigned the Permission in the Group.
175      */

176     boolean hasPermission(Permission permission, Group group);
177
178     /**
179      * Checks if the user is assigned a specific Permission in any of the given
180      * Groups
181      *
182      * @param permission the Permission
183      * @param groupset a Groupset
184      * @return <code>true</code> if the user is assigned the Permission in any
185      * of the given Groups.
186      */

187     boolean hasPermission(Permission permission, GroupSet groupset);
188
189     /**
190      * Checks if the user is assigned a specific Permission in the Group.
191      *
192      * @param permission the Permission
193      * @param group the Group
194      * @return <code>true</code> if the user is assigned the Permission in the Group.
195      */

196     boolean hasPermission(String JavaDoc permission, String JavaDoc group);
197
198     /**
199      * Checks if the user is assigned a specific Permission in the Group.
200      *
201      * @param permission the Permission
202      * @param group the Group
203      * @return <code>true</code> if the user is assigned the Permission in the Group.
204      */

205     boolean hasPermission(String JavaDoc permission, Group group);
206
207     /**
208      * Checks if the user is assigned a specifie Permission in any of the given
209      * Groups
210      *
211      * @param permissionName the name of the Permission
212      * @param groupset a Groupset
213      * @return <code>true</code> if the user is assigned the Permission in any
214      * of the given Groups.
215      */

216     boolean hasPermission(String JavaDoc permissionName, GroupSet groupset);
217
218     /**
219      * Checks if the user is assigned a specific Permission in the global Group.
220      *
221      * @param permission the Permission
222      * @return <code>true</code> if the user is assigned the Permission in the global Group.
223      */

224     boolean hasPermission(Permission permission);
225
226     /**
227      * Checks if the user is assigned a specific Permission in the global Group.
228      *
229      * @param permission the Permission
230      * @return <code>true</code> if the user is assigned the Permission in the global Group.
231      */

232     boolean hasPermission(String JavaDoc permission);
233
234     /**
235      * Returns all groups definded in the system.
236      *
237      * @return A Group [] of all defined Groups
238      *
239      * This is useful for debugging, when you want to display all roles
240      * and permissions an user is assigned. This method is needed
241      * because you can't call static methods of TurbineSecurity class
242      * from within WebMacro/Velocity template
243      */

244     Group [] getAllGroups();
245
246 }
247
Popular Tags