Auth_OpenID_PostgreSQLStore
extends Auth_OpenID_SQLStore
in package
An SQL store that uses PostgreSQL as its backend.
Table of Contents
- $associations_table_name : string
- $connection : Auth_OpenID_DatabaseConnection|db_common
- $max_nonce_age : int
- $nonces_table_name : string
- $sql : array<string|int, mixed>
- __construct() : mixed
- This creates a new SQLStore instance. It requires an established database connection be given to it, and it allows overriding the default table names.
- _add_nonce() : bool
- _fixSQL() : mixed
- _get_assoc() : array<string|int, mixed>|bool|null
- _get_assocs() : array<string|int, mixed>
- _octify() : string
- "Octifies" a binary string by returning a string with escaped octal bytes. This is used for preparing binary data for PostgreSQL BYTEA fields.
- _set_assoc() : mixed
- _unoctify() : string
- "Unoctifies" octal-escaped data from PostgreSQL and returns the resulting ASCII (possibly binary) string.
- _verifySQL() : mixed
- blobDecode() : mixed
- blobEncode() : mixed
- cleanup() : array<string|int, mixed>
- Shortcut for cleanupNonces(), cleanupAssociations().
- cleanupAssociations() : int
- Remove expired associations from the store.
- cleanupNonces() : int
- Remove expired nonces from the store.
- create_assoc_table() : mixed
- create_nonce_table() : mixed
- createTables() : mixed
- getAssociation() : Auth_OpenID_Association
- 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.
- isError() : mixed
- Returns true if $value constitutes a database error; returns false otherwise.
- removeAssociation() : mixed
- This method removes the matching association if it's found, and returns whether the association was removed or not.
- reset() : mixed
- Removes all entries from the store; implementation is optional.
- resultToBool() : mixed
- 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.
- setSQL() : mixed
- 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.
- storeAssociation() : mixed
- This method puts an Association object into storage, retrievable by server URL and handle.
- supportsCleanup() : mixed
- Report whether this storage supports cleanup
- tableExists() : mixed
- useNonce() : bool
- Called when using a nonce.
Properties
$associations_table_name
protected
string
$associations_table_name
= ''
$connection
protected
Auth_OpenID_DatabaseConnection|db_common
$connection
$max_nonce_age
protected
int
$max_nonce_age
= 0
$nonces_table_name
protected
string
$nonces_table_name
= ''
$sql
protected
array<string|int, mixed>
$sql
= []
Methods
__construct()
This creates a new SQLStore instance. It requires an established database connection be given to it, and it allows overriding the default table names.
public
__construct(Auth_OpenID_DatabaseConnection $connection[, mixed $associations_table = null ][, mixed $nonces_table = null ]) : mixed
Parameters
- $connection : Auth_OpenID_DatabaseConnection
-
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 : mixed = null
- $nonces_table : mixed = null
Return values
mixed —_add_nonce()
public
_add_nonce(string $server_url, int $timestamp, string $salt) : bool
Parameters
- $server_url : string
- $timestamp : int
- $salt : string
Tags
Return values
bool —_fixSQL()
public
_fixSQL() : mixed
Tags
Return values
mixed —_get_assoc()
public
_get_assoc(string $server_url, int $handle) : array<string|int, mixed>|bool|null
Parameters
- $server_url : string
- $handle : int
Tags
Return values
array<string|int, mixed>|bool|null —_get_assocs()
public
_get_assocs(string $server_url) : array<string|int, mixed>
Parameters
- $server_url : string
Tags
Return values
array<string|int, mixed> —_octify()
"Octifies" a binary string by returning a string with escaped octal bytes. This is used for preparing binary data for PostgreSQL BYTEA fields.
public
_octify(string $str) : string
Parameters
- $str : string
Tags
Return values
string —_set_assoc()
public
_set_assoc(mixed $server_url, mixed $handle, mixed $secret, mixed $issued, mixed $lifetime, mixed $assoc_type) : mixed
Parameters
- $server_url : mixed
- $handle : mixed
- $secret : mixed
- $issued : mixed
- $lifetime : mixed
- $assoc_type : mixed
Tags
Return values
mixed —_unoctify()
"Unoctifies" octal-escaped data from PostgreSQL and returns the resulting ASCII (possibly binary) string.
public
_unoctify(string $str) : string
Parameters
- $str : string
Tags
Return values
string —_verifySQL()
public
_verifySQL() : mixed
Tags
Return values
mixed —blobDecode()
public
blobDecode(mixed $blob) : mixed
Parameters
- $blob : mixed
Tags
Return values
mixed —blobEncode()
public
blobEncode(mixed $blob) : mixed
Parameters
- $blob : mixed
Tags
Return values
mixed —cleanup()
Shortcut for cleanupNonces(), cleanupAssociations().
public
cleanup() : array<string|int, mixed>
This method is not called in the normal operation of the library. It provides a way for store admins to keep their storage from filling up with expired data.
Return values
array<string|int, mixed> —cleanupAssociations()
Remove expired associations from the store.
public
cleanupAssociations() : int
This method is not called in the normal operation of the library. It provides a way for store admins to keep their storage from filling up with expired data.
Return values
int —the number of associations expired.
cleanupNonces()
Remove expired nonces from the store.
public
cleanupNonces() : int
Discards any nonce from storage that is old enough that its timestamp would not pass useNonce().
This method is not called in the normal operation of the library. It provides a way for store admins to keep their storage from filling up with expired data.
Return values
int —the number of nonces expired
create_assoc_table()
public
create_assoc_table() : mixed
Return values
mixed —create_nonce_table()
public
create_nonce_table() : mixed
Return values
mixed —createTables()
public
createTables() : mixed
Return values
mixed —getAssociation()
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.
public
getAssociation(string $server_url[, mixed $handle = null ]) : Auth_OpenID_Association
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 : string
-
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 : mixed = null
-
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.
Return values
Auth_OpenID_Association —The Association for the given identity server.
isError()
Returns true if $value constitutes a database error; returns false otherwise.
public
isError(mixed $value) : mixed
Parameters
- $value : mixed
Return values
mixed —removeAssociation()
This method removes the matching association if it's found, and returns whether the association was removed or not.
public
removeAssociation(string $server_url, string $handle) : mixed
Parameters
- $server_url : string
-
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 : string
-
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.
Return values
mixed —Returns whether or not the given association existed.
reset()
Removes all entries from the store; implementation is optional.
public
reset() : mixed
Return values
mixed —resultToBool()
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
resultToBool(mixed $obj) : mixed
Parameters
- $obj : mixed
Return values
mixed —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.
public
setSQL() : mixed
Tags
Return values
mixed —storeAssociation()
This method puts an Association object into storage, retrievable by server URL and handle.
public
storeAssociation(string $server_url, Auth_OpenID_Association $association) : mixed
Parameters
- $server_url : string
-
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 : Auth_OpenID_Association
-
The Association to store.
Return values
mixed —supportsCleanup()
Report whether this storage supports cleanup
public
supportsCleanup() : mixed
Return values
mixed —tableExists()
public
tableExists(mixed $table_name) : mixed
Parameters
- $table_name : mixed
Return values
mixed —useNonce()
Called when using a nonce.
public
useNonce(string $server_url, int $timestamp, string $salt) : bool
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 : string
- $timestamp : int
- $salt : string
Return values
bool —Whether or not the nonce was valid.