12 require_once
"Auth/OpenID/SQLStore.php";
25 $this->sql[
'nonce_table'] =
26 "CREATE TABLE %s (server_url VARCHAR(2047) NOT NULL, ".
27 "timestamp INTEGER NOT NULL, ".
28 "salt CHAR(40) NOT NULL, ".
29 "UNIQUE (server_url, timestamp, salt))";
31 $this->sql[
'assoc_table'] =
32 "CREATE TABLE %s (server_url VARCHAR(2047) NOT NULL, ".
33 "handle VARCHAR(255) NOT NULL, ".
34 "secret BYTEA NOT NULL, ".
35 "issued INTEGER NOT NULL, ".
36 "lifetime INTEGER NOT NULL, ".
37 "assoc_type VARCHAR(64) NOT NULL, ".
38 "PRIMARY KEY (server_url, handle), ".
39 "CONSTRAINT secret_length_constraint CHECK ".
40 "(LENGTH(secret) <= 128))";
42 $this->sql[
'set_assoc'] =
44 'insert_assoc' =>
"INSERT INTO %s (server_url, handle, ".
45 "secret, issued, lifetime, assoc_type) VALUES ".
46 "(?, ?, '!', ?, ?, ?)",
47 'update_assoc' =>
"UPDATE %s SET secret = '!', issued = ?, ".
48 "lifetime = ?, assoc_type = ? WHERE server_url = ? AND ".
52 $this->sql[
'get_assocs'] =
53 "SELECT handle, secret, issued, lifetime, assoc_type FROM %s ".
54 "WHERE server_url = ?";
56 $this->sql[
'get_assoc'] =
57 "SELECT handle, secret, issued, lifetime, assoc_type FROM %s ".
58 "WHERE server_url = ? AND handle = ?";
60 $this->sql[
'remove_assoc'] =
61 "DELETE FROM %s WHERE server_url = ? AND handle = ?";
63 $this->sql[
'add_nonce'] =
64 "INSERT INTO %s (server_url, timestamp, salt) VALUES ".
68 $this->sql[
'clean_nonce'] =
69 "DELETE FROM %s WHERE timestamp < ?";
71 $this->sql[
'clean_assoc'] =
72 "DELETE FROM %s WHERE issued + lifetime < ?";
78 function _set_assoc($server_url, $handle, $secret, $issued, $lifetime,
84 $this->connection->query($this->sql[
'set_assoc'][
'update_assoc'],
85 array($secret, $issued, $lifetime,
86 $assoc_type, $server_url, $handle));
90 $this->connection->query($this->sql[
'set_assoc'][
'insert_assoc'],
91 array($server_url, $handle, $secret,
92 $issued, $lifetime, $assoc_type));