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


PHP SimpleSAML_Session::getSession方法代码示例

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


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

示例1: Exception

/* Load simpleSAMLphp, configuration and metadata */
$casconfig = SimpleSAML_Configuration::getConfig('module_casserver.php');
if (!$casconfig->getValue('enable_logout', false)) {
    $message = 'Logout not allowed';
    SimpleSAML_Logger::debug('casserver:' . $message);
    throw new Exception($message);
}
$skipLogoutPage = $casconfig->getValue('skip_logout_page', false);
if ($skipLogoutPage && !array_key_exists('url', $_GET)) {
    $message = 'Required URL query parameter [url] not provided. (CAS Server)';
    SimpleSAML_Logger::debug('casserver:' . $message);
    throw new Exception($message);
}
/* Load simpleSAMLphp metadata */
$as = new SimpleSAML_Auth_Simple($casconfig->getValue('authsource'));
$session = SimpleSAML_Session::getSession();
if (!is_null($session)) {
    $ticketStoreConfig = $casconfig->getValue('ticketstore', array('class' => 'casserver:FileSystemTicketStore'));
    $ticketStoreClass = SimpleSAML_Module::resolveClass($ticketStoreConfig['class'], 'Cas_Ticket');
    $ticketStore = new $ticketStoreClass($casconfig);
    $ticketStore->deleteTicket($session->getSessionId());
}
if ($as->isAuthenticated()) {
    SimpleSAML_Logger::debug('casserver: performing a real logout');
    if ($casconfig->getValue('skip_logout_page', false)) {
        $as->logout($_GET['url']);
    } else {
        $as->logout(SimpleSAML\Utils\HTTP::addURLParameters(SimpleSAML_Module::getModuleURL('casserver/loggedOut.php'), array_key_exists('url', $_GET) ? array('url' => $_GET['url']) : array()));
    }
} else {
    SimpleSAML_Logger::debug('casserver: no session to log out of, performing redirect');
开发者ID:simplesamlphp,项目名称:simplesamlphp-module-casserver,代码行数:31,代码来源:logout.php

示例2: elseif

 *
 * @package simpleSAMLphp
 */
if (array_key_exists('RedirId', $_REQUEST)) {
    $postId = $_REQUEST['RedirId'];
    $session = SimpleSAML_Session::getSessionFromRequest();
} elseif (array_key_exists('RedirInfo', $_REQUEST)) {
    $encData = base64_decode($_REQUEST['RedirInfo']);
    if (empty($encData)) {
        throw new SimpleSAML_Error_BadRequest('Invalid RedirInfo data.');
    }
    list($sessionId, $postId) = explode(':', SimpleSAML\Utils\Crypto::aesDecrypt($encData));
    if (empty($sessionId) || empty($postId)) {
        throw new SimpleSAML_Error_BadRequest('Invalid session info data.');
    }
    $session = SimpleSAML_Session::getSession($sessionId);
} else {
    throw new SimpleSAML_Error_BadRequest('Missing redirection info parameter.');
}
if ($session === NULL) {
    throw new Exception('Unable to load session.');
}
$postData = $session->getData('core_postdatalink', $postId);
if ($postData === NULL) {
    /* The post data is missing, probably because it timed out. */
    throw new Exception('The POST data we should restore was lost.');
}
$session->deleteData('core_postdatalink', $postId);
assert('is_array($postData)');
assert('array_key_exists("url", $postData)');
assert('array_key_exists("post", $postData)');
开发者ID:jstormes,项目名称:simplesamlphp,代码行数:31,代码来源:postredirect.php

示例3: logoutSessions

 /**
  * Log out of the given sessions.
  *
  * @param string $authId  The authsource ID.
  * @param array $nameId  The NameID of the user.
  * @param array $sessionIndexes  The SessionIndexes we should log out of. Logs out of all if this is empty.
  * @returns int|FALSE  Number of sessions logged out, or FALSE if not supported.
  */
 public static function logoutSessions($authId, array $nameId, array $sessionIndexes)
 {
     assert('is_string($authId)');
     $store = SimpleSAML_Store::getInstance();
     if ($store === FALSE) {
         /* We don't have a datastore. */
         return FALSE;
     }
     /* Normalize NameID. */
     ksort($nameId);
     $strNameId = serialize($nameId);
     $strNameId = sha1($strNameId);
     /* Normalize SessionIndexes. */
     foreach ($sessionIndexes as &$sessionIndex) {
         assert('is_string($sessionIndex)');
         if (strlen($sessionIndex) > 50) {
             $sessionIndex = sha1($sessionIndex);
         }
     }
     unset($sessionIndex);
     // Remove reference
     if ($store instanceof SimpleSAML_Store_SQL) {
         $sessions = self::getSessionsSQL($store, $authId, $strNameId);
     } elseif (empty($sessionIndexes)) {
         /* We cannot fetch all sessions without a SQL store. */
         return FALSE;
     } else {
         $sessions = self::getSessionsStore($store, $authId, $strNameId, $sessionIndexes);
     }
     if (empty($sessionIndexes)) {
         $sessionIndexes = array_keys($sessions);
     }
     $sessionHandler = SimpleSAML_SessionHandler::getSessionHandler();
     $numLoggedOut = 0;
     foreach ($sessionIndexes as $sessionIndex) {
         if (!isset($sessions[$sessionIndex])) {
             SimpleSAML_Logger::info('saml.LogoutStore: Logout requested for unknown SessionIndex.');
             continue;
         }
         $sessionId = $sessions[$sessionIndex];
         $session = SimpleSAML_Session::getSession($sessionId);
         if ($session === NULL) {
             SimpleSAML_Logger::info('saml.LogoutStore: Skipping logout of missing session.');
             continue;
         }
         if (!$session->isValid($authId)) {
             SimpleSAML_Logger::info('saml.LogoutStore: Skipping logout of session because it isn\'t authenticated.');
             continue;
         }
         SimpleSAML_Logger::info('saml.LogoutStore: Logging out of session with trackId [' . $session->getTrackId() . '].');
         $session->doLogout($authId);
         $numLoggedOut += 1;
     }
     return $numLoggedOut;
 }
开发者ID:rchavik,项目名称:simplesamlphp,代码行数:63,代码来源:LogoutStore.php


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