Skip to content
Snippets Groups Projects
Commit 5ac62a5b authored by Andjelko Horvat's avatar Andjelko Horvat
Browse files

SimpleSAML_Auth_State: add cloneState function (issue 451).

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2979 44740490-163a-0410-bde0-09ae8108e29a
parent 3d916a20
No related branches found
No related tags found
No related merge requests found
......@@ -37,6 +37,13 @@ class SimpleSAML_Auth_State {
const ID = 'SimpleSAML_Auth_State.id';
/**
* The index in the cloned state array which contains the identifier of the
* original state.
*/
const CLONE_ORIGINAL_ID = 'SimpleSAML_Auth_State.cloneOriginalId';
/**
* The index in the state array which contains the current stage.
*/
......@@ -162,6 +169,30 @@ class SimpleSAML_Auth_State {
}
/**
* Clone the state.
*
* This function clones and returns the new cloned state.
*
* @param array $state The original request state.
* @return array Cloned state data.
*/
public static function cloneState(array $state) {
$clonedState = $state;
if (array_key_exists(self::ID, $state)) {
$clonedState[self::CLONE_ORIGINAL_ID] = $state[self::ID];
unset($clonedState[self::ID]);
SimpleSAML_Logger::debug('Cloned state: ' . var_export($state[self::ID], TRUE));
} else {
SimpleSAML_Logger::debug('Cloned state with undefined id.');
}
return $clonedState;
}
/**
* Retrieve saved state.
*
......
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