From 580cd62f0a4fac5dba37a8a152afaecd99e8c767 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Thu, 15 Dec 2011 20:07:48 -0500 Subject: removed old libraries - depends on openid_api now --- .../Tests/Auth/OpenID/MemStore.php | 176 --------------------- 1 file changed, 176 deletions(-) delete mode 100644 models/openid-php-openid-782224d/Tests/Auth/OpenID/MemStore.php (limited to 'models/openid-php-openid-782224d/Tests/Auth/OpenID/MemStore.php') diff --git a/models/openid-php-openid-782224d/Tests/Auth/OpenID/MemStore.php b/models/openid-php-openid-782224d/Tests/Auth/OpenID/MemStore.php deleted file mode 100644 index 772471963..000000000 --- a/models/openid-php-openid-782224d/Tests/Auth/OpenID/MemStore.php +++ /dev/null @@ -1,176 +0,0 @@ -assocs = array(); - } - - function set($assoc) - { - $this->assocs[$assoc->handle] = $assoc; - } - - function get($handle) - { - return Auth_OpenID::arrayGet($this->assocs, $handle); - } - - function remove($handle) - { - if (array_key_exists($handle, $this->assocs)) { - unset($this->assocs[$handle]); - return true; - } else { - return false; - } - } - - /* - * Returns association with the oldest issued date. - * - * or null if there are no associations. - */ - function best() - { - $best = null; - foreach ($this->assocs as $handle => $assoc) { - if (($best === null) || ($best->issued < $assoc->issued)) { - $best = $assoc; - } - } - return $best; - } - - /* - * Remove expired associations. - * - * @return (removed associations, remaining associations) - */ - function cleanup() - { - $remove = array(); - foreach ($this->assocs as $handle => $assoc) { - if ($assoc->getExpiresIn() == 0) { - $remove[] = $handle; - } - } - - foreach ($remove as $handle) { - unset($this->assocs[$handle]); - } - - return array(count($remove), count($this->assocs)); - } -} - -/* - * In-process memory store. - * - * Use for single long-running processes. No persistence supplied. - */ -class Tests_Auth_OpenID_MemStore extends Auth_OpenID_OpenIDStore { - function Tests_Auth_OpenID_MemStore() - { - $this->server_assocs = array(); - $this->nonces = array(); - } - - function &_getServerAssocs($server_url) - { - if (!array_key_exists($server_url, $this->server_assocs)) { - $this->server_assocs[$server_url] = new ServerAssocs(); - } - - return $this->server_assocs[$server_url]; - } - - function storeAssociation($server_url, $assoc) - { - $assocs =& $this->_getServerAssocs($server_url); - $assocs->set($assoc); - } - - function getAssociation($server_url, $handle=null) - { - $assocs =& $this->_getServerAssocs($server_url); - if ($handle === null) { - return $assocs->best(); - } else { - return $assocs->get($handle); - } - } - - function removeAssociation($server_url, $handle) - { - $assocs =& $this->_getServerAssocs($server_url); - return $assocs->remove($handle); - } - - function useNonce($server_url, $timestamp, $salt) - { - global $Auth_OpenID_SKEW; - - if (abs($timestamp - time()) > $Auth_OpenID_SKEW) { - return false; - } - - $anonce = array($server_url, intval($timestamp), $salt); - - if (in_array($anonce, $this->nonces)) { - return false; - } else { - array_push($this->nonces, $anonce); - return true; - } - } - - function cleanupNonces() - { - global $Auth_OpenID_SKEW; - - $now = time(); - $expired = array(); - foreach ($this->nonces as $anonce) { - if (abs($anonce[1] - $now) > $Auth_OpenID_SKEW) { - // removing items while iterating over the set could - // be bad. - $expired[] = $anonce; - } - } - - foreach ($expired as $anonce) { - unset($this->nonces[array_search($anonce, $this->nonces)]); - } - - return count($expired); - } - - function cleanupAssociations() - { - $remove_urls = array(); - $removed_assocs = 0; - foreach ($this->server_assocs as $server_url => $assocs) { - list($removed, $remaining) = $assocs->cleanup(); - $removed_assocs += $removed; - if (!$remaining) { - $remove_urls[] = $server_url; - } - } - - // Remove entries from server_assocs that had none remaining. - foreach ($remove_urls as $server_url) { - unset($this->server_assocs[$server_url]); - } - - return $removed_assocs; - } -} - - -- cgit v1.2.3