/tags/openid_192/Auth/OpenID/DumbStore.php

https://bitbucket.org/pombredanne/spip-zone-treemap · PHP · 116 lines · 36 code · 12 blank · 68 comment · 0 complexity · 0229aa09806d191ebb1581b66fc56238 MD5 · raw file

  1. <?php
  2. /**
  3. * This file supplies a dumb store backend for OpenID servers and
  4. * consumers.
  5. *
  6. * PHP versions 4 and 5
  7. *
  8. * LICENSE: See the COPYING file included in this distribution.
  9. *
  10. * @package OpenID
  11. * @author JanRain, Inc. <openid@janrain.com>
  12. * @copyright 2005 Janrain, Inc.
  13. * @license http://www.gnu.org/copyleft/lesser.html LGPL
  14. */
  15. /**
  16. * Import the interface for creating a new store class.
  17. */
  18. require_once 'Auth/OpenID/Interface.php';
  19. require_once 'Auth/OpenID/HMACSHA1.php';
  20. /**
  21. * This is a store for use in the worst case, when you have no way of
  22. * saving state on the consumer site. Using this store makes the
  23. * consumer vulnerable to replay attacks, as it's unable to use
  24. * nonces. Avoid using this store if it is at all possible.
  25. *
  26. * Most of the methods of this class are implementation details.
  27. * Users of this class need to worry only about the constructor.
  28. *
  29. * @package OpenID
  30. */
  31. class Auth_OpenID_DumbStore extends Auth_OpenID_OpenIDStore {
  32. /**
  33. * Creates a new {@link Auth_OpenID_DumbStore} instance. For the security
  34. * of the tokens generated by the library, this class attempts to
  35. * at least have a secure implementation of getAuthKey.
  36. *
  37. * When you create an instance of this class, pass in a secret
  38. * phrase. The phrase is hashed with sha1 to make it the correct
  39. * length and form for an auth key. That allows you to use a long
  40. * string as the secret phrase, which means you can make it very
  41. * difficult to guess.
  42. *
  43. * Each {@link Auth_OpenID_DumbStore} instance that is created for use by
  44. * your consumer site needs to use the same $secret_phrase.
  45. *
  46. * @param string secret_phrase The phrase used to create the auth
  47. * key returned by getAuthKey
  48. */
  49. function Auth_OpenID_DumbStore($secret_phrase)
  50. {
  51. $this->auth_key = Auth_OpenID_SHA1($secret_phrase);
  52. }
  53. /**
  54. * This implementation does nothing.
  55. */
  56. function storeAssociation($server_url, $association)
  57. {
  58. }
  59. /**
  60. * This implementation always returns null.
  61. */
  62. function getAssociation($server_url, $handle = null)
  63. {
  64. return null;
  65. }
  66. /**
  67. * This implementation always returns false.
  68. */
  69. function removeAssociation($server_url, $handle)
  70. {
  71. return false;
  72. }
  73. /**
  74. * This implementation does nothing.
  75. */
  76. function storeNonce($nonce)
  77. {
  78. }
  79. /**
  80. * In a system truly limited to dumb mode, nonces must all be
  81. * accepted. This therefore always returns true, which makes
  82. * replay attacks feasible.
  83. */
  84. function useNonce($nonce)
  85. {
  86. return true;
  87. }
  88. /**
  89. * This method returns the auth key generated by the constructor.
  90. */
  91. function getAuthKey()
  92. {
  93. return $this->auth_key;
  94. }
  95. /**
  96. * This store is a dumb mode store, so this method is overridden
  97. * to return true.
  98. */
  99. function isDumb()
  100. {
  101. return true;
  102. }
  103. }
  104. ?>