ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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. More...
 
 storeAssociation ($server_url, $association)
 Store association until its expiration time in memcached. More...
 
 getAssociation ($server_url, $handle=null)
 Read association from memcached. More...
 
 removeAssociation ($server_url, $handle)
 Immediately delete association from memcache. More...
 
 useNonce ($server_url, $timestamp, $salt)
 Create nonce for server and salt, expiring after $Auth_OpenID_SKEW seconds. More...
 
 associationKey ($server_url, $handle=null)
 Memcache key is prefixed with 'openid_association_' string. More...
 
 associationServerKey ($server_url)
 Memcache key is prefixed with 'openid_association_' string. More...
 
 supportsCleanup ()
 Report that this storage doesn't support cleanup. More...
 
- Public Member Functions inherited from Auth_OpenID_OpenIDStore
 storeAssociation ($server_url, $association)
 This method puts an Association object into storage, retrievable by server URL and handle. More...
 
 cleanupNonces ()
 
 cleanupAssociations ()
 
 cleanup ()
 
 supportsCleanup ()
 Report whether this storage supports cleanup. More...
 
 getAssociation ($server_url, $handle=null)
 This method returns an Association object from storage that matches the server URL and, if specified, handle. More...
 
 removeAssociation ($server_url, $handle)
 This method removes the matching association if it's found, and returns whether the association was removed or not. More...
 
 useNonce ($server_url, $timestamp, $salt)
 Called when using a nonce. More...
 
 reset ()
 Removes all entries from the store; implementation is optional. More...
 

Detailed Description

Definition at line 36 of file MemcachedStore.php.

Member Function Documentation

◆ associationKey()

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

Memcache key is prefixed with 'openid_association_' string.

Definition at line 186 of file MemcachedStore.php.

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

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

+ Here is the caller graph for this function:

◆ associationServerKey()

Auth_OpenID_MemcachedStore::associationServerKey (   $server_url)

Memcache key is prefixed with 'openid_association_' string.

Definition at line 194 of file MemcachedStore.php.

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

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

+ Here is the caller graph for this function:

◆ Auth_OpenID_MemcachedStore()

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.

45 {
46 $this->connection = $connection;
47 $this->compress = $compress ? MEMCACHE_COMPRESSED : 0;
48 }

◆ getAssociation()

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.

92 {
93 // simple case: handle given
94 if ($handle !== null) {
95 // get association, return null if failed
96 $association = $this->connection->get(
97 $this->associationKey($server_url, $handle));
98 return $association ? $association : null;
99 }
100
101 // no handle given, working with list
102 // create key for list of associations
103 $serverKey = $this->associationServerKey($server_url);
104
105 // get list of associations
106 $serverAssociations = $this->connection->get($serverKey);
107 // return null if failed or got empty list
108 if (!$serverAssociations) {
109 return null;
110 }
111
112 // get key of most recently issued association
113 $keys = array_keys($serverAssociations);
114 sort($keys);
115 $lastKey = $serverAssociations[array_pop($keys)];
116
117 // get association, return null if failed
118 $association = $this->connection->get($lastKey);
119 return $association ? $association : null;
120 }
associationKey($server_url, $handle=null)
Memcache key is prefixed with 'openid_association_' string.
associationServerKey($server_url)
Memcache key is prefixed with 'openid_association_' string.

References associationKey(), and associationServerKey().

+ Here is the call graph for this function:

◆ removeAssociation()

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.

126 {
127 // create memcached keys for association itself
128 // and list of associations for this server
129 $serverKey = $this->associationServerKey($server_url);
130 $associationKey = $this->associationKey($server_url,
131 $handle);
132
133 // get list of associations
134 $serverAssociations = $this->connection->get($serverKey);
135 // return null if failed or got empty list
136 if (!$serverAssociations) {
137 return false;
138 }
139
140 // ensure that given association key exists in list
141 $serverAssociations = array_flip($serverAssociations);
142 if (!array_key_exists($associationKey, $serverAssociations)) {
143 return false;
144 }
145
146 // remove given association key from list
147 unset($serverAssociations[$associationKey]);
148 $serverAssociations = array_flip($serverAssociations);
149
150 // save updated list
151 $this->connection->set(
152 $serverKey,
153 $serverAssociations,
154 $this->compress
155 );
156
157 // delete association
158 return $this->connection->delete($associationKey);
159 }

References associationKey(), and associationServerKey().

+ Here is the call graph for this function:

◆ storeAssociation()

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.

56 {
57 // create memcached keys for association itself
58 // and list of associations for this server
59 $associationKey = $this->associationKey($server_url,
60 $association->handle);
61 $serverKey = $this->associationServerKey($server_url);
62
63 // get list of associations
64 $serverAssociations = $this->connection->get($serverKey);
65
66 // if no such list, initialize it with empty array
67 if (!$serverAssociations) {
68 $serverAssociations = array();
69 }
70 // and store given association key in it
71 $serverAssociations[$association->issued] = $associationKey;
72
73 // save associations' keys list
74 $this->connection->set(
75 $serverKey,
76 $serverAssociations,
77 $this->compress
78 );
79 // save association itself
80 $this->connection->set(
81 $associationKey,
82 $association,
83 $this->compress,
84 $association->issued + $association->lifetime);
85 }

References associationKey(), and associationServerKey().

+ Here is the call graph for this function:

◆ supportsCleanup()

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.

203 {
204 return false;
205 }

◆ useNonce()

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.

166 {
167 global $Auth_OpenID_SKEW;
168
169 // save one request to memcache when nonce obviously expired
170 if (abs($timestamp - time()) > $Auth_OpenID_SKEW) {
171 return false;
172 }
173
174 // returns false when nonce already exists
175 // otherwise adds nonce
176 return $this->connection->add(
177 'openid_nonce_' . sha1($server_url) . '_' . sha1($salt),
178 1, // any value here
179 $this->compress,
181 }
global $Auth_OpenID_SKEW
Definition: Nonce.php:23
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:81

References $Auth_OpenID_SKEW, and $timestamp.


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