From 78cf59dbb48d054f2c53a5fe45a6a136b9dd977b Mon Sep 17 00:00:00 2001 From: Jaime Perez Crespo <jaime.perez@uninett.no> Date: Thu, 23 Apr 2015 14:31:13 +0200 Subject: [PATCH] Move SimpleSAML_Utilities::parseStateID() to SimpleSAML_Auth_State::parseStateID() and deprecate the former. --- lib/SimpleSAML/Auth/ProcessingChain.php | 2 +- lib/SimpleSAML/Auth/State.php | 24 +++++++++++++++++++++++- lib/SimpleSAML/Utilities.php | 17 ++--------------- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/lib/SimpleSAML/Auth/ProcessingChain.php b/lib/SimpleSAML/Auth/ProcessingChain.php index 7f31063de..b034220d9 100644 --- a/lib/SimpleSAML/Auth/ProcessingChain.php +++ b/lib/SimpleSAML/Auth/ProcessingChain.php @@ -302,7 +302,7 @@ class SimpleSAML_Auth_ProcessingChain { * Retrieve a state which has finished processing. * * @param string $id The state identifier. - * @see SimpleSAML_Utilities::parseStateID() + * @see SimpleSAML_Auth_State::parseStateID() * @return Array The state referenced by the $id parameter. */ public static function fetchProcessedState($id) { diff --git a/lib/SimpleSAML/Auth/State.php b/lib/SimpleSAML/Auth/State.php index 3c6665cc0..4f5e263be 100644 --- a/lib/SimpleSAML/Auth/State.php +++ b/lib/SimpleSAML/Auth/State.php @@ -210,7 +210,7 @@ class SimpleSAML_Auth_State { assert('is_bool($allowMissing)'); SimpleSAML_Logger::debug('Loading state: ' . var_export($id, TRUE)); - $sid = SimpleSAML_Utilities::parseStateID($id); + $sid = self::parseStateID($id); $session = SimpleSAML_Session::getSessionFromRequest(); $state = $session->getData('SimpleSAML_Auth_State', $sid['id']); @@ -337,4 +337,26 @@ class SimpleSAML_Auth_State { return $state; } + + /** + * Get the ID and (optionally) a URL embedded in a StateID, in the form 'id:url'. + * + * @param string $stateId The state ID to use. + * + * @return array A hashed array with the ID and the URL (if any), in the 'id' and 'url' keys, respectively. If + * there's no URL in the input parameter, NULL will be returned as the value for the 'url' key. + * + * @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no> + * @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no> + */ + public static function parseStateID($stateId) { + $tmp = explode(':', $stateId, 2); + $id = $tmp[0]; + $url = null; + if (count($tmp) === 2) { + $url = $tmp[1]; + } + return array('id' => $id, 'url' => $url); + } + } diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php index 43adfb9c6..c12c8aca5 100644 --- a/lib/SimpleSAML/Utilities.php +++ b/lib/SimpleSAML/Utilities.php @@ -110,23 +110,10 @@ class SimpleSAML_Utilities { /** - * Get the ID and (optionally) a URL embedded in a StateID, - * in the form 'id:url'. - * - * @param string $stateId The state ID to use. - * @return array A hashed array with the ID and the URL (if any), - * in the 'id' and 'url' keys, respectively. If there's no URL - * in the input parameter, NULL will be returned as the value for - * the 'url' key. + * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML_Auth_State::parseStateID() instead. */ public static function parseStateID($stateId) { - $tmp = explode(':', $stateId, 2); - $id = $tmp[0]; - $url = NULL; - if (count($tmp) === 2) { - $url = $tmp[1]; - } - return array('id' => $id, 'url' => $url); + return SimpleSAML_Auth_State::parseStateID($stateId); } -- GitLab