Source for file HardcodedAccounts.php

Documentation is available at HardcodedAccounts.php

  1. <?php
  2. /** 
  3.  * @author Dirk Merkel <dirk@waferthin.com>
  4.  * @package WebServices
  5.  * @subpackage Authentication
  6.  * @copyright Waferthin Web Works LLC
  7.  * @license http://www.gnu.org/copyleft/gpl.html Freely available under GPL
  8.  */
  9. /** 
  10.  * <i>Authentication_HardcodedAccounts</i> class
  11.  * 
  12.  * This class implements the login method needed to handle
  13.  * actual user authentication. It extends <i>Authentication</i>
  14.  * and implements the <i>Accountable</i> interface.
  15.  *
  16.  * @package WebServices
  17.  * @subpackage Authentication
  18.  * @see Authentication
  19.  * @author Dirk Merkel <dirk@waferthin.com>
  20.  * @version 0.6
  21.  * @since r14
  22.  */
  23. {
  24.     /**
  25.      * Referece to <i>Users</i> object
  26.      * @access private
  27.      * @var Users 
  28.      */
  29.     private $users;
  30.  
  31.     /**
  32.      * Authentication_HardcodedAccounts constructor
  33.      *
  34.      * Instantiates a new {@link Users} object and stores a reference
  35.      * in the {@link users} property.
  36.      *
  37.      * @see Users
  38.      * @access public
  39.      * @return void 
  40.      */
  41.     public function __construct()
  42.     {
  43.         $this->users new Users();
  44.     }
  45.     
  46.     /**
  47.      * login method
  48.      *
  49.      * Uses the reference {@link Users} class to handle
  50.      * user validation.
  51.      *
  52.      * @see Users
  53.      * @todo Decide which validate method to user instead of both
  54.      * @access public
  55.      * @param string $user account user name
  56.      * @param string $password account password
  57.      * @return boolean 
  58.      */
  59.     public function login($user$password)
  60.     {
  61.         if (empty($user|| empty($password)) {
  62.             return false;
  63.         else {
  64.  
  65.             // both validation methods should work ...
  66.  
  67.             // user static method to validate account
  68.             $firstValidation Users::validate($user$password);
  69.  
  70.             // use magic method validate<username>($password)
  71.             $userLoginFunction 'validate' $user;
  72.             $secondValidation $this->users->$userLoginFunction($password);
  73.  
  74.             return ($firstValidation && $secondValidation);
  75.         }
  76.     }
  77. }
  78.  
  79. ?>

Documentation generated on Mon, 26 Jul 2010 22:07:04 +0100 by phpDocumentor 1.4.3