TYPO3 API  SVNRelease
Interface.php
Go to the documentation of this file.
00001 <?php
00002 
00003 /**
00004  * This file specifies the interface for PHP OpenID store implementations.
00005  *
00006  * PHP versions 4 and 5
00007  *
00008  * LICENSE: See the COPYING file included in this distribution.
00009  *
00010  * @package OpenID
00011  * @author JanRain, Inc. <openid@janrain.com>
00012  * @copyright 2005-2008 Janrain, Inc.
00013  * @license http://www.apache.org/licenses/LICENSE-2.0 Apache
00014  */
00015 
00016 /**
00017  * This is the interface for the store objects the OpenID library
00018  * uses. It is a single class that provides all of the persistence
00019  * mechanisms that the OpenID library needs, for both servers and
00020  * consumers.  If you want to create an SQL-driven store, please see
00021  * then {@link Auth_OpenID_SQLStore} class.
00022  *
00023  * Change: Version 2.0 removed the storeNonce, getAuthKey, and isDumb
00024  * methods, and changed the behavior of the useNonce method to support
00025  * one-way nonces.
00026  *
00027  * @package OpenID
00028  * @author JanRain, Inc. <openid@janrain.com>
00029  */
00030 class Auth_OpenID_OpenIDStore {
00031     /**
00032      * This method puts an Association object into storage,
00033      * retrievable by server URL and handle.
00034      *
00035      * @param string $server_url The URL of the identity server that
00036      * this association is with. Because of the way the server portion
00037      * of the library uses this interface, don't assume there are any
00038      * limitations on the character set of the input string. In
00039      * particular, expect to see unescaped non-url-safe characters in
00040      * the server_url field.
00041      *
00042      * @param Association $association The Association to store.
00043      */
00044     function storeAssociation($server_url, $association)
00045     {
00046         trigger_error("Auth_OpenID_OpenIDStore::storeAssociation ".
00047                       "not implemented", E_USER_ERROR);
00048     }
00049 
00050     /*
00051      * Remove expired nonces from the store.
00052      *
00053      * Discards any nonce from storage that is old enough that its
00054      * timestamp would not pass useNonce().
00055      *
00056      * This method is not called in the normal operation of the
00057      * library.  It provides a way for store admins to keep their
00058      * storage from filling up with expired data.
00059      *
00060      * @return the number of nonces expired
00061      */
00062     function cleanupNonces()
00063     {
00064         trigger_error("Auth_OpenID_OpenIDStore::cleanupNonces ".
00065                       "not implemented", E_USER_ERROR);
00066     }
00067 
00068     /*
00069      * Remove expired associations from the store.
00070      *
00071      * This method is not called in the normal operation of the
00072      * library.  It provides a way for store admins to keep their
00073      * storage from filling up with expired data.
00074      *
00075      * @return the number of associations expired.
00076      */
00077     function cleanupAssociations()
00078     {
00079         trigger_error("Auth_OpenID_OpenIDStore::cleanupAssociations ".
00080                       "not implemented", E_USER_ERROR);
00081     }
00082 
00083     /*
00084      * Shortcut for cleanupNonces(), cleanupAssociations().
00085      *
00086      * This method is not called in the normal operation of the
00087      * library.  It provides a way for store admins to keep their
00088      * storage from filling up with expired data.
00089      */
00090     function cleanup()
00091     {
00092         return array($this->cleanupNonces(),
00093                      $this->cleanupAssociations());
00094     }
00095 
00096     /**
00097      * Report whether this storage supports cleanup
00098      */
00099     function supportsCleanup()
00100     {
00101         return true;
00102     }
00103 
00104     /**
00105      * This method returns an Association object from storage that
00106      * matches the server URL and, if specified, handle. It returns
00107      * null if no such association is found or if the matching
00108      * association is expired.
00109      *
00110      * If no handle is specified, the store may return any association
00111      * which matches the server URL. If multiple associations are
00112      * valid, the recommended return value for this method is the one
00113      * most recently issued.
00114      *
00115      * This method is allowed (and encouraged) to garbage collect
00116      * expired associations when found. This method must not return
00117      * expired associations.
00118      *
00119      * @param string $server_url The URL of the identity server to get
00120      * the association for. Because of the way the server portion of
00121      * the library uses this interface, don't assume there are any
00122      * limitations on the character set of the input string.  In
00123      * particular, expect to see unescaped non-url-safe characters in
00124      * the server_url field.
00125      *
00126      * @param mixed $handle This optional parameter is the handle of
00127      * the specific association to get. If no specific handle is
00128      * provided, any valid association matching the server URL is
00129      * returned.
00130      *
00131      * @return Association The Association for the given identity
00132      * server.
00133      */
00134     function getAssociation($server_url, $handle = null)
00135     {
00136         trigger_error("Auth_OpenID_OpenIDStore::getAssociation ".
00137                       "not implemented", E_USER_ERROR);
00138     }
00139 
00140     /**
00141      * This method removes the matching association if it's found, and
00142      * returns whether the association was removed or not.
00143      *
00144      * @param string $server_url The URL of the identity server the
00145      * association to remove belongs to. Because of the way the server
00146      * portion of the library uses this interface, don't assume there
00147      * are any limitations on the character set of the input
00148      * string. In particular, expect to see unescaped non-url-safe
00149      * characters in the server_url field.
00150      *
00151      * @param string $handle This is the handle of the association to
00152      * remove. If there isn't an association found that matches both
00153      * the given URL and handle, then there was no matching handle
00154      * found.
00155      *
00156      * @return mixed Returns whether or not the given association existed.
00157      */
00158     function removeAssociation($server_url, $handle)
00159     {
00160         trigger_error("Auth_OpenID_OpenIDStore::removeAssociation ".
00161                       "not implemented", E_USER_ERROR);
00162     }
00163 
00164     /**
00165      * Called when using a nonce.
00166      *
00167      * This method should return C{True} if the nonce has not been
00168      * used before, and store it for a while to make sure nobody
00169      * tries to use the same value again.  If the nonce has already
00170      * been used, return C{False}.
00171      *
00172      * Change: In earlier versions, round-trip nonces were used and a
00173      * nonce was only valid if it had been previously stored with
00174      * storeNonce.  Version 2.0 uses one-way nonces, requiring a
00175      * different implementation here that does not depend on a
00176      * storeNonce call.  (storeNonce is no longer part of the
00177      * interface.
00178      *
00179      * @param string $nonce The nonce to use.
00180      *
00181      * @return bool Whether or not the nonce was valid.
00182      */
00183     function useNonce($server_url, $timestamp, $salt)
00184     {
00185         trigger_error("Auth_OpenID_OpenIDStore::useNonce ".
00186                       "not implemented", E_USER_ERROR);
00187     }
00188 
00189     /**
00190      * Removes all entries from the store; implementation is optional.
00191      */
00192     function reset()
00193     {
00194     }
00195 
00196 }
00197 ?>