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

Remove deprecated SimpleSAML_MemcacheStore class. This closes #152.

parent 6e13e83f
No related branches found
No related tags found
No related merge requests found
...@@ -623,8 +623,8 @@ $config = array( ...@@ -623,8 +623,8 @@ $config = array(
/* /*
* Configuration for the MemcacheStore class. This allows you to store * Configuration for the 'memcache' session store. This allows you to store
* multiple redudant copies of sessions on different memcache servers. * multiple redundant copies of sessions on different memcache servers.
* *
* 'memcache_store.servers' is an array of server groups. Every data * 'memcache_store.servers' is an array of server groups. Every data
* item will be mirrored in every server group. * item will be mirrored in every server group.
...@@ -645,7 +645,7 @@ $config = array( ...@@ -645,7 +645,7 @@ $config = array(
* - 'timeout': The timeout for this server. By default, the timeout * - 'timeout': The timeout for this server. By default, the timeout
* is 3 seconds. * is 3 seconds.
* *
* Example of redudant configuration with load balancing: * Example of redundant configuration with load balancing:
* This configuration makes it possible to lose both servers in the * This configuration makes it possible to lose both servers in the
* a-group or both servers in the b-group without losing any sessions. * a-group or both servers in the b-group without losing any sessions.
* Note that sessions will be lost if one server is lost from both the * Note that sessions will be lost if one server is lost from both the
......
<?php
/**
* This class provides a class with behaviour similar to the $_SESSION variable.
* Data is automatically saved on exit.
*
* Care should be taken when using this class to store objects. It will not detect changes to objects
* automatically. Instead, a call to set(...) should be done to notify this class of changes.
*
* @author Olav Morken, UNINETT AS.
* @package simpleSAMLphp
* @deprecated This class will be removed in version 1.8 of simpleSAMLphp.
*/
class SimpleSAML_MemcacheStore {
/**
* This variable contains an array with all key-value pairs stored
* in this object.
*/
private $data = NULL;
/**
* This function is used to find an existing storage object. It will return NULL if no storage object
* with the given id is found.
*
* @param $id The id of the storage object we are looking for. A id consists of lowercase
* alphanumeric characters.
* @return The corresponding MemcacheStorage object if the data is found or NULL if it isn't found.
*/
public static function find($id) {
assert(self::isValidID($id));
$serializedData = SimpleSAML_Memcache::get($id);
if($serializedData === NULL) {
return NULL;
}
$data = unserialize($serializedData);
if(!($data instanceof self)) {
SimpleSAML_Logger::warning('Retrieved key from memcache did not contain a MemcacheStore object.');
return NULL;
}
return $data;
}
/**
* This function retrieves the specified key from this storage object.
*
* @param $key The key we should retrieve the value of.
* @return The value of the specified key, or NULL of the key wasn't found.
*/
public function get($key) {
if(!array_key_exists($key, $this->data)) {
return NULL;
}
return $this->data[$key];
}
/**
* This function determines whether the argument is a valid id.
* A valid id is a string containing lowercase alphanumeric
* characters.
*
* @param $id The id we should validate.
* @return TRUE if the id is valid, FALSE otherwise.
*/
private static function isValidID($id) {
if(!is_string($id)) {
return FALSE;
}
if(strlen($id) < 1) {
return FALSE;
}
if(preg_match('/[^0-9a-z]/', $id)) {
return FALSE;
}
return TRUE;
}
}
...@@ -41,27 +41,7 @@ class SimpleSAML_SessionHandlerStore extends SimpleSAML_SessionHandlerCookie { ...@@ -41,27 +41,7 @@ class SimpleSAML_SessionHandlerStore extends SimpleSAML_SessionHandlerCookie {
return $session; return $session;
} }
if (!($this->store instanceof SimpleSAML_Store_Memcache)) { return NULL;
return NULL;
}
/* For backwards compatibility, check the MemcacheStore object. */
$store = SimpleSAML_MemcacheStore::find($sessionId);
if ($store === NULL) {
return NULL;
}
$session = $store->get('SimpleSAMLphp_SESSION');
if ($session === NULL) {
return NULL;
}
assert('is_string($session)');
$session = unserialize($session);
assert('$session instanceof SimpleSAML_Session');
return $session;
} }
......
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