KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > turbine > services > security > passive > PassiveUserManager


1 package org.apache.turbine.services.security.passive;
2
3 /*
4  * Copyright 2001-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License")
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 import java.util.List JavaDoc;
20
21 import org.apache.commons.configuration.Configuration;
22
23 import org.apache.torque.util.Criteria;
24
25 import org.apache.turbine.om.security.User;
26 import org.apache.turbine.services.security.UserManager;
27 import org.apache.turbine.util.security.DataBackendException;
28 import org.apache.turbine.util.security.EntityExistsException;
29 import org.apache.turbine.util.security.PasswordMismatchException;
30 import org.apache.turbine.util.security.UnknownEntityException;
31
32 /**
33  * Void user manager can be used where no data storage is needed
34  * by the application.
35  * It's methods don't provide any useful functionality except throwing
36  * DataBackendExceptions. Security service will be still able to create
37  * anonymous User objects when this UserManager is used.
38  *
39  * @author <a HREF="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
40  * @author <a HREF="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
41  * @version $Id: PassiveUserManager.java,v 1.10.2.3 2004/10/08 12:09:43 henning Exp $
42  */

43 public class PassiveUserManager implements UserManager
44 {
45     /**
46      * Initializes the UserManager
47      *
48      * @param conf A Configuration object to init this Manager
49      */

50     public void init(Configuration conf)
51     {
52         // GNDN
53
}
54
55     /**
56      * Check whether a specified user's account exists.
57      *
58      * The login name is used for looking up the account.
59      *
60      * @param user The user to be checked.
61      * @return true if the specified account exists
62      * @throws DataBackendException if there was an error accessing the data backend.
63      */

64     public boolean accountExists(User user)
65             throws DataBackendException
66     {
67         throw new DataBackendException("PassiveUserManager knows no users");
68     }
69
70     /**
71      * Check whether a specified user's account exists.
72      *
73      * The login name is used for looking up the account.
74      *
75      * @param userName The name of the user to be checked.
76      * @return true if the specified account exists
77      * @throws DataBackendException if there was an error accessing the data backend.
78      */

79     public boolean accountExists(String JavaDoc userName)
80             throws DataBackendException
81     {
82         throw new DataBackendException("PassiveUserManager knows no users");
83     }
84
85     /**
86      * Retrieve a user from persistent storage using username as the
87      * key.
88      *
89      * @param username the name of the user.
90      * @return an User object.
91      * @exception UnknownEntityException if the user's record does not
92      * exist in the database.
93      * @exception DataBackendException if there is a problem accessing the
94      * storage.
95      */

96     public User retrieve(String JavaDoc username)
97             throws UnknownEntityException, DataBackendException
98     {
99         throw new DataBackendException("PassiveUserManager knows no users");
100     }
101
102     /**
103      * Retrieve a user from persistent storage using the primary key
104      *
105      * @param key The primary key object
106      * @return an User object.
107      * @throws UnknownEntityException if the user's record does not
108      * exist in the database.
109      * @throws DataBackendException if there is a problem accessing the
110      * storage.
111      */

112     public User retrieveById(Object JavaDoc key)
113             throws UnknownEntityException, DataBackendException
114     {
115         throw new DataBackendException("PassiveUserManager knows no users");
116     }
117
118     /**
119      * Retrieve a set of users that meet the specified criteria.
120      *
121      * As the keys for the criteria, you should use the constants that
122      * are defined in {@link User} interface, plus the names
123      * of the custom attributes you added to your user representation
124      * in the data storage. Use verbatim names of the attributes -
125      * without table name prefix in case of DB implementation.
126      *
127      * @param criteria The criteria of selection.
128      * @return a List of users meeting the criteria.
129      * @throws DataBackendException if there is a problem accessing the
130      * storage.
131      * @deprecated Use <a HREF="#retrieveList">retrieveList</a> instead.
132      */

133     public User[] retrieve(Criteria criteria)
134             throws DataBackendException
135     {
136         throw new DataBackendException("PassiveUserManager knows no users");
137     }
138
139     /**
140      * Retrieve a set of users that meet the specified criteria.
141      *
142      * As the keys for the criteria, you should use the constants that
143      * are defined in {@link User} interface, plus the names
144      * of the custom attributes you added to your user representation
145      * in the data storage. Use verbatim names of the attributes -
146      * without table name prefix in case of DB implementation.
147      *
148      * @param criteria The criteria of selection.
149      * @return a List of users meeting the criteria.
150      * @throws DataBackendException if there is a problem accessing the
151      * storage.
152      */

153     public List JavaDoc retrieveList(Criteria criteria)
154             throws DataBackendException
155     {
156         throw new DataBackendException("PassiveUserManager knows no users");
157     }
158
159     /**
160      * Retrieve a user from persistent storage using username as the
161      * key, and authenticate the user. The implementation may chose
162      * to authenticate to the server as the user whose data is being
163      * retrieved.
164      *
165      * @param username the name of the user.
166      * @param password the user supplied password.
167      * @return an User object.
168      * @exception PasswordMismatchException if the supplied password was
169      * incorrect.
170      * @exception UnknownEntityException if the user's record does not
171      * exist in the database.
172      * @exception DataBackendException if there is a problem accessing the
173      * storage.
174      */

175     public User retrieve(String JavaDoc username, String JavaDoc password)
176             throws PasswordMismatchException, UnknownEntityException,
177             DataBackendException
178     {
179         throw new DataBackendException("PassiveUserManager knows no users");
180     }
181
182     /**
183      * Save an User object to persistent storage. User's record is
184      * required to exist in the storage.
185      *
186      * @param user an User object to store.
187      * @exception UnknownEntityException if the user's record does not
188      * exist in the database.
189      * @exception DataBackendException if there is a problem accessing the
190      * storage.
191      */

192     public void store(User user)
193             throws UnknownEntityException, DataBackendException
194     {
195         throw new DataBackendException("PassiveUserManager does not support saving user data");
196     }
197
198     /**
199      * Saves User data when the session is unbound. The user account is required
200      * to exist in the storage.
201      *
202      * LastLogin, AccessCounter, persistent pull tools, and any data stored
203      * in the permData hashtable that is not mapped to a column will be saved.
204      *
205      * @exception UnknownEntityException if the user's account does not
206      * exist in the database.
207      * @exception DataBackendException if there is a problem accessing the
208      * storage.
209      */

210     public void saveOnSessionUnbind(User user)
211             throws UnknownEntityException, DataBackendException
212     {
213         throw new DataBackendException("PassiveUserManager does not support saving user data");
214     }
215
216     /**
217      * Authenticate an User with the specified password. If authentication
218      * is successful the method returns nothing. If there are any problems,
219      * exception was thrown.
220      *
221      * @param user an User object to authenticate.
222      * @param password the user supplied password.
223      * @exception PasswordMismatchException if the supplied password was
224      * incorrect.
225      * @exception UnknownEntityException if the user's record does not
226      * exist in the database.
227      * @exception DataBackendException if there is a problem accessing the
228      * storage.
229      */

230     public void authenticate(User user, String JavaDoc password)
231             throws PasswordMismatchException, UnknownEntityException,
232             DataBackendException
233     {
234         throw new DataBackendException("PassiveUserManager knows no users");
235     }
236
237     /**
238      * Creates new user account with specified attributes.
239      *
240      * @param user the object describing account to be created.
241      * @param initialPassword The password to use for the object creation
242      *
243      * @throws DataBackendException if there was an error accessing the data backend.
244      * @throws EntityExistsException if the user account already exists.
245      */

246     public void createAccount(User user, String JavaDoc initialPassword)
247             throws EntityExistsException, DataBackendException
248     {
249         throw new DataBackendException("PassiveUserManager does not support"
250                 + " creating accounts");
251     }
252
253     /**
254      * Removes an user account from the system.
255      *
256      * @param user the object describing the account to be removed.
257      * @throws DataBackendException if there was an error accessing the data backend.
258      * @throws UnknownEntityException if the user account is not present.
259      */

260     public void removeAccount(User user)
261             throws UnknownEntityException, DataBackendException
262     {
263         throw new DataBackendException("PassiveUserManager does not support removing accounts");
264     }
265
266     /**
267      * Change the password for an User.
268      *
269      * @param user an User to change password for.
270      * @param oldPassword the current password supplied by the user.
271      * @param newPassword the current password requested by the user.
272      * @exception PasswordMismatchException if the supplied password was
273      * incorrect.
274      * @exception UnknownEntityException if the user's record does not
275      * exist in the database.
276      * @exception DataBackendException if there is a problem accessing the
277      * storage.
278      */

279     public void changePassword(User user, String JavaDoc oldPassword,
280                                String JavaDoc newPassword)
281             throws PasswordMismatchException, UnknownEntityException,
282             DataBackendException
283     {
284         throw new DataBackendException("PassiveUserManager does not support setting passwords");
285     }
286
287     /**
288      * Forcibly sets new password for an User.
289      *
290      * This is supposed by the administrator to change the forgotten or
291      * compromised passwords. Certain implementatations of this feature
292      * would require administrative level access to the authenticating
293      * server / program.
294      *
295      * @param user an User to change password for.
296      * @param password the new password.
297      * @exception UnknownEntityException if the user's record does not
298      * exist in the database.
299      * @exception DataBackendException if there is a problem accessing the
300      * storage.
301      */

302     public void forcePassword(User user, String JavaDoc password)
303             throws UnknownEntityException, DataBackendException
304     {
305         throw new DataBackendException("PassiveUserManager does not support setting passwords");
306     }
307 }
308
Popular Tags