当前位置: 首页>>代码示例>>PHP>>正文


PHP phpCAS::getUser方法代码示例

本文整理汇总了PHP中phpCAS::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP phpCAS::getUser方法的具体用法?PHP phpCAS::getUser怎么用?PHP phpCAS::getUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在phpCAS的用法示例。


在下文中一共展示了phpCAS::getUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 public function execute($filterChain)
 {
     $user = $this->getContext()->getUser();
     // We put an LDAP object in the context in order to reuse it later
     $this->getContext()->set('ldap', new uapvLdap());
     // Filters can be called several times (because of internal forwards)
     // Authentication is only done the first time
     if ($this->isFirstCall() && (sfConfig::get('app_cas_server_force_authentication', false) || !$user->isAuthenticated())) {
         // phpCAS is not php5-compliant, we remove php warnings and strict errors
         $errorReporting = ini_get('error_reporting');
         error_reporting($errorReporting & ~E_STRICT & ~E_NOTICE);
         if (sfConfig::get('app_cas_server_debug', false)) {
             phpCAS::setDebug();
         }
         // see /tmp/phpCAS.log
         phpCAS::client(sfConfig::get('app_cas_server_version', CAS_VERSION_2_0), sfConfig::get('app_cas_server_host', 'localhost'), sfConfig::get('app_cas_server_port', 443), sfConfig::get('app_cas_server_path', ''), false);
         // Don't call session_start again,
         // symfony already did it
         //phpCAS::handleLogoutRequests ();
         phpCAS::setNoCasServerValidation();
         phpCAS::forceAuthentication();
         // if necessary the user will be
         // redirected to the cas server
         // At this point the user is authenticated, we log him in
         $user->signIn(phpCAS::getUser());
         // Previous settings can now be restored
         error_reporting($errorReporting);
     }
     // "credential" verification
     parent::execute($filterChain);
 }
开发者ID:ArnaudD,项目名称:RdvZ,代码行数:31,代码来源:uapvSecurityFilterCas.class.php

示例2: checkAndSetUserSession

function checkAndSetUserSession()
{
    // store session data
    if (!isset($_SESSION['user'])) {
        $_SESSION['user'] = null;
    }
    if (isset($_REQUEST['login']) or isset($_REQUEST['logout'])) {
        // initialize phpCAS
        phpCAS::client(CAS_VERSION_2_0, 'login.kth.se', 443, '');
        //phpCAS::proxy(CAS_VERSION_2_0,'login.kth.se',443,'');
        phpCAS::setNoCasServerValidation();
        // If you want the redirect back from the login server to enter your application by some
        // specfic URL rather than just back to the current request URI, call setFixedCallbackURL.
        //phpCAS::setFixedCallbackURL('http://xml.csc.kth.se/~wiiala/DM2517/project/php/index.php');
        // force CAS authentication
        phpCAS::forceAuthentication();
        // at this step, the user has been authenticated by the CAS server
        // and the user's login name can be read with phpCAS::getUser().
        $_SESSION['user'] = phpCAS::getUser();
        //Logga ut och redirecta till vår standardsida
        if (isset($_REQUEST['logout'])) {
            unset($_SESSION['user']);
            phpCAS::logoutWithRedirectService('http://kth.kribba.com/');
        }
    }
}
开发者ID:guuurris,项目名称:skolprojektOchLabbar,代码行数:26,代码来源:index.php

示例3: getUser

 function getUser()
 {
     if (phpCAS::isAuthenticated()) {
         return phpCAS::getUser();
     }
     return null;
 }
开发者ID:hharchani,项目名称:felicity16-website,代码行数:7,代码来源:cas_lib.php

示例4: get_login

 public function get_login()
 {
     Logger::debug('main', 'AuthMethod_CAS::get_login()');
     if (!isset($_SESSION['backup_sso']) || !is_array($_SESSION['backup_sso'])) {
         $_SESSION['backup_sso'] = array();
     }
     foreach ($_REQUEST as $k => $v) {
         $_SESSION['backup_sso'][$k] = $v;
     }
     $buf = $this->prefs->get('AuthMethod', 'CAS');
     $CAS_server_url = $buf['user_authenticate_cas_server_url'];
     if (!isset($CAS_server_url) || $CAS_server_url == '') {
         Logger::error('main', 'AuthMethod_CAS::get_login() - Unable to find CAS server url in Preferences');
         return NULL;
     }
     phpCAS::client(CAS_VERSION_2_0, parse_url($CAS_server_url, PHP_URL_HOST), parse_url($CAS_server_url, PHP_URL_PORT), parse_url($CAS_server_url, PHP_URL_PATH));
     Logger::debug('main', 'AuthMethod_CAS::get_login() - Parsing URL - Host:"' . parse_url($CAS_server_url, PHP_URL_HOST) . '" Port:"' . parse_url($CAS_server_url, PHP_URL_PORT) . '" Path:"' . parse_url($CAS_server_url, PHP_URL_PATH) . '"');
     phpCAS::setNoCasServerValidation();
     if (!phpCAS::forceAuthentication()) {
         Logger::error('main', 'AuthMethod_CAS::get_login() - phpCAS::forceAuthentication failed');
         return NULL;
     }
     if (!phpCAS::isAuthenticated()) {
         Logger::error('main', 'AuthMethod_CAS::get_login() - phpCAS::isAuthenticated failed');
         return NULL;
     }
     $this->login = phpCAS::getUser();
     foreach ($_SESSION['backup_sso'] as $k => $v) {
         if (isset($_REQUEST[$k])) {
             continue;
         }
         $_REQUEST[$k] = $v;
     }
     return $this->login;
 }
开发者ID:skdong,项目名称:nfs-ovd,代码行数:35,代码来源:CAS.php

示例5: processLogin

 public function processLogin()
 {
     include_once COPIX_UTILS_PATH . '../../CAS-1.2.2/CAS.php';
     $_SESSION['chartValid'] = false;
     $ppo = new CopixPPO();
     $ppo->user = _currentUser();
     if ($ppo->user->isConnected()) {
         $url_return = CopixUrl::get('kernel||doSelectHome');
         /*
          * PATCH FOR CHARTE
          */
         $this->user->forceReload();
         if (!$this->service('charte|CharteService')->checkUserValidation()) {
             $this->flash->redirect = $url_return;
             return $this->go('charte|charte|valid');
         }
         return _arRedirect($url_return);
         //return new CopixActionReturn (COPIX_AR_REDIRECT, $url_return);
     } else {
         $conf_Cas_host = CopixConfig::get('default|conf_Cas_host');
         $conf_Cas_port = CopixConfig::get('default|conf_Cas_port');
         $conf_Cas_path = CopixConfig::get('default|conf_Cas_path');
         phpCAS::client(CAS_VERSION_2_0, $conf_Cas_host, (int) $conf_Cas_port, $conf_Cas_path, false);
         phpCAS::setNoCasServerValidation();
         phpCAS::forceAuthentication();
         $ppo->cas_user = phpCAS::getUser();
         if ($ppo->cas_user) {
             $ppo->iconito_user = Kernel::getUserInfo("LOGIN", $ppo->cas_user);
             if ($ppo->iconito_user['login']) {
                 _currentUser()->login(array('login' => $ppo->iconito_user['login'], 'assistance' => true));
                 $url_return = CopixUrl::get('kernel||doSelectHome');
                 // $url_return = CopixUrl::get ('assistance||users');
                 $this->user->forceReload();
                 if (!$this->service('charte|CharteService')->checkUserValidation()) {
                     $this->flash->redirect = $url_return;
                     return $this->go('charte|charte|valid');
                 }
                 return new CopixActionReturn(COPIX_AR_REDIRECT, $url_return);
             } else {
                 $ppo->cas_error = 'no-iconito-user';
                 return _arPpo($ppo, 'cas.tpl');
             }
         }
     }
     $ppo = new CopixPPO();
     $ppo->TITLE_PAGE = $pTitle;
     phpCAS::setDebug();
     $conf_Cas_host = CopixConfig::get('default|conf_Cas_host');
     $conf_Cas_port = CopixConfig::get('default|conf_Cas_port');
     $conf_Cas_path = CopixConfig::get('default|conf_Cas_path');
     phpCAS::client(CAS_VERSION_2_0, $conf_Cas_host, (int) $conf_Cas_port, $conf_Cas_path, false);
     phpCAS::setNoCasServerValidation();
     phpCAS::forceAuthentication();
     if (isset($_REQUEST['logout'])) {
         phpCAS::logout();
     }
     die(phpCAS::getUser());
     die('ok');
     return _arPpo($ppo, 'handlers.list.tpl');
 }
开发者ID:JVS-IS,项目名称:ICONITO-EcoleNumerique,代码行数:60,代码来源:cas.actiongroup.php

示例6: __construct

 public function __construct()
 {
     $this->attr = phpCAS::getAttributes();
     $this->attr['username'] = phpCAS::getUser();
     $this->id = $this->attr['user_id'];
     unset($this->attr['sequence_token']);
 }
开发者ID:nitroxy,项目名称:nxauth,代码行数:7,代码来源:NXUser.php

示例7: metodillo

 function metodillo()
 {
     $sSQL = "SELECT * FROM PM_PARAMETERS WHERE PRM_ID = 'CAS_URL' ";
     $aResSQL = executeQuery($sSQL);
     if (count($aResSQL)) {
         $sURL = $aResSQL[1]['PRM_VALUE'];
         $sURI = $aResSQL[1]['PRM_VALUE_2'];
         $res = false;
         $RBAC = RBAC::getSingleton();
         $RBAC->initRBAC();
         require_once 'CAS-1.2.2/CAS.php';
         phpCAS::client(CAS_VERSION_2_0, $sURL, 443, $sURI, false);
         phpCAS::setNoCasServerValidation();
         phpCAS::forceAuthentication();
         if (phpCAS::isAuthenticated() == true) {
             $sCasUser = phpCAS::getUser();
             $sSQL = "SELECT USR_UID FROM USERS WHERE USR_USERNAME = '{$sCasUser}' ";
             $aResSQL = executeQuery($sSQL);
             if (count($aResSQL)) {
                 $nUserId = $aResSQL[1]['USR_UID'];
                 $RBAC->singleSignOn = true;
                 $RBAC->userObj->fields['USR_UID'] = $nUserId;
                 $RBAC->userObj->fields['USR_USERNAME'] = $sCasUser;
                 $res = true;
             } else {
                 $res = false;
             }
         } else {
             $res = false;
         }
     } else {
         $res = false;
     }
     return $res;
 }
开发者ID:juantroche,项目名称:pmos-cas,代码行数:35,代码来源:class.cas2.php

示例8: beforeLogin

 public function beforeLogin()
 {
     // configure phpCAS
     $cas_host = $this->get('casAuthServer');
     $cas_context = $this->get('casAuthUri');
     $cas_port = (int) $this->get('casAuthPort');
     // import phpCAS lib
     $basedir = dirname(__FILE__);
     Yii::setPathOfAlias('myplugin', $basedir);
     Yii::import('myplugin.third_party.CAS.*');
     require_once 'third_party/CAS/CAS.php';
     // Initialize phpCAS
     phpCAS::client(CAS_VERSION_2_0, $cas_host, $cas_port, $cas_context, false);
     // disable SSL validation of the CAS server
     phpCAS::setNoCasServerValidation();
     //force CAS authentication
     phpCAS::forceAuthentication();
     $this->setUsername(phpCAS::getUser());
     $oUser = $this->api->getUserByName($this->getUserName());
     if ($oUser || $this->get('autoCreate')) {
         // User authenticated and found. Cas become the authentication system
         $this->getEvent()->set('default', get_class($this));
         $this->setAuthPlugin();
         // This plugin handles authentication, halt further execution of auth plugins
     } elseif ($this->get('is_default', null, null)) {
         // Fall back to another authentication mecanism
         throw new CHttpException(401, 'Wrong credentials for LimeSurvey administration.');
     }
 }
开发者ID:withhope,项目名称:HIT-Survey,代码行数:29,代码来源:AuthCAS.php

示例9: index

 /**
  * Attempts to authenticate users via CAS
  */
 public function index()
 {
     // If they don't have CAS configured, send them onto the application's
     // internal authentication system
     if (!defined('CAS')) {
         header('Location: ' . BASE_URL . '/login/login?return_url=' . $this->return_url);
         exit;
     }
     require_once CAS . '/CAS.php';
     \phpCAS::client(CAS_VERSION_2_0, CAS_SERVER, 443, CAS_URI, false);
     \phpCAS::setNoCasServerValidation();
     \phpCAS::forceAuthentication();
     // at this step, the user has been authenticated by the CAS server
     // and the user's login name can be read with phpCAS::getUser().
     // They may be authenticated according to CAS,
     // but that doesn't mean they have person record
     // and even if they have a person record, they may not
     // have a user account for that person record.
     try {
         $_SESSION['USER'] = new Person(\phpCAS::getUser());
         header("Location: {$this->return_url}");
         exit;
     } catch (\Exception $e) {
         $_SESSION['errorMessages'][] = $e;
     }
     $this->template->blocks[] = new Block('loginForm.inc', array('return_url' => $this->return_url));
 }
开发者ID:CodeForEindhoven,项目名称:uReport,代码行数:30,代码来源:LoginController.php

示例10: startup

 /** 
  * Main execution method.  Initializes CAS client and force authentication if required before passing user to parent startup method.
  * 
  * @param object $controller A reference to the instantiating controller object 
  * @return boolean 
  * @access public 
  */
 function startup(&$controller)
 {
     // CAS authentication required if user is not logged in
     //debug($controller);exit;
     //if (!$this->user()) {
     if (!isset($this->request->query['ticket'])) {
         // Set debug mode
         phpCAS::setDebug(false);
         //if(!empty(phpCAS::getUser()))
         //    debug($this);
         //Initialize phpCAS
         //debug(isset($this->request->query['ticket']));
         phpCAS::client(CAS_VERSION_2_0, Configure::read('CAS.hostname'), Configure::read('CAS.port'), Configure::read('CAS.uri'));
         // No SSL validation for the CAS server
         phpCAS::setNoCasServerValidation();
         // Force CAS authentication if required
         phpCAS::forceAuthentication();
         //debug();exit;
         $model =& $this->getModel();
         $controller->data[$model->alias][$this->fields['username']] = phpCAS::getUser();
         $controller->data[$model->alias][$this->fields['password']] = 'a';
         //$this->User->['username']=phpCAS::getUser();
         //$this->User->['password']='a';
     }
     return parent::startup($controller);
     //$this->redirect(array('controller'=>'User','action'=>'login'));
 }
开发者ID:rajankz,项目名称:webspace,代码行数:34,代码来源:CasAuthComponent+copy.php

示例11: __construct

 public function __construct()
 {
     \phpCAS::setDebug();
     \phpCAS::client(CAS_VERSION_2_0, "itebeta.baidu.com", 443, "");
     \phpCAS::setNoCasServerValidation();
     \phpCAS::forceAuthentication();
     $this->username = \phpCAS::getUser();
 }
开发者ID:sayi21cn,项目名称:Atomu,代码行数:8,代码来源:Uuap.class.php

示例12: checkPassword

 public function checkPassword($uid, $password)
 {
     if (!phpCAS::isAuthenticated()) {
         return false;
     }
     $uid = phpCAS::getUser();
     return $uid;
 }
开发者ID:anolisti,项目名称:apps,代码行数:8,代码来源:user_cas.php

示例13: collect

 /**
  * Collect any tokens that the user may have supplied. Reply NULL if none
  * are found.
  * 
  * @return mixed
  * @access public
  * @since 3/16/05
  */
 function collect()
 {
     if (phpCAS::isAuthenticated()) {
         return phpCAS::getUser();
     } else {
         return null;
     }
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:16,代码来源:CasTokenCollector.class.php

示例14: determineUsername

 protected function determineUsername()
 {
     $this->initializeCASClient();
     if ($this->isAuthenticated()) {
         return phpCAS::getUser();
     } else {
         return false;
     }
 }
开发者ID:asadaqain,项目名称:Guide-on-the-Side,代码行数:9,代码来源:CasAuthenticate.php

示例15: Login

 public function Login($username, $loginContext)
 {
     Log::Debug('Attempting CAS login for username: %s', $username);
     $isAuth = phpCAS::isAuthenticated();
     Log::Debug('CAS is auth ok: %s', $isAuth);
     $username = phpCAS::getUser();
     $this->Synchronize($username);
     return $this->authToDecorate->Login($username, $loginContext);
 }
开发者ID:hugutux,项目名称:booked,代码行数:9,代码来源:CAS.php


注:本文中的phpCAS::getUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。