KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > aspects > user > UserConf


1 /*
2   Copyright (C) 2002 Laurent Martelli <laurent@aopsys.com>
3                      Renaud Pawlak <renaud@aopsys.com>
4
5   This program is free software; you can redistribute it and/or modify
6   it under the terms of the GNU Lesser General Public License as
7   published by the Free Software Foundation; either version 2 of the
8   License, or (at your option) any later version.
9
10   This program is distributed in the hope that it will be useful, but
11   WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13   Lesser General Public License for more details.
14
15   You should have received a copy of the GNU Lesser General Public
16   License along with this program; if not, write to the Free Software
17   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18   USA */

19
20 package org.objectweb.jac.aspects.user;
21
22 import org.objectweb.jac.core.rtti.CollectionItem;
23 import org.objectweb.jac.core.rtti.ClassItem;
24 import org.objectweb.jac.core.rtti.MethodItem;
25
26 public interface UserConf {
27
28    /**
29     * Sets the class of the application that must be used as a storage
30     * for the users.
31     *
32     * <p>The users are eventually used to know what user is currently
33     * logged into the system so you should define fields that can be
34     * used to identify the user.
35     *
36     * @param userClass the class that represents the application's
37     * users
38     * @param loginField the field that stores the login (iow the
39     * user's id)
40     * @param passwordField the field that stores the password (not
41     * mandatory it no password authentication is performed)
42     * @param profileField the field that contains the profile (if
43     * any, can be null)
44     * @see org.objectweb.jac.aspects.authentication.UserPasswordAuthenticator */

45  
46    void setUserClass(ClassItem userClass,
47                      String JavaDoc loginField,
48                      String JavaDoc passwordField,
49                      String JavaDoc profileField);
50
51    /**
52     * This method should affect all the classes that define a
53     * reference towards a user of the application and that should be
54     * seamlessly initialized to the currently logged user (instead of
55     * been filled in interactively).
56     *
57     * @param classExpr a class pointcut expression that denote all the
58     * classes that should be affected by this behavior */

59
60    void autoInitClasses(String JavaDoc classExpr);
61
62    /**
63     * Declares a new profile (that has no parent).
64     *
65     * <p>A profile is a kind of user type that has some well-defined
66     * persmissions to access or to modify elements of the configured
67     * application (e.g. the default <code>user.acc</code> defines an
68     * <code>administrator</code> profile that grants access and
69     * modification of all the elements).
70     *
71     * @param profile the profile's name
72     * @see #declareProfile(String,String) */

73
74    void declareProfile(String JavaDoc profile);
75
76    /**
77     * Use this config method to clear a profile so that it can be
78     * reinitialized from the config file.
79     * @param name name of the profile to clear
80     */

81    void clearProfile(String JavaDoc name);
82
83    /**
84     * Declares a new profile that inherits from the caracteristics of
85     * its parent.
86     *
87     * <p>All the parent access permissions can be restrained (and only
88     * restrained) by the child profile (a permission that is not
89     * granted by the parent cannot be granted by the child).
90     *
91     * @param profile the profile's name
92     * @param parent the parent profile's name
93     * @see #declareProfile(String) */

94
95    void declareProfile(String JavaDoc profile,String JavaDoc parent);
96
97    /**
98     * Adds a readable resources set to a profile.
99     *
100     * @param profile the profile's name
101     * @param resourceExpr a regular expression that denotes a set of
102     * resources (based on <code>package.class.member</code>) */

103    
104    void addReadable(String JavaDoc profile,String JavaDoc resourceExpr);
105
106    /**
107     * Adds a writable resources set to a profile.
108     *
109     * @param profile the profile's name
110     * @param resourceExpr a regular expression that denotes a set of
111     * resources (based on <code>package.class.member</code>) */

112
113    void addWritable(String JavaDoc profile,String JavaDoc resourceExpr);
114
115    /**
116     * Adds an removable resources set to a profile (collection
117     * dedicated).
118     *
119     * @param profile the profile's name
120     * @param resourceExpr a regular expression that denotes a set of
121     * resources (based on <code>package.class.member</code>)
122     */

123    void addRemovable(String JavaDoc profile,String JavaDoc resourceExpr);
124
125    /**
126     * Adds an addable resources set to a profile (collection
127     * dedicated).
128     *
129     * @param profile the profile's name
130     * @param resourceExpr a regular expression that denotes a set of
131     * resources (based on <code>package.class.member</code>)
132     */

133    void addAddable(String JavaDoc profile,String JavaDoc resourceExpr);
134
135
136    /**
137     * Adds a creatable resources set to a profile (collection
138     * dedicated).
139     *
140     * @param profile the profile's name
141     * @param resourceExpr a regular expression that denotes a set of
142     * resources (based on <code>package.class</code>)
143     */

144    void addCreatable(String JavaDoc profile,String JavaDoc resourceExpr);
145
146    /**
147     * Create an administrator user.
148     *
149     * <p>A user class must have been defined with
150     * <code>setUserClass()</code>. The administrator user will be
151     * created only if no user with the given login already exist. If
152     * created, the administrator user will be given the
153     * "administrator" profile.</p>
154     *
155     * @param login the login name of the administrator
156     * @param password the password of the administrator
157     *
158     * @see #setUserClass(ClassItem,String,String,String) */

159    void defineAdministrator(String JavaDoc login,String JavaDoc password);
160
161    /**
162     * Defines a contextual habilitation test (this is a generic method to
163     * be used when the habilitation does not fit any simple scheme).
164     *
165     * @param condition the contextual condition (a static method
166     * that takes the substance, the currently tested item, the
167     * action's type and that returns true if the habilitation is
168     * granted)
169     * @see #defineHabilitation(ClassItem,MethodItem)
170     */

171    void defineHabilitation(MethodItem condition);
172
173    /**
174     * Defines a contextual habilitation test for instances of given
175     * class (This is a generic method to be used when the habilitation
176     * does not fit any simple scheme).
177     *
178     * @param cli the class the test applies to
179     * @param condition the contextual condition (a static method that
180     * takes the substance, the currently tested item, the action's
181     * type (one of GuiAC.VISIBLE, GuiAC.EDITABLE, GuiAC.ADDABLE
182     * or GuiAC.REMOVABLE) and that returns true if the habilitation is
183     * granted)
184     * @see #defineHabilitation(MethodItem)
185     */

186    void defineHabilitation(ClassItem cli, MethodItem condition);
187
188    /**
189     * For the specified collection, users will only see the objects
190     * that they own.
191     *
192     * @param profile apply the filter only if the user has this profile
193     * @param cl the class holding the collection
194     * @param collectionName name of the collection attribute
195     */

196    void addOwnerFilter(String JavaDoc profile,ClassItem cl,
197                        String JavaDoc collectionName);
198
199    /**
200     * For the specified collection, apply a filter on its getter, so
201     * that some items can be hidden depending on the user.
202     *
203     * @param collection the collection to filter
204     * @param filter a static method which takes a Collection (the one
205     * to filter), an Object (the holder of the collection), a
206     * CollectionItem, and a User and returns the filtered collection.
207     */

208    void addFilter(CollectionItem collection, MethodItem filter);
209
210    /**
211     * Set a contextual profile to a reference or a collection that
212     * contains user(s).
213     *
214     * <p>If one user is added to the given field at runtime, the user
215     * will then have the given profile for the current object.</p>
216     *
217     * @param cl the class that owns the field
218     * @param field the profiled field
219     * @param profile the profile to be set contextually */

220
221    void setContextualProfile(ClassItem cl, String JavaDoc field,
222                              String JavaDoc profile);
223
224
225 }
226
Popular Tags