KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fulcrum > security > impl > passive > PassiveUserManager


1 package org.apache.fulcrum.security.impl.passive;
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 org.apache.fulcrum.security.entity.User;
58
59 import org.apache.torque.util.Criteria;
60 import org.apache.fulcrum.security.util.DataBackendException;
61 import org.apache.fulcrum.security.util.UnknownEntityException;
62 import org.apache.fulcrum.security.util.EntityExistsException;
63 import org.apache.fulcrum.security.util.PasswordMismatchException;
64
65 import org.apache.fulcrum.security.UserManager;
66
67 /**
68  * Void user manager can be used where no data storage is needed
69  * by the application.
70  * It's methods don't provide any useful functionality except throwing
71  * DataBackendExceptions. Security service will be still able to create
72  * anonymous User objects when this UserManager is used.
73  *
74  * @author <a HREF="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
75  * @version $Id: PassiveUserManager.java,v 1.1 2004/11/12 10:26:31 epugh Exp $
76  */

77 public class PassiveUserManager implements UserManager
78 {
79     /**
80      * Check whether a specified user's account exists.
81      *
82      * The login name is used for looking up the account.
83      *
84      * @param user The user to be checked.
85      * @return true if the specified account exists
86      * @throws DataBackendException if there was an error accessing the data backend.
87      */

88     public boolean accountExists(User user)
89         throws DataBackendException
90     {
91         throw new DataBackendException("PassiveUserManager knows no users");
92     }
93
94     /**
95      * Check whether a specified user's account exists.
96      *
97      * The login name is used for looking up the account.
98      *
99      * @param userName The name of the user to be checked.
100      * @return true if the specified account exists
101      * @throws DataBackendException if there was an error accessing the data backend.
102      */

103     public boolean accountExists(String JavaDoc userName)
104         throws DataBackendException
105     {
106         throw new DataBackendException("PassiveUserManager knows no users");
107     }
108
109     /**
110      * Retrieve a user from persistent storage using username as the
111      * key.
112      *
113      * @param username the name of the user.
114      * @return an User object.
115      * @exception UnknownEntityException if the user's record does not
116      * exist in the database.
117      * @exception DataBackendException if there is a problem accessing the
118      * storage.
119      */

120     public User retrieve(String JavaDoc username)
121         throws UnknownEntityException, DataBackendException
122     {
123         throw new DataBackendException("PassiveUserManager knows no users");
124     }
125
126     /**
127      * Retrieve a set of users that meet the specified criteria.
128      *
129      * As the keys for the criteria, you should use the constants that
130      * are defined in {@link User} interface, plus the names
131      * of the custom attributes you added to your user representation
132      * in the data storage. Use verbatim names of the attributes -
133      * without table name prefix in case of DB implementation.
134      *
135      * @param criteria The criteria of selection.
136      * @return a List of users meeting the criteria.
137      * @throws DataBackendException if there is a problem accessing the
138      * storage.
139      */

140     public User[] retrieve(Criteria criteria)
141         throws DataBackendException
142     {
143         throw new DataBackendException("PassiveUserManager knows no users");
144     }
145
146     /**
147      * Retrieve a user from persistent storage using username as the
148      * key, and authenticate the user. The implementation may chose
149      * to authenticate to the server as the user whose data is being
150      * retrieved.
151      *
152      * @param username the name of the user.
153      * @param password the user supplied password.
154      * @return an User object.
155      * @exception PasswordMismatchException if the supplied password was
156      * incorrect.
157      * @exception UnknownEntityException if the user's record does not
158      * exist in the database.
159      * @exception DataBackendException if there is a problem accessing the
160      * storage.
161      */

162     public User retrieve(String JavaDoc username, String JavaDoc password)
163         throws PasswordMismatchException, UnknownEntityException,
164                DataBackendException
165     {
166         throw new DataBackendException("PassiveUserManager knows no users");
167     }
168
169     /**
170      * Save an User object to persistent storage. User's record is
171      * required to exist in the storage.
172      *
173      * @param user an User object to store.
174      * @exception UnknownEntityException if the user's record does not
175      * exist in the database.
176      * @exception DataBackendException if there is a problem accessing the
177      * storage.
178      */

179     public void store(User user)
180         throws UnknownEntityException, DataBackendException
181     {
182         throw new DataBackendException("PassiveUserManager does not support saving user data");
183     }
184
185     /**
186      * Authenticate an User with the specified password. If authentication
187      * is successful the method returns nothing. If there are any problems,
188      * exception was thrown.
189      *
190      * @param user an User object to authenticate.
191      * @param password the user supplied password.
192      * @exception PasswordMismatchException if the supplied password was
193      * incorrect.
194      * @exception UnknownEntityException if the user's record does not
195      * exist in the database.
196      * @exception DataBackendException if there is a problem accessing the
197      * storage.
198      */

199     public void authenticate(User user, String JavaDoc password)
200         throws PasswordMismatchException, UnknownEntityException,
201                DataBackendException
202     {
203         throw new DataBackendException("PassiveUserManager knows no users");
204     }
205
206     /**
207      * Creates new user account with specified attributes.
208      *
209      * @param user the object describing account to be created.
210      * @param password The password to use for the object creation
211      *
212      * @throws DataBackendException if there was an error accessing the data backend.
213      * @throws EntityExistsException if the user account already exists.
214      */

215     public void createAccount(User user, String JavaDoc password)
216         throws EntityExistsException, DataBackendException
217     {
218         throw new DataBackendException("PassiveUserManager does not support creating accounts");
219     }
220
221     /**
222      * Removes an user account from the system.
223      *
224      * @param user the object describing the account to be removed.
225      * @throws DataBackendException if there was an error accessing the data backend.
226      * @throws UnknownEntityException if the user account is not present.
227      */

228     public void removeAccount(User user)
229         throws UnknownEntityException, DataBackendException
230     {
231         throw new DataBackendException("PassiveUserManager does not support removing accounts");
232     }
233
234     /**
235      * Change the password for an User.
236      *
237      * @param user an User to change password for.
238      * @param oldPassword the current password supplied by the user.
239      * @param newPassword the current password requested by the user.
240      * @exception PasswordMismatchException if the supplied password was
241      * incorrect.
242      * @exception UnknownEntityException if the user's record does not
243      * exist in the database.
244      * @exception DataBackendException if there is a problem accessing the
245      * storage.
246      */

247     public void changePassword(User user, String JavaDoc oldPassword, String JavaDoc newPassword)
248         throws PasswordMismatchException, UnknownEntityException,
249                DataBackendException
250     {
251         throw new DataBackendException("PassiveUserManager does not support setting passwords");
252     }
253
254     /**
255      * Forcibly sets new password for an User.
256      *
257      * This is supposed by the administrator to change the forgotten or
258      * compromised passwords. Certain implementatations of this feature
259      * would require administrative level access to the authenticating
260      * server / program.
261      *
262      * @param user an User to change password for.
263      * @param password the new password.
264      * @exception UnknownEntityException if the user's record does not
265      * exist in the database.
266      * @exception DataBackendException if there is a problem accessing the
267      * storage.
268      */

269     public void forcePassword(User user, String JavaDoc password)
270         throws UnknownEntityException, DataBackendException
271     {
272         throw new DataBackendException("PassiveUserManager does not support setting passwords");
273     }
274 }
275
Popular Tags