1 | <?php //vim: foldmethod=marker |
||
2 | //require_once("../init.php"); |
||
3 | |||
4 | class TestOAuthServer extends OAuthServer { |
||
5 | public function get_signature_methods() { |
||
6 | return $this->signature_methods; |
||
7 | } |
||
8 | } |
||
9 | |||
10 | class TestOAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod_RSA_SHA1 { |
||
11 | public function fetch_private_cert(&$request) { |
||
12 | $cert = <<<EOD |
||
13 | -----BEGIN PRIVATE KEY----- |
||
14 | MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALRiMLAh9iimur8V |
||
15 | A7qVvdqxevEuUkW4K+2KdMXmnQbG9Aa7k7eBjK1S+0LYmVjPKlJGNXHDGuy5Fw/d |
||
16 | 7rjVJ0BLB+ubPK8iA/Tw3hLQgXMRRGRXXCn8ikfuQfjUS1uZSatdLB81mydBETlJ |
||
17 | hI6GH4twrbDJCR2Bwy/XWXgqgGRzAgMBAAECgYBYWVtleUzavkbrPjy0T5FMou8H |
||
18 | X9u2AC2ry8vD/l7cqedtwMPp9k7TubgNFo+NGvKsl2ynyprOZR1xjQ7WgrgVB+mm |
||
19 | uScOM/5HVceFuGRDhYTCObE+y1kxRloNYXnx3ei1zbeYLPCHdhxRYW7T0qcynNmw |
||
20 | rn05/KO2RLjgQNalsQJBANeA3Q4Nugqy4QBUCEC09SqylT2K9FrrItqL2QKc9v0Z |
||
21 | zO2uwllCbg0dwpVuYPYXYvikNHHg+aCWF+VXsb9rpPsCQQDWR9TT4ORdzoj+Nccn |
||
22 | qkMsDmzt0EfNaAOwHOmVJ2RVBspPcxt5iN4HI7HNeG6U5YsFBb+/GZbgfBT3kpNG |
||
23 | WPTpAkBI+gFhjfJvRw38n3g/+UeAkwMI2TJQS4n8+hid0uus3/zOjDySH3XHCUno |
||
24 | cn1xOJAyZODBo47E+67R4jV1/gzbAkEAklJaspRPXP877NssM5nAZMU0/O/NGCZ+ |
||
25 | 3jPgDUno6WbJn5cqm8MqWhW1xGkImgRk+fkDBquiq4gPiT898jusgQJAd5Zrr6Q8 |
||
26 | AO/0isr/3aa6O6NLQxISLKcPDk2NOccAfS/xOtfOz4sJYM3+Bs4Io9+dZGSDCA54 |
||
27 | Lw03eHTNQghS0A== |
||
28 | -----END PRIVATE KEY----- |
||
29 | EOD; |
||
30 | return $cert; |
||
31 | } |
||
32 | |||
33 | public function fetch_public_cert(&$request) { |
||
34 | $cert = <<<EOD |
||
35 | -----BEGIN CERTIFICATE----- |
||
36 | MIIBpjCCAQ+gAwIBAgIBATANBgkqhkiG9w0BAQUFADAZMRcwFQYDVQQDDA5UZXN0 |
||
37 | IFByaW5jaXBhbDAeFw03MDAxMDEwODAwMDBaFw0zODEyMzEwODAwMDBaMBkxFzAV |
||
38 | BgNVBAMMDlRlc3QgUHJpbmNpcGFsMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB |
||
39 | gQC0YjCwIfYoprq/FQO6lb3asXrxLlJFuCvtinTF5p0GxvQGu5O3gYytUvtC2JlY |
||
40 | zypSRjVxwxrsuRcP3e641SdASwfrmzyvIgP08N4S0IFzEURkV1wp/IpH7kH41Etb |
||
41 | mUmrXSwfNZsnQRE5SYSOhh+LcK2wyQkdgcMv11l4KoBkcwIDAQABMA0GCSqGSIb3 |
||
42 | DQEBBQUAA4GBAGZLPEuJ5SiJ2ryq+CmEGOXfvlTtEL2nuGtr9PewxkgnOjZpUy+d |
||
43 | 4TvuXJbNQc8f4AMWL/tO9w0Fk80rWKp9ea8/df4qMq5qlFWlx6yOLQxumNOmECKb |
||
44 | WpkUQDIDJEoFUzKMVuJf4KO/FJ345+BNLGgbJ6WujreoM1X/gYfdnJ/J |
||
45 | -----END CERTIFICATE----- |
||
46 | EOD; |
||
47 | return $cert; |
||
48 | } |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * A mock store for testing |
||
53 | */ |
||
54 | class MockOAuthDataStore extends OAuthDataStore {/*{{{*/ |
||
55 | private $consumer; |
||
56 | private $request_token; |
||
57 | private $access_token; |
||
58 | private $nonce; |
||
59 | |||
60 | function __construct() {/*{{{*/ |
||
61 | $this->consumer = new OAuthConsumer("key", "secret", NULL); |
||
62 | $this->request_token = new OAuthToken("requestkey", "requestsecret", 1); |
||
63 | $this->access_token = new OAuthToken("accesskey", "accesssecret", 1); |
||
64 | $this->nonce = "nonce"; |
||
65 | }/*}}}*/ |
||
66 | |||
67 | function lookup_consumer($consumer_key) {/*{{{*/ |
||
0 ignored issues
–
show
|
|||
68 | if ($consumer_key == $this->consumer->key) return $this->consumer; |
||
69 | return NULL; |
||
70 | }/*}}}*/ |
||
71 | |||
72 | function lookup_token($consumer, $token_type, $token) {/*{{{*/ |
||
0 ignored issues
–
show
|
|||
73 | $token_attrib = $token_type . "_token"; |
||
74 | if ($consumer->key == $this->consumer->key |
||
75 | && $token == $this->$token_attrib->key) { |
||
76 | return $this->$token_attrib; |
||
77 | } |
||
78 | return NULL; |
||
79 | }/*}}}*/ |
||
80 | |||
81 | function lookup_nonce($consumer, $token, $nonce, $timestamp) {/*{{{*/ |
||
0 ignored issues
–
show
|
|||
82 | if ($consumer->key == $this->consumer->key |
||
83 | && (($token && $token->key == $this->request_token->key) |
||
84 | || ($token && $token->key == $this->access_token->key)) |
||
85 | && $nonce == $this->nonce) { |
||
86 | return $this->nonce; |
||
87 | } |
||
88 | return NULL; |
||
89 | }/*}}}*/ |
||
90 | |||
91 | function new_request_token($consumer) {/*{{{*/ |
||
0 ignored issues
–
show
|
|||
92 | if ($consumer->key == $this->consumer->key) { |
||
93 | return $this->request_token; |
||
94 | } |
||
95 | return NULL; |
||
96 | }/*}}}*/ |
||
97 | |||
98 | function new_access_token($token, $consumer) {/*{{{*/ |
||
0 ignored issues
–
show
|
|||
99 | if ($consumer->key == $this->consumer->key |
||
100 | && $token->key == $this->request_token->key) { |
||
101 | return $this->access_token; |
||
102 | } |
||
103 | return NULL; |
||
104 | }/*}}}*/ |
||
105 | }/*}}}*/ |
||
106 | ?> |
||
0 ignored issues
–
show
It is not recommended to use PHP's closing tag
?> in files other than templates.
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore. A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever. ![]() |
|||
107 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.