ILIAS  release_8 Revision v8.23
SecurityContract.php
Go to the documentation of this file.
1 <?php
2 
20 
22 
31 {
37  public function __construct(Tool $tool, string $secret)
38  {
39  $tcContexts = array();
40  foreach ($tool->platform->profile->{'@context'} as $context) {
41  if (is_object($context)) {
42  $tcContexts = array_merge(get_object_vars($context), $tcContexts);
43  }
44  }
45 
46  $this->shared_secret = $secret;
47  $toolServices = array();
48  foreach ($tool->requiredServices as $requiredService) {
49  foreach ($requiredService->formats as $format) {
50  $service = $tool->findService($format, $requiredService->actions);
51  if (($service !== false) && !array_key_exists($service->{'@id'}, $toolServices)) {
52  $id = $service->{'@id'};
53  $parts = explode(':', $id, 2);
54  if (count($parts) > 1) {
55  if (array_key_exists($parts[0], $tcContexts)) {
56  $id = "{$tcContexts[$parts[0]]}{$parts[1]}";
57  }
58  }
59  $toolService = new \stdClass();
60  $toolService->{'@type'} = 'RestServiceProfile';
61  $toolService->service = $id;
62  $toolService->action = $requiredService->actions;
63  $toolServices[$service->{'@id'}] = $toolService;
64  }
65  }
66  }
67  foreach ($tool->optionalServices as $optionalService) {
68  foreach ($optionalService->formats as $format) {
69  $service = $tool->findService($format, $optionalService->actions);
70  if (($service !== false) && !array_key_exists($service->{'@id'}, $toolServices)) {
71  $id = $service->{'@id'};
72  $parts = explode(':', $id, 2);
73  if (count($parts) > 1) {
74  if (array_key_exists($parts[0], $tcContexts)) {
75  $id = "{$tcContexts[$parts[0]]}{$parts[1]}";
76  }
77  }
78  $toolService = new \stdClass();
79  $toolService->{'@type'} = 'RestServiceProfile';
80  $toolService->service = $id;
81  $toolService->action = $optionalService->actions;
82  $toolServices[$service->{'@id'}] = $toolService;
83  }
84  }
85  }
86  $this->tool_service = array_values($toolServices);
87  }
88 }
$context
Definition: webdav.php:29
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:64
Class to represent an LTI Tool.
Definition: Tool.php:38
int $id
System ID value.
Definition: System.php:186
string $secret
Shared secret.
Definition: System.php:43
Class to represent an LTI Security Contract document.
$format
Definition: metadata.php:235
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Message.php:19
$service
Definition: ltiservices.php:43
__construct(Tool $tool, string $secret)
Class constructor.