Storage.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_OpenId
  17. * @subpackage Zend_OpenId_Consumer
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * Abstract class to implement external storage for OpenID consumer
  24. *
  25. * @category Zend
  26. * @package Zend_OpenId
  27. * @subpackage Zend_OpenId_Consumer
  28. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  29. * @license http://framework.zend.com/license/new-bsd New BSD License
  30. */
  31. abstract class Zend_OpenId_Consumer_Storage
  32. {
  33. /**
  34. * Stores information about association identified by $url/$handle
  35. *
  36. * @param string $url OpenID server URL
  37. * @param string $handle assiciation handle
  38. * @param string $macFunc HMAC function (sha1 or sha256)
  39. * @param string $secret shared secret
  40. * @param long $expires expiration UNIX time
  41. * @return void
  42. */
  43. abstract public function addAssociation($url, $handle, $macFunc, $secret, $expires);
  44. /**
  45. * Gets information about association identified by $url
  46. * Returns true if given association found and not expired and false
  47. * otherwise
  48. *
  49. * @param string $url OpenID server URL
  50. * @param string &$handle assiciation handle
  51. * @param string &$macFunc HMAC function (sha1 or sha256)
  52. * @param string &$secret shared secret
  53. * @param long &$expires expiration UNIX time
  54. * @return bool
  55. */
  56. abstract public function getAssociation($url, &$handle, &$macFunc, &$secret, &$expires);
  57. /**
  58. * Gets information about association identified by $handle
  59. * Returns true if given association found and not expired and false
  60. * othverwise
  61. *
  62. * @param string $handle assiciation handle
  63. * @param string &$url OpenID server URL
  64. * @param string &$macFunc HMAC function (sha1 or sha256)
  65. * @param string &$secret shared secret
  66. * @param long &$expires expiration UNIX time
  67. * @return bool
  68. */
  69. abstract public function getAssociationByHandle($handle, &$url, &$macFunc, &$secret, &$expires);
  70. /**
  71. * Deletes association identified by $url
  72. *
  73. * @param string $url OpenID server URL
  74. * @return void
  75. */
  76. abstract public function delAssociation($url);
  77. /**
  78. * Stores information discovered from identity $id
  79. *
  80. * @param string $id identity
  81. * @param string $realId discovered real identity URL
  82. * @param string $server discovered OpenID server URL
  83. * @param float $version discovered OpenID protocol version
  84. * @param long $expires expiration UNIX time
  85. * @return void
  86. */
  87. abstract public function addDiscoveryInfo($id, $realId, $server, $version, $expires);
  88. /**
  89. * Gets information discovered from identity $id
  90. * Returns true if such information exists and false otherwise
  91. *
  92. * @param string $id identity
  93. * @param string &$realId discovered real identity URL
  94. * @param string &$server discovered OpenID server URL
  95. * @param float &$version discovered OpenID protocol version
  96. * @param long &$expires expiration UNIX time
  97. * @return bool
  98. */
  99. abstract public function getDiscoveryInfo($id, &$realId, &$server, &$version, &$expires);
  100. /**
  101. * Removes cached information discovered from identity $id
  102. *
  103. * @param string $id identity
  104. * @return bool
  105. */
  106. abstract public function delDiscoveryInfo($id);
  107. /**
  108. * The function checks the uniqueness of openid.response_nonce
  109. *
  110. * @param string $provider openid.openid_op_endpoint field from authentication response
  111. * @param string $nonce openid.response_nonce field from authentication response
  112. * @return bool
  113. */
  114. abstract public function isUniqueNonce($provider, $nonce);
  115. /**
  116. * Removes data from the uniqueness database that is older then given date
  117. *
  118. * @param string $date Date of expired data
  119. */
  120. abstract public function purgeNonces($date=null);
  121. }