/library/Zend/OpenId/Consumer/Storage/AbstractStorage.php

https://github.com/knutBachmann/zf2 · PHP · 136 lines · 14 code · 12 blank · 110 comment · 0 complexity · 1fcc298ad94fd98a9c232afb4189d561 MD5 · raw file

  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-2011 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. /**
  22. * @namespace
  23. */
  24. namespace Zend\OpenId\Consumer\Storage;
  25. /**
  26. * Abstract class to implement external storage for OpenID consumer
  27. *
  28. * @category Zend
  29. * @package Zend_OpenId
  30. * @subpackage Zend_OpenId_Consumer
  31. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  32. * @license http://framework.zend.com/license/new-bsd New BSD License
  33. */
  34. abstract class AbstractStorage
  35. {
  36. /**
  37. * Stores information about association identified by $url/$handle
  38. *
  39. * @param string $url OpenID server URL
  40. * @param string $handle assiciation handle
  41. * @param string $macFunc HMAC function (sha1 or sha256)
  42. * @param string $secret shared secret
  43. * @param long $expires expiration UNIX time
  44. * @return void
  45. */
  46. abstract public function addAssociation($url, $handle, $macFunc, $secret, $expires);
  47. /**
  48. * Gets information about association identified by $url
  49. * Returns true if given association found and not expired and false
  50. * otherwise
  51. *
  52. * @param string $url OpenID server URL
  53. * @param string &$handle assiciation handle
  54. * @param string &$macFunc HMAC function (sha1 or sha256)
  55. * @param string &$secret shared secret
  56. * @param long &$expires expiration UNIX time
  57. * @return bool
  58. */
  59. abstract public function getAssociation($url, &$handle, &$macFunc, &$secret, &$expires);
  60. /**
  61. * Gets information about association identified by $handle
  62. * Returns true if given association found and not expired and false
  63. * othverwise
  64. *
  65. * @param string $handle assiciation handle
  66. * @param string &$url OpenID server URL
  67. * @param string &$macFunc HMAC function (sha1 or sha256)
  68. * @param string &$secret shared secret
  69. * @param long &$expires expiration UNIX time
  70. * @return bool
  71. */
  72. abstract public function getAssociationByHandle($handle, &$url, &$macFunc, &$secret, &$expires);
  73. /**
  74. * Deletes association identified by $url
  75. *
  76. * @param string $url OpenID server URL
  77. * @return void
  78. */
  79. abstract public function delAssociation($url);
  80. /**
  81. * Stores information discovered from identity $id
  82. *
  83. * @param string $id identity
  84. * @param string $realId discovered real identity URL
  85. * @param string $server discovered OpenID server URL
  86. * @param float $version discovered OpenID protocol version
  87. * @param long $expires expiration UNIX time
  88. * @return void
  89. */
  90. abstract public function addDiscoveryInfo($id, $realId, $server, $version, $expires);
  91. /**
  92. * Gets information discovered from identity $id
  93. * Returns true if such information exists and false otherwise
  94. *
  95. * @param string $id identity
  96. * @param string &$realId discovered real identity URL
  97. * @param string &$server discovered OpenID server URL
  98. * @param float &$version discovered OpenID protocol version
  99. * @param long &$expires expiration UNIX time
  100. * @return bool
  101. */
  102. abstract public function getDiscoveryInfo($id, &$realId, &$server, &$version, &$expires);
  103. /**
  104. * Removes cached information discovered from identity $id
  105. *
  106. * @param string $id identity
  107. * @return bool
  108. */
  109. abstract public function delDiscoveryInfo($id);
  110. /**
  111. * The function checks the uniqueness of openid.response_nonce
  112. *
  113. * @param string $provider openid.openid_op_endpoint field from authentication response
  114. * @param string $nonce openid.response_nonce field from authentication response
  115. * @return bool
  116. */
  117. abstract public function isUniqueNonce($provider, $nonce);
  118. /**
  119. * Removes data from the uniqueness database that is older then given date
  120. *
  121. * @param string $date Date of expired data
  122. */
  123. abstract public function purgeNonces($date=null);
  124. }