Array.php

Go to the documentation of this file.
00001 <?php
00002 
00031 class Robo47_Auth_Adapter_Array implements Zend_Auth_Adapter_Interface
00032 {
00033 
00039     protected $_username = '';
00045     protected $_password = '';
00051     protected $_userdata = array();
00052 
00059     public function __construct($username = '', $password = '',
00060         array $userData = array())
00061     {
00062         $this->setUsername($username);
00063         $this->setPassword($password);
00064         $this->setUserData($userData);
00065     }
00066 
00072     public function setUsername($username)
00073     {
00074         $this->_username = $username;
00075         return $this;
00076     }
00077 
00083     public function setPassword($password)
00084     {
00085         $this->_password = $password;
00086         return $this;
00087     }
00088 
00093     public function getUsername()
00094     {
00095         return $this->_username;
00096     }
00097 
00102     public function getPassword()
00103     {
00104         return $this->_password;
00105     }
00106 
00112     public function setUserData(array $userData = array())
00113     {
00114         $this->_userdata = $userData;
00115         return $this;
00116     }
00117 
00122     public function getUserData()
00123     {
00124         return $this->_userdata;
00125     }
00126 
00130     public function authenticate()
00131     {
00132         foreach ($this->_userdata as $username => $password) {
00133             if ($username == $this->_username &&
00134                 $password == $this->_password) {
00135                 return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS,
00136                     $this->_username);
00137             }
00138         }
00139         return new Zend_Auth_Result(Zend_Auth_Result::FAILURE,
00140             $this->_username);
00141     }
00142 }