View Javadoc
1 package org.apache.turbine.services.security.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.turbine.om.security.User; 58 59 import org.apache.torque.util.Criteria; 60 import org.apache.turbine.util.security.DataBackendException; 61 import org.apache.turbine.util.security.UnknownEntityException; 62 import org.apache.turbine.util.security.EntityExistsException; 63 import org.apache.turbine.util.security.PasswordMismatchException; 64 65 import org.apache.turbine.services.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.2 2002/07/11 07:16:43 mpoeschl 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 usename 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 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 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 username, String 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 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 * @throws DataBackendException if there was an error accessing the data backend. 211 * @throws EntityExistsException if the user account already exists. 212 */ 213 public void createAccount( User user, String initialPassword ) 214 throws EntityExistsException, DataBackendException 215 { 216 throw new DataBackendException("PassiveUserManager does not support creting accounts"); 217 } 218 219 /*** 220 * Removes an user account from the system. 221 * 222 * @param user the object describing the account to be removed. 223 * @throws DataBackendException if there was an error accessing the data backend. 224 * @throws UnknownEntityException if the user account is not present. 225 */ 226 public void removeAccount( User user ) 227 throws UnknownEntityException, DataBackendException 228 { 229 throw new DataBackendException("PassiveUserManager does not support removing accounts"); 230 } 231 232 /*** 233 * Change the password for an User. 234 * 235 * @param user an User to change password for. 236 * @param oldPassword the current password supplied by the user. 237 * @param newPassword the current password requested by the user. 238 * @exception PasswordMismatchException if the supplied password was 239 * incorrect. 240 * @exception UnknownEntityException if the user's record does not 241 * exist in the database. 242 * @exception DataBackendException if there is a problem accessing the 243 * storage. 244 */ 245 public void changePassword( User user, String oldPassword, String newPassword ) 246 throws PasswordMismatchException, UnknownEntityException, 247 DataBackendException 248 { 249 throw new DataBackendException("PassiveUserManager does not support setting passwords"); 250 } 251 252 /*** 253 * Forcibly sets new password for an User. 254 * 255 * This is supposed by the administrator to change the forgotten or 256 * compromised passwords. Certain implementatations of this feature 257 * would require administrative level access to the authenticating 258 * server / program. 259 * 260 * @param user an User to change password for. 261 * @param password the new password. 262 * @exception UnknownEntityException if the user's record does not 263 * exist in the database. 264 * @exception DataBackendException if there is a problem accessing the 265 * storage. 266 */ 267 public void forcePassword( User user, String password ) 268 throws UnknownEntityException, DataBackendException 269 { 270 throw new DataBackendException("PassiveUserManager does not support setting passwords"); 271 } 272 }

This page was automatically generated by Maven