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