summaryrefslogtreecommitdiffstats
path: root/Auth/OpenID/SQLStore.php
diff options
context:
space:
mode:
authortailor <cygnus@janrain.com>2006-08-25 22:36:31 +0000
committertailor <cygnus@janrain.com>2006-08-25 22:36:31 +0000
commitc5e1f65fbeaaac13e1b25a166df7b23a2061adb0 (patch)
tree8e06a1591a46274d798c6a12f5aef0a257ff39c7 /Auth/OpenID/SQLStore.php
parent6459176ec9a2c94996fbe14a7428643c7b52e163 (diff)
downloadphp-openid-c5e1f65fbeaaac13e1b25a166df7b23a2061adb0.zip
php-openid-c5e1f65fbeaaac13e1b25a166df7b23a2061adb0.tar.gz
php-openid-c5e1f65fbeaaac13e1b25a166df7b23a2061adb0.tar.bz2
[project @ Server-generated and one-way nonces patch from python openid]
Diffstat (limited to 'Auth/OpenID/SQLStore.php')
-rw-r--r--Auth/OpenID/SQLStore.php73
1 files changed, 7 insertions, 66 deletions
diff --git a/Auth/OpenID/SQLStore.php b/Auth/OpenID/SQLStore.php
index c7bd540..4b4fceb 100644
--- a/Auth/OpenID/SQLStore.php
+++ b/Auth/OpenID/SQLStore.php
@@ -236,9 +236,6 @@ class Auth_OpenID_SQLStore extends Auth_OpenID_OpenIDStore {
'get_assoc',
'get_assocs',
'remove_assoc',
- 'add_nonce',
- 'get_nonce',
- 'remove_nonce'
);
foreach ($required_sql_keys as $key) {
@@ -261,9 +258,7 @@ class Auth_OpenID_SQLStore extends Auth_OpenID_OpenIDStore {
array(
'value' => $this->nonces_table_name,
'keys' => array('nonce_table',
- 'add_nonce',
- 'get_nonce',
- 'remove_nonce')
+ 'add_nonce')
),
array(
'value' => $this->associations_table_name,
@@ -529,72 +524,18 @@ class Auth_OpenID_SQLStore extends Auth_OpenID_OpenIDStore {
/**
* @access private
*/
- function _add_nonce($nonce, $expires)
+ function _add_nonce($server_url, $timestamp, $salt)
{
$sql = $this->sql['add_nonce'];
- $result = $this->connection->query($sql, array($nonce, $expires));
+ $result = $this->connection->query($sql, array($server_url,
+ $timestamp,
+ $salt));
return $this->resultToBool($result);
}
- /**
- * @access private
- */
- function storeNonce($nonce)
- {
- if ($this->_add_nonce($nonce, time())) {
- $this->connection->commit();
- } else {
- $this->connection->rollback();
- }
- }
-
- /**
- * @access private
- */
- function _get_nonce($nonce)
- {
- $result = $this->connection->getRow($this->sql['get_nonce'],
- array($nonce));
-
- if ($this->isError($result)) {
- return null;
- } else {
- return $result;
- }
- }
-
- /**
- * @access private
- */
- function _remove_nonce($nonce)
+ function useNonce($server_url, $timestamp, $salt)
{
- $this->connection->query($this->sql['remove_nonce'],
- array($nonce));
- }
-
- function useNonce($nonce)
- {
- $row = $this->_get_nonce($nonce);
-
- if ($row !== null) {
- $nonce = $row['nonce'];
- $timestamp = $row['expires'];
- $nonce_age = time() - $timestamp;
-
- if ($nonce_age > $this->max_nonce_age) {
- $present = 0;
- } else {
- $present = 1;
- }
-
- $this->_remove_nonce($nonce);
- } else {
- $present = 0;
- }
-
- $this->connection->commit();
-
- return $present;
+ return $this->_add_nonce($server_url, $timestamp, $salt);
}
/**