Ejemplo n.º 1
0
 /**
  * Fetches authentication adapter from authentication.conf,
  * loads the corresponding class if it exists and sets
  * AuthenticationManager::$g_authentication_adapter accordingly.
  *
  * @throws AuthClassDoesNotExistException
  */
 public static function init()
 {
     if (strlen(self::$g_authentication_adapter) == 0 || !class_exists(self::$g_authentication_adapter)) {
         $o_app_conf = Configuration::load();
         $o_auth_config = Configuration::load($o_app_conf->get('authentication_config'));
         $vs_auth_adapter = $o_auth_config->get('auth_adapter');
         if (file_exists(__CA_LIB_DIR__ . "/core/Auth/Adapters/{$vs_auth_adapter}.php")) {
             @(require_once __CA_LIB_DIR__ . "/core/Auth/Adapters/{$vs_auth_adapter}.php");
             if (class_exists($vs_auth_adapter . 'AuthAdapter')) {
                 self::$g_authentication_adapter = $vs_auth_adapter . 'AuthAdapter';
                 return;
             }
         }
         throw new AuthClassDoesNotExistException();
     }
 }
Ejemplo n.º 2
0
 /**
  * Get user info from back-end
  *
  * @param string $ps_username
  * @param string $ps_password
  * @return array
  */
 public static function getUserInfo($ps_username, $ps_password)
 {
     self::init();
     if ($vn_rc = call_user_func(self::$g_authentication_adapter . '::getUserInfo', $ps_username, $ps_password)) {
         return $vn_rc;
     } elseif (self::$g_authentication_adapter !== 'CaUsers') {
         // fall back to ca_users "native" authentication
         self::init('CaUsers');
         $vn_rc = call_user_func(self::$g_authentication_adapter . '::getUserInfo', $ps_username, $ps_password, $pa_options);
         self::$g_authentication_adapter = null;
         return $vn_rc;
     }
 }
 /**
  * Get user info from back-end
  *
  * @param string $ps_username
  * @param string $ps_password
  * @return array
  */
 public static function getUserInfo($ps_username, $ps_password)
 {
     self::init();
     if ($vn_rc = self::$g_authentication_adapter->getUserInfo($ps_username, $ps_password)) {
         return $vn_rc;
     }
     if (!self::$g_authentication_adapter instanceof CaUsersAuthAdapter) {
         // fall back to ca_users "native" authentication
         self::init('CaUsers');
         $vn_rc = self::$g_authentication_adapter->getUserInfo($ps_username, $ps_password);
         self::$g_authentication_adapter = null;
         return $vn_rc;
     }
     return null;
 }