PageRenderTime 41ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/lib/include/Auth/OpenID/Interface.php

https://github.com/applideveloper/OpenPNE2CE
PHP | 189 lines | 42 code | 10 blank | 137 comment | 0 complexity | 741810047e813b62ee38f6af3bb622c2 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-2.1
  1. <?php
  2. /**
  3. * This file specifies the interface for PHP OpenID store implementations.
  4. *
  5. * PHP versions 4 and 5
  6. *
  7. * LICENSE: See the COPYING file included in this distribution.
  8. *
  9. * @package OpenID
  10. * @author JanRain, Inc. <openid@janrain.com>
  11. * @copyright 2005 Janrain, Inc.
  12. * @license http://www.gnu.org/copyleft/lesser.html LGPL
  13. */
  14. /**
  15. * This is the interface for the store objects the OpenID library
  16. * uses. It is a single class that provides all of the persistence
  17. * mechanisms that the OpenID library needs, for both servers and
  18. * consumers. If you want to create an SQL-driven store, please see
  19. * then {@link Auth_OpenID_SQLStore} class.
  20. *
  21. * Change: Version 2.0 removed the storeNonce, getAuthKey, and isDumb
  22. * methods, and changed the behavior of the useNonce method to support
  23. * one-way nonces.
  24. *
  25. * @package OpenID
  26. * @author JanRain, Inc. <openid@janrain.com>
  27. */
  28. class Auth_OpenID_OpenIDStore {
  29. /**
  30. * This method puts an Association object into storage,
  31. * retrievable by server URL and handle.
  32. *
  33. * @param string $server_url The URL of the identity server that
  34. * this association is with. Because of the way the server portion
  35. * of the library uses this interface, don't assume there are any
  36. * limitations on the character set of the input string. In
  37. * particular, expect to see unescaped non-url-safe characters in
  38. * the server_url field.
  39. *
  40. * @param Association $association The Association to store.
  41. */
  42. function storeAssociation($server_url, $association)
  43. {
  44. trigger_error("Auth_OpenID_OpenIDStore::storeAssociation ".
  45. "not implemented", E_USER_ERROR);
  46. }
  47. /*
  48. * Remove expired nonces from the store.
  49. *
  50. * Discards any nonce from storage that is old enough that its
  51. * timestamp would not pass useNonce().
  52. *
  53. * This method is not called in the normal operation of the
  54. * library. It provides a way for store admins to keep their
  55. * storage from filling up with expired data.
  56. *
  57. * @return the number of nonces expired
  58. */
  59. function cleanupNonces()
  60. {
  61. trigger_error("Auth_OpenID_OpenIDStore::cleanupNonces ".
  62. "not implemented", E_USER_ERROR);
  63. }
  64. /*
  65. * Remove expired associations from the store.
  66. *
  67. * This method is not called in the normal operation of the
  68. * library. It provides a way for store admins to keep their
  69. * storage from filling up with expired data.
  70. *
  71. * @return the number of associations expired.
  72. */
  73. function cleanupAssociations()
  74. {
  75. trigger_error("Auth_OpenID_OpenIDStore::cleanupAssociations ".
  76. "not implemented", E_USER_ERROR);
  77. }
  78. /*
  79. * Shortcut for cleanupNonces(), cleanupAssociations().
  80. *
  81. * This method is not called in the normal operation of the
  82. * library. It provides a way for store admins to keep their
  83. * storage from filling up with expired data.
  84. */
  85. function cleanup()
  86. {
  87. return array($this->cleanupNonces(),
  88. $this->cleanupAssociations());
  89. }
  90. /**
  91. * This method returns an Association object from storage that
  92. * matches the server URL and, if specified, handle. It returns
  93. * null if no such association is found or if the matching
  94. * association is expired.
  95. *
  96. * If no handle is specified, the store may return any association
  97. * which matches the server URL. If multiple associations are
  98. * valid, the recommended return value for this method is the one
  99. * most recently issued.
  100. *
  101. * This method is allowed (and encouraged) to garbage collect
  102. * expired associations when found. This method must not return
  103. * expired associations.
  104. *
  105. * @param string $server_url The URL of the identity server to get
  106. * the association for. Because of the way the server portion of
  107. * the library uses this interface, don't assume there are any
  108. * limitations on the character set of the input string. In
  109. * particular, expect to see unescaped non-url-safe characters in
  110. * the server_url field.
  111. *
  112. * @param mixed $handle This optional parameter is the handle of
  113. * the specific association to get. If no specific handle is
  114. * provided, any valid association matching the server URL is
  115. * returned.
  116. *
  117. * @return Association The Association for the given identity
  118. * server.
  119. */
  120. function getAssociation($server_url, $handle = null)
  121. {
  122. trigger_error("Auth_OpenID_OpenIDStore::getAssociation ".
  123. "not implemented", E_USER_ERROR);
  124. }
  125. /**
  126. * This method removes the matching association if it's found, and
  127. * returns whether the association was removed or not.
  128. *
  129. * @param string $server_url The URL of the identity server the
  130. * association to remove belongs to. Because of the way the server
  131. * portion of the library uses this interface, don't assume there
  132. * are any limitations on the character set of the input
  133. * string. In particular, expect to see unescaped non-url-safe
  134. * characters in the server_url field.
  135. *
  136. * @param string $handle This is the handle of the association to
  137. * remove. If there isn't an association found that matches both
  138. * the given URL and handle, then there was no matching handle
  139. * found.
  140. *
  141. * @return mixed Returns whether or not the given association existed.
  142. */
  143. function removeAssociation($server_url, $handle)
  144. {
  145. trigger_error("Auth_OpenID_OpenIDStore::removeAssociation ".
  146. "not implemented", E_USER_ERROR);
  147. }
  148. /**
  149. * Called when using a nonce.
  150. *
  151. * This method should return C{True} if the nonce has not been
  152. * used before, and store it for a while to make sure nobody
  153. * tries to use the same value again. If the nonce has already
  154. * been used, return C{False}.
  155. *
  156. * Change: In earlier versions, round-trip nonces were used and a
  157. * nonce was only valid if it had been previously stored with
  158. * storeNonce. Version 2.0 uses one-way nonces, requiring a
  159. * different implementation here that does not depend on a
  160. * storeNonce call. (storeNonce is no longer part of the
  161. * interface.
  162. *
  163. * @param string $nonce The nonce to use.
  164. *
  165. * @return bool Whether or not the nonce was valid.
  166. */
  167. function useNonce($server_url, $timestamp, $salt)
  168. {
  169. trigger_error("Auth_OpenID_OpenIDStore::useNonce ".
  170. "not implemented", E_USER_ERROR);
  171. }
  172. /**
  173. * Removes all entries from the store; implementation is optional.
  174. */
  175. function reset()
  176. {
  177. }
  178. }
  179. ?>