Coverage Report - org.apache.turbine.services.security.passive.PassiveUserManager
 
Classes in this File Line Coverage Branch Coverage Complexity
PassiveUserManager
0%
0/19
N/A
1,889
 
 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  
 import org.apache.fulcrum.security.acl.AccessControlList;
 28  
 import org.apache.fulcrum.security.util.DataBackendException;
 29  
 import org.apache.fulcrum.security.util.EntityExistsException;
 30  
 import org.apache.fulcrum.security.util.PasswordMismatchException;
 31  
 import org.apache.fulcrum.security.util.UnknownEntityException;
 32  
 import org.apache.turbine.om.security.User;
 33  
 import org.apache.turbine.services.security.UserManager;
 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 1773378 2016-12-09 13:19:59Z tv $
 45  
  */
 46  0
 public class PassiveUserManager implements UserManager
 47  
 {
 48  
     /**
 49  
      * Initializes the UserManager
 50  
      *
 51  
      * @param conf A Configuration object to init this Manager
 52  
      */
 53  
     @Override
 54  
     public void init(Configuration conf)
 55  
     {
 56  
         // GNDN
 57  0
     }
 58  
 
 59  
     /**
 60  
      * Check whether a specified user's account exists.
 61  
      *
 62  
      * The login name is used for looking up the account.
 63  
      *
 64  
      * @param user The user to be checked.
 65  
      * @return true if the specified account exists
 66  
      * @throws DataBackendException if there was an error accessing the data backend.
 67  
      */
 68  
     @Override
 69  
     public boolean accountExists(User user)
 70  
             throws DataBackendException
 71  
     {
 72  0
         throw new DataBackendException("PassiveUserManager knows no users");
 73  
     }
 74  
 
 75  
     /**
 76  
      * Check whether a specified user's account exists.
 77  
      *
 78  
      * The login name is used for looking up the account.
 79  
      *
 80  
      * @param userName The name of the user to be checked.
 81  
      * @return true if the specified account exists
 82  
      * @throws DataBackendException if there was an error accessing the data backend.
 83  
      */
 84  
     @Override
 85  
     public boolean accountExists(String userName)
 86  
             throws DataBackendException
 87  
     {
 88  0
         throw new DataBackendException("PassiveUserManager knows no users");
 89  
     }
 90  
 
 91  
     /**
 92  
      * Retrieve a user from persistent storage using username as the
 93  
      * key.
 94  
      *
 95  
      * @param username the name of the user.
 96  
      * @return an User object.
 97  
      * @throws UnknownEntityException if the user's record does not
 98  
      *            exist in the database.
 99  
      * @throws DataBackendException if there is a problem accessing the
 100  
      *            storage.
 101  
      */
 102  
     @Override
 103  
     public <U extends User> U retrieve(String username)
 104  
             throws UnknownEntityException, DataBackendException
 105  
     {
 106  0
         throw new DataBackendException("PassiveUserManager knows no users");
 107  
     }
 108  
 
 109  
     /**
 110  
      * Retrieve a set of users that meet the specified criteria.
 111  
      *
 112  
      * As the keys for the criteria, you should use the constants that
 113  
      * are defined in {@link User} interface, plus the names
 114  
      * of the custom attributes you added to your user representation
 115  
      * in the data storage. Use verbatim names of the attributes -
 116  
      * without table name prefix in case of DB implementation.
 117  
      *
 118  
      * @param criteria The criteria of selection.
 119  
      * @return a List of users meeting the criteria.
 120  
      * @throws DataBackendException if there is a problem accessing the
 121  
      *         storage.
 122  
      */
 123  
     @Override
 124  
     public List<? extends User> retrieveList(Object criteria)
 125  
             throws DataBackendException
 126  
     {
 127  0
         throw new DataBackendException("PassiveUserManager knows no users");
 128  
     }
 129  
 
 130  
     /**
 131  
      * Retrieve a user from persistent storage using username as the
 132  
      * key, and authenticate the user. The implementation may chose
 133  
      * to authenticate to the server as the user whose data is being
 134  
      * retrieved.
 135  
      *
 136  
      * @param username the name of the user.
 137  
      * @param password the user supplied password.
 138  
      * @return an User object.
 139  
      * @throws PasswordMismatchException if the supplied password was
 140  
      *            incorrect.
 141  
      * @throws UnknownEntityException if the user's record does not
 142  
      *            exist in the database.
 143  
      * @throws DataBackendException if there is a problem accessing the
 144  
      *            storage.
 145  
      */
 146  
     @Override
 147  
     public <U extends User> U retrieve(String username, String password)
 148  
             throws PasswordMismatchException, UnknownEntityException,
 149  
             DataBackendException
 150  
     {
 151  0
         throw new DataBackendException("PassiveUserManager knows no users");
 152  
     }
 153  
 
 154  
     /**
 155  
      * Save an User object to persistent storage. User's record is
 156  
      * required to exist in the storage.
 157  
      *
 158  
      * @param user an User object to store.
 159  
      * @throws UnknownEntityException if the user's record does not
 160  
      *            exist in the database.
 161  
      * @throws DataBackendException if there is a problem accessing the
 162  
      *            storage.
 163  
      */
 164  
     @Override
 165  
     public void store(User user)
 166  
             throws UnknownEntityException, DataBackendException
 167  
     {
 168  0
         throw new DataBackendException("PassiveUserManager does not support saving user data");
 169  
     }
 170  
 
 171  
     /**
 172  
      * Saves User data when the session is unbound. The user account is required
 173  
      * to exist in the storage.
 174  
      *
 175  
      * LastLogin, AccessCounter, persistent pull tools, and any data stored
 176  
      * in the permData hashmap that is not mapped to a column will be saved.
 177  
      *
 178  
      * @throws UnknownEntityException if the user's account does not
 179  
      *            exist in the database.
 180  
      * @throws DataBackendException if there is a problem accessing the
 181  
      *            storage.
 182  
      */
 183  
     @Override
 184  
     public void saveOnSessionUnbind(User user)
 185  
             throws UnknownEntityException, DataBackendException
 186  
     {
 187  0
         throw new DataBackendException("PassiveUserManager does not support saving user data");
 188  
     }
 189  
 
 190  
     /**
 191  
      * Authenticate an User with the specified password. If authentication
 192  
      * is successful the method returns nothing. If there are any problems,
 193  
      * exception was thrown.
 194  
      *
 195  
      * @param user an User object to authenticate.
 196  
      * @param password the user supplied password.
 197  
      * @throws PasswordMismatchException if the supplied password was
 198  
      *            incorrect.
 199  
      * @throws UnknownEntityException if the user's record does not
 200  
      *            exist in the database.
 201  
      * @throws DataBackendException if there is a problem accessing the
 202  
      *            storage.
 203  
      */
 204  
     @Override
 205  
     public void authenticate(User user, String password)
 206  
             throws PasswordMismatchException, UnknownEntityException,
 207  
             DataBackendException
 208  
     {
 209  0
         throw new DataBackendException("PassiveUserManager knows no users");
 210  
     }
 211  
 
 212  
     /**
 213  
      * Creates new user account with specified attributes.
 214  
      *
 215  
      * @param user the object describing account to be created.
 216  
      * @param initialPassword The password to use for the object creation
 217  
      *
 218  
      * @throws DataBackendException if there was an error accessing the data backend.
 219  
      * @throws EntityExistsException if the user account already exists.
 220  
      */
 221  
     @Override
 222  
     public void createAccount(User user, String initialPassword)
 223  
             throws EntityExistsException, DataBackendException
 224  
     {
 225  0
         throw new DataBackendException("PassiveUserManager does not support"
 226  
                 + " creating accounts");
 227  
     }
 228  
 
 229  
     /**
 230  
      * Removes an user account from the system.
 231  
      *
 232  
      * @param user the object describing the account to be removed.
 233  
      * @throws DataBackendException if there was an error accessing the data backend.
 234  
      * @throws UnknownEntityException if the user account is not present.
 235  
      */
 236  
     @Override
 237  
     public void removeAccount(User user)
 238  
             throws UnknownEntityException, DataBackendException
 239  
     {
 240  0
         throw new DataBackendException("PassiveUserManager does not support removing accounts");
 241  
     }
 242  
 
 243  
     /**
 244  
      * Change the password for an User.
 245  
      *
 246  
      * @param user an User to change password for.
 247  
      * @param oldPassword the current password supplied by the user.
 248  
      * @param newPassword the current password requested by the user.
 249  
      * @throws PasswordMismatchException if the supplied password was
 250  
      *            incorrect.
 251  
      * @throws UnknownEntityException if the user's record does not
 252  
      *            exist in the database.
 253  
      * @throws DataBackendException if there is a problem accessing the
 254  
      *            storage.
 255  
      */
 256  
     @Override
 257  
     public void changePassword(User user, String oldPassword,
 258  
                                String newPassword)
 259  
             throws PasswordMismatchException, UnknownEntityException,
 260  
             DataBackendException
 261  
     {
 262  0
         throw new DataBackendException("PassiveUserManager does not support setting passwords");
 263  
     }
 264  
 
 265  
     /**
 266  
      * Forcibly sets new password for an User.
 267  
      *
 268  
      * This is supposed by the administrator to change the forgotten or
 269  
      * compromised passwords. Certain implementations of this feature
 270  
      * would require administrative level access to the authenticating
 271  
      * server / program.
 272  
      *
 273  
      * @param user an User to change password for.
 274  
      * @param password the new password.
 275  
      * @throws UnknownEntityException if the user's record does not
 276  
      *            exist in the database.
 277  
      * @throws DataBackendException if there is a problem accessing the
 278  
      *            storage.
 279  
      */
 280  
     @Override
 281  
     public void forcePassword(User user, String password)
 282  
             throws UnknownEntityException, DataBackendException
 283  
     {
 284  0
         throw new DataBackendException("PassiveUserManager does not support setting passwords");
 285  
     }
 286  
 
 287  
     /**
 288  
      * Constructs an User object to represent an anonymous user of the
 289  
      * application.
 290  
      *
 291  
      * @return An anonymous Turbine User.
 292  
      * @throws UnknownEntityException
 293  
      *             if the anonymous User object couldn't be constructed.
 294  
      */
 295  
     @Override
 296  
     public <T extends User> T getAnonymousUser() throws UnknownEntityException
 297  
     {
 298  0
         throw new UnknownEntityException("PassiveUserManager knows no users");
 299  
     }
 300  
 
 301  
     /**
 302  
      * Checks whether a passed user object matches the anonymous user pattern
 303  
      * according to the configured user manager
 304  
      *
 305  
      * @param u a user object
 306  
      *
 307  
      * @return true if this is an anonymous user
 308  
      *
 309  
      */
 310  
     @Override
 311  
     public boolean isAnonymousUser(User u)
 312  
     {
 313  0
         return true;
 314  
     }
 315  
 
 316  
     /**
 317  
      * Construct a blank User object.
 318  
      *
 319  
      * This method calls getUserClass, and then creates a new object using the
 320  
      * default constructor.
 321  
      *
 322  
      * @return an object implementing User interface.
 323  
      * @throws DataBackendException
 324  
      *             if the object could not be instantiated.
 325  
      */
 326  
     @Override
 327  
     public <T extends User> T getUserInstance() throws DataBackendException
 328  
     {
 329  0
         throw new DataBackendException("PassiveUserManager knows no users");
 330  
     }
 331  
 
 332  
     /**
 333  
      * Construct a blank User object.
 334  
      *
 335  
      * This method calls getUserClass, and then creates a new object using the
 336  
      * default constructor.
 337  
      *
 338  
      * @param userName
 339  
      *            The name of the user.
 340  
      *
 341  
      * @return an object implementing User interface.
 342  
      * @throws DataBackendException
 343  
      *             if the object could not be instantiated.
 344  
      */
 345  
     @Override
 346  
     public <T extends User> T getUserInstance(String userName) throws DataBackendException
 347  
     {
 348  0
         throw new DataBackendException("PassiveUserManager knows no users");
 349  
     }
 350  
 
 351  
     /**
 352  
      * Return a Class object representing the system's chosen implementation of
 353  
      * of ACL interface.
 354  
      *
 355  
      * @return systems's chosen implementation of ACL interface.
 356  
      * @throws UnknownEntityException
 357  
      *             if the implementation of ACL interface could not be
 358  
      *             determined, or does not exist.
 359  
      */
 360  
     @Override
 361  
     public <T extends AccessControlList> T getACL(User user) throws UnknownEntityException
 362  
     {
 363  0
         throw new UnknownEntityException("PassiveUserManager knows no users");
 364  
     }
 365  
 }