This is the parent class for the SQL stores, which contains the
logic common to all of the SQL stores.
The table names used are determined by the class variables
associations_table_name and nonces_table_name. To change the name
of the tables used, pass new table names into the constructor.
To create the tables with the proper schema, see the createTables
method.
This class shouldn't be used directly. Use one of its subclasses
instead, as those contain the code necessary to use a specific
database. If you're an OpenID integrator and you'd like to create
an SQL-driven store that wraps an application's database
abstraction, be sure to create a subclass of
Auth_OpenID_DatabaseConnection
that calls the application's
database abstraction calls. Then, pass an instance of your new
database connection class to your SQLStore subclass constructor.
All methods other than the constructor and createTables should be
considered implementation details.
Methods summary
public
|
#
Auth_OpenID_SQLStore( connection $connection, associations_table: $associations_table = null, nonces_table: $nonces_table = null )
This creates a new SQLStore instance. It requires an
established database connection be given to it, and it allows
overriding the default table names.
This creates a new SQLStore instance. It requires an
established database connection be given to it, and it allows
overriding the default table names.
Parameters
- $connection
This must be an established
connection to a database of the correct type for the SQLStore
subclass you're using. This must either be an PEAR DB
connection handle or an instance of a subclass of
Auth_OpenID_DatabaseConnection.
- $associations_table
is an optional parameter to
specify the name of the table used for storing associations.
The default value is 'oid_associations'.
- $nonces_table
is an optional parameter to specify
the name of the table used for storing nonces. The default
value is 'oid_nonces'.
|
public
|
|
public
|
#
isError( $value )
Returns true if $value constitutes a database error; returns
false otherwise.
Returns true if $value constitutes a database error; returns
false otherwise.
|
public
|
#
resultToBool( $obj )
Converts a query result to a boolean. If the result is a
database error according to $this->isError(), this returns
false; otherwise, this returns true.
Converts a query result to a boolean. If the result is a
database error according to $this->isError(), this returns
false; otherwise, this returns true.
|
public
|
#
setSQL( )
This method should be overridden by subclasses. This method is
called by the constructor to set values in $this->sql, which is
an array keyed on sql name.
This method should be overridden by subclasses. This method is
called by the constructor to set values in $this->sql, which is
an array keyed on sql name.
|
public
|
#
reset( )
Resets the store by removing all records from the store's
tables.
Resets the store by removing all records from the store's
tables.
Overrides
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
#
_set_assoc( $server_url, $handle, $secret, $issued, $lifetime, $assoc_type )
|
public
|
#
storeAssociation( string $server_url, Association $association )
This method puts an Association object into storage,
retrievable by server URL and handle.
This method puts an Association object into storage,
retrievable by server URL and handle.
Parameters
- $server_url
The URL of the identity server that
this association is with. Because of the way the server portion
of the library uses this interface, don't assume there are any
limitations on the character set of the input string. In
particular, expect to see unescaped non-url-safe characters in
the server_url field.
- $association
- The Association to store.
Overrides
|
public
|
|
public
|
|
public
mixed
|
#
removeAssociation( string $server_url, string $handle )
This method removes the matching association if it's found, and
returns whether the association was removed or not.
This method removes the matching association if it's found, and
returns whether the association was removed or not.
Parameters
- $server_url
The URL of the identity server the
association to remove belongs to. Because of the way the server
portion of the library uses this interface, don't assume there
are any limitations on the character set of the input
string. In particular, expect to see unescaped non-url-safe
characters in the server_url field.
- $handle
This is the handle of the association to
remove. If there isn't an association found that matches both
the given URL and handle, then there was no matching handle
found.
Returns
mixed Returns whether or not the given association existed.
Overrides
|
public
Association
|
#
getAssociation( string $server_url, mixed $handle = null )
This method returns an Association object from storage that
matches the server URL and, if specified, handle. It returns
null if no such association is found or if the matching
association is expired.
This method returns an Association object from storage that
matches the server URL and, if specified, handle. It returns
null if no such association is found or if the matching
association is expired.
If no handle is specified, the store may return any association
which matches the server URL. If multiple associations are
valid, the recommended return value for this method is the one
most recently issued.
This method is allowed (and encouraged) to garbage collect
expired associations when found. This method must not return
expired associations.
Parameters
- $server_url
The URL of the identity server to get
the association for. Because of the way the server portion of
the library uses this interface, don't assume there are any
limitations on the character set of the input string. In
particular, expect to see unescaped non-url-safe characters in
the server_url field.
- $handle
This optional parameter is the handle of
the specific association to get. If no specific handle is
provided, any valid association matching the server URL is
returned.
Returns
Association The Association for the given identity
server.
Overrides
|
public
|
|
public
boolean
|
#
useNonce( string $server_url, $timestamp, $salt )
Called when using a nonce.
Called when using a nonce.
This method should return C{True} if the nonce has not been
used before, and store it for a while to make sure nobody
tries to use the same value again. If the nonce has already
been used, return C{False}.
Change: In earlier versions, round-trip nonces were used and a
nonce was only valid if it had been previously stored with
storeNonce. Version 2.0 uses one-way nonces, requiring a
different implementation here that does not depend on a
storeNonce call. (storeNonce is no longer part of the
interface.
Parameters
- $server_url
- $nonce The nonce to use.
- $timestamp
- $salt
Returns
boolean Whether or not the nonce was valid.
Overrides
|
public
|
#
_octify( $str )
"Octifies" a binary string by returning a string with escaped
octal bytes. This is used for preparing binary data for
PostgreSQL BYTEA fields.
"Octifies" a binary string by returning a string with escaped
octal bytes. This is used for preparing binary data for
PostgreSQL BYTEA fields.
|
public
|
#
_unoctify( $str )
"Unoctifies" octal-escaped data from PostgreSQL and returns the
resulting ASCII (possibly binary) string.
"Unoctifies" octal-escaped data from PostgreSQL and returns the
resulting ASCII (possibly binary) string.
|
public
|
|
public
|
|