[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/libraries/openid/Auth/OpenID/ -> PostgreSQLStore.php (source)

   1  <?php
   2  
   3  /**
   4   * A PostgreSQL store.
   5   *
   6   * @package OpenID
   7   */
   8  
   9  // Do not allow direct access
  10  defined( '_JEXEC' ) or die( 'Restricted access' );
  11  
  12  /**
  13   * Require the base class file.
  14   */
  15  require_once "Auth/OpenID/SQLStore.php";
  16  
  17  /**
  18   * An SQL store that uses PostgreSQL as its backend.
  19   *
  20   * @package OpenID
  21   */
  22  class Auth_OpenID_PostgreSQLStore extends Auth_OpenID_SQLStore {
  23      /**
  24       * @access private
  25       */
  26      function setSQL()
  27      {
  28          $this->sql['nonce_table'] =
  29              "CREATE TABLE %s (server_url VARCHAR(2047) NOT NULL, ".
  30                               "timestamp INTEGER NOT NULL, ".
  31                               "salt CHAR(40) NOT NULL, ".
  32                  "UNIQUE (server_url, timestamp, salt))";
  33  
  34          $this->sql['assoc_table'] =
  35              "CREATE TABLE %s (server_url VARCHAR(2047) NOT NULL, ". 
  36                               "handle VARCHAR(255) NOT NULL, ".
  37                               "secret BYTEA NOT NULL, ".
  38                               "issued INTEGER NOT NULL, ".
  39                               "lifetime INTEGER NOT NULL, ".
  40                               "assoc_type VARCHAR(64) NOT NULL, ".
  41              "PRIMARY KEY (server_url, handle), ".
  42              "CONSTRAINT secret_length_constraint CHECK ".
  43              "(LENGTH(secret) <= 128))";
  44  
  45          $this->sql['set_assoc'] =
  46              array(
  47                    'insert_assoc' => "INSERT INTO %s (server_url, handle, ".
  48                    "secret, issued, lifetime, assoc_type) VALUES ".
  49                    "(?, ?, '!', ?, ?, ?)",
  50                    'update_assoc' => "UPDATE %s SET secret = '!', issued = ?, ".
  51                    "lifetime = ?, assoc_type = ? WHERE server_url = ? AND ".
  52                    "handle = ?"
  53                    );
  54  
  55          $this->sql['get_assocs'] =
  56              "SELECT handle, secret, issued, lifetime, assoc_type FROM %s ".
  57              "WHERE server_url = ?";
  58  
  59          $this->sql['get_assoc'] =
  60              "SELECT handle, secret, issued, lifetime, assoc_type FROM %s ".
  61              "WHERE server_url = ? AND handle = ?";
  62  
  63          $this->sql['remove_assoc'] =
  64              "DELETE FROM %s WHERE server_url = ? AND handle = ?";
  65  
  66          $this->sql['add_nonce'] =
  67                    "INSERT INTO %s (server_url, timestamp, salt) VALUES ".
  68                    "(?, ?, ?)"
  69                    ;
  70  
  71          $this->sql['clean_nonce'] =
  72              "DELETE FROM %s WHERE timestamp < ?";
  73  
  74          $this->sql['clean_assoc'] =
  75              "DELETE FROM %s WHERE issued + lifetime < ?";
  76      }
  77  
  78      /**
  79       * @access private
  80       */
  81      function _set_assoc($server_url, $handle, $secret, $issued, $lifetime,
  82                          $assoc_type)
  83      {
  84          $result = $this->_get_assoc($server_url, $handle);
  85          if ($result) {
  86              // Update the table since this associations already exists.
  87              $this->connection->query($this->sql['set_assoc']['update_assoc'],
  88                                       array($secret, $issued, $lifetime,
  89                                             $assoc_type, $server_url, $handle));
  90          } else {
  91              // Insert a new record because this association wasn't
  92              // found.
  93              $this->connection->query($this->sql['set_assoc']['insert_assoc'],
  94                                       array($server_url, $handle, $secret,
  95                                             $issued, $lifetime, $assoc_type));
  96          }
  97      }
  98  
  99      /**
 100       * @access private
 101       */
 102      function blobEncode($blob)
 103      {
 104          return $this->_octify($blob);
 105      }
 106  
 107      /**
 108       * @access private
 109       */
 110      function blobDecode($blob)
 111      {
 112          return $this->_unoctify($blob);
 113      }
 114  }
 115  
 116  ?>


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1