class_ShipSimuGuestLogin.php
Go to the documentation of this file.00001 <?php
00024 class ShipSimuGuestLogin extends BaseFrameworkSystem implements LoginableUser {
00028 private $hashedPassword = "";
00029
00035 protected function __construct () {
00036
00037 parent::__construct(__CLASS__);
00038
00039
00040 $this->removeNumberFormaters();
00041 $this->removeSystemArray();
00042 }
00043
00049 public final static function createShipSimuGuestLogin () {
00050
00051 $loginInstance = new ShipSimuGuestLogin();
00052
00053
00054 return $loginInstance;
00055 }
00056
00072 public function doLogin (Requestable $requestInstance, Responseable $responseInstance) {
00073
00074 $method = null;
00075 $data = "";
00076
00077
00078 if (!is_null($requestInstance->getRequestElement('user'))) {
00079
00080 $method = 'createGuestByUsername';
00081 $data = $requestInstance->getRequestElement('user');
00082 }
00083
00084
00085 if (is_null($method)) {
00086
00087 throw new UserAuthMethodException($this, self::EXCEPTION_MISSING_METHOD);
00088 } elseif (!method_exists($this->getConfigInstance()->readConfig('guest_class'), $method)) {
00089
00090 throw new MissingMethodException(array($this, $method), self::EXCEPTION_MISSING_METHOD);
00091 }
00092
00093
00094 $userInstance = Registry::getRegistry()->getInstance('user');
00095
00096
00097 if (is_null($userInstance)) {
00098
00099 $userInstance = call_user_func_array(array($this->getConfigInstance()->readConfig('guest_class'), $method), array($data));
00100
00101
00102 Registry::getRegistry()->addInstance($userInstance);
00103 }
00104
00105
00106 if ($userInstance->ifPasswordHashMatches($requestInstance) === false) {
00107
00108 throw new UserPasswordMismatchException(array($this, $userInstance), BaseUser::EXCEPTION_USER_PASS_MISMATCH);
00109 }
00110
00111
00112
00113
00114 $helperInstance = ObjectFactory::createObjectByConfiguredName('login_helper_class', array($requestInstance));
00115
00116
00117 $helperInstance->executeLogin($responseInstance);
00118 }
00119
00125 public function ifLoginWasSuccessfull () {
00126
00127 $loginDone = (Registry::getRegistry()->getInstance('login') instanceof Registerable);
00128
00129
00130 return $loginDone;
00131 }
00132
00140 public function encryptPassword ($requestKey) {
00141
00142 if ($this->getRequestInstance()->isRequestElementSet($requestKey)) {
00143
00144
00145
00146
00147 $plainPassword = $this->getRequestInstance()->getRequestElement($requestKey);
00148
00149
00150 $userInstance = Registry::getRegistry()->getInstance('user');
00151
00152
00153 $this->hashedPassword = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($plainPassword, $userInstance->getPasswordHash());
00154
00155
00156 $this->getRequestInstance()->setRequestElement('pass_hash', $this->hashedPassword);
00157 }
00158 }
00159 }
00160
00161
00162 ?>