class_AdminUserLogin.php

Go to the documentation of this file.
00001 <?php
00024 class AdminUserLogin extends BaseFrameworkSystem implements LoginableUser {
00028         private $hashedPassword = "";
00029 
00035         protected function __construct () {
00036                 // Call parent constructor
00037                 parent::__construct(__CLASS__);
00038 
00039                 // Clean up a little
00040                 $this->removeNumberFormaters();
00041                 $this->removeSystemArray();
00042         }
00043 
00049         public final static function createAdminUserLogin () {
00050                 // Get a new instance
00051                 $loginInstance = new AdminUserLogin();
00052 
00053                 // Return the instance
00054                 return $loginInstance;
00055         }
00056 
00071         public function doLogin (Requestable $requestInstance, Responseable $responseInstance) {
00072                 // By default no method is selected
00073                 $method = null;
00074                 $data = "";
00075 
00076                 // Get a instance of the registry
00077                 $userInstance = Registry::getRegistry()->getInstance('user');
00078 
00079                 // Is there an instance?
00080                 if (is_null($userInstance)) {
00081                         // Get member class
00082                         $userClass = $this->getConfigInstance()->readConfig('user_class');
00083 
00084                         // Get a user instance
00085                         $userInstance = call_user_func_array(array($userClass, 'createMemberByRequest'), array($requestInstance));
00086 
00087                         // Remember this new instance in registry
00088                         Registry::getRegistry()->addInstance($userInstance);
00089                 } // END - if
00090 
00091                 // Is the password correct?
00092                 if ($userInstance->ifPasswordHashMatches($requestInstance) === false) {
00093                         // Mismatching password
00094                         throw new UserPasswordMismatchException(array($this, $userInstance), BaseUser::EXCEPTION_USER_PASS_MISMATCH);
00095                 } // END - if
00096 
00097                 // ToDo place
00098 
00099                 // Now do the real login. This can be cookie- or session-based login
00100                 // which depends on the admins setting then on the user's taste.
00101                 // 1) Get a login helper instance
00102                 $helperInstance = ObjectFactory::createObjectByConfiguredName('login_helper_class', array($requestInstance));
00103 
00104                 // 2) Execute the login. This will now login...
00105                 $helperInstance->executeLogin($responseInstance);
00106         }
00107 
00113         public function ifLoginWasSuccessfull () {
00114                 // Is the registry key there?
00115                 $loginDone = (Registry::getRegistry()->getInstance('login') instanceof Registerable);
00116 
00117                 // Return the result
00118                 return $loginDone;
00119         }
00120 
00128         public function encryptPassword ($requestKey) {
00129                 // Check if password is found in request
00130                 if ($this->getRequestInstance()->isRequestElementSet($requestKey)) {
00131                         // So encrypt the password and store it for later usage in
00132                         // the request:
00133 
00134                         // Get the plain password
00135                         $plainPassword = $this->getRequestInstance()->getRequestElement($requestKey);
00136 
00137                         // Get user instance
00138                         $userInstance = Registry::getRegistry()->getInstance('user');
00139 
00140                         // Get a crypto helper and hash the password
00141                         $this->hashedPassword = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($plainPassword, $userInstance->getPasswordHash());
00142 
00143                         // Store the hash back in request
00144                         $this->getRequestInstance()->setRequestElement('pass_hash', $this->hashedPassword);
00145                 } // END - if
00146         }
00147 }
00148 
00149 // [EOF]
00150 ?>

Generated on Mon Dec 8 01:06:44 2008 for Ship-Simulator by  doxygen 1.5.6