Subversion Repositories Applications.annuaire

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
42 aurelien 1
<?php
2
 
3
/**
4
 * A MySQL store.
5
 *
6
 * @package OpenID
7
 */
8
 
9
/**
10
 * Require the base class file.
11
 */
12
require_once "Auth/OpenID/SQLStore.php";
13
 
14
/**
15
 * An SQL store that uses MySQL as its backend.
16
 *
17
 * @package OpenID
18
 */
19
class Auth_OpenID_MySQLStore extends Auth_OpenID_SQLStore {
20
    /**
21
     * @access private
22
     */
23
    function setSQL()
24
    {
25
        $this->sql['nonce_table'] =
26
            "CREATE TABLE %s (nonce CHAR(8) UNIQUE PRIMARY KEY, ".
27
            "expires INTEGER) TYPE=InnoDB";
28
 
29
        $this->sql['assoc_table'] =
30
            "CREATE TABLE %s (server_url BLOB, handle VARCHAR(255), ".
31
            "secret BLOB, issued INTEGER, lifetime INTEGER, ".
32
            "assoc_type VARCHAR(64), PRIMARY KEY (server_url(255), handle)) ".
33
            "TYPE=InnoDB";
34
 
35
        $this->sql['settings_table'] =
36
            "CREATE TABLE %s (setting VARCHAR(128) UNIQUE PRIMARY KEY, ".
37
            "value BLOB) TYPE=InnoDB";
38
 
39
        $this->sql['create_auth'] =
40
            "INSERT INTO %s VALUES ('auth_key', !)";
41
 
42
        $this->sql['get_auth'] =
43
            "SELECT value FROM %s WHERE setting = 'auth_key'";
44
 
45
        $this->sql['set_assoc'] =
46
            "REPLACE INTO %s VALUES (?, ?, !, ?, ?, ?)";
47
 
48
        $this->sql['get_assocs'] =
49
            "SELECT handle, secret, issued, lifetime, assoc_type FROM %s ".
50
            "WHERE server_url = ?";
51
 
52
        $this->sql['get_assoc'] =
53
            "SELECT handle, secret, issued, lifetime, assoc_type FROM %s ".
54
            "WHERE server_url = ? AND handle = ?";
55
 
56
        $this->sql['remove_assoc'] =
57
            "DELETE FROM %s WHERE server_url = ? AND handle = ?";
58
 
59
        $this->sql['add_nonce'] =
60
            "REPLACE INTO %s (nonce, expires) VALUES (?, ?)";
61
 
62
        $this->sql['get_nonce'] =
63
            "SELECT * FROM %s WHERE nonce = ?";
64
 
65
        $this->sql['remove_nonce'] =
66
            "DELETE FROM %s WHERE nonce = ?";
67
    }
68
 
69
    /**
70
     * @access private
71
     */
72
    function blobEncode($blob)
73
    {
74
        return "0x" . bin2hex($blob);
75
    }
76
}
77
 
78
?>