| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| PassiveUserManager |
|
| 1.9285714285714286;1,929 |
| 1 | package org.apache.turbine.services.security.passive; | |
| 2 | ||
| 3 | ||
| 4 | /* | |
| 5 | * Licensed to the Apache Software Foundation (ASF) under one | |
| 6 | * or more contributor license agreements. See the NOTICE file | |
| 7 | * distributed with this work for additional information | |
| 8 | * regarding copyright ownership. The ASF licenses this file | |
| 9 | * to you under the Apache License, Version 2.0 (the | |
| 10 | * "License"); you may not use this file except in compliance | |
| 11 | * with the License. You may obtain a copy of the License at | |
| 12 | * | |
| 13 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 14 | * | |
| 15 | * Unless required by applicable law or agreed to in writing, | |
| 16 | * software distributed under the License is distributed on an | |
| 17 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
| 18 | * KIND, either express or implied. See the License for the | |
| 19 | * specific language governing permissions and limitations | |
| 20 | * under the License. | |
| 21 | */ | |
| 22 | ||
| 23 | ||
| 24 | import java.util.List; | |
| 25 | ||
| 26 | import org.apache.commons.configuration.Configuration; | |
| 27 | ||
| 28 | import org.apache.turbine.om.security.User; | |
| 29 | import org.apache.turbine.services.security.UserManager; | |
| 30 | import org.apache.turbine.util.security.DataBackendException; | |
| 31 | import org.apache.turbine.util.security.EntityExistsException; | |
| 32 | import org.apache.turbine.util.security.PasswordMismatchException; | |
| 33 | import org.apache.turbine.util.security.UnknownEntityException; | |
| 34 | ||
| 35 | /** | |
| 36 | * Void user manager can be used where no data storage is needed | |
| 37 | * by the application. | |
| 38 | * It's methods don't provide any useful functionality except throwing | |
| 39 | * DataBackendExceptions. Security service will be still able to create | |
| 40 | * anonymous User objects when this UserManager is used. | |
| 41 | * | |
| 42 | * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a> | |
| 43 | * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a> | |
| 44 | * @version $Id: PassiveUserManager.java 1096130 2011-04-23 10:37:19Z ludwig $ | |
| 45 | */ | |
| 46 | 2 | public class PassiveUserManager implements UserManager |
| 47 | { | |
| 48 | /** | |
| 49 | * Initializes the UserManager | |
| 50 | * | |
| 51 | * @param conf A Configuration object to init this Manager | |
| 52 | */ | |
| 53 | public void init(Configuration conf) | |
| 54 | { | |
| 55 | // GNDN | |
| 56 | 2 | } |
| 57 | ||
| 58 | /** | |
| 59 | * Check whether a specified user's account exists. | |
| 60 | * | |
| 61 | * The login name is used for looking up the account. | |
| 62 | * | |
| 63 | * @param user The user to be checked. | |
| 64 | * @return true if the specified account exists | |
| 65 | * @throws DataBackendException if there was an error accessing the data backend. | |
| 66 | */ | |
| 67 | public boolean accountExists(User user) | |
| 68 | throws DataBackendException | |
| 69 | { | |
| 70 | 0 | throw new DataBackendException("PassiveUserManager knows no users"); |
| 71 | } | |
| 72 | ||
| 73 | /** | |
| 74 | * Check whether a specified user's account exists. | |
| 75 | * | |
| 76 | * The login name is used for looking up the account. | |
| 77 | * | |
| 78 | * @param userName The name of the user to be checked. | |
| 79 | * @return true if the specified account exists | |
| 80 | * @throws DataBackendException if there was an error accessing the data backend. | |
| 81 | */ | |
| 82 | public boolean accountExists(String userName) | |
| 83 | throws DataBackendException | |
| 84 | { | |
| 85 | 0 | throw new DataBackendException("PassiveUserManager knows no users"); |
| 86 | } | |
| 87 | ||
| 88 | /** | |
| 89 | * Retrieve a user from persistent storage using username as the | |
| 90 | * key. | |
| 91 | * | |
| 92 | * @param username the name of the user. | |
| 93 | * @return an User object. | |
| 94 | * @exception UnknownEntityException if the user's record does not | |
| 95 | * exist in the database. | |
| 96 | * @exception DataBackendException if there is a problem accessing the | |
| 97 | * storage. | |
| 98 | */ | |
| 99 | public User retrieve(String username) | |
| 100 | throws UnknownEntityException, DataBackendException | |
| 101 | { | |
| 102 | 0 | throw new DataBackendException("PassiveUserManager knows no users"); |
| 103 | } | |
| 104 | ||
| 105 | /** | |
| 106 | * Retrieve a set of users that meet the specified criteria. | |
| 107 | * | |
| 108 | * As the keys for the criteria, you should use the constants that | |
| 109 | * are defined in {@link User} interface, plus the names | |
| 110 | * of the custom attributes you added to your user representation | |
| 111 | * in the data storage. Use verbatim names of the attributes - | |
| 112 | * without table name prefix in case of DB implementation. | |
| 113 | * | |
| 114 | * @param criteria The criteria of selection. | |
| 115 | * @return a List of users meeting the criteria. | |
| 116 | * @throws DataBackendException if there is a problem accessing the | |
| 117 | * storage. | |
| 118 | * @deprecated Use <a href="#retrieveList">retrieveList</a> instead. | |
| 119 | */ | |
| 120 | public User[] retrieve(Object criteria) | |
| 121 | throws DataBackendException | |
| 122 | { | |
| 123 | 0 | 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 List retrieveList(Object criteria) | |
| 141 | throws DataBackendException | |
| 142 | { | |
| 143 | 0 | 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 | 0 | 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 | 0 | throw new DataBackendException("PassiveUserManager does not support saving user data"); |
| 183 | } | |
| 184 | ||
| 185 | /** | |
| 186 | * Saves User data when the session is unbound. The user account is required | |
| 187 | * to exist in the storage. | |
| 188 | * | |
| 189 | * LastLogin, AccessCounter, persistent pull tools, and any data stored | |
| 190 | * in the permData hashtable that is not mapped to a column will be saved. | |
| 191 | * | |
| 192 | * @exception UnknownEntityException if the user's account does not | |
| 193 | * exist in the database. | |
| 194 | * @exception DataBackendException if there is a problem accessing the | |
| 195 | * storage. | |
| 196 | */ | |
| 197 | public void saveOnSessionUnbind(User user) | |
| 198 | throws UnknownEntityException, DataBackendException | |
| 199 | { | |
| 200 | 0 | throw new DataBackendException("PassiveUserManager does not support saving user data"); |
| 201 | } | |
| 202 | ||
| 203 | /** | |
| 204 | * Authenticate an User with the specified password. If authentication | |
| 205 | * is successful the method returns nothing. If there are any problems, | |
| 206 | * exception was thrown. | |
| 207 | * | |
| 208 | * @param user an User object to authenticate. | |
| 209 | * @param password the user supplied password. | |
| 210 | * @exception PasswordMismatchException if the supplied password was | |
| 211 | * incorrect. | |
| 212 | * @exception UnknownEntityException if the user's record does not | |
| 213 | * exist in the database. | |
| 214 | * @exception DataBackendException if there is a problem accessing the | |
| 215 | * storage. | |
| 216 | */ | |
| 217 | public void authenticate(User user, String password) | |
| 218 | throws PasswordMismatchException, UnknownEntityException, | |
| 219 | DataBackendException | |
| 220 | { | |
| 221 | 0 | throw new DataBackendException("PassiveUserManager knows no users"); |
| 222 | } | |
| 223 | ||
| 224 | /** | |
| 225 | * Creates new user account with specified attributes. | |
| 226 | * | |
| 227 | * @param user the object describing account to be created. | |
| 228 | * @param initialPassword The password to use for the object creation | |
| 229 | * | |
| 230 | * @throws DataBackendException if there was an error accessing the data backend. | |
| 231 | * @throws EntityExistsException if the user account already exists. | |
| 232 | */ | |
| 233 | public void createAccount(User user, String initialPassword) | |
| 234 | throws EntityExistsException, DataBackendException | |
| 235 | { | |
| 236 | 0 | throw new DataBackendException("PassiveUserManager does not support" |
| 237 | + " creating accounts"); | |
| 238 | } | |
| 239 | ||
| 240 | /** | |
| 241 | * Removes an user account from the system. | |
| 242 | * | |
| 243 | * @param user the object describing the account to be removed. | |
| 244 | * @throws DataBackendException if there was an error accessing the data backend. | |
| 245 | * @throws UnknownEntityException if the user account is not present. | |
| 246 | */ | |
| 247 | public void removeAccount(User user) | |
| 248 | throws UnknownEntityException, DataBackendException | |
| 249 | { | |
| 250 | 0 | throw new DataBackendException("PassiveUserManager does not support removing accounts"); |
| 251 | } | |
| 252 | ||
| 253 | /** | |
| 254 | * Change the password for an User. | |
| 255 | * | |
| 256 | * @param user an User to change password for. | |
| 257 | * @param oldPassword the current password supplied by the user. | |
| 258 | * @param newPassword the current password requested by the user. | |
| 259 | * @exception PasswordMismatchException if the supplied password was | |
| 260 | * incorrect. | |
| 261 | * @exception UnknownEntityException if the user's record does not | |
| 262 | * exist in the database. | |
| 263 | * @exception DataBackendException if there is a problem accessing the | |
| 264 | * storage. | |
| 265 | */ | |
| 266 | public void changePassword(User user, String oldPassword, | |
| 267 | String newPassword) | |
| 268 | throws PasswordMismatchException, UnknownEntityException, | |
| 269 | DataBackendException | |
| 270 | { | |
| 271 | 0 | throw new DataBackendException("PassiveUserManager does not support setting passwords"); |
| 272 | } | |
| 273 | ||
| 274 | /** | |
| 275 | * Forcibly sets new password for an User. | |
| 276 | * | |
| 277 | * This is supposed by the administrator to change the forgotten or | |
| 278 | * compromised passwords. Certain implementatations of this feature | |
| 279 | * would require administrative level access to the authenticating | |
| 280 | * server / program. | |
| 281 | * | |
| 282 | * @param user an User to change password for. | |
| 283 | * @param password the new password. | |
| 284 | * @exception UnknownEntityException if the user's record does not | |
| 285 | * exist in the database. | |
| 286 | * @exception DataBackendException if there is a problem accessing the | |
| 287 | * storage. | |
| 288 | */ | |
| 289 | public void forcePassword(User user, String password) | |
| 290 | throws UnknownEntityException, DataBackendException | |
| 291 | { | |
| 292 | 0 | throw new DataBackendException("PassiveUserManager does not support setting passwords"); |
| 293 | } | |
| 294 | } |