Exemple #1
0
 public static function autodetect($mode = NULL)
 {
     $originalActivePlugin = self::$_activePlugin;
     if (self::$_supportsInternal && self::$_activePlugin) {
         $simulatedLockOn = isset($_SESSION) && array_key_exists('simulated_login_lock', $_SESSION);
         $currentSimulatedUser = array_key_exists('simulated_user', $_SESSION) ? $_SESSION['simulated_user'] : '';
         if ($simulatedLockOn) {
             $mode = self::MODE_SIMULATED;
             Saf_Kickstart::defineLoad('AUTH_SIMULATED_USER', $currentSimulatedUser);
         }
         $userToLogin = $mode == self::MODE_SIMULATED && AUTH_SIMULATED_USER ? AUTH_SIMULATED_USER : self::USER_AUTODETECT;
         if (self::_login($userToLogin) && self::$_activePlugin->auth()) {
             if (self::$_authenticated && $mode == self::MODE_SIMULATED) {
                 $_SESSION['simulated_login_lock'] = TRUE;
                 $_SESSION['simulated_user'] = AUTH_SIMULATED_USER;
             }
             return self::$_authenticated;
         }
     }
     self::init();
     $plugins = !array_key_exists('loginRealm', $_GET) || !in_array(trim($_GET['loginRealm']), self::$_loadedPlugins) ? self::$_defaultPlugins : array(trim($_GET['loginRealm']));
     foreach ($plugins as $pluginName) {
         try {
             $plugin = self::_getPlugin($pluginName);
             self::$_activePlugin = $plugin;
             if ($plugin->auth()) {
                 return self::_login($plugin->getProvidedUsername(), TRUE);
             } else {
                 self::$_activePlugin = NULL;
             }
             /*
             				$pluginClass = self::$_classMap[$pluginName];
             				$plugin = new $pluginClass();
             				self::$_activePlugin = $plugin;
             				if($plugin->auth() && self::$_authenticated) { //#TODO #2.0.0 maybe too over zealous (artifact of old methods)
             					return self::_login(self::$_userObject, TRUE);
             				} else {
             					self::$_activePlugin = NULL;
             				}
             */
         } catch (Exception $e) {
             self::$_activePlugin = NULL;
             if (Saf_Debug::isEnabled()) {
                 self::$_errorMessages[] = "Exception in auth plugin {$pluginName} : " . $e->getMessage();
             }
         }
     }
     if (count(self::$_errorMessages) > 0) {
         count(self::$_errorMessages) == 1 ? Saf_Layout::setMessage('loginError', self::$_errorMessages[0]) : Saf_Layout::setMessage('loginError', 'Multiple errors: <ul><li>' . implode('</li><li>', self::$_errorMessages) . '</li></ul>');
         if (count($plugins) > 0 && $plugins[0] == 'Local' && self::$_credentialMissmatch) {
             Saf_Layout::setMessage('passwordResetPrompt', '<a href="?cmd=resetPasswordRequest">Forgotten/Lost Password</a>?');
         }
     }
     //$usersObject = new users();
     //Rd_Registry::set('root:userInterface',$usersObject->initUser('', ''));
     //Account_Rd::init();
     if (is_null(self::$_activePlugin)) {
         self::$_activePlugin = $originalActivePlugin;
     }
     return FALSE;
 }
Exemple #2
0
 /**
  * steps to take when preparing for a Zend Framework application
  */
 protected static function _goZend()
 {
     Saf_Kickstart::defineLoad('ZEND_PATH', '');
     if (ZEND_PATH != '') {
         self::addIfNotInPath(ZEND_PATH);
     }
     if (!file_exists(ZEND_PATH . '/Zend/Application.php') && !file_exists(LIBRARY_PATH . '/Zend/Application.php') && !self::fileExistsInPath('Zend/Application.php')) {
         header('HTTP/1.0 500 Internal Server Error');
         die('Unable to find Zend Framework.');
     }
     if (!is_readable('Zend/Application.php') && !is_readable(ZEND_PATH . '/Zend/Application.php') && !is_readable(LIBRARY_PATH . '/Zend/Application.php')) {
         header('HTTP/1.0 500 Internal Server Error');
         die('Unable to access Zend Framework.');
     }
     if (file_exists(LIBRARY_PATH . '/Zend/Application.php') && is_readable(LIBRARY_PATH . '/Zend/Application.php') && !self::fileExistsInPath('Zend/Application.php')) {
         self::addIfNotInPath(LIBRARY_PATH);
     }
     require_once 'Zend/Application.php';
     self::$_controllerPath = 'controllers';
 }