From 75f5dcce58a4b4d606e5f20b3b21225fe43f1760 Mon Sep 17 00:00:00 2001
From: Jaime Perez Crespo <jaime.perez@uninett.no>
Date: Tue, 25 Aug 2015 15:39:54 +0200
Subject: [PATCH] Refactor SimpleSAML_Auth_State::extractPersistentAuthState()
 to getPersistentAuthData() to avoid confusions around the behaviour of this
 method.

---
 lib/SimpleSAML/Auth/Default.php         |  6 +++---
 lib/SimpleSAML/Auth/Source.php          |  2 +-
 lib/SimpleSAML/Auth/State.php           |  4 ++--
 modules/saml/lib/Auth/Source/SP.php     |  4 ++--
 tests/lib/SimpleSAML/Auth/StateTest.php | 14 +++++++-------
 5 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/lib/SimpleSAML/Auth/Default.php b/lib/SimpleSAML/Auth/Default.php
index d5553aa19..4541f02db 100644
--- a/lib/SimpleSAML/Auth/Default.php
+++ b/lib/SimpleSAML/Auth/Default.php
@@ -27,11 +27,11 @@ class SimpleSAML_Auth_Default {
 
 	/**
 	 * @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) {
 
-		return SimpleSAML_Auth_State::extractPersistentAuthState($state);
+		return SimpleSAML_Auth_State::getPersistentAuthData($state);
 	}
 
 
@@ -50,7 +50,7 @@ class SimpleSAML_Auth_Default {
 		/* Save session state. */
 		$session = SimpleSAML_Session::getSessionFromRequest();
 		$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... */
diff --git a/lib/SimpleSAML/Auth/Source.php b/lib/SimpleSAML/Auth/Source.php
index 70b8cf70a..4637f8ba7 100644
--- a/lib/SimpleSAML/Auth/Source.php
+++ b/lib/SimpleSAML/Auth/Source.php
@@ -216,7 +216,7 @@ abstract class SimpleSAML_Auth_Source
         // save session state
         $session = SimpleSAML_Session::getSessionFromRequest();
         $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...
             \SimpleSAML\Utils\HTTP::redirectTrustedURL($return);
diff --git a/lib/SimpleSAML/Auth/State.php b/lib/SimpleSAML/Auth/State.php
index 5d6ebc614..a756535f2 100644
--- a/lib/SimpleSAML/Auth/State.php
+++ b/lib/SimpleSAML/Auth/State.php
@@ -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.
 	 * @return array The persistent authentication state.
 	 */
-	public static function extractPersistentAuthState(array $state)
+	public static function getPersistentAuthData(array $state)
 	{
 		// save persistent authentication data
 		$persistent = array();
diff --git a/modules/saml/lib/Auth/Source/SP.php b/modules/saml/lib/Auth/Source/SP.php
index 28ca102d7..1411b05bd 100644
--- a/modules/saml/lib/Auth/Source/SP.php
+++ b/modules/saml/lib/Auth/Source/SP.php
@@ -440,7 +440,7 @@ class sspmod_saml_Auth_Source_SP extends SimpleSAML_Auth_Source {
 		// Update session state
 		$session = SimpleSAML_Session::getSessionFromRequest();
 		$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
 		call_user_func($state['ReturnCallback'], $state);
@@ -595,7 +595,7 @@ class sspmod_saml_Auth_Source_SP extends SimpleSAML_Auth_Source {
 		assert('is_string($redirectTo)');
 
 		$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);
 	}
diff --git a/tests/lib/SimpleSAML/Auth/StateTest.php b/tests/lib/SimpleSAML/Auth/StateTest.php
index 741acdaab..5bbb9c5d8 100644
--- a/tests/lib/SimpleSAML/Auth/StateTest.php
+++ b/tests/lib/SimpleSAML/Auth/StateTest.php
@@ -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(
@@ -28,7 +28,7 @@ class Auth_StateTest extends PHPUnit_Framework_TestCase
         $expected = $mandatory;
         $this->assertEquals(
             $expected,
-            SimpleSAML_Auth_State::extractPersistentAuthState($state),
+            SimpleSAML_Auth_State::getPersistentAuthData($state),
             'Mandatory state attributes did not survive as expected'.print_r($expected, true)
         );
 
@@ -38,7 +38,7 @@ class Auth_StateTest extends PHPUnit_Framework_TestCase
         $expected = $state;
         $this->assertEquals(
             $expected,
-            SimpleSAML_Auth_State::extractPersistentAuthState($state),
+            SimpleSAML_Auth_State::getPersistentAuthData($state),
             'Some error occurred with missing mandatory parameters'
         );
 
@@ -51,7 +51,7 @@ class Auth_StateTest extends PHPUnit_Framework_TestCase
         $expected = $mandatory;
         $this->assertEquals(
             $expected,
-            SimpleSAML_Auth_State::extractPersistentAuthState($state),
+            SimpleSAML_Auth_State::getPersistentAuthData($state),
             'Additional parameters survived'
         );
 
@@ -63,7 +63,7 @@ class Auth_StateTest extends PHPUnit_Framework_TestCase
         unset($expected['PersistentAuthData']);
         $this->assertEquals(
             $expected,
-            SimpleSAML_Auth_State::extractPersistentAuthState($state),
+            SimpleSAML_Auth_State::getPersistentAuthData($state),
             'Some error occurred with additional, persistent parameters'
         );
 
@@ -74,7 +74,7 @@ class Auth_StateTest extends PHPUnit_Framework_TestCase
         unset($expected['PersistentAuthData']);
         $this->assertEquals(
             $expected,
-            SimpleSAML_Auth_State::extractPersistentAuthState($state),
+            SimpleSAML_Auth_State::getPersistentAuthData($state),
             'Some error occurred with additional, persistent parameters, and no mandatory ones'
         );
     }
-- 
GitLab