Extension.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * An interface for OpenID extensions.
  4. *
  5. * @package OpenID
  6. */
  7. /**
  8. * Require the Message implementation.
  9. */
  10. require_once 'Auth/OpenID/Message.php';
  11. /**
  12. * A base class for accessing extension request and response data for
  13. * the OpenID 2 protocol.
  14. *
  15. * @package OpenID
  16. */
  17. class Auth_OpenID_Extension {
  18. /**
  19. * ns_uri: The namespace to which to add the arguments for this
  20. * extension
  21. */
  22. var $ns_uri = null;
  23. var $ns_alias = null;
  24. /**
  25. * Get the string arguments that should be added to an OpenID
  26. * message for this extension.
  27. */
  28. function getExtensionArgs()
  29. {
  30. return null;
  31. }
  32. /**
  33. * Add the arguments from this extension to the provided message.
  34. *
  35. * Returns the message with the extension arguments added.
  36. */
  37. function toMessage(&$message)
  38. {
  39. $implicit = $message->isOpenID1();
  40. $added = $message->namespaces->addAlias($this->ns_uri,
  41. $this->ns_alias,
  42. $implicit);
  43. if ($added === null) {
  44. if ($message->namespaces->getAlias($this->ns_uri) !=
  45. $this->ns_alias) {
  46. return null;
  47. }
  48. }
  49. $message->updateArgs($this->ns_uri,
  50. $this->getExtensionArgs());
  51. return $message;
  52. }
  53. }
  54. ?>