ILIAS  release_8 Revision v8.23
ILIAS\LTI\ToolProvider\Platform Class Reference

Class to represent a platform. More...

+ Collaboration diagram for ILIAS\LTI\ToolProvider\Platform:

Public Member Functions

 getAccessToken ()
 Get the authorization access token. More...
 
 setAccessToken (AccessToken $accessToken)
 Set the authorization access token. More...
 
 __construct (DataConnector $dataConnector=null)
 Class constructor. More...
 
 initialize ()
 Initialise the platform. More...
 
 initialise ()
 Initialise the platform. More...
 
 save ()
 Save the platform to the database. More...
 
 delete ()
 Delete the platform from the database. More...
 
 getId ()
 Get the platform ID. More...
 
 getFamilyCode ()
 Get platform family code (as reported by last platform connection). More...
 
 getDataConnector ()
 Get the data connector. More...
 
 getIsAvailable ()
 Is the platform available to accept launch requests? More...
 
 hasToolSettingsService ()
 Check if the Tool Settings service is supported. More...
 
 getToolSettings (bool $simple=true)
 Get Tool Settings. More...
 
 setToolSettings (array $settings=array())
 Set Tool Settings. More...
 
 getTools ()
 Get an array of defined tools. More...
 
 hasAccessTokenService ()
 Check if the Access Token service is supported. More...
 
 getMessageParameters ()
 Get the message parameters. More...
 
 handleRequest ()
 Process an incoming request. More...
 

Static Public Member Functions

static fromConsumerKey (string $key=null, DataConnector $dataConnector=null, bool $autoEnable=false)
 Load the platform from the database by its consumer key. More...
 

Data Fields

string $name = null
 Local name of platform. More...
 
string $platformId = null
 Platform ID. More...
 
string $clientId = null
 Client ID. More...
 
string $deploymentId = null
 Deployment ID. More...
 
string $authorizationServerId = null
 Authorization server ID. More...
 
string $authenticationUrl = null
 Login authentication URL. More...
 
string $accessTokenUrl = null
 Access Token service URL. More...
 
string $ltiVersion = null
 LTI version (as reported by last platform connection). More...
 
string $consumerName = null
 Name of tool consumer (as reported by last tool consumer connection). More...
 
string $consumerVersion = null
 Tool consumer version (as reported by last tool consumer connection). More...
 
object $profile = null
 The platform profile data. More...
 
object $toolProxy = null
 The tool proxy. More...
 
string $consumerGuid = null
 Tool consumer GUID (as reported by first tool consumer connection). More...
 
string $cssPath = null
 Optional CSS path (as reported by last tool consumer connection). More...
 
bool $protected = false
 Whether the platform instance is protected by matching the consumer_guid value in incoming requests. More...
 
int $idScope = Tool::ID_SCOPE_ID_ONLY
 Default scope to use when generating an Id value for a user. More...
 
string $defaultEmail = ''
 Default email address (or email domain) to use when no email address is provided for a user. More...
 
HTTPMessage $lastServiceRequest = null
 HttpMessage object for last service request. More...
 

Static Public Attributes

static array $MESSAGE_TYPES
 List of supported incoming message types. More...
 

Protected Member Functions

 onInitiateLogin (string &$url, string &$loginHint, string &$ltiMessageHint, array $params)
 Load the platform from the database by its platform, client and deployment IDs. More...
 
 onAuthenticate ()
 Check the hint and recover the message parameters for an authentication request. More...
 
 onContentItem ()
 Process a valid content-item message. More...
 
 onLtiStartAssessment ()
 Process a valid start assessment message. More...
 
 onError ()
 Process a response to an invalid message. More...
 

Private Member Functions

 authenticate ()
 Check the authenticity of the LTI message. More...
 
 handleAuthenticationRequest ()
 Process an authentication request. More...
 

Private Attributes

AccessToken $accessToken = null
 Access token to authorize service requests. More...
 

Detailed Description

Class to represent a platform.

Author
Stephen P Vickers steph.nosp@m.en@s.nosp@m.pvsof.nosp@m.twar.nosp@m.eprod.nosp@m.ucts.nosp@m..com

Definition at line 35 of file Platform.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\LTI\ToolProvider\Platform::__construct ( DataConnector  $dataConnector = null)

Class constructor.

Parameters
DataConnector | null$dataConnectorA data connector object

Definition at line 204 of file Platform.php.

References ILIAS\LTI\ToolProvider\$dataConnector, ILIAS\LTI\ToolProvider\DataConnector\DataConnector\getDataConnector(), and ILIAS\LTI\ToolProvider\Platform\initialize().

205  {
206  $this->initialize();
207  if (empty($dataConnector)) {
209  }
210  $this->dataConnector = $dataConnector;
211  }
static getDataConnector(object $db=null, string $dbTableNamePrefix='', string $type='')
Create data connector object.
ilLTIDataConnector $dataConnector
Data connector object.
Definition: System.php:64
initialize()
Initialise the platform.
Definition: Platform.php:216
+ Here is the call graph for this function:

Member Function Documentation

◆ authenticate()

ILIAS\LTI\ToolProvider\Platform::authenticate ( )
private

Check the authenticity of the LTI message.

The platform, resource link and user objects will be initialised if the request is valid.

Returns
bool True if the request has been successfully validated.

Definition at line 646 of file Platform.php.

References ILIAS\LTI\ToolProvider\checkMessage(), and ILIAS\LTI\ToolProvider\verifySignature().

Referenced by ILIAS\LTI\ToolProvider\Platform\handleRequest().

646  : bool
647  {
648  $this->checkMessage();
649  if ($this->ok) {
650  $this->ok = $this->verifySignature();
651  }
652 
653  return $this->ok;
654  }
checkMessage()
Verify the required properties of an LTI message.
Definition: System.php:728
verifySignature()
Verify the signature of a message.
Definition: System.php:781
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ILIAS\LTI\ToolProvider\Platform::delete ( )

Delete the platform from the database.

Returns
bool True if the object was successfully deleted

Definition at line 273 of file Platform.php.

273  : bool
274  {
275  return $this->dataConnector->deletePlatform($this);
276  }

◆ fromConsumerKey()

static ILIAS\LTI\ToolProvider\Platform::fromConsumerKey ( string  $key = null,
DataConnector  $dataConnector = null,
bool  $autoEnable = false 
)
static

Load the platform from the database by its consumer key.

Parameters
string | null$keyConsumer key
DataConnector | null$dataConnectorA data connector object
bool$autoEnabletrue if the platform is to be enabled automatically (optional, default is false)
Returns
Platform The platform object

Definition at line 496 of file Platform.php.

References ILIAS\LTI\ToolProvider\$dataConnector, ILIAS\LTI\ToolProvider\$key, and ilLTIDataConnector\loadPlatform().

Referenced by ILIAS\LTI\ToolProvider\Tool\authenticate().

496  : Platform
497  {
498  $platform = new static($dataConnector);
499  $platform->key = $key;
500  if (!empty($dataConnector)) {
501  $ok = $dataConnector->loadPlatform($platform);
502  if ($ok && $autoEnable) {
503  $platform->enabled = true;
504  }
505  }
506 
507  return $platform;
508  }
loadPlatform(\ILIAS\LTI\ToolProvider\Platform $platform)
Load platform object.
string $key
Consumer key/client ID value.
Definition: System.php:193
ilLTIDataConnector $dataConnector
Data connector object.
Definition: System.php:64
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAccessToken()

ILIAS\LTI\ToolProvider\Platform::getAccessToken ( )

Get the authorization access token.

Returns
AccessToken Access token

Definition at line 158 of file Platform.php.

References ILIAS\LTI\ToolProvider\Platform\$accessToken.

158  : ?AccessToken
159  {
160  return $this->accessToken;
161  }
AccessToken $accessToken
Access token to authorize service requests.
Definition: Platform.php:151

◆ getDataConnector()

ILIAS\LTI\ToolProvider\Platform::getDataConnector ( )

Get the data connector.

Returns
DataConnector|null Data connector object or string

Definition at line 328 of file Platform.php.

References ILIAS\LTI\ToolProvider\$dataConnector.

Referenced by ILIAS\LTI\ToolProvider\Context\fromPlatform(), and ILIAS\LTI\ToolProvider\ResourceLink\fromPlatform().

328  : ?DataConnector
329  {
330  return $this->dataConnector;
331  }
ilLTIDataConnector $dataConnector
Data connector object.
Definition: System.php:64
+ Here is the caller graph for this function:

◆ getFamilyCode()

ILIAS\LTI\ToolProvider\Platform::getFamilyCode ( )

Get platform family code (as reported by last platform connection).

Returns
string Family code

Definition at line 309 of file Platform.php.

References ILIAS\LTI\ToolProvider\Platform\$consumerVersion.

Referenced by ILIAS\LTI\ToolProvider\Platform\getToolSettings(), ILIAS\LTI\ToolProvider\Platform\hasAccessTokenService(), ILIAS\LTI\ToolProvider\Platform\hasToolSettingsService(), and ILIAS\LTI\ToolProvider\Platform\setToolSettings().

309  : ?string
310  {
311  $familyCode = '';
312  if (!empty($this->consumerVersion)) {
313  $familyCode = $this->consumerVersion;
314  $pos = strpos($familyCode, '-');
315  if ($pos !== false) {
316  $familyCode = substr($familyCode, 0, $pos);
317  }
318  }
319 
320  return $familyCode;
321  }
string $consumerVersion
Tool consumer version (as reported by last tool consumer connection).
Definition: Platform.php:116
+ Here is the caller graph for this function:

◆ getId()

ILIAS\LTI\ToolProvider\Platform::getId ( )

Get the platform ID.

The ID will be the consumer key if one exists, otherwise a concatenation of the platform/client/deployment IDs

Returns
string Platform ID value

Definition at line 285 of file Platform.php.

References ILIAS\LTI\ToolProvider\Platform\$clientId, ILIAS\LTI\ToolProvider\Platform\$deploymentId, ILIAS\LTI\ToolProvider\$id, ILIAS\LTI\ToolProvider\$key, and ILIAS\LTI\ToolProvider\Platform\$platformId.

285  : ?string
286  {
287  if (!empty($this->key)) {
288  $id = $this->key;
289  } elseif (!empty($this->platformId)) {
291  if (!empty($this->clientId)) {
292  $id .= '/' . $this->clientId;
293  }
294  if (!empty($this->deploymentId)) {
295  $id .= '#' . $this->deploymentId;
296  }
297  } else {
298  $id = null;
299  }
300 
301  return $id;
302  }
string $deploymentId
Deployment ID.
Definition: Platform.php:74
string $clientId
Client ID.
Definition: Platform.php:67
int $id
System ID value.
Definition: System.php:186
string $platformId
Platform ID.
Definition: Platform.php:60
string $key
Consumer key/client ID value.
Definition: System.php:193

◆ getIsAvailable()

ILIAS\LTI\ToolProvider\Platform::getIsAvailable ( )

Is the platform available to accept launch requests?

Returns
bool True if the platform is enabled and within any date constraints

Definition at line 338 of file Platform.php.

References ILIAS\LTI\ToolProvider\$enabled.

338  : bool
339  {
340  $ok = $this->enabled;
341 
342  $now = time();
343  if ($ok && !is_null($this->enableFrom)) {
344  $ok = $this->enableFrom <= $now;
345  }
346  if ($ok && !is_null($this->enableUntil)) {
347  $ok = $this->enableUntil > $now;
348  }
349 
350  return $ok;
351  }
bool $enabled
Whether the system instance is enabled to accept connection requests.
Definition: System.php:123

◆ getMessageParameters()

ILIAS\LTI\ToolProvider\Platform::getMessageParameters ( )

Get the message parameters.

Returns
array The message parameter array

Definition at line 444 of file Platform.php.

References ILIAS\LTI\ToolProvider\$messageParameters, and ILIAS\LTI\ToolProvider\parseMessage().

Referenced by ILIAS\LTI\ToolProvider\Platform\handleRequest().

444  : array
445  {
446  if ($this->ok && is_null($this->messageParameters)) {
447  $this->parseMessage();
448  }
449 
451  }
array $messageParameters
LTI message parameters.
Definition: System.php:179
parseMessage()
Parse the message.
Definition: System.php:885
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTools()

ILIAS\LTI\ToolProvider\Platform::getTools ( )

Get an array of defined tools.

Returns
array Array of Tool objects

Definition at line 420 of file Platform.php.

420  : array
421  {
422  return $this->dataConnector->getTools();
423  }

◆ getToolSettings()

ILIAS\LTI\ToolProvider\Platform::getToolSettings ( bool  $simple = true)

Get Tool Settings.

Parameters
bool$simpleTrue if all the simple media type is to be used (optional, default is true)
Returns
mixed The array of settings if successful, otherwise false

Definition at line 372 of file Platform.php.

References $service, ILIAS\LTI\ToolProvider\$settings, ILIAS\LTI\ToolProvider\ApiHook\$TOOL_SETTINGS_SERVICE_HOOK, $url, ILIAS\LTI\ToolProvider\ApiHook\getApiHook(), ILIAS\LTI\ToolProvider\Platform\getFamilyCode(), ILIAS\getSetting(), and ILIAS\LTI\ToolProvider\ApiHook\hasConfiguredApiHook().

373  {
374  $ok = false;
375  $settings = array();
376  if (!empty($this->getSetting('custom_system_setting_url'))) {
377  $url = $this->getSetting('custom_system_setting_url');
378  $service = new Service\ToolSettings($this, $url, $simple);
379  $settings = $service->get();
380  $this->lastServiceRequest = $service->getHttpMessage();
381  $ok = $settings !== false;
382  }
383  if (!$ok && $this->hasConfiguredApiHook(self::$TOOL_SETTINGS_SERVICE_HOOK, $this->getFamilyCode(), $this)) {
384  $className = $this->getApiHook(self::$TOOL_SETTINGS_SERVICE_HOOK, $this->getFamilyCode());
385  $hook = new $className($this);
386  $settings = $hook->getToolSettings($simple);
387  }
388 
389  return $settings;
390  }
getSetting(string $a_keyword, ?string $a_default_value=null)
read one value from settingstable
Definition: class.ilias.php:88
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
static hasConfiguredApiHook(string $hookName, string $familyCode, $sourceObject)
Check if an API hook is registered and configured.
Definition: ApiHook.php:115
static getApiHook(string $hookName, string $familyCode)
Get the class name for an API hook.
Definition: ApiHook.php:88
getFamilyCode()
Get platform family code (as reported by last platform connection).
Definition: Platform.php:309
$url
$service
Definition: ltiservices.php:43
static string $TOOL_SETTINGS_SERVICE_HOOK
Tool Settings service hook name.
Definition: ApiHook.php:58
+ Here is the call graph for this function:

◆ handleAuthenticationRequest()

ILIAS\LTI\ToolProvider\Platform::handleAuthenticationRequest ( )
private

Process an authentication request.

Generates an auto-submit form to respond to the request.

Definition at line 661 of file Platform.php.

References ILIAS\LTI\ToolProvider\Tool\$defaultTool, $scopes, ILIAS\LTI\ToolProvider\addSignature(), exit, ILIAS\LTI\ToolProvider\Util\getRequestParameters(), ILIAS\LTI\ToolProvider\Platform\onAuthenticate(), and ILIAS\LTI\ToolProvider\Util\sendForm().

Referenced by ILIAS\LTI\ToolProvider\Platform\handleRequest().

662  {
663  $this->messageParameters = array();
664  $parameters = Util::getRequestParameters();
665  $this->ok = isset($parameters['scope']) && isset($parameters['response_type']) &&
666  isset($parameters['client_id']) && isset($parameters['redirect_uri']) &&
667  isset($parameters['login_hint']) && isset($parameters['nonce']);
668  if (!$this->ok) {
669  $this->messageParameters['error'] = 'invalid_request';
670  }
671  if ($this->ok) {
672  $scopes = explode(' ', $parameters['scope']);
673  $this->ok = in_array('openid', $scopes);
674  if (!$this->ok) {
675  $this->messageParameters['error'] = 'invalid_scope';
676  }
677  }
678  if ($this->ok && ($parameters['response_type'] !== 'id_token')) {
679  $this->ok = false;
680  $this->messageParameters['error'] = 'unsupported_response_type';
681  }
682  if ($this->ok && ($parameters['client_id'] !== $this->clientId)) {
683  $this->ok = false;
684  $this->messageParameters['error'] = 'unauthorized_client';
685  }
686  if ($this->ok) {
687  $this->ok = in_array($parameters['redirect_uri'], Tool::$defaultTool->redirectionUris);
688  if (!$this->ok) {
689  $this->messageParameters['error'] = 'invalid_request';
690  $this->messageParameters['error_description'] = 'Unregistered redirect_uri';
691  }
692  }
693  if ($this->ok) {
694  if (isset($parameters['response_mode'])) {
695  $this->ok = ($parameters['response_mode'] === 'form_post');
696  } else {
697  $this->ok = false;
698  }
699  if (!$this->ok) {
700  $this->messageParameters['error'] = 'invalid_request';
701  $this->messageParameters['error_description'] = 'Invalid response_mode';
702  }
703  }
704  if ($this->ok && (!isset($parameters['prompt']) || ($parameters['prompt'] !== 'none'))) {
705  $this->ok = false;
706  $this->messageParameters['error'] = 'invalid_request';
707  $this->messageParameters['error_description'] = 'Invalid prompt';
708  }
709 
710  if ($this->ok) {
711  $this->onAuthenticate();
712  }
713  if ($this->ok) {
714  $this->messageParameters = $this->addSignature(
715  Tool::$defaultTool->messageUrl,
716  $this->messageParameters,
717  'POST',
718  null,
719  $parameters['nonce']
720  );
721  }
722  if (isset($parameters['state'])) {
723  $this->messageParameters['state'] = $parameters['state'];
724  }
725  $html = Util::sendForm($parameters['redirect_uri'], $this->messageParameters);
726  echo $html;
727  exit;
728  }
exit
Definition: login.php:28
$scopes
Definition: ltitoken.php:99
onAuthenticate()
Check the hint and recover the message parameters for an authentication request.
Definition: Platform.php:585
static sendForm(string $url, array $params, string $target='')
Generate a web page containing an auto-submitted form of parameters.
Definition: Util.php:466
addSignature(string $endpoint, $data, string $method='POST', ?string $type=null, ?string $nonce='', ?string $hash=null, ?int $timestamp=null)
Add the signature to an array of message parameters or to a header string.
Definition: System.php:714
static getRequestParameters()
Return GET and POST request parameters (POST parameters take precedence)
Definition: Util.php:224
static Tool $defaultTool
Default tool for use with service requests.
Definition: Tool.php:299
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleRequest()

ILIAS\LTI\ToolProvider\Platform::handleRequest ( )

Process an incoming request.

Definition at line 456 of file Platform.php.

References ILIAS\LTI\ToolProvider\Util\$logLevel, ILIAS\LTI\ToolProvider\Platform\authenticate(), ILIAS\LTI\ToolProvider\doCallback(), ILIAS\LTI\ToolProvider\Platform\getMessageParameters(), ILIAS\LTI\ToolProvider\Util\getRequestParameters(), ILIAS\LTI\ToolProvider\Platform\handleAuthenticationRequest(), ILIAS\LTI\ToolProvider\Util\logError(), ILIAS\LTI\ToolProvider\Util\LOGLEVEL_DEBUG, ILIAS\LTI\ToolProvider\Util\logRequest(), and ILIAS\LTI\ToolProvider\Platform\onError().

457  {
458  $parameters = Util::getRequestParameters();
459  if ($this->debugMode) {
461  }
462  if ($this->ok) {
463  if (!empty($parameters['client_id'])) { // Authentication request
466  } else { // LTI message
467  $this->getMessageParameters();
469  if ($this->ok && $this->authenticate()) {
470  $this->doCallback();
471  }
472  }
473  }
474  if (!$this->ok) {
475  $this->onError();
476  }
477  if (!$this->ok) {
478  $errorMessage = "Request failed with reason: '{$this->reason}'";
479  if (!empty($this->details)) {
480  $errorMessage .= PHP_EOL . 'Debug information:';
481  foreach ($this->details as $detail) {
482  $errorMessage .= PHP_EOL . " {$detail}";
483  }
484  }
485  Util::logError($errorMessage);
486  }
487  }
getMessageParameters()
Get the message parameters.
Definition: Platform.php:444
const LOGLEVEL_DEBUG
Log all messages.
Definition: Util.php:156
authenticate()
Check the authenticity of the LTI message.
Definition: Platform.php:646
static getRequestParameters()
Return GET and POST request parameters (POST parameters take precedence)
Definition: Util.php:224
doCallback()
Call any callback function for the requested action.
Definition: System.php:1141
static logRequest(bool $debugLevel=false)
Log a request received.
Definition: Util.php:375
handleAuthenticationRequest()
Process an authentication request.
Definition: Platform.php:661
static logError(string $message, bool $showSource=true)
Log an error message.
Definition: Util.php:337
onError()
Process a response to an invalid message.
Definition: Platform.php:630
static int $logLevel
Current logging level.
Definition: Util.php:189
+ Here is the call graph for this function:

◆ hasAccessTokenService()

ILIAS\LTI\ToolProvider\Platform::hasAccessTokenService ( )

Check if the Access Token service is supported.

Returns
bool True if this platform supports the Access Token service

Definition at line 430 of file Platform.php.

References ILIAS\LTI\ToolProvider\ApiHook\$ACCESS_TOKEN_SERVICE_HOOK, ILIAS\LTI\ToolProvider\Platform\getFamilyCode(), ILIAS\getSetting(), and ILIAS\LTI\ToolProvider\ApiHook\hasConfiguredApiHook().

430  : bool
431  {
432  $has = !empty($this->getSetting('custom_oauth2_access_token_url'));
433  if (!$has) {
435  }
436  return $has;
437  }
getSetting(string $a_keyword, ?string $a_default_value=null)
read one value from settingstable
Definition: class.ilias.php:88
static hasConfiguredApiHook(string $hookName, string $familyCode, $sourceObject)
Check if an API hook is registered and configured.
Definition: ApiHook.php:115
getFamilyCode()
Get platform family code (as reported by last platform connection).
Definition: Platform.php:309
static string $ACCESS_TOKEN_SERVICE_HOOK
Access Token service hook name.
Definition: ApiHook.php:63
+ Here is the call graph for this function:

◆ hasToolSettingsService()

ILIAS\LTI\ToolProvider\Platform::hasToolSettingsService ( )

Check if the Tool Settings service is supported.

Returns
bool True if this platform supports the Tool Settings service

Definition at line 358 of file Platform.php.

References ILIAS\LTI\ToolProvider\ApiHook\$TOOL_SETTINGS_SERVICE_HOOK, ILIAS\LTI\ToolProvider\Platform\getFamilyCode(), ILIAS\getSetting(), and ILIAS\LTI\ToolProvider\ApiHook\hasConfiguredApiHook().

358  : bool
359  {
360  $has = !empty($this->getSetting('custom_system_setting_url'));
361  if (!$has) {
363  }
364  return $has;
365  }
getSetting(string $a_keyword, ?string $a_default_value=null)
read one value from settingstable
Definition: class.ilias.php:88
static hasConfiguredApiHook(string $hookName, string $familyCode, $sourceObject)
Check if an API hook is registered and configured.
Definition: ApiHook.php:115
getFamilyCode()
Get platform family code (as reported by last platform connection).
Definition: Platform.php:309
static string $TOOL_SETTINGS_SERVICE_HOOK
Tool Settings service hook name.
Definition: ApiHook.php:58
+ Here is the call graph for this function:

◆ initialise()

ILIAS\LTI\ToolProvider\Platform::initialise ( )

Initialise the platform.

Synonym for initialize().

Definition at line 253 of file Platform.php.

References ILIAS\LTI\ToolProvider\Platform\initialize().

254  {
255  $this->initialize();
256  }
initialize()
Initialise the platform.
Definition: Platform.php:216
+ Here is the call graph for this function:

◆ initialize()

ILIAS\LTI\ToolProvider\Platform::initialize ( )

Initialise the platform.

Definition at line 216 of file Platform.php.

References ILIAS\LTI\ToolProvider\Tool\ID_SCOPE_ID_ONLY, and ILIAS\Repository\settings().

Referenced by ILIAS\LTI\ToolProvider\Platform\__construct(), ILIAS\LTI\ToolProvider\DataConnector\DataConnector\deletePlatform(), and ILIAS\LTI\ToolProvider\Platform\initialise().

217  {
218  $this->id = null;
219  $this->key = null;
220  $this->name = null;
221  $this->secret = null;
222  $this->signatureMethod = 'HMAC-SHA1';
223  $this->encryptionMethod = ''; //changed from null
224  $this->rsaKey = null;
225  $this->kid = null;
226  $this->jku = null;
227  $this->platformId = null;
228  $this->clientId = null;
229  $this->deploymentId = null;
230  $this->ltiVersion = null;
231  $this->consumerName = null;
232  $this->consumerVersion = null;
233  $this->consumerGuid = null;
234  $this->profile = null;
235  $this->toolProxy = null;
236  $this->settings = array();
237  $this->protected = false;
238  $this->enabled = false;
239  $this->enableFrom = null;
240  $this->enableUntil = null;
241  $this->lastAccess = null;
242  $this->idScope = Tool::ID_SCOPE_ID_ONLY;
243  $this->defaultEmail = '';
244  $this->created = null;
245  $this->updated = null;
246  }
const ID_SCOPE_ID_ONLY
Use ID value only.
Definition: Tool.php:51
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ onAuthenticate()

ILIAS\LTI\ToolProvider\Platform::onAuthenticate ( )
protected

Check the hint and recover the message parameters for an authentication request.

Override this method if the data has been saved elsewhere.

Definition at line 585 of file Platform.php.

References ILIAS\LTI\ToolProvider\Tool\$defaultTool, and ILIAS\LTI\ToolProvider\Util\getRequestParameters().

Referenced by ILIAS\LTI\ToolProvider\Platform\handleAuthenticationRequest().

586  {
587  $hasSession = !empty(session_id());
588  if (!$hasSession) {
589  session_start();
590  }
591  if (isset($_SESSION['ceLTIc_lti_initiated_login'])) {
592  $login = $_SESSION['ceLTIc_lti_initiated_login'];
593  $parameters = Util::getRequestParameters();
594  if ($parameters['login_hint'] !== $login['login_hint'] ||
595  (isset($login['lti_message_hint']) && (!isset($parameters['lti_message_hint']) || ($parameters['lti_message_hint'] !== $login['lti_message_hint'])))) {
596  $this->ok = false;
597  $this->messageParameters['error'] = 'access_denied';
598  } else {
599  Tool::$defaultTool->messageUrl = $login['messageUrl'];
600  $this->messageParameters = $login['params'];
601  }
602  unset($_SESSION['ceLTIc_lti_initiated_login']);
603  }
604  if (!$hasSession) {
605  session_write_close();
606  }
607  }
static getRequestParameters()
Return GET and POST request parameters (POST parameters take precedence)
Definition: Util.php:224
static Tool $defaultTool
Default tool for use with service requests.
Definition: Tool.php:299
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ onContentItem()

ILIAS\LTI\ToolProvider\Platform::onContentItem ( )
protected

Process a valid content-item message.

Definition at line 612 of file Platform.php.

References ILIAS\LTI\ToolProvider\Platform\onError().

613  {
614  $this->reason = 'No onContentItem method found for platform';
615  $this->onError();
616  }
onError()
Process a response to an invalid message.
Definition: Platform.php:630
+ Here is the call graph for this function:

◆ onError()

ILIAS\LTI\ToolProvider\Platform::onError ( )
protected

Process a response to an invalid message.

Definition at line 630 of file Platform.php.

Referenced by ILIAS\LTI\ToolProvider\Platform\handleRequest(), ILIAS\LTI\ToolProvider\Platform\onContentItem(), and ILIAS\LTI\ToolProvider\Platform\onLtiStartAssessment().

631  {
632  $this->ok = false;
633  }
+ Here is the caller graph for this function:

◆ onInitiateLogin()

ILIAS\LTI\ToolProvider\Platform::onInitiateLogin ( string &  $url,
string &  $loginHint,
string &  $ltiMessageHint,
array  $params 
)
protected

Load the platform from the database by its platform, client and deployment IDs.

Parameters
string$platformIdThe platform ID
string$clientIdThe client ID
string$deploymentIdThe deployment ID
DataConnector | null$dataConnectorA data connector object
bool$autoEnableTrue if the platform is to be enabled automatically (optional, default is false)
Returns
Platform The platform object Load the platform from the database by its record ID.
Parameters
int$idThe platform record ID //UK: changed to int
DataConnector$dataConnectorA data connector object
Returns
Platform The platform object Save the hint and message parameters when sending an initiate login request. Override this method to save the data elsewhere.
Parameters
string$urlThe message URL
string$loginHintThe ID of the user
string$ltiMessageHintThe message hint being sent to the tool
array$paramsAn associative array of message parameters

Definition at line 563 of file Platform.php.

564  {
565  $hasSession = !empty(session_id());
566  if (!$hasSession) {
567  session_start();
568  }
569  $_SESSION['ceLTIc_lti_initiated_login'] = array(
570  'messageUrl' => $url,
571  'login_hint' => $loginHint,
572  'lti_message_hint' => $ltiMessageHint,
573  'params' => $params
574  );
575  if (!$hasSession) {
576  session_write_close();
577  }
578  }
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33
$ltiMessageHint
Definition: ltiauth.php:51
$url

◆ onLtiStartAssessment()

ILIAS\LTI\ToolProvider\Platform::onLtiStartAssessment ( )
protected

Process a valid start assessment message.

Definition at line 621 of file Platform.php.

References ILIAS\LTI\ToolProvider\Platform\onError().

622  {
623  $this->reason = 'No onLtiStartAssessment method found for platform';
624  $this->onError();
625  }
onError()
Process a response to an invalid message.
Definition: Platform.php:630
+ Here is the call graph for this function:

◆ save()

ILIAS\LTI\ToolProvider\Platform::save ( )

Save the platform to the database.

Returns
bool True if the object was successfully saved

Definition at line 263 of file Platform.php.

263  : bool
264  {
265  return $this->dataConnector->savePlatform($this);
266  }

◆ setAccessToken()

ILIAS\LTI\ToolProvider\Platform::setAccessToken ( AccessToken  $accessToken)

Set the authorization access token.

Parameters
AccessToken$accessTokenAccess token

Definition at line 167 of file Platform.php.

References ILIAS\LTI\ToolProvider\Platform\$accessToken.

168  {
169  $this->accessToken = $accessToken;
170  }
AccessToken $accessToken
Access token to authorize service requests.
Definition: Platform.php:151

◆ setToolSettings()

ILIAS\LTI\ToolProvider\Platform::setToolSettings ( array  $settings = array())

Set Tool Settings.

Parameters
array$settingsAn associative array of settings (optional, default is none)
Returns
bool True if action was successful, otherwise false

Definition at line 397 of file Platform.php.

References $service, ILIAS\LTI\ToolProvider\$settings, ILIAS\LTI\ToolProvider\ApiHook\$TOOL_SETTINGS_SERVICE_HOOK, $url, ILIAS\LTI\ToolProvider\ApiHook\getApiHook(), ILIAS\LTI\ToolProvider\Platform\getFamilyCode(), ILIAS\getSetting(), and ILIAS\LTI\ToolProvider\ApiHook\hasConfiguredApiHook().

397  : bool
398  {
399  $ok = false;
400  if (!empty($this->getSetting('custom_system_setting_url'))) {
401  $url = $this->getSetting('custom_system_setting_url');
402  $service = new Service\ToolSettings($this, $url);
403  $ok = $service->set($settings);
404  $this->lastServiceRequest = $service->getHttpMessage();
405  }
406  if (!$ok && $this->hasConfiguredApiHook(self::$TOOL_SETTINGS_SERVICE_HOOK, $this->getFamilyCode(), $this)) {
407  $className = $this->getApiHook(self::$TOOL_SETTINGS_SERVICE_HOOK, $this->getFamilyCode());
408  $hook = new $className($this);
409  $ok = $hook->setToolSettings($settings);
410  }
411 
412  return $ok;
413  }
getSetting(string $a_keyword, ?string $a_default_value=null)
read one value from settingstable
Definition: class.ilias.php:88
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
static hasConfiguredApiHook(string $hookName, string $familyCode, $sourceObject)
Check if an API hook is registered and configured.
Definition: ApiHook.php:115
static getApiHook(string $hookName, string $familyCode)
Get the class name for an API hook.
Definition: ApiHook.php:88
getFamilyCode()
Get platform family code (as reported by last platform connection).
Definition: Platform.php:309
$url
$service
Definition: ltiservices.php:43
static string $TOOL_SETTINGS_SERVICE_HOOK
Tool Settings service hook name.
Definition: ApiHook.php:58
+ Here is the call graph for this function:

Field Documentation

◆ $accessToken

AccessToken null ILIAS\LTI\ToolProvider\Platform::$accessToken = null
private

Access token to authorize service requests.

Definition at line 151 of file Platform.php.

Referenced by ILIAS\LTI\ToolProvider\Platform\getAccessToken(), and ILIAS\LTI\ToolProvider\Platform\setAccessToken().

◆ $accessTokenUrl

string null ILIAS\LTI\ToolProvider\Platform::$accessTokenUrl = null

Access Token service URL.

Definition at line 95 of file Platform.php.

◆ $authenticationUrl

string null ILIAS\LTI\ToolProvider\Platform::$authenticationUrl = null

Login authentication URL.

Definition at line 88 of file Platform.php.

◆ $authorizationServerId

string null ILIAS\LTI\ToolProvider\Platform::$authorizationServerId = null

Authorization server ID.

Definition at line 81 of file Platform.php.

◆ $clientId

string null ILIAS\LTI\ToolProvider\Platform::$clientId = null

Client ID.

Definition at line 67 of file Platform.php.

Referenced by ILIAS\LTI\ToolProvider\Platform\getId().

◆ $consumerGuid

string null ILIAS\LTI\ToolProvider\Platform::$consumerGuid = null

Tool consumer GUID (as reported by first tool consumer connection).

Definition at line 137 of file Platform.php.

◆ $consumerName

string null ILIAS\LTI\ToolProvider\Platform::$consumerName = null

Name of tool consumer (as reported by last tool consumer connection).

Definition at line 109 of file Platform.php.

◆ $consumerVersion

string null ILIAS\LTI\ToolProvider\Platform::$consumerVersion = null

Tool consumer version (as reported by last tool consumer connection).

Definition at line 116 of file Platform.php.

Referenced by ILIAS\LTI\ToolProvider\Platform\getFamilyCode().

◆ $cssPath

string ILIAS\LTI\ToolProvider\Platform::$cssPath = null

Optional CSS path (as reported by last tool consumer connection).

Definition at line 144 of file Platform.php.

◆ $defaultEmail

string ILIAS\LTI\ToolProvider\Platform::$defaultEmail = ''

Default email address (or email domain) to use when no email address is provided for a user.

Definition at line 191 of file Platform.php.

◆ $deploymentId

string null ILIAS\LTI\ToolProvider\Platform::$deploymentId = null

Deployment ID.

Definition at line 74 of file Platform.php.

Referenced by ILIAS\LTI\ToolProvider\Platform\getId().

◆ $idScope

int ILIAS\LTI\ToolProvider\Platform::$idScope = Tool::ID_SCOPE_ID_ONLY

Default scope to use when generating an Id value for a user.

Definition at line 184 of file Platform.php.

◆ $lastServiceRequest

HttpMessage null ILIAS\LTI\ToolProvider\Platform::$lastServiceRequest = null

HttpMessage object for last service request.

Definition at line 198 of file Platform.php.

◆ $ltiVersion

string null ILIAS\LTI\ToolProvider\Platform::$ltiVersion = null

LTI version (as reported by last platform connection).

Definition at line 102 of file Platform.php.

◆ $MESSAGE_TYPES

array ILIAS\LTI\ToolProvider\Platform::$MESSAGE_TYPES
static
Initial value:
= array(
'ContentItemSelection',
'LtiStartAssessment'
)

List of supported incoming message types.

Definition at line 43 of file Platform.php.

◆ $name

string null ILIAS\LTI\ToolProvider\Platform::$name = null

Local name of platform.

Definition at line 53 of file Platform.php.

◆ $platformId

string null ILIAS\LTI\ToolProvider\Platform::$platformId = null

Platform ID.

Definition at line 60 of file Platform.php.

Referenced by ILIAS\LTI\ToolProvider\Platform\getId().

◆ $profile

object null ILIAS\LTI\ToolProvider\Platform::$profile = null

The platform profile data.

Definition at line 123 of file Platform.php.

◆ $protected

bool ILIAS\LTI\ToolProvider\Platform::$protected = false

Whether the platform instance is protected by matching the consumer_guid value in incoming requests.

Definition at line 177 of file Platform.php.

◆ $toolProxy

object null ILIAS\LTI\ToolProvider\Platform::$toolProxy = null

The tool proxy.

Definition at line 130 of file Platform.php.


The documentation for this class was generated from the following file: