File indexing completed on 2024-12-22 05:36:53

0001 <?php
0002 
0003 /**
0004  * Zend Framework
0005  *
0006  * LICENSE
0007  *
0008  * This source file is subject to the new BSD license that is bundled
0009  * with this package in the file LICENSE.txt.
0010  * It is also available through the world-wide-web at this URL:
0011  * http://framework.zend.com/license/new-bsd
0012  * If you did not receive a copy of the license and are unable to
0013  * obtain it through the world-wide-web, please send an email
0014  * to license@zend.com so we can send you a copy immediately.
0015  *
0016  * @category   Zend
0017  * @package    Zend_OpenId
0018  * @subpackage Zend_OpenId_Consumer
0019  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0020  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0021  * @version    $Id$
0022  */
0023 
0024 /**
0025  * Abstract class to implement external storage for OpenID consumer
0026  *
0027  * @category   Zend
0028  * @package    Zend_OpenId
0029  * @subpackage Zend_OpenId_Consumer
0030  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0031  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0032  */
0033 abstract class Zend_OpenId_Consumer_Storage
0034 {
0035 
0036     /**
0037      * Stores information about association identified by $url/$handle
0038      *
0039      * @param string $url OpenID server URL
0040      * @param string $handle assiciation handle
0041      * @param string $macFunc HMAC function (sha1 or sha256)
0042      * @param string $secret shared secret
0043      * @param long $expires expiration UNIX time
0044      * @return void
0045      */
0046     abstract public function addAssociation($url, $handle, $macFunc, $secret, $expires);
0047 
0048     /**
0049      * Gets information about association identified by $url
0050      * Returns true if given association found and not expired and false
0051      * otherwise
0052      *
0053      * @param string $url OpenID server URL
0054      * @param string &$handle assiciation handle
0055      * @param string &$macFunc HMAC function (sha1 or sha256)
0056      * @param string &$secret shared secret
0057      * @param long &$expires expiration UNIX time
0058      * @return bool
0059      */
0060     abstract public function getAssociation($url, &$handle, &$macFunc, &$secret, &$expires);
0061 
0062     /**
0063      * Gets information about association identified by $handle
0064      * Returns true if given association found and not expired and false
0065      * othverwise
0066      *
0067      * @param string $handle assiciation handle
0068      * @param string &$url OpenID server URL
0069      * @param string &$macFunc HMAC function (sha1 or sha256)
0070      * @param string &$secret shared secret
0071      * @param long &$expires expiration UNIX time
0072      * @return bool
0073      */
0074     abstract public function getAssociationByHandle($handle, &$url, &$macFunc, &$secret, &$expires);
0075 
0076     /**
0077      * Deletes association identified by $url
0078      *
0079      * @param string $url OpenID server URL
0080      * @return void
0081      */
0082     abstract public function delAssociation($url);
0083 
0084     /**
0085      * Stores information discovered from identity $id
0086      *
0087      * @param string $id identity
0088      * @param string $realId discovered real identity URL
0089      * @param string $server discovered OpenID server URL
0090      * @param float $version discovered OpenID protocol version
0091      * @param long $expires expiration UNIX time
0092      * @return void
0093      */
0094     abstract public function addDiscoveryInfo($id, $realId, $server, $version, $expires);
0095 
0096     /**
0097      * Gets information discovered from identity $id
0098      * Returns true if such information exists and false otherwise
0099      *
0100      * @param string $id identity
0101      * @param string &$realId discovered real identity URL
0102      * @param string &$server discovered OpenID server URL
0103      * @param float &$version discovered OpenID protocol version
0104      * @param long &$expires expiration UNIX time
0105      * @return bool
0106      */
0107     abstract public function getDiscoveryInfo($id, &$realId, &$server, &$version, &$expires);
0108 
0109     /**
0110      * Removes cached information discovered from identity $id
0111      *
0112      * @param string $id identity
0113      * @return bool
0114      */
0115     abstract public function delDiscoveryInfo($id);
0116 
0117     /**
0118      * The function checks the uniqueness of openid.response_nonce
0119      *
0120      * @param string $provider openid.openid_op_endpoint field from authentication response
0121      * @param string $nonce openid.response_nonce field from authentication response
0122      * @return bool
0123      */
0124     abstract public function isUniqueNonce($provider, $nonce);
0125 
0126     /**
0127      * Removes data from the uniqueness database that is older then given date
0128      *
0129      * @param string $date Date of expired data
0130      */
0131     abstract public function purgeNonces($date=null);
0132 }