00001 <?php 00032 class ShipSimuLoginHelper extends BaseLoginHelper implements HelpableLogin { 00036 private $authMethod = ""; 00037 00038 // Exception constants 00039 const EXCEPTION_INVALID_USER_INSTANCE = 0x190; 00040 00046 protected function __construct () { 00047 // Call parent constructor 00048 parent::__construct(__CLASS__); 00049 } 00050 00059 public final static function createShipSimuLoginHelper (Requestable $requestInstance) { 00060 // Get a new instance first 00061 $helperInstance = new ShipSimuLoginHelper(); 00062 00063 // Get a user instance from registry 00064 $userInstance = Registry::getRegistry()->getInstance('user'); 00065 00066 // Is this instance valid? 00067 if (!$userInstance instanceof ManageableAccount) { 00068 // Thrown an exception here 00069 throw new UserInstanceMissingException (array($helperInstance, 'user'), self::EXCEPTION_INVALID_USER_INSTANCE); 00070 } // END - if 00071 00072 // Set default login method from config 00073 $helperInstance->setDefaultAuthMethod(); 00074 00075 // Set request instance 00076 $helperInstance->setRequestInstance($requestInstance); 00077 00078 // Return the prepared instance 00079 return $helperInstance; 00080 } 00081 00087 protected function setDefaultAuthMethod () { 00088 $this->authMethod = $this->getConfigInstance()->readConfig('auth_method_class'); 00089 } 00090 00098 public function executeLogin (Responseable $responseInstance) { 00099 // Get an instance from the login method 00100 $loginInstance = ObjectFactory::createObjectByName($this->authMethod, array($responseInstance)); 00101 00102 // Set user cookie 00103 $loginInstance->setUserAuth($this->getRequestInstance()->getRequestElement('username')); 00104 00105 // Set password cookie 00106 $loginInstance->setPasswordAuth($this->getRequestInstance()->getRequestElement('pass_hash')); 00107 00108 // Remember this login instance for later usage 00109 Registry::getRegistry()->addInstance('login', $loginInstance); 00110 } 00111 } 00112 00113 // 00114 ?>
1.5.6