001: package org.apache.turbine.services.security.passive;
002:
003: /*
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021:
022: import java.util.List;
023:
024: import org.apache.commons.configuration.Configuration;
025:
026: import org.apache.torque.util.Criteria;
027:
028: import org.apache.turbine.om.security.User;
029: import org.apache.turbine.services.security.UserManager;
030: import org.apache.turbine.util.security.DataBackendException;
031: import org.apache.turbine.util.security.EntityExistsException;
032: import org.apache.turbine.util.security.PasswordMismatchException;
033: import org.apache.turbine.util.security.UnknownEntityException;
034:
035: /**
036: * Void user manager can be used where no data storage is needed
037: * by the application.
038: * It's methods don't provide any useful functionality except throwing
039: * DataBackendExceptions. Security service will be still able to create
040: * anonymous User objects when this UserManager is used.
041: *
042: * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
043: * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
044: * @version $Id: PassiveUserManager.java 534527 2007-05-02 16:10:59Z tv $
045: */
046: public class PassiveUserManager implements UserManager {
047: /**
048: * Initializes the UserManager
049: *
050: * @param conf A Configuration object to init this Manager
051: */
052: public void init(Configuration conf) {
053: // GNDN
054: }
055:
056: /**
057: * Check whether a specified user's account exists.
058: *
059: * The login name is used for looking up the account.
060: *
061: * @param user The user to be checked.
062: * @return true if the specified account exists
063: * @throws DataBackendException if there was an error accessing the data backend.
064: */
065: public boolean accountExists(User user) throws DataBackendException {
066: throw new DataBackendException(
067: "PassiveUserManager knows no users");
068: }
069:
070: /**
071: * Check whether a specified user's account exists.
072: *
073: * The login name is used for looking up the account.
074: *
075: * @param userName The name of the user to be checked.
076: * @return true if the specified account exists
077: * @throws DataBackendException if there was an error accessing the data backend.
078: */
079: public boolean accountExists(String userName)
080: throws DataBackendException {
081: throw new DataBackendException(
082: "PassiveUserManager knows no users");
083: }
084:
085: /**
086: * Retrieve a user from persistent storage using username as the
087: * key.
088: *
089: * @param username the name of the user.
090: * @return an User object.
091: * @exception UnknownEntityException if the user's record does not
092: * exist in the database.
093: * @exception DataBackendException if there is a problem accessing the
094: * storage.
095: */
096: public User retrieve(String username)
097: throws UnknownEntityException, DataBackendException {
098: throw new DataBackendException(
099: "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 key) throws UnknownEntityException,
113: DataBackendException {
114: throw new DataBackendException(
115: "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: throw new DataBackendException(
136: "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 retrieveList(Criteria criteria)
154: throws DataBackendException {
155: throw new DataBackendException(
156: "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 username, String password)
176: throws PasswordMismatchException, UnknownEntityException,
177: DataBackendException {
178: throw new DataBackendException(
179: "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) throws UnknownEntityException,
193: DataBackendException {
194: throw new DataBackendException(
195: "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: throw new DataBackendException(
213: "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 password)
231: throws PasswordMismatchException, UnknownEntityException,
232: DataBackendException {
233: throw new DataBackendException(
234: "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 initialPassword)
247: throws EntityExistsException, DataBackendException {
248: throw new DataBackendException(
249: "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) throws UnknownEntityException,
261: DataBackendException {
262: throw new DataBackendException(
263: "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 oldPassword,
280: String newPassword) throws PasswordMismatchException,
281: UnknownEntityException, DataBackendException {
282: throw new DataBackendException(
283: "PassiveUserManager does not support setting passwords");
284: }
285:
286: /**
287: * Forcibly sets new password for an User.
288: *
289: * This is supposed by the administrator to change the forgotten or
290: * compromised passwords. Certain implementatations of this feature
291: * would require administrative level access to the authenticating
292: * server / program.
293: *
294: * @param user an User to change password for.
295: * @param password the new password.
296: * @exception UnknownEntityException if the user's record does not
297: * exist in the database.
298: * @exception DataBackendException if there is a problem accessing the
299: * storage.
300: */
301: public void forcePassword(User user, String password)
302: throws UnknownEntityException, DataBackendException {
303: throw new DataBackendException(
304: "PassiveUserManager does not support setting passwords");
305: }
306: }
|