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


PHP SimpleSAML_Session::getInstance方法代码示例

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


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

示例1: process

 public function process(&$state)
 {
     assert('is_array($state)');
     if (empty($state['Expire']) || empty($state['Authority'])) {
         return;
     }
     $now = time();
     $delta = $state['Expire'] - $now;
     $globalConfig = SimpleSAML_Configuration::getInstance();
     $sessionDuration = $globalConfig->getInteger('session.duration', 8 * 60 * 60);
     /* Extend only if half of session duration already passed */
     if ($delta >= $sessionDuration * 0.5) {
         return;
     }
     /* Update authority expire time */
     $session = SimpleSAML_Session::getInstance();
     $session->setAuthorityExpire($state['Authority']);
     /* Update session cookies duration */
     /* If remember me is active */
     $rememberMeExpire = $session->getRememberMeExpire();
     if (!empty($state['RememberMe']) && $rememberMeExpire !== NULL && $globalConfig->getBoolean('session.rememberme.enable', FALSE)) {
         $session->setRememberMeExpire();
         return;
     }
     /* Or if session lifetime is more than zero */
     $sessionHandler = SimpleSAML_SessionHandler::getSessionHandler();
     $cookieParams = $sessionHandler->getCookieParams();
     if ($cookieParams['lifetime'] > 0) {
         $session->updateSessionCookies();
     }
 }
开发者ID:danielkjfrog,项目名称:docker,代码行数:31,代码来源:ExtendIdPSession.php

示例2: loginComplete

 /**
  * When login is complete, save the SSPAuthentication object to the session
  */
 public final function loginComplete()
 {
     //Use the same session as SimpleSAMLphp to avoid session state loss
     Session::start(SimpleSAML_Session::getInstance()->getSessionId());
     Session::set('ssp_current_auth_source', $this->getAuthSource()->getAuthId());
     Session::set('ssp_current_auth_class', get_class($this));
     Session::save();
 }
开发者ID:helpfulrobot,项目名称:antons-silverstripe-ssp,代码行数:11,代码来源:SSPAuthenticator.php

示例3: show

 /**
  * Display this error.
  *
  * This method displays a standard simpleSAMLphp error page and exits.
  */
 public function show()
 {
     $this->setHTTPCode();
     $session = SimpleSAML_Session::getInstance();
     if ($this->cause !== NULL) {
         $e = $this->cause;
     } else {
         $e = $this;
     }
     SimpleSAML_Utilities::fatalError($session->getTrackID(), $this->errorCode, $e);
 }
开发者ID:hukumonline,项目名称:yii,代码行数:16,代码来源:Error.php

示例4: checkLoggedAndSameAuth

 public static function checkLoggedAndSameAuth()
 {
     $session = SimpleSAML_Session::getInstance();
     if ($session->isAuthenticated()) {
         $uregconf = SimpleSAML_Configuration::getConfig('module_selfregister.php');
         /* Get a reference to our authentication source. */
         $asId = $uregconf->getString('auth');
         if ($session->getAuthority() == $asId) {
             return new SimpleSAML_Auth_Simple($asId);
         }
     }
     return false;
 }
开发者ID:googlecode-mirror,项目名称:simplesamlphp-labs,代码行数:13,代码来源:Util.php

示例5: process

 /**
  * Apply filter to add the UID attribute.
  *
  * @param array &$request  The current request
  */
 public function process(&$request)
 {
     assert('is_array($request)');
     assert('array_key_exists("Attributes", $request)');
     $authModule = NULL;
     // Fetch Auth module
     if (array_key_exists("SimpleSAML_Auth_State.stage", $request)) {
         $authStage = implode(":", array_slice(explode(':', $request["SimpleSAML_Auth_State.stage"]), 0, -1));
         $authId = $authStage . ':AuthId';
         $authModule = $request[$authId];
     } else {
         if (isset($request['AuthnInstant']) && isset($request['Expire'])) {
             // Probably dealing with a cached response
             $cachedAuthModule = SimpleSAML_Session::getInstance()->getData(sspmod_multiauth_Auth_Source_MultiAuth::SESSION_SOURCE, 'multi');
             if ($cachedAuthModule) {
                 $authModule = $cachedAuthModule;
             }
         }
     }
     if (!isset($authModule)) {
         throw new Exception("Auth module not found?!?!");
     }
     $attributes =& $request['Attributes'];
     $filter = null;
     // Set or replace the filter attribute
     if (array_key_exists($authModule, $this->map)) {
         $filter = $this->map[$authModule];
     }
     switch ($filter) {
         case 'GOOGLE':
             $attributes['uid'] = $this->_useEmailAsUid($attributes);
             break;
         case 'YAHOO':
             $attributes['uid'] = $this->_useEmailAsUid($attributes);
             break;
         case 'HYVES':
             if (!array_key_exists('openid.local_id', $attributes)) {
                 throw new Exception('No local id attribute provided! Cannot use it as UID');
             }
             $attributes['uid'] = str_replace('.hyves.nl/', '', str_replace('http://', '', $attributes['openid.local_id']));
             break;
         default:
             if (!array_key_exists('uid', $attributes)) {
                 throw new Exception('No UID set?!?!');
             }
             break;
     }
 }
开发者ID:WebSpider,项目名称:OpenConext-guestidp,代码行数:53,代码来源:SetUid.php

示例6: __construct

 /**
  * Constructor
  *
  * Note that the person is tied to a session and a simplesaml configuration
  * here
  */
 function __construct($person = NULL)
 {
     parent::__construct($person);
     /* Find the path to simpelsamlphp and run the autoloader */
     try {
         $sspdir = Config::get_config('simplesaml_path');
     } catch (KeyNotFoundException $knfe) {
         echo "Cannot find path to simplesaml. This install is not valid. Aborting.<br />\n";
         Logger::logEvent(LOG_ALERT, "Confusa_Auth_IdP", "__construct()", "Trying to instantiate SimpleSAMLphp without a configured path.");
         exit(0);
     }
     require_once $sspdir . '/lib/_autoload.php';
     SimpleSAML_Configuration::setConfigDir($sspdir . '/config');
     /* start a session needed for the IdP-based AuthN approach */
     $this->as = new SimpleSAML_Auth_Simple('default-sp');
     $this->session = SimpleSAML_Session::getInstance();
 }
开发者ID:henrikau,项目名称:confusa,代码行数:23,代码来源:Confusa_Auth_IdP.php

示例7: authenticate

 /**
  * Log-in using Facebook platform
  *
  * @param array &$state  Information about the current authentication.
  */
 public function authenticate(&$state)
 {
     assert('is_array($state)');
     /* We are going to need the authId in order to retrieve this authentication source later. */
     $state[self::AUTHID] = $this->authId;
     $stateID = SimpleSAML_Auth_State::saveState($state, self::STAGE_INIT);
     // SimpleSAML_Logger::debug('facebook auth state id = ' . $stateID);
     $consumer = new sspmod_oauth_Consumer($this->key, $this->secret);
     // Get the request token
     $requestToken = $consumer->getRequestToken('http://twitter.com/oauth/request_token');
     SimpleSAML_Logger::debug("Got a request token from the OAuth service provider [" . $requestToken->key . "] with the secret [" . $requestToken->secret . "]");
     $oauthState = array('requestToken' => serialize($requestToken), 'stateid' => $stateID);
     $session = SimpleSAML_Session::getInstance();
     $session->setData('oauth', 'oauth', $oauthState);
     // Authorize the request token
     $consumer->getAuthorizeRequest('http://twitter.com/oauth/authenticate', $requestToken);
 }
开发者ID:filonuse,项目名称:fedlab,代码行数:22,代码来源:Twitter.php

示例8: __construct

 /**
  * Initializes this discovery service.
  *
  * The constructor does the parsing of the request. If this is an invalid request, it will
  * throw an exception.
  *
  * @param array $metadataSets  Array with metadata sets we find remote entities in.
  * @param string $instance  The name of this instance of the discovery service.
  */
 public function __construct(array $metadataSets, $instance)
 {
     assert('is_string($instance)');
     /* Initialize standard classes. */
     $this->config = SimpleSAML_Configuration::getInstance();
     $this->metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
     $this->session = SimpleSAML_Session::getInstance();
     $this->instance = $instance;
     $this->metadataSets = $metadataSets;
     $this->log('Accessing discovery service.');
     /* Standard discovery service parameters. */
     if (!array_key_exists('entityID', $_GET)) {
         throw new Exception('Missing parameter: entityID');
     } else {
         $this->spEntityId = $_GET['entityID'];
     }
     if (!array_key_exists('returnIDParam', $_GET)) {
         $this->returnIdParam = 'entityID';
     } else {
         $this->returnIdParam = $_GET['returnIDParam'];
     }
     $this->log('returnIdParam initially set to [' . $this->returnIdParam . ']');
     if (!array_key_exists('return', $_GET)) {
         throw new Exception('Missing parameter: return');
     } else {
         $this->returnURL = $_GET['return'];
     }
     $this->isPassive = FALSE;
     if (array_key_exists('isPassive', $_GET)) {
         if ($_GET['isPassive'] === 'true') {
             $this->isPassive = TRUE;
         }
     }
     $this->log('isPassive initially set to [' . ($this->isPassive ? 'TRUE' : 'FALSE') . ']');
     if (array_key_exists('IdPentityID', $_GET)) {
         $this->setIdPentityID = $_GET['IdPentityID'];
     } else {
         $this->setIdPentityID = NULL;
     }
     if (array_key_exists('IDPList', $_GET)) {
         $this->scopedIDPList = $_GET['IDPList'];
     }
 }
开发者ID:hukumonline,项目名称:yii,代码行数:52,代码来源:IdPDisco.php

示例9: authenticate

 public function authenticate(TokenInterface $token)
 {
     /** @var string $authenticationType */
     $authenticationType = $this->config->getValue('auth', 'login-admin');
     if (php_sapi_name() === 'cli') {
         return $this->getTokenForUsername($authenticationType);
     }
     $session = \SimpleSAML_Session::getInstance();
     if (!$session->isValid($authenticationType)) {
         throw new AuthenticationException("Authsource '{$authenticationType}' is invalid");
     }
     /** @var string $userIdAttributeName */
     $userIdAttributeName = $this->config->getValue('useridattr', 'eduPersonPrincipalName');
     // Check if userid exists
     $attributes = $session->getAttributes();
     if (!isset($attributes[$userIdAttributeName])) {
         throw new AuthenticationException("Attribute '{$userIdAttributeName}' with User ID is missing.");
     }
     return $this->getTokenForUsername($attributes[$userIdAttributeName][0]);
 }
开发者ID:baszoetekouw,项目名称:janus,代码行数:20,代码来源:SspProvider.php

示例10: process

 /**
  * Apply filter to add the SchacHomeOrganization attribute.
  *
  * @param array &$request  The current request
  */
 public function process(&$request)
 {
     assert('is_array($request)');
     assert('array_key_exists("Attributes", $request)');
     $authModule = NULL;
     // Fetch Auth module
     if (array_key_exists("SimpleSAML_Auth_State.stage", $request)) {
         $authStage = implode(":", array_slice(explode(':', $request["SimpleSAML_Auth_State.stage"]), 0, -1));
         $authId = $authStage . ':AuthId';
         $authModule = $request[$authId];
     } else {
         if (isset($request['AuthnInstant']) && isset($request['Expire'])) {
             // Probably dealing with a cached response
             $cachedAuthModule = SimpleSAML_Session::getInstance()->getData(sspmod_multiauth_Auth_Source_MultiAuth::SESSION_SOURCE, 'multi');
             if ($cachedAuthModule) {
                 $authModule = $cachedAuthModule;
             }
         }
     }
     if (!isset($authModule)) {
         throw new Exception("Auth module not found?!?!");
     }
     $attributes =& $request['Attributes'];
     // Set or replace the schacHomeOrganization attribute
     if (array_key_exists($authModule, $this->map)) {
         $schacHomeOrganization = $this->map[$authModule];
         if (isset($schacHomeOrganization)) {
             $attributes["schacHomeOrganization"] = $schacHomeOrganization;
             return;
         }
     }
     if (array_key_exists(DEFAULT_SCHACHOMEORG, $this->map)) {
         throw new Exception("No default schacHomeOrganization?!?");
     }
     $attributes["schacHomeOrganization"] = $this->map[DEFAULT_SCHACHOMEORG];
 }
开发者ID:WebSpider,项目名称:OpenConext-guestidp,代码行数:41,代码来源:SchacHomeOrganization.php

示例11: show

 /**
  * Show the error to the user.
  *
  * This function does not return.
  */
 public function show()
 {
     header('HTTP/1.0 500 Internal Server Error');
     $errorData = $this->saveError();
     $session = SimpleSAML_Session::getInstance();
     $attributes = $session->getAttributes();
     if (isset($attributes['mail'][0])) {
         $email = $attributes['mail'][0];
     } else {
         $email = '';
     }
     $globalConfig = SimpleSAML_Configuration::getInstance();
     $t = new SimpleSAML_XHTML_Template($globalConfig, 'core:no_state.tpl.php');
     /* Enable error reporting if we have a valid technical contact email. */
     if ($globalConfig->getString('technicalcontact_email', 'na@example.org') !== 'na@example.org') {
         /* Enable error reporting. */
         $baseurl = SimpleSAML_Utilities::getBaseURL();
         $t->data['errorReportAddress'] = $baseurl . 'errorreport.php';
         $t->data['reportId'] = $errorData['reportId'];
         $t->data['email'] = $email;
     }
     $t->show();
     exit;
 }
开发者ID:filonuse,项目名称:fedlab,代码行数:29,代码来源:NoState.php

示例12: process

 /**
  * Process a authentication response.
  *
  * This function saves the state, and redirects the user to the page where the user
  * can authorize the release of the attributes.
  *
  * @param array $state  The state of the response.
  */
 public function process(&$state)
 {
     assert('is_array($state)');
     assert('array_key_exists("UserID", $state)');
     assert('array_key_exists("Destination", $state)');
     assert('array_key_exists("entityid", $state["Destination"])');
     assert('array_key_exists("metadata-set", $state["Destination"])');
     assert('array_key_exists("entityid", $state["Source"])');
     assert('array_key_exists("metadata-set", $state["Source"])');
     $session = SimpleSAML_Session::getInstance();
     $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
     /* If the consent module is active on a bridge $state['saml:sp:IdP'] will contain
      * an entry id for the remote IdP. If not, then the
      * consent module is active on a local IdP and nothing needs to be done.
      */
     if (isset($state['saml:sp:IdP'])) {
         $idpmeta = $metadata->getMetaData($state['saml:sp:IdP'], 'saml20-idp-remote');
         $state['Source'] = $idpmeta;
     } elseif ($session->getIdP() !== NULL) {
         /* For backwards compatibility. TODO: Remove in version 1.8. */
         $idpmeta = $metadata->getMetaData($session->getIdP(), 'saml20-idp-remote');
         $state['Source'] = $idpmeta;
     }
     if ($this->store !== NULL) {
         // Do not use consent if disabled on source entity
         if (isset($state['Source']['consent.disable']) && in_array($state['Destination']['entityid'], $state['Source']['consent.disable'])) {
             SimpleSAML_Logger::debug('Consent - Consent disabled for entity ' . $state['Destination']['entityid']);
             return;
         }
         $source = $state['Source']['metadata-set'] . '|' . $state['Source']['entityid'];
         $destination = $state['Destination']['metadata-set'] . '|' . $state['Destination']['entityid'];
         SimpleSAML_Logger::debug('Consent - userid : ' . $state['UserID']);
         SimpleSAML_Logger::debug('Consent - source : ' . $source);
         SimpleSAML_Logger::debug('Consent - destination : ' . $destination);
         $userId = self::getHashedUserID($state['UserID'], $source);
         $targetedId = self::getTargetedID($state['UserID'], $source, $destination);
         $attributeSet = self::getAttributeHash($state['Attributes'], $this->includeValues);
         SimpleSAML_Logger::debug('Consent - hasConsent() : [' . $userId . '|' . $targetedId . '|' . $attributeSet . ']');
         if ($this->store->hasConsent($userId, $targetedId, $attributeSet)) {
             SimpleSAML_Logger::stats('consent found');
             /* Consent already given. */
             return;
         }
         SimpleSAML_Logger::stats('consent notfound');
         $state['consent:store'] = $this->store;
         $state['consent:store.userId'] = $userId;
         $state['consent:store.destination'] = $targetedId;
         $state['consent:store.attributeSet'] = $attributeSet;
     } else {
         SimpleSAML_Logger::stats('consent nostorage');
     }
     $state['consent:focus'] = $this->focus;
     $state['consent:checked'] = $this->checked;
     $state['consent:hiddenAttributes'] = $this->hiddenAttributes;
     /* User interaction nessesary. Throw exception on isPassive request */
     if (isset($state['isPassive']) && $state['isPassive'] == TRUE) {
         throw new SimpleSAML_Error_NoPassive('Unable to give consent on passive request.');
     }
     /* Save state and redirect. */
     $id = SimpleSAML_Auth_State::saveState($state, 'consent:request');
     $url = SimpleSAML_Module::getModuleURL('consent/getconsent.php');
     SimpleSAML_Utilities::redirect($url, array('StateId' => $id));
 }
开发者ID:filonuse,项目名称:fedlab,代码行数:71,代码来源:Consent.php

示例13: callLogoutCallback

 /**
  * Call a logout callback based on association.
  *
  * This function calls a logout callback based on an association saved with
  * addLogoutCallback(...).
  *
  * This function always returns.
  *
  * @param string $assoc  The logout association which should be called.
  */
 protected function callLogoutCallback($assoc)
 {
     assert('is_string($assoc)');
     $id = strlen($this->authId) . ':' . $this->authId . $assoc;
     $session = SimpleSAML_Session::getInstance();
     $data = $session->getData('SimpleSAML_Auth_Source.LogoutCallbacks', $id);
     if ($data === NULL) {
         /* FIXME: fix for IdP-first flow (issue 397) -> reevaluate logout callback infrastructure */
         $session->doLogout($this->authId);
         return;
     }
     assert('is_array($data)');
     assert('array_key_exists("callback", $data)');
     assert('array_key_exists("state", $data)');
     $callback = $data['callback'];
     $callbackState = $data['state'];
     call_user_func($callback, $callbackState);
 }
开发者ID:JVS-IS,项目名称:ICONITO-EcoleNumerique,代码行数:28,代码来源:Source.php

示例14: getSession

 /**
  * @return SimpleSAML_Session
  */
 public function getSession()
 {
     return SimpleSAML_Session::getInstance();
 }
开发者ID:baszoetekouw,项目名称:janus,代码行数:7,代码来源:DiContainer.php

示例15: checkCookie

 /**
  * Check for session cookie, and show missing-cookie page if it is missing.
  *
  * @param string|NULL $retryURL  The URL the user should access to retry the operation.
  */
 public static function checkCookie($retryURL = NULL)
 {
     assert('is_string($retryURL) || is_null($retryURL)');
     $session = SimpleSAML_Session::getInstance();
     if ($session->hasSessionCookie()) {
         return;
     }
     /* We didn't have a session cookie. Redirect to the no-cookie page. */
     $url = SimpleSAML_Module::getModuleURL('core/no_cookie.php');
     if ($retryURL !== NULL) {
         $url = self::addURLParameter($url, array('retryURL' => $retryURL));
     }
     self::redirectTrustedURL($url);
 }
开发者ID:danielkjfrog,项目名称:docker,代码行数:19,代码来源:Utilities.php


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