blob: c4b898f7b5b4955d9d9bfa247469280d11b327d1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
<?php
namespace Studip\LTI13a;
use OAT\Library\Lti1p3Core\Registration\RegistrationInterface;
use OAT\Library\Lti1p3Core\Tool\ToolInterface;
use OAT\Library\Lti1p3Core\Platform\PlatformInterface;
use OAT\Library\Lti1p3Core\Security\Key\KeyChainInterface;
class Registration implements RegistrationInterface
{
public function __construct(
protected ?\LtiTool $tool
) {
}
public function setLtiTool(\LtiTool $tool)
{
$this->tool = $tool;
}
public function getLtiTool() : ?\LtiTool
{
return $this->tool;
}
#[\Override]
public function getIdentifier(): string
{
if (!$this->tool) {
return '';
}
return $this->tool->id;
}
#[\Override]
public function getClientId(): string
{
return $this->tool->id ?? '';
}
#[\Override]
public function getPlatform(): PlatformInterface
{
return PlatformManager::getPlatformConfiguration();
}
#[\Override]
public function getTool(): ToolInterface
{
if (!$this->tool) {
throw new \Studip\LTIException(
'No LTI tool link present.',
\Studip\LTIException::REGISTRATION_NOT_LINKED_TO_TOOL
);
}
return $this->tool->getToolData();
}
#[\Override]
public function getDeploymentIds(): array
{
if (!$this->tool) {
return [];
}
return \DBManager::get()->fetchFirst("SELECT `id` FROM `lti_deployments` WHERE `tool_id` = ?", [$this->tool->id]);
}
#[\Override]
public function hasDeploymentId(string $deploymentId): bool
{
if (!$this->tool) {
return false;
}
return \LtiDeployment::countBySql(
"`tool_id` = :tool_id AND `id` = :deployment_id",
['tool_id' => $this->tool->id, 'deployment_id' => $deploymentId]
) > 0;
}
#[\Override]
public function getDefaultDeploymentId(): ?string
{
//There is no default deployment-ID in Stud.IP:
return null;
}
#[\Override]
public function getPlatformKeyChain(): ?KeyChainInterface
{
$platform_keyring = PlatformManager::getPlatformKeyring();
if (!$platform_keyring) {
$platform_keyring = PlatformManager::generatePlatformKeyring();
}
return $platform_keyring->toKeyChain();
}
#[\Override]
public function getToolKeyChain(): ?KeyChainInterface
{
if (!$this->tool) {
return null;
}
$keyring = $this->tool->getKeyring();
if (!$keyring) {
$keyring = $this->tool->getKeyring(true);
}
return $keyring->toKeyChain();
}
#[\Override]
public function getPlatformJwksUrl(): ?string
{
return PlatformManager::getJwksUrl();
}
#[\Override]
public function getToolJwksUrl(): ?string
{
return $this->tool->jwks_url ?? null;
}
}
|