_users = parse_ini_file($iniFilename, true); } /** * set the username, which is used for authentication. * * @param string $username The username * * @return void */ public function setUsername($username) { $this->_username = (string)$username; } /** * Set the password, which is used for authentication. * * @param string $password The password * * @return void */ public function setPassword($password) { $this->_password = (string)$password; } /** * Authenticate with the given credentials. * * @throws Msd_Exception * * @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['users']['user'] as $name => $pass) { if ($this->_username == $name && md5($this->_password) == $pass) { $authResult = array( 'id' => $name, 'name' => $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 ); } }