本文整理汇总了PHP中SimpleSAML_Auth_State::extractPersistentAuthState方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleSAML_Auth_State::extractPersistentAuthState方法的具体用法?PHP SimpleSAML_Auth_State::extractPersistentAuthState怎么用?PHP SimpleSAML_Auth_State::extractPersistentAuthState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleSAML_Auth_State
的用法示例。
在下文中一共展示了SimpleSAML_Auth_State::extractPersistentAuthState方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testExtractPersistentAuthState
/**
* Test the extractPersistentAuthState() function.
*/
public function testExtractPersistentAuthState()
{
$mandatory = array('Attributes' => array(), 'Expire' => 1234, 'LogoutState' => 'logoutState', 'AuthInstant' => 123456, 'RememberMe' => true, 'saml:sp:NameID' => 'nameID');
// check just mandatory parameters
$state = $mandatory;
$expected = $mandatory;
$this->assertEquals($expected, SimpleSAML_Auth_State::extractPersistentAuthState($state), 'Mandatory state attributes did not survive as expected' . print_r($expected, true));
// check missing mandatory parameters
unset($state['LogoutState']);
unset($state['RememberMe']);
$expected = $state;
$this->assertEquals($expected, SimpleSAML_Auth_State::extractPersistentAuthState($state), 'Some error occurred with missing mandatory parameters');
// check additional non-persistent parameters
$additional = array('additional1' => 1, 'additional2' => 2);
$state = array_merge($mandatory, $additional);
$expected = $mandatory;
$this->assertEquals($expected, SimpleSAML_Auth_State::extractPersistentAuthState($state), 'Additional parameters survived');
// check additional persistent parameters
$additional['PersistentAuthData'] = array('additional1');
$state = array_merge($mandatory, $additional);
$expected = $state;
unset($expected['additional2']);
unset($expected['PersistentAuthData']);
$this->assertEquals($expected, SimpleSAML_Auth_State::extractPersistentAuthState($state), 'Some error occurred with additional, persistent parameters');
// check only additional persistent parameters
$state = $additional;
$expected = $state;
unset($expected['additional2']);
unset($expected['PersistentAuthData']);
$this->assertEquals($expected, SimpleSAML_Auth_State::extractPersistentAuthState($state), 'Some error occurred with additional, persistent parameters, and no mandatory ones');
}
示例2: loginCompleted
/**
* @deprecated This method will be removed in SSP 2.0.
*/
public static function loginCompleted($state)
{
assert('is_array($state)');
assert('array_key_exists("SimpleSAML_Auth_Default.Return", $state)');
assert('array_key_exists("SimpleSAML_Auth_Default.id", $state)');
assert('array_key_exists("Attributes", $state)');
assert('!array_key_exists("LogoutState", $state) || is_array($state["LogoutState"])');
$return = $state['SimpleSAML_Auth_Default.Return'];
/* Save session state. */
$session = SimpleSAML_Session::getSessionFromRequest();
$authId = $state['SimpleSAML_Auth_Default.id'];
$state = SimpleSAML_Auth_State::extractPersistentAuthState($state);
$session->doLogin($authId, $state);
if (is_string($return)) {
/* Redirect... */
\SimpleSAML\Utils\HTTP::redirectTrustedURL($return);
} else {
call_user_func($return, $state);
assert('FALSE');
}
}
示例3: handleUnsolicitedAuth
/**
* Handle an unsolicited login operations.
*
* This method creates a session from the information received. It will then redirect to the given URL. This is used
* to handle IdP initiated SSO. This method will never return.
*
* @param string $authId The id of the authentication source that received the request.
* @param array $state A state array.
* @param string $redirectTo The URL we should redirect the user to after updating the session. The function will
* check if the URL is allowed, so there is no need to manually check the URL on beforehand. Please refer to the
* 'trusted.url.domains' configuration directive for more information about allowing (or disallowing) URLs.
*/
public static function handleUnsolicitedAuth($authId, array $state, $redirectTo)
{
assert('is_string($authId)');
assert('is_string($redirectTo)');
$session = SimpleSAML_Session::getSessionFromRequest();
$session->doLogin($authId, SimpleSAML_Auth_State::extractPersistentAuthState($state));
\SimpleSAML\Utils\HTTP::redirectUntrustedURL($redirectTo);
}