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


PHP phpCAS::getAttributes方法代码示例

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


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

示例1: __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

示例2: getAttributes

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

示例3: loginCallback

 public function loginCallback()
 {
     $attributes = phpCAS::getAttributes();
     $this->updateLocalUserFromBackend($attributes);
     $usr_id = User::getUserIDByEmail($attributes['mail'], true);
     $user = User::getDetails($usr_id);
     Auth::createLoginCookie(APP_COOKIE, $user['usr_email'], true);
 }
开发者ID:korusdipl,项目名称:eventum,代码行数:8,代码来源:class.cas_auth_backend.php

示例4: modelAttributes

 public static function modelAttributes()
 {
     $userInfo = array_combine(array('username', 'email', 'user_id'), explode('|', \phpCAS::getUser()));
     $casInfo = array_change_key_case(array_map('urldecode', \phpCAS::getAttributes()), CASE_LOWER);
     $casInfo['realname'] = $casInfo['username'];
     unset($casInfo['useraccountcontrol'], $casInfo['usernum'], $casInfo['useremail']);
     $return = array_merge($casInfo, $userInfo);
     return $return;
 }
开发者ID:oyoy8629,项目名称:yii-core,代码行数:9,代码来源:phpCas.php

示例5: user

 /**
  *  Return user details, if the user is logged in.
  */
 public function user()
 {
     if (phpCAS::isAuthenticated()) {
         $userlogin = phpCAS::getUser();
         $attributes = phpCAS::getAttributes();
         return (object) array('userlogin' => $userlogin, 'attributes' => $attributes);
     } else {
         show_error("User was not authenticated yet.");
     }
 }
开发者ID:hharchani,项目名称:mail-merge-portal,代码行数:13,代码来源:Cas.php

示例6: post_login

 public static function post_login($parameters)
 {
     $uid = $parameters['uid'];
     $casBackend = OC_USER_CAS::getInstance();
     $userDatabase = new \OC\User\Database();
     if (phpCAS::isAuthenticated()) {
         // $cas_attributes may vary in name, therefore attributes are fetched to $attributes
         $cas_attributes = phpCAS::getAttributes();
         $cas_uid = phpCAS::getUser();
         // parameters
         $attributes = array();
         if ($cas_uid == $uid) {
             \OCP\Util::writeLog('cas', 'attr  \\"' . implode(',', $cas_attributes) . '\\" for the user: ' . $uid, \OCP\Util::DEBUG);
             if (array_key_exists($casBackend->displayNameMapping, $cas_attributes)) {
                 $attributes['cas_name'] = $cas_attributes[$casBackend->displayNameMapping];
             } else {
                 $attributes['cas_name'] = $cas_attributes['cn'];
             }
             if (array_key_exists($casBackend->mailMapping, $cas_attributes)) {
                 $attributes['cas_email'] = $cas_attributes[$casBackend->mailMapping];
             } else {
                 $attributes['cas_email'] = $cas_attributes['mail'];
             }
             if (array_key_exists($casBackend->groupMapping, $cas_attributes)) {
                 $attributes['cas_groups'] = $cas_attributes[$casBackend->groupMapping];
             } else {
                 if (!empty($casBackend->defaultGroup)) {
                     $attributes['cas_groups'] = array($casBackend->defaultGroup);
                     \OCP\Util::writeLog('cas', 'Using default group "' . $casBackend->defaultGroup . '" for the user: ' . $uid, \OCP\Util::DEBUG);
                 }
             }
             if (!$userDatabase->userExists($uid) && $casBackend->autocreate) {
                 // create users if they do not exist
                 if (preg_match('/[^a-zA-Z0-9 _\\.@\\-]/', $uid)) {
                     \OCP\Util::writeLog('cas', 'Invalid username "' . $uid . '", allowed chars "a-zA-Z0-9" and "_.@-" ', \OCP\Util::DEBUG);
                     return false;
                 } else {
                     $random_password = \OCP\Util::generateRandomBytes(20);
                     \OCP\Util::writeLog('cas', 'Creating new user: ' . $uid, \OCP\Util::DEBUG);
                     $userDatabase->createUser($uid, $random_password);
                     // after creating the user, fill the attributes
                     if ($userDatabase->userExists($uid)) {
                         OC_USER_CAS_Hooks::update_user($uid, $attributes);
                     }
                 }
             }
             // try to update user attributes
             if ($casBackend->updateUserData) {
                 OC_USER_CAS_Hooks::update_user($cas_uid, $attributes);
             }
             return true;
         }
     }
     return false;
 }
开发者ID:felixrupp,项目名称:user_cas,代码行数:55,代码来源:hooks.php

示例7: sso

 public static function sso($action = 'login')
 {
     include_once ROOT_PATH . 'lib/cas/CAS.php';
     include_once ROOT_PATH . 'config/cas.php';
     $client = '';
     // error_reporting(E_ALL);
     // ini_set("display_errors", 1);
     $cas_host = CAS_HOST;
     $cas_port = intval(CAS_PORT);
     $cas_context = CAS_CONTEXT;
     $phpCAS = new \phpCAS();
     // $phpCAS->setDebug();
     $phpCAS->client(CAS_VERSION_2_0, $cas_host, $cas_port, $cas_context);
     $phpCAS->setNoCasServerValidation();
     $phpCAS->handleLogoutRequests();
     $phpCAS->forceAuthentication();
     if (isset($action) && $action == 'logout') {
         $phpCAS->logout();
     }
     $client = $phpCAS->getAttributes();
     return $client;
 }
开发者ID:hellocc2,项目名称:crmht,代码行数:22,代码来源:CheckLogin.php

示例8: cas_authenticate

 * ======================================================================== */


/*
 *  	Authors:	Giannis Kapetanakis <bilias@edu.physics.uoc.gr>
 */

require_once '../../include/baseTheme.php';
require_once 'include/CAS/CAS.php';
require_once 'modules/auth/auth.inc.php';

$auth = 7;
cas_authenticate($auth);
if (phpCAS::checkAuthentication()) {
    $cas = get_auth_settings($auth);
    $_SESSION['cas_attributes'] = phpCAS::getAttributes();
    $attrs = get_cas_attrs($_SESSION['cas_attributes'], $cas);
    $_SESSION['cas_uname'] = phpCAS::getUser();

    if (!empty($_SESSION['cas_uname'])) {
        $_SESSION['uname'] = $_SESSION['cas_uname'];
    }
    if (!empty($attrs['casuserlastattr'])) {
        $_SESSION['cas_surname'] = $attrs['casuserlastattr'];
    }
    if (!empty($attrs['casuserfirstattr'])) {
        $_SESSION['cas_givenname'] = $attrs['casuserfirstattr'];
    }
    if (!empty($attrs['casusermailattr'])) {
        $_SESSION['cas_email'] = $attrs['casusermailattr'];
    }
开发者ID:nikosv,项目名称:openeclass,代码行数:31,代码来源:cas.php

示例9: bindtextdomain

    $theme = $default_theme;
}
bindtextdomain('nixtape', $install_path . '/themes/' . $theme . '/locale/');
textdomain('nixtape');
$smarty = new Smarty();
$smarty->setTemplateDir(array($install_path . '/themes/' . $theme . '/templates/', $install_path . '/themes/thelist/templates/'));
$smarty->setPluginsDir(array(SMARTY_DIR . '/plugins/', $install_path . '/themes/' . $theme . '/plugins/', $install_path . '/themes/thelist/plugins/'));
$smarty->setCompileDir($install_path . '/themes/' . $theme . '/templates_c/');
$smarty->setCacheDir($install_path . '/cache/');
$smarty->setConfigDir(array($install_path . '/themes/' . $theme . '/config/', $install_path . '/themes/thelist/config/'));
$current_lang = preg_replace('/.UTF-8/', '', $current_lang);
$smarty->assign('casauth', $auth);
if ($auth) {
    $casuid = phpCAS::getUser();
    $smarty->assign('userid', phpCAS::getUser());
    $attr = phpCAS::getAttributes();
    $nickname = $attr['nickname'];
    $smarty->assign('handle', $nickname);
    $user = new User($casuid);
    $userid = $user->id;
    $makerid = $user->makerid;
    $smarty->assign('makerid', $makerid);
}
$smarty->assign('lang_selector_array', array($current_lang => 1));
$smarty->assign('base_url', $base_url);
$smarty->assign('default_theme', $default_theme);
$smarty->assign('site_name', $site_name);
$smarty->assign('img_url', $base_url . '/themes/' . $theme . '/img/');
$smarty->assign('this_page', $_SERVER['REQUEST_URI']);
$smarty->assign('this_page_absolute', (empty($_SERVER['HTTPS']) ? 'http://' : 'http://') . (empty($_SERVER['HOST']) ? $_SERVER['SERVER_NAME'] : $_SERVER['HOST']) . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT']) . $_SERVER['REQUEST_URI']);
if (isset($logged_in) && $logged_in) {
开发者ID:tom2320x,项目名称:list,代码行数:31,代码来源:templating.php

示例10: foreach

  <body>
<h2>Advanced SAML 1.1 example</h2>
<?php 
require 'script_info.php';
?>

Authentication succeeded for user
<strong><?php 
echo phpCAS::getUser();
?>
</strong>.

<h3>User Attributes</h3>
<ul>
<?php 
foreach (phpCAS::getAttributes() as $key => $value) {
    if (is_array($value)) {
        echo '<li>', $key, ':<ol>';
        foreach ($value as $item) {
            echo '<li><strong>', $item, '</strong></li>';
        }
        echo '</ol></li>';
    } else {
        echo '<li>', $key, ': <strong>', $value, '</strong></li>' . PHP_EOL;
    }
}
?>
</ul>
<p><a href="?logout=">Logout</a></p>
</body>
</html>
开发者ID:jundialwan,项目名称:oprecristek2016,代码行数:31,代码来源:example_hardening.php

示例11: print_r

// logout if desired
if (isset($_REQUEST['logout'])) {
    \phpCAS::logout(array('service' => 'http://www.testlogin1.my/login.php'));
}
// for this test, simply print that the authentication was successfull
?>
<html>
  <head>
    <title>www.testlogin1.my</title>
  </head>
  <body>
    <h1>Successfull Authentication!</h1>
    <?php 
require 'script_info.php';
?>
    <p>the user's login is <b><?php 
echo \phpCAS::getUser();
?>
</b>.</p>
    <p>phpCAS version is <b><?php 
echo \phpCAS::getVersion();
?>
</b>.</p>
    <p>the user's attributes is <b><?php 
print_r(\phpCAS::getAttributes());
?>
</b></p>
    <p><a href="?logout=1">Logout</a></p>
  </body>
</html>
<?php 
开发者ID:jifangshiyanshi,项目名称:tuonews,代码行数:31,代码来源:index.php

示例12: draw

         draw($tool_content, 0);
         exit;
     } else {
         // try to authenticate user
         $auth_method_settings = get_auth_settings($auth);
         if ($auth == 6) {
             redirect_to_home_page('secure/index_reg.php' . ($prof ? '?p=1' : ''));
         }
         $is_valid = auth_user_login($auth, $uname, $passwd, $auth_method_settings);
     }
     if ($auth == 7) {
         if (phpCAS::checkAuthentication()) {
             $uname = phpCAS::getUser();
             $cas = get_auth_settings($auth);
             // store CAS released attributes in $GLOBALS['auth_user_info']
             get_cas_attrs(phpCAS::getAttributes(), $cas);
             if (!empty($uname)) {
                 $is_valid = true;
             }
         }
     }
 }
 if ($is_valid) {
     // connection successful
     $_SESSION['was_validated'] = array('auth' => $auth, 'uname' => $uname, 'uname_exists' => user_exists($uname));
     if (isset($GLOBALS['auth_user_info'])) {
         $_SESSION['was_validated']['auth_user_info'] = $GLOBALS['auth_user_info'];
     }
 } else {
     $tool_content .= "<div class='alert alert-danger'>{$langConnNo}<br>{$langAuthNoValidUser}</div>" . "<p>&laquo; <a href='{$lastpage}'>{$langBack}</a></p>";
 }
开发者ID:kostastzo,项目名称:openeclass,代码行数:31,代码来源:altsearch.php

示例13: getUser

 public function getUser(CakeRequest $request)
 {
     phpCAS::handleLogoutRequests(false);
     phpCAS::forceAuthentication();
     return array_merge(array('username' => phpCAS::getUser()), phpCAS::getAttributes());
 }
开发者ID:byu-oit-appdev,项目名称:eamWS,代码行数:6,代码来源:CasAuthenticate.php

示例14: buildsurveysession

function buildsurveysession($surveyid, $preview = false)
{
    global $hitid, $hitname;
    Yii::trace('start', 'survey.buildsurveysession');
    global $secerror, $clienttoken;
    global $tokensexist;
    //global $surveyid;
    global $move, $rooturl;
    $sLangCode = App()->language;
    $languagechanger = makeLanguageChangerSurvey($sLangCode);
    if (!$preview) {
        $preview = Yii::app()->getConfig('previewmode');
    }
    $thissurvey = getSurveyInfo($surveyid, $sLangCode);
    $_SESSION['survey_' . $surveyid]['templatename'] = $thissurvey['template'];
    // $thissurvey['template'] already fixed by model : but why put this in session ?
    $_SESSION['survey_' . $surveyid]['templatepath'] = getTemplatePath($thissurvey['template']) . DIRECTORY_SEPARATOR;
    $sTemplatePath = $_SESSION['survey_' . $surveyid]['templatepath'];
    $loadsecurity = returnGlobal('loadsecurity', true);
    // NO TOKEN REQUIRED BUT CAPTCHA ENABLED FOR SURVEY ACCESS
    if ($tokensexist == 0 && isCaptchaEnabled('surveyaccessscreen', $thissurvey['usecaptcha']) && !isset($_SESSION['survey_' . $surveyid]['captcha_surveyaccessscreen']) && !$preview) {
        //session_start();
        require_once dirname(__FILE__) . "/CAS/CAS.php";
        //指定log文件
        phpCAS::setDebug('./log.log');
        //指定cas地址,最后一个true表示是否cas服务器为https
        phpCAS::client(CAS_VERSION_2_0, 'ids.hit.edu.cn', 443, 'authserver', true);
        phpCAS::handleLogoutRequests();
        //本地退出应该重定向到CAS进行退出,传递service参数可以使CAS退出后返回本应用
        //demo表示退出请求为logout的请求
        if (isset($_GET['logout'])) {
            $param = array('service' => 'http://demo.cas.wisedu.cn:3273/');
            phpCAS::logout($param);
            exit;
        }
        //设置no ssl,即忽略证书检查.如果需要ssl,请用 phpCAS::setCasServerCACert()设置
        //setCasServerCACert方法设置ssl证书,
        phpCAS::setNoCasServerValidation();
        phpCAS::forceAuthentication();
        $hitid = phpCAS::getUser();
        $hitname = phpCAS::getAttributes()["cn"];
        /*//默认的就是这种状况
                // IF CAPTCHA ANSWER IS NOT CORRECT OR NOT SET
                //echo 2221;
                if (!isset($loadsecurity) ||
                !isset($_SESSION['survey_'.$surveyid]['secanswer']) ||
                $loadsecurity != $_SESSION['survey_'.$surveyid]['secanswer'])
                {
                    //echo 111;
                    sendCacheHeaders();
                    doHeader();
                    // No or bad answer to required security question
        
                    $redata = compact(array_keys(get_defined_vars()));
                    //下面一行测试注释掉,除样式没有发现其他影响
                    //echo templatereplace(file_get_contents($sTemplatePath."startpage.pstpl"),array(),$redata,'frontend_helper[875]');
                    //echo makedropdownlist();
                    echo templatereplace(file_get_contents($sTemplatePath."survey.pstpl"),array(),$redata,'frontend_helper[877]');
                    echo "我们需要对你的身份进行确认,确保你是哈尔滨工业大学师生,请点击下面的按钮进行全校统一认证登录";
                    if (isset($loadsecurity))
                    { // was a bad answer
                        echo "<font color='#FF0000'>".gT("The answer to the security question is incorrect.")."</font><br />";
                    }
        
                    echo "<p class='captcha'>".gT("Please confirm access to survey by answering the security question below and click continue.")."</p>"
                    .CHtml::form(array("/survey/index","sid"=>$surveyid), 'post', array('class'=>'captcha'))."
                    <table align='center'>
                    <tr>
                    <td align='right' valign='middle'>
                    <input type='hidden' name='sid' value='".$surveyid."' id='sid' />
                    <input type='hidden' name='lang' value='".$sLangCode."' id='lang' />";
                    // In case we this is a direct Reload previous answers URL, then add hidden fields
                    if (isset($_GET['loadall']) && isset($_GET['scid'])
                    && isset($_GET['loadname']) && isset($_GET['loadpass']))
                    {
                        echo "
                        <input type='hidden' name='loadall' value='".htmlspecialchars($_GET['loadall'],ENT_QUOTES, 'UTF-8')."' id='loadall' />
                        <input type='hidden' name='scid' value='".returnGlobal('scid',true)."' id='scid' />
                        <input type='hidden' name='loadname' value='".htmlspecialchars($_GET['loadname'],ENT_QUOTES, 'UTF-8')."' id='loadname' />
                        <input type='hidden' name='loadpass' value='".htmlspecialchars($_GET['loadpass'],ENT_QUOTES, 'UTF-8')."' id='loadpass' />";
                    }
        
                    echo "
                    </td>
                    </tr>";
                    if (function_exists("ImageCreate") && isCaptchaEnabled('surveyaccessscreen', $thissurvey['usecaptcha']))
                    {
                        echo "<tr>
                        <td align='center' valign='middle'><label for='captcha'>".gT("Security question:")."</label></td><td align='left' valign='middle'><table><tr><td valign='middle'><img src='".Yii::app()->getController()->createUrl('/verification/image/sid/'.$surveyid)."' alt='captcha' /></td>
                        <td valign='middle'><input id='captcha' type='text' size='5' maxlength='3' name='loadsecurity' value='' /></td></tr></table>
                        </td>
                        </tr>";
                    }
                    echo "<tr><td colspan='2' align='center'><input class='submit' type='submit' value='".gT("Continue")."' /></td></tr>
                    </table>
                    </form>";
        
                    echo templatereplace(file_get_contents($sTemplatePath."endpage.pstpl"),array(),$redata,'frontend_helper[1567]');
                    doFooter();
                    exit;
//.........这里部分代码省略.........
开发者ID:withhope,项目名称:HIT-Survey,代码行数:101,代码来源:frontend_helper.php

示例15: authenticate_cas

	private function authenticate_cas() {
/* *****
 *  Toute la partie authentification en elle-même a été déplacée dans le
 *  fichier login_sso.php, afin de permettre à phpCAS de gérer tout seul
 *  la session PHP.
 * *****
 * 
		include_once('CAS.php');
		if ($GLOBALS['mode_debug']) {
		    phpCAS::setDebug($GLOBALS['debug_log_file']);
    }
		// config_cas.inc.php est le fichier d'informations de connexions au serveur cas
		$path = dirname(__FILE__)."/../secure/config_cas.inc.php";
		include($path);

		# On défini l'URL de base, pour que phpCAS ne se trompe pas dans la génération
		# de l'adresse de retour vers le service (attention, requiert patchage manuel
		# de phpCAS !!)
		if (isset($GLOBALS['gepiBaseUrl'])) {
			$url_base = $GLOBALS['gepiBaseUrl'];
		} else {
			$url_base = $this->https_request() ? 'https' : 'http';
			$url_base .= '://';
			$url_base .= $_SERVER['SERVER_NAME'];
		}

		// Le premier argument est la version du protocole CAS
		// Le dernier argument a été ajouté par patch manuel de phpCAS.
		phpCAS::client(CAS_VERSION_2_0, $cas_host, $cas_port, $cas_root, false, $url_base);
		phpCAS::setLang('french');

		// redirige vers le serveur d'authentification si aucun utilisateur authentifié n'a
		// été trouvé par le client CAS.
		phpCAS::setNoCasServerValidation();

		// Gestion du single sign-out
		phpCAS::handleLogoutRequests(false);
		
		// Authentification
		phpCAS::forceAuthentication();
*/
if (getSettingValue("sso_cas_table") == 'yes') {
            $this->login_sso = phpCAS::getUser();
            $test = $this->test_loginsso();
            if ($test == '0') {
                //la correspondance n'existe pas dans gépi; on detruit la session avant de rediriger.            
                session_destroy();
                header("Location:login_failure.php?error=11&mode=sso_table");
                exit;
            } else {
                $this->login = $test;
            }
        } else {
            $this->login = phpCAS::getUser();
        }
		
/* La session est gérée par phpCAS directement, en amont. On n'y touche plus.
		session_name("GEPI");
		session_start();
*/
		$_SESSION['login'] = $this->login;

		$this->current_auth_mode = "sso";
    
    // Extractions des attributs supplémentaires, le cas échéant
    $tab = phpCAS::getAttributes();
    $attributs = array('prenom','nom','email');
    foreach($attributs as $attribut) {
      $code_attribut = getSettingValue('cas_attribut_'.$attribut);
      // Si un attribut a été spécifié, on va le chercher
      if (!empty($code_attribut)) {
      	if (isset($tab[$code_attribut])) {
        	$valeur = $tab[$code_attribut];
					if (!empty($valeur)){
					    // L'attribut est trouvé et non vide, on l'assigne pour mettre à jour l'utilisateur
						// On s'assure que la chaîne est bien enregistrée en UTF-8.
						$valeur = ensure_utf8($valeur);
						$this->cas_extra_attributes[$attribut] = trim(mysqli_real_escape_string($GLOBALS["mysqli"], $valeur));
					}
        }
      }
    }
		return true;
	}
开发者ID:rhertzog,项目名称:lcs,代码行数:84,代码来源:Session.class.php


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