summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortailor <cygnus@janrain.com>2006-02-14 23:01:07 +0000
committertailor <cygnus@janrain.com>2006-02-14 23:01:07 +0000
commitecce27920ed37b53efe31d451b21c94ae90919d8 (patch)
tree0e71b226fab1b3e020e4af2c0b1c2becbc311b2b
parent1956fe224e7158d066c0871a7e9d6bacaa132fb9 (diff)
downloadphp-openid-ecce27920ed37b53efe31d451b21c94ae90919d8.zip
php-openid-ecce27920ed37b53efe31d451b21c94ae90919d8.tar.gz
php-openid-ecce27920ed37b53efe31d451b21c94ae90919d8.tar.bz2
[project @ Moved MySQL store into its own file.]
-rw-r--r--Auth/OpenID/MySQLStore.php78
-rw-r--r--Auth/OpenID/SQLStore.php64
-rw-r--r--Tests/Auth/OpenID/StoreTest.php2
3 files changed, 79 insertions, 65 deletions
diff --git a/Auth/OpenID/MySQLStore.php b/Auth/OpenID/MySQLStore.php
new file mode 100644
index 0000000..f89afc6
--- /dev/null
+++ b/Auth/OpenID/MySQLStore.php
@@ -0,0 +1,78 @@
+<?php
+
+/**
+ * A MySQL store.
+ *
+ * @package OpenID
+ */
+
+/**
+ * Require the base class file.
+ */
+require_once "Auth/OpenID/SQLStore.php";
+
+/**
+ * An SQL store that uses MySQL as its backend.
+ *
+ * @package OpenID
+ */
+class Auth_OpenID_MySQLStore extends Auth_OpenID_SQLStore {
+ /**
+ * @access private
+ */
+ function setSQL()
+ {
+ $this->sql['nonce_table'] =
+ "CREATE TABLE %s (nonce CHAR(8) UNIQUE PRIMARY KEY, ".
+ "expires INTEGER) TYPE=InnoDB";
+
+ $this->sql['assoc_table'] =
+ "CREATE TABLE %s (server_url BLOB, handle VARCHAR(255), ".
+ "secret BLOB, issued INTEGER, lifetime INTEGER, ".
+ "assoc_type VARCHAR(64), PRIMARY KEY (server_url(255), handle)) ".
+ "TYPE=InnoDB";
+
+ $this->sql['settings_table'] =
+ "CREATE TABLE %s (setting VARCHAR(128) UNIQUE PRIMARY KEY, ".
+ "value BLOB) TYPE=InnoDB";
+
+ $this->sql['create_auth'] =
+ "INSERT INTO %s VALUES ('auth_key', !)";
+
+ $this->sql['get_auth'] =
+ "SELECT value FROM %s WHERE setting = 'auth_key'";
+
+ $this->sql['set_assoc'] =
+ "REPLACE INTO %s VALUES (?, ?, !, ?, ?, ?)";
+
+ $this->sql['get_assocs'] =
+ "SELECT handle, secret, issued, lifetime, assoc_type FROM %s ".
+ "WHERE server_url = ?";
+
+ $this->sql['get_assoc'] =
+ "SELECT handle, secret, issued, lifetime, assoc_type FROM %s ".
+ "WHERE server_url = ? AND handle = ?";
+
+ $this->sql['remove_assoc'] =
+ "DELETE FROM %s WHERE server_url = ? AND handle = ?";
+
+ $this->sql['add_nonce'] =
+ "REPLACE INTO %s (nonce, expires) VALUES (?, ?)";
+
+ $this->sql['get_nonce'] =
+ "SELECT * FROM %s WHERE nonce = ?";
+
+ $this->sql['remove_nonce'] =
+ "DELETE FROM %s WHERE nonce = ?";
+ }
+
+ /**
+ * @access private
+ */
+ function blobEncode($blob)
+ {
+ return "0x" . bin2hex($blob);
+ }
+}
+
+?> \ No newline at end of file
diff --git a/Auth/OpenID/SQLStore.php b/Auth/OpenID/SQLStore.php
index 3025349..7811923 100644
--- a/Auth/OpenID/SQLStore.php
+++ b/Auth/OpenID/SQLStore.php
@@ -630,68 +630,4 @@ class Auth_OpenID_SQLStore extends Auth_OpenID_OpenIDStore {
}
}
-/**
- * An SQL store that uses MySQL as its backend.
- *
- * @package OpenID
- */
-class Auth_OpenID_MySQLStore extends Auth_OpenID_SQLStore {
- /**
- * @access private
- */
- function setSQL()
- {
- $this->sql['nonce_table'] =
- "CREATE TABLE %s (nonce CHAR(8) UNIQUE PRIMARY KEY, ".
- "expires INTEGER) TYPE=InnoDB";
-
- $this->sql['assoc_table'] =
- "CREATE TABLE %s (server_url BLOB, handle VARCHAR(255), ".
- "secret BLOB, issued INTEGER, lifetime INTEGER, ".
- "assoc_type VARCHAR(64), PRIMARY KEY (server_url(255), handle)) ".
- "TYPE=InnoDB";
-
- $this->sql['settings_table'] =
- "CREATE TABLE %s (setting VARCHAR(128) UNIQUE PRIMARY KEY, ".
- "value BLOB) TYPE=InnoDB";
-
- $this->sql['create_auth'] =
- "INSERT INTO %s VALUES ('auth_key', !)";
-
- $this->sql['get_auth'] =
- "SELECT value FROM %s WHERE setting = 'auth_key'";
-
- $this->sql['set_assoc'] =
- "REPLACE INTO %s VALUES (?, ?, !, ?, ?, ?)";
-
- $this->sql['get_assocs'] =
- "SELECT handle, secret, issued, lifetime, assoc_type FROM %s ".
- "WHERE server_url = ?";
-
- $this->sql['get_assoc'] =
- "SELECT handle, secret, issued, lifetime, assoc_type FROM %s ".
- "WHERE server_url = ? AND handle = ?";
-
- $this->sql['remove_assoc'] =
- "DELETE FROM %s WHERE server_url = ? AND handle = ?";
-
- $this->sql['add_nonce'] =
- "REPLACE INTO %s (nonce, expires) VALUES (?, ?)";
-
- $this->sql['get_nonce'] =
- "SELECT * FROM %s WHERE nonce = ?";
-
- $this->sql['remove_nonce'] =
- "DELETE FROM %s WHERE nonce = ?";
- }
-
- /**
- * @access private
- */
- function blobEncode($blob)
- {
- return "0x" . bin2hex($blob);
- }
-}
-
?>
diff --git a/Tests/Auth/OpenID/StoreTest.php b/Tests/Auth/OpenID/StoreTest.php
index 3917c0e..11b9bd5 100644
--- a/Tests/Auth/OpenID/StoreTest.php
+++ b/Tests/Auth/OpenID/StoreTest.php
@@ -472,7 +472,7 @@ explicitly');
return;
}
- require_once 'Auth/OpenID/SQLStore.php';
+ require_once 'Auth/OpenID/MySQLStore.php';
require_once 'DB.php';
global $_Auth_OpenID_db_test_host;