_users = parse_ini_file($iniFilename, true); } /** * set the username, which is used for authentication. * * @return void */ public function setUsername($username) { $this->_username = (string) $username; } /** * Set the password, which is used for authentication. * * @return void */ public function setPassword($password) { $this->_password = (string) $password; } /** * Authenticate with the given credentials. * * @return Zend_Auth_Result */ public function authenticate() { if ($this->_username == null || $this->_password == null) { throw new Msd_Exception( 'You must set the username and password first!' ); } $authResult = false; foreach ($this->_users as $userId => $user) { if ( $this->_username == $user['name'] && md5($this->_password) == $user['pass'] ) { $authResult = array( 'id' => $userId, 'name' => $user['name'], ); } } if ($authResult === false) { return new Zend_Auth_Result( Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, array(), array('L_LOGIN_INVALID_USER') ); } return new Zend_Auth_Result( Zend_Auth_Result::SUCCESS, $authResult ); } }