ILIAS  release_8 Revision v8.24
OAuthDataStore.php
Go to the documentation of this file.
1<?php
2
20
22use ILIAS\LTIOAuth\OAuthConsumer;
23use ILIAS\LTIOAuth\OAuthToken;
24use ILIAS\LTIOAuth\OAuthException;
25
34{
40 private $system = null;
41
47 public function __construct($system)
48 {
49 $this->system = $system;
50 }
51
57 public function lookup_consumer(string $consumerKey): OAuthConsumer
58 {
59 $key = $this->system->getKey();
60 $secret = '';
61 if (!empty($key)) {
62 $secret = $this->system->secret;
63 } elseif (($this->system instanceof Tool) && !empty($this->system->platform)) {
64 $key = $this->system->platform->getKey();
65 $secret = $this->system->platform->secret;
66 } elseif (($this->system instanceof Platform) && !empty(Tool::$defaultTool)) {
67 $key = Tool::$defaultTool->getKey();
69 }
70 if ($key !== $consumerKey) {
71 throw new OAuthException('Consumer key not found');
72 }
73
74 return new OAuthConsumer($key, $secret);
75 }
76
84 public function lookup_token(OAuthConsumer $consumer, string $tokenType, string $token): OAuthToken
85 {
86 return new OAuthToken($consumer, '');
87 }
88
97 public function lookup_nonce(OAuthConsumer $consumer, ?OAuthToken $token, string $value, int $timestamp): bool
98 {
99 if ($this->system instanceof Platform) {
100 $platform = $this->system;
101 } else {
102 $platform = $this->system->platform;
103 }
104 $nonce = new PlatformNonce($platform, $value);
105 $ok = !$nonce->load();
106 if ($ok) {
107 $ok = $nonce->save();
108 }
109 if (!$ok) {
110 $this->system->reason = 'Invalid nonce.';
111 }
112
113 return !$ok;
114 }
115
122 public function new_request_token(OAuthConsumer $consumer, $callback = null): ?string
123 {
124 return null;
125 }
126
134 public function new_access_token(OAuthToken $token, OAuthConsumer $consumer, $verifier = null): ?string
135 {
136 return null;
137 }
138}
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:70
Class to represent an OAuth datastore.
lookup_token(OAuthConsumer $consumer, string $tokenType, string $token)
Create an OAuthToken object for the system.
lookup_nonce(OAuthConsumer $consumer, ?OAuthToken $token, string $value, int $timestamp)
Lookup nonce value for the system.
new_request_token(OAuthConsumer $consumer, $callback=null)
Get new request token.
lookup_consumer(string $consumerKey)
Create an OAuthConsumer object for the system.
__construct($system)
Class constructor.
new_access_token(OAuthToken $token, OAuthConsumer $consumer, $verifier=null)
Get new access token.
Class to represent a platform nonce.
Class to represent a platform.
Definition: Platform.php:36
Class to represent an LTI Tool.
Definition: Tool.php:39
static Tool $defaultTool
Default tool for use with service requests.
Definition: Tool.php:299
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: OAuth.php:21
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: AccessToken.php:19
string $key
Consumer key/client ID value.
Definition: System.php:193
string $secret
Shared secret.
Definition: System.php:43
$token
Definition: xapitoken.php:70