c9f08333946e3f476b25d6c29c2f2a7dbdbac90f
[WP-Plugins/glm-member-db.git] /
1 <?php //vim: foldmethod=marker
2 namespace PayPal\Auth\Oauth;
3 class MockOAuthDataStore extends OAuthDataStore {/*{{{*/
4     private $consumer;
5     private $request_token;
6     private $access_token;
7     private $nonce;
8
9     function __construct() {/*{{{*/
10         $this->consumer = new OAuthConsumer("key", "secret", NULL);
11         $this->request_token = new OAuthToken("requestkey", "requestsecret", 1);
12         $this->access_token = new OAuthToken("accesskey", "accesssecret", 1);
13         $this->nonce = "nonce";
14     }/*}}}*/
15
16     function lookup_consumer($consumer_key) {/*{{{*/
17         if ($consumer_key == $this->consumer->key) return $this->consumer;
18         return NULL;
19     }/*}}}*/
20
21     function lookup_token($consumer, $token_type, $token) {/*{{{*/
22         $token_attrib = $token_type . "_token";
23         if ($consumer->key == $this->consumer->key
24             && $token == $this->$token_attrib->key) {
25             return $this->$token_attrib;
26         }
27         return NULL;
28     }/*}}}*/
29
30     function lookup_nonce($consumer, $token, $nonce, $timestamp) {/*{{{*/
31         if ($consumer->key == $this->consumer->key
32             && (($token && $token->key == $this->request_token->key)
33                 || ($token && $token->key == $this->access_token->key))
34             && $nonce == $this->nonce) {
35             return $this->nonce;
36         }
37         return NULL;
38     }/*}}}*/
39
40     function new_request_token($consumer, $callback = NULL) {/*{{{*/
41         if ($consumer->key == $this->consumer->key) {
42             return $this->request_token;
43         }
44         return NULL;
45     }/*}}}*/
46
47     function new_access_token($token, $consumer, $verifier = NULL) {/*{{{*/
48         if ($consumer->key == $this->consumer->key
49             && $token->key == $this->request_token->key) {
50             return $this->access_token;
51         }
52         return NULL;
53     }/*}}}*/
54 }/*}}}*/