Skip to content
Snippets Groups Projects
Commit 75f5dcce authored by Jaime Perez Crespo's avatar Jaime Perez Crespo
Browse files

Refactor SimpleSAML_Auth_State::extractPersistentAuthState() to...

Refactor SimpleSAML_Auth_State::extractPersistentAuthState() to getPersistentAuthData() to avoid confusions around the behaviour of this method.
parent 5128993b
No related branches found
No related tags found
No related merge requests found
...@@ -27,11 +27,11 @@ class SimpleSAML_Auth_Default { ...@@ -27,11 +27,11 @@ class SimpleSAML_Auth_Default {
/** /**
* @deprecated This method will be removed in SSP 2.0. Please use * @deprecated This method will be removed in SSP 2.0. Please use
* SimpleSAML_Auth_State::extractPersistentAuthState() instead. * SimpleSAML_Auth_State::getPersistentAuthData() instead.
*/ */
public static function extractPersistentAuthState(array &$state) { public static function extractPersistentAuthState(array &$state) {
return SimpleSAML_Auth_State::extractPersistentAuthState($state); return SimpleSAML_Auth_State::getPersistentAuthData($state);
} }
...@@ -50,7 +50,7 @@ class SimpleSAML_Auth_Default { ...@@ -50,7 +50,7 @@ class SimpleSAML_Auth_Default {
/* Save session state. */ /* Save session state. */
$session = SimpleSAML_Session::getSessionFromRequest(); $session = SimpleSAML_Session::getSessionFromRequest();
$authId = $state['SimpleSAML_Auth_Default.id']; $authId = $state['SimpleSAML_Auth_Default.id'];
$session->doLogin($authId, SimpleSAML_Auth_State::extractPersistentAuthState($state)); $session->doLogin($authId, SimpleSAML_Auth_State::getPersistentAuthData($state));
if (is_string($return)) { if (is_string($return)) {
/* Redirect... */ /* Redirect... */
......
...@@ -216,7 +216,7 @@ abstract class SimpleSAML_Auth_Source ...@@ -216,7 +216,7 @@ abstract class SimpleSAML_Auth_Source
// save session state // save session state
$session = SimpleSAML_Session::getSessionFromRequest(); $session = SimpleSAML_Session::getSessionFromRequest();
$authId = $state['SimpleSAML_Auth_Default.id']; $authId = $state['SimpleSAML_Auth_Default.id'];
$session->doLogin($authId, SimpleSAML_Auth_State::extractPersistentAuthState($state)); $session->doLogin($authId, SimpleSAML_Auth_State::getPersistentAuthData($state));
if (is_string($return)) { // redirect... if (is_string($return)) { // redirect...
\SimpleSAML\Utils\HTTP::redirectTrustedURL($return); \SimpleSAML\Utils\HTTP::redirectTrustedURL($return);
......
...@@ -92,12 +92,12 @@ class SimpleSAML_Auth_State { ...@@ -92,12 +92,12 @@ class SimpleSAML_Auth_State {
/** /**
* Extract the persistent authentication state from the state array. * Get the persistent authentication state from the state array.
* *
* @param array $state The state array to analyze. * @param array $state The state array to analyze.
* @return array The persistent authentication state. * @return array The persistent authentication state.
*/ */
public static function extractPersistentAuthState(array $state) public static function getPersistentAuthData(array $state)
{ {
// save persistent authentication data // save persistent authentication data
$persistent = array(); $persistent = array();
......
...@@ -440,7 +440,7 @@ class sspmod_saml_Auth_Source_SP extends SimpleSAML_Auth_Source { ...@@ -440,7 +440,7 @@ class sspmod_saml_Auth_Source_SP extends SimpleSAML_Auth_Source {
// Update session state // Update session state
$session = SimpleSAML_Session::getSessionFromRequest(); $session = SimpleSAML_Session::getSessionFromRequest();
$authId = $state['saml:sp:AuthId']; $authId = $state['saml:sp:AuthId'];
$session->doLogin($authId, SimpleSAML_Auth_State::extractPersistentAuthState($state)); $session->doLogin($authId, SimpleSAML_Auth_State::getPersistentAuthData($state));
// resume the login process // resume the login process
call_user_func($state['ReturnCallback'], $state); call_user_func($state['ReturnCallback'], $state);
...@@ -595,7 +595,7 @@ class sspmod_saml_Auth_Source_SP extends SimpleSAML_Auth_Source { ...@@ -595,7 +595,7 @@ class sspmod_saml_Auth_Source_SP extends SimpleSAML_Auth_Source {
assert('is_string($redirectTo)'); assert('is_string($redirectTo)');
$session = SimpleSAML_Session::getSessionFromRequest(); $session = SimpleSAML_Session::getSessionFromRequest();
$session->doLogin($authId, SimpleSAML_Auth_State::extractPersistentAuthState($state)); $session->doLogin($authId, SimpleSAML_Auth_State::getPersistentAuthData($state));
\SimpleSAML\Utils\HTTP::redirectUntrustedURL($redirectTo); \SimpleSAML\Utils\HTTP::redirectUntrustedURL($redirectTo);
} }
......
...@@ -9,9 +9,9 @@ class Auth_StateTest extends PHPUnit_Framework_TestCase ...@@ -9,9 +9,9 @@ class Auth_StateTest extends PHPUnit_Framework_TestCase
/** /**
* Test the extractPersistentAuthState() function. * Test the getPersistentAuthData() function.
*/ */
public function testExtractPersistentAuthState() public function testGetPersistentAuthData()
{ {
$mandatory = array( $mandatory = array(
...@@ -28,7 +28,7 @@ class Auth_StateTest extends PHPUnit_Framework_TestCase ...@@ -28,7 +28,7 @@ class Auth_StateTest extends PHPUnit_Framework_TestCase
$expected = $mandatory; $expected = $mandatory;
$this->assertEquals( $this->assertEquals(
$expected, $expected,
SimpleSAML_Auth_State::extractPersistentAuthState($state), SimpleSAML_Auth_State::getPersistentAuthData($state),
'Mandatory state attributes did not survive as expected'.print_r($expected, true) 'Mandatory state attributes did not survive as expected'.print_r($expected, true)
); );
...@@ -38,7 +38,7 @@ class Auth_StateTest extends PHPUnit_Framework_TestCase ...@@ -38,7 +38,7 @@ class Auth_StateTest extends PHPUnit_Framework_TestCase
$expected = $state; $expected = $state;
$this->assertEquals( $this->assertEquals(
$expected, $expected,
SimpleSAML_Auth_State::extractPersistentAuthState($state), SimpleSAML_Auth_State::getPersistentAuthData($state),
'Some error occurred with missing mandatory parameters' 'Some error occurred with missing mandatory parameters'
); );
...@@ -51,7 +51,7 @@ class Auth_StateTest extends PHPUnit_Framework_TestCase ...@@ -51,7 +51,7 @@ class Auth_StateTest extends PHPUnit_Framework_TestCase
$expected = $mandatory; $expected = $mandatory;
$this->assertEquals( $this->assertEquals(
$expected, $expected,
SimpleSAML_Auth_State::extractPersistentAuthState($state), SimpleSAML_Auth_State::getPersistentAuthData($state),
'Additional parameters survived' 'Additional parameters survived'
); );
...@@ -63,7 +63,7 @@ class Auth_StateTest extends PHPUnit_Framework_TestCase ...@@ -63,7 +63,7 @@ class Auth_StateTest extends PHPUnit_Framework_TestCase
unset($expected['PersistentAuthData']); unset($expected['PersistentAuthData']);
$this->assertEquals( $this->assertEquals(
$expected, $expected,
SimpleSAML_Auth_State::extractPersistentAuthState($state), SimpleSAML_Auth_State::getPersistentAuthData($state),
'Some error occurred with additional, persistent parameters' 'Some error occurred with additional, persistent parameters'
); );
...@@ -74,7 +74,7 @@ class Auth_StateTest extends PHPUnit_Framework_TestCase ...@@ -74,7 +74,7 @@ class Auth_StateTest extends PHPUnit_Framework_TestCase
unset($expected['PersistentAuthData']); unset($expected['PersistentAuthData']);
$this->assertEquals( $this->assertEquals(
$expected, $expected,
SimpleSAML_Auth_State::extractPersistentAuthState($state), SimpleSAML_Auth_State::getPersistentAuthData($state),
'Some error occurred with additional, persistent parameters, and no mandatory ones' 'Some error occurred with additional, persistent parameters, and no mandatory ones'
); );
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment