|
| Auth_OpenID_MDB2Store ($connection, $associations_table=null, $nonces_table=null) |
| This creates a new MDB2Store instance. More...
|
|
| tableExists ($table_name) |
|
| createTables () |
|
| create_nonce_table () |
|
| create_assoc_table () |
|
| storeAssociation ($server_url, $association) |
|
| cleanupNonces () |
|
| cleanupAssociations () |
|
| getAssociation ($server_url, $handle=null) |
|
| removeAssociation ($server_url, $handle) |
|
| useNonce ($server_url, $timestamp, $salt) |
|
| reset () |
| Resets the store by removing all records from the store's tables. More...
|
|
| 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...
|
|
Definition at line 46 of file MDB2Store.php.
◆ Auth_OpenID_MDB2Store()
Auth_OpenID_MDB2Store::Auth_OpenID_MDB2Store |
( |
|
$connection, |
|
|
|
$associations_table = null , |
|
|
|
$nonces_table = null |
|
) |
| |
This creates a new MDB2Store instance.
It requires an established database connection be given to it, and it allows overriding the default table names.
- Parameters
-
connection | $connection | This must be an established connection to a database of the correct type for the SQLStore subclass you're using. This must be a PEAR::MDB2 connection handle. |
| associations_table | This is an optional parameter to specify the name of the table used for storing associations. The default value is 'oid_associations'. |
| nonces_table | This is an optional parameter to specify the name of the table used for storing nonces. The default value is 'oid_nonces'. |
Definition at line 65 of file MDB2Store.php.
References PEAR\isError(), and MDB2_FETCHMODE_ASSOC.
69 $this->associations_table_name =
"oid_associations";
70 $this->nonces_table_name =
"oid_nonces";
74 if (!is_object($connection) ||
75 !is_subclass_of($connection,
'mdb2_driver_common')) {
76 trigger_error(
"Auth_OpenID_MDB2Store expected PEAR connection " .
77 "object (got ".get_class($connection).
")",
82 $this->connection = $connection;
88 if (
PEAR::isError($this->connection->loadModule(
'Extended'))) {
89 trigger_error(
"Unable to load MDB2_Extended module", E_USER_ERROR);
93 if ($associations_table) {
94 $this->associations_table_name = $associations_table;
98 $this->nonces_table_name = $nonces_table;
101 $this->max_nonce_age = 6 * 60 * 60;
const MDB2_FETCHMODE_ASSOC
Column data indexed by column names.
isError($data, $code=null)
Tell whether a value is a PEAR error.
◆ cleanupAssociations()
Auth_OpenID_MDB2Store::cleanupAssociations |
( |
| ) |
|
Definition at line 311 of file MDB2Store.php.
313 return $this->connection->exec(
314 sprintf(
"DELETE FROM %s WHERE issued + lifetime < %d",
315 $this->associations_table_name, time()));
◆ cleanupNonces()
Auth_OpenID_MDB2Store::cleanupNonces |
( |
| ) |
|
Definition at line 301 of file MDB2Store.php.
References $Auth_OpenID_SKEW.
306 return $this->connection->exec(
307 sprintf(
"DELETE FROM %s WHERE timestamp < %d",
308 $this->nonces_table_name, $v));
◆ create_assoc_table()
Auth_OpenID_MDB2Store::create_assoc_table |
( |
| ) |
|
Definition at line 192 of file MDB2Store.php.
References $options, $r, PEAR\isError(), and tableExists().
Referenced by createTables().
194 if (!$this->
tableExists($this->associations_table_name)) {
195 switch ($this->connection->phptype) {
200 $r = $this->connection->exec(
201 sprintf(
"CREATE TABLE %s(\n".
202 " server_url VARCHAR(2047) NOT NULL DEFAULT '',\n".
203 " handle VARCHAR(255) NOT NULL,\n".
204 " secret BLOB NOT NULL,\n".
205 " issued INTEGER NOT NULL,\n".
206 " lifetime INTEGER NOT NULL,\n".
207 " assoc_type VARCHAR(64) NOT NULL,\n".
208 " PRIMARY KEY (server_url(255), handle)\n".
210 $this->associations_table_name));
217 $this->connection->loadModule(
'Manager'))) {
221 "server_url" => array(
244 "assoc_type" => array(
252 "server_url" =>
true,
257 $r = $this->connection->createTable(
258 $this->associations_table_name,
if(!is_array($argv)) $options
isError($data, $code=null)
Tell whether a value is a PEAR error.
◆ create_nonce_table()
Auth_OpenID_MDB2Store::create_nonce_table |
( |
| ) |
|
Definition at line 122 of file MDB2Store.php.
References $r, PEAR\isError(), and tableExists().
Referenced by createTables().
124 if (!$this->
tableExists($this->nonces_table_name)) {
125 switch ($this->connection->phptype) {
130 $r = $this->connection->exec(
131 sprintf(
"CREATE TABLE %s (\n".
132 " server_url VARCHAR(2047) NOT NULL DEFAULT '',\n".
133 " timestamp INTEGER NOT NULL,\n".
134 " salt CHAR(40) NOT NULL,\n".
135 " UNIQUE (server_url(255), timestamp, salt)\n".
137 $this->nonces_table_name));
144 $this->connection->loadModule(
'Manager'))) {
148 "server_url" => array(
153 "timestamp" => array(
167 "server_url" =>
true,
173 $r = $this->connection->createTable($this->nonces_table_name,
179 $r = $this->connection->createConstraint(
180 $this->nonces_table_name,
181 $this->nonces_table_name .
"_constraint",
isError($data, $code=null)
Tell whether a value is a PEAR error.
◆ createTables()
Auth_OpenID_MDB2Store::createTables |
( |
| ) |
|
◆ getAssociation()
Auth_OpenID_MDB2Store::getAssociation |
( |
|
$server_url, |
|
|
|
$handle = null |
|
) |
| |
Definition at line 318 of file MDB2Store.php.
References PEAR\isError().
329 if ($handle !== null) {
330 $sql = sprintf(
"SELECT handle, secret, issued, lifetime, assoc_type " .
331 "FROM %s WHERE server_url = ? AND handle = ?",
332 $this->associations_table_name);
333 $params = array($server_url, $handle);
335 $sql = sprintf(
"SELECT handle, secret, issued, lifetime, assoc_type " .
336 "FROM %s WHERE server_url = ? ORDER BY issued DESC",
337 $this->associations_table_name);
338 $params = array($server_url);
341 $assoc = $this->connection->getRow($sql, $types, $params);
351 $assoc[
'assoc_type']);
352 fclose($assoc[
'secret']);
isError($data, $code=null)
Tell whether a value is a PEAR error.
◆ removeAssociation()
Auth_OpenID_MDB2Store::removeAssociation |
( |
|
$server_url, |
|
|
|
$handle |
|
) |
| |
Definition at line 357 of file MDB2Store.php.
References $r, and PEAR\isError().
359 $r = $this->connection->execParam(
360 sprintf(
"DELETE FROM %s WHERE server_url = ? AND handle = ?",
361 $this->associations_table_name),
362 array($server_url, $handle));
isError($data, $code=null)
Tell whether a value is a PEAR error.
◆ reset()
Auth_OpenID_MDB2Store::reset |
( |
| ) |
|
Resets the store by removing all records from the store's tables.
Definition at line 402 of file MDB2Store.php.
404 $this->connection->query(sprintf(
"DELETE FROM %s",
405 $this->associations_table_name));
407 $this->connection->query(sprintf(
"DELETE FROM %s",
408 $this->nonces_table_name));
◆ storeAssociation()
Auth_OpenID_MDB2Store::storeAssociation |
( |
|
$server_url, |
|
|
|
$association |
|
) |
| |
Definition at line 270 of file MDB2Store.php.
References PEAR\isError().
273 "server_url" => array(
274 "value" => $server_url,
278 "value" => $association->handle,
282 "value" => $association->secret,
286 "value" => $association->issued
289 "value" => $association->lifetime
291 "assoc_type" => array(
292 "value" => $association->assoc_type
297 $this->associations_table_name,
isError($data, $code=null)
Tell whether a value is a PEAR error.
◆ tableExists()
Auth_OpenID_MDB2Store::tableExists |
( |
|
$table_name | ) |
|
◆ useNonce()
Auth_OpenID_MDB2Store::useNonce |
( |
|
$server_url, |
|
|
|
$timestamp, |
|
|
|
$salt |
|
) |
| |
Definition at line 370 of file MDB2Store.php.
References $Auth_OpenID_SKEW, $r, $timestamp, PEAR\isError(), and MDB2_AUTOQUERY_INSERT.
374 if (abs(
$timestamp - time()) > $Auth_OpenID_SKEW ) {
383 if (!empty($server_url)) {
384 $fields[
"server_url"] = $server_url;
387 $r = $this->connection->autoExecute(
388 $this->nonces_table_name,
foreach($mandatory_scripts as $file) $timestamp
const MDB2_AUTOQUERY_INSERT
Used by autoPrepare()
isError($data, $code=null)
Tell whether a value is a PEAR error.
The documentation for this class was generated from the following file: