Merge branch 'MDL-45851' of git://github.com/timhunt/moodle
[moodle.git] / enrol / lti / ims-blti / TrivialOAuthDataStore.php
blobe283eed336056b5ac951b64dd0a41f818b1dddcf
1 <?php
3 require_once($CFG->dirroot . '/enrol/lti/ims-blti/OAuth.php');
5 /**
6 * A Trivial memory-based store - no support for tokens
7 */
8 class TrivialOAuthDataStore extends OAuthDataStore {
9 private $consumers = array();
11 function add_consumer($consumer_key, $consumer_secret) {
12 $this->consumers[$consumer_key] = $consumer_secret;
15 function lookup_consumer($consumer_key) {
16 if ( strpos($consumer_key, "http://" ) === 0 ) {
17 $consumer = new OAuthConsumer($consumer_key,"secret", NULL);
18 return $consumer;
20 if ( $this->consumers[$consumer_key] ) {
21 $consumer = new OAuthConsumer($consumer_key,$this->consumers[$consumer_key], NULL);
22 return $consumer;
24 return NULL;
27 function lookup_token($consumer, $token_type, $token) {
28 return new OAuthToken($consumer, "");
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;
40 function new_request_token($consumer) {
41 return NULL;
44 function new_access_token($token, $consumer) {
45 return NULL;