1 |
efrain |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
require_once($CFG->dirroot . '/enrol/lti/ims-blti/OAuth.php');
|
|
|
4 |
|
|
|
5 |
/**
|
|
|
6 |
* A Trivial memory-based store - no support for tokens
|
|
|
7 |
*/
|
|
|
8 |
class TrivialOAuthDataStore extends OAuthDataStore {
|
|
|
9 |
private $consumers = array();
|
|
|
10 |
|
|
|
11 |
function add_consumer($consumer_key, $consumer_secret) {
|
|
|
12 |
$this->consumers[$consumer_key] = $consumer_secret;
|
|
|
13 |
}
|
|
|
14 |
|
|
|
15 |
function lookup_consumer($consumer_key) {
|
|
|
16 |
if ( strpos($consumer_key, "http://" ) === 0 ) {
|
|
|
17 |
$consumer = new OAuthConsumer($consumer_key,"secret", NULL);
|
|
|
18 |
return $consumer;
|
|
|
19 |
}
|
|
|
20 |
if ( $this->consumers[$consumer_key] ) {
|
|
|
21 |
$consumer = new OAuthConsumer($consumer_key,$this->consumers[$consumer_key], NULL);
|
|
|
22 |
return $consumer;
|
|
|
23 |
}
|
|
|
24 |
return NULL;
|
|
|
25 |
}
|
|
|
26 |
|
|
|
27 |
function lookup_token($consumer, $token_type, $token) {
|
|
|
28 |
return new OAuthToken($consumer, "");
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
// Return NULL if the nonce has not been used
|
|
|
32 |
// Return $nonce if the nonce was previously used
|
|
|
33 |
function lookup_nonce($consumer, $token, $nonce, $timestamp) {
|
|
|
34 |
// Should add some clever logic to keep nonces from
|
|
|
35 |
// being reused - for no we are really trusting
|
|
|
36 |
// that the timestamp will save us
|
|
|
37 |
return NULL;
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
function new_request_token($consumer) {
|
|
|
41 |
return NULL;
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
function new_access_token($token, $consumer) {
|
|
|
45 |
return NULL;
|
|
|
46 |
}
|
|
|
47 |
}
|
|
|
48 |
?>
|