ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
Auth_OpenID_MemcachedStore Class Reference
+ Inheritance diagram for Auth_OpenID_MemcachedStore:
+ Collaboration diagram for Auth_OpenID_MemcachedStore:

Public Member Functions

 Auth_OpenID_MemcachedStore ($connection, $compress=false)
 Initializes a new Auth_OpenID_MemcachedStore instance.
 storeAssociation ($server_url, $association)
 Store association until its expiration time in memcached.
 getAssociation ($server_url, $handle=null)
 Read association from memcached.
 removeAssociation ($server_url, $handle)
 Immediately delete association from memcache.
 useNonce ($server_url, $timestamp, $salt)
 Create nonce for server and salt, expiring after $Auth_OpenID_SKEW seconds.
 associationKey ($server_url, $handle=null)
 Memcache key is prefixed with 'openid_association_' string.
 associationServerKey ($server_url)
 Memcache key is prefixed with 'openid_association_' string.
 supportsCleanup ()
 Report that this storage doesn't support cleanup.
- Public Member Functions inherited from Auth_OpenID_OpenIDStore
 cleanupNonces ()
 cleanupAssociations ()
 cleanup ()
 reset ()
 Removes all entries from the store; implementation is optional.

Detailed Description

Definition at line 36 of file MemcachedStore.php.

Member Function Documentation

Auth_OpenID_MemcachedStore::associationKey (   $server_url,
  $handle = null 
)

Memcache key is prefixed with 'openid_association_' string.

Definition at line 186 of file MemcachedStore.php.

Referenced by getAssociation(), removeAssociation(), and storeAssociation().

{
return 'openid_association_' . sha1($server_url) . '_' . sha1($handle);
}

+ Here is the caller graph for this function:

Auth_OpenID_MemcachedStore::associationServerKey (   $server_url)

Memcache key is prefixed with 'openid_association_' string.

Definition at line 194 of file MemcachedStore.php.

Referenced by getAssociation(), removeAssociation(), and storeAssociation().

{
return 'openid_association_server_' . sha1($server_url);
}

+ Here is the caller graph for this function:

Auth_OpenID_MemcachedStore::Auth_OpenID_MemcachedStore (   $connection,
  $compress = false 
)

Initializes a new Auth_OpenID_MemcachedStore instance.

Just saves memcached object as property.

Parameters
resourceconnection Memcache connection resourse

Definition at line 44 of file MemcachedStore.php.

{
$this->connection = $connection;
$this->compress = $compress ? MEMCACHE_COMPRESSED : 0;
}
Auth_OpenID_MemcachedStore::getAssociation (   $server_url,
  $handle = null 
)

Read association from memcached.

If no handle given and multiple associations found, returns latest issued

Reimplemented from Auth_OpenID_OpenIDStore.

Definition at line 91 of file MemcachedStore.php.

References associationKey(), and associationServerKey().

{
// simple case: handle given
if ($handle !== null) {
// get association, return null if failed
$association = $this->connection->get(
$this->associationKey($server_url, $handle));
return $association ? $association : null;
}
// no handle given, working with list
// create key for list of associations
$serverKey = $this->associationServerKey($server_url);
// get list of associations
$serverAssociations = $this->connection->get($serverKey);
// return null if failed or got empty list
if (!$serverAssociations) {
return null;
}
// get key of most recently issued association
$keys = array_keys($serverAssociations);
sort($keys);
$lastKey = $serverAssociations[array_pop($keys)];
// get association, return null if failed
$association = $this->connection->get($lastKey);
return $association ? $association : null;
}

+ Here is the call graph for this function:

Auth_OpenID_MemcachedStore::removeAssociation (   $server_url,
  $handle 
)

Immediately delete association from memcache.

Reimplemented from Auth_OpenID_OpenIDStore.

Definition at line 125 of file MemcachedStore.php.

References associationKey(), and associationServerKey().

{
// create memcached keys for association itself
// and list of associations for this server
$serverKey = $this->associationServerKey($server_url);
$associationKey = $this->associationKey($server_url,
$handle);
// get list of associations
$serverAssociations = $this->connection->get($serverKey);
// return null if failed or got empty list
if (!$serverAssociations) {
return false;
}
// ensure that given association key exists in list
$serverAssociations = array_flip($serverAssociations);
if (!array_key_exists($associationKey, $serverAssociations)) {
return false;
}
// remove given association key from list
unset($serverAssociations[$associationKey]);
$serverAssociations = array_flip($serverAssociations);
// save updated list
$this->connection->set(
$serverKey,
$serverAssociations,
$this->compress
);
// delete association
return $this->connection->delete($associationKey);
}

+ Here is the call graph for this function:

Auth_OpenID_MemcachedStore::storeAssociation (   $server_url,
  $association 
)

Store association until its expiration time in memcached.

Overwrites any existing association with same server_url and handle. Handles list of associations for every server.

Reimplemented from Auth_OpenID_OpenIDStore.

Definition at line 55 of file MemcachedStore.php.

References associationKey(), and associationServerKey().

{
// create memcached keys for association itself
// and list of associations for this server
$associationKey = $this->associationKey($server_url,
$association->handle);
$serverKey = $this->associationServerKey($server_url);
// get list of associations
$serverAssociations = $this->connection->get($serverKey);
// if no such list, initialize it with empty array
if (!$serverAssociations) {
$serverAssociations = array();
}
// and store given association key in it
$serverAssociations[$association->issued] = $associationKey;
// save associations' keys list
$this->connection->set(
$serverKey,
$serverAssociations,
$this->compress
);
// save association itself
$this->connection->set(
$associationKey,
$association,
$this->compress,
$association->issued + $association->lifetime);
}

+ Here is the call graph for this function:

Auth_OpenID_MemcachedStore::supportsCleanup ( )

Report that this storage doesn't support cleanup.

Reimplemented from Auth_OpenID_OpenIDStore.

Definition at line 202 of file MemcachedStore.php.

{
return false;
}
Auth_OpenID_MemcachedStore::useNonce (   $server_url,
  $timestamp,
  $salt 
)

Create nonce for server and salt, expiring after $Auth_OpenID_SKEW seconds.

Reimplemented from Auth_OpenID_OpenIDStore.

Definition at line 165 of file MemcachedStore.php.

References $Auth_OpenID_SKEW, and $timestamp.

{
// save one request to memcache when nonce obviously expired
if (abs($timestamp - time()) > $Auth_OpenID_SKEW) {
return false;
}
// returns false when nonce already exists
// otherwise adds nonce
return $this->connection->add(
'openid_nonce_' . sha1($server_url) . '_' . sha1($salt),
1, // any value here
$this->compress,
$Auth_OpenID_SKEW);
}

The documentation for this class was generated from the following file: