3 declare(strict_types=1);
39 private \ILIAS\DI\Container
$dic;
49 $this->
lng = $DIC->language();
50 $this->
user = $DIC->user();
64 $command = $DIC->ctrl()->getCmd(self::CMD_LAUNCH);
74 if ($this->dic->access()->checkAccess(
'read',
'', $this->
object->getRefId())) {
75 if ($this->
object->getProvider()->getLtiVersion() ==
"LTI-1p0") {
76 if ($this->
object->isLaunchMethodEmbedded()) {
77 $tpl =
new ilTemplate(
'tpl.lti_content.html',
true,
true,
'Modules/LTIConsumer');
78 $tpl->setVariable(
"EMBEDDED_IFRAME_SRC", $this->dic->ctrl()->getLinkTarget(
80 self::CMD_SHOW_EMBEDDED
82 $this->dic->ui()->mainTemplate()->setContent(
$tpl->get());
88 $tpl =
new ilTemplate(
'tpl.lti_content.html',
true,
true,
'Modules/LTIConsumer');
89 $tpl->setVariable(
"EMBEDDED_IFRAME_SRC", $this->dic->ctrl()->getLinkTarget(
91 self::CMD_SHOW_EMBEDDED
93 $this->dic->ui()->mainTemplate()->setContent(
$tpl->get());
99 $this->dic->ui()->mainTemplate()->setOnScreenMessage(
101 'initialLogin Error: ',
106 $this->dic->http()->saveResponse(
$response);
107 $this->dic->http()->sendResponse();
108 $this->dic->http()->close();
128 if (isset($loginData[
'state'])) {
129 $params[
'state'] = $loginData[
'state'];
132 $r =
'<form action="' . $loginData[
'redirect_uri'] .
"\" name=\"ltiAuthForm\" id=\"ltiAuthForm\" " .
133 "method=\"post\" enctype=\"application/x-www-form-urlencoded\">\n";
137 $value = htmlspecialchars($value);
138 $r .=
" <input type=\"hidden\" name=\"{$key}\" value=\"{$value}\"/>\n";
142 $r .=
"<script type=\"text/javascript\">\n" .
144 "document.ltiAuthForm.submit();\n" .
155 if ($this->
object->getOfflineStatus() ||
156 $this->
object->isLaunchMethodEmbedded() ||
163 $this->
user->getId(),
164 $this->
object->getProvider()->getPrivacyIdent()
167 if ($user_ident ==
'' || $user_ident == null) {
173 $context = $ilLTIConsumerLaunch->getContext();
174 $contextType = $ilLTIConsumerLaunch::getLTIContextType($context[
"type"]);
175 $contextId = $context[
"id"];
176 $contextTitle = $context[
"title"];
179 $this->dic->user()->getId(),
180 $this->
object->getRefId(),
181 $this->
object->getId()
184 $returnUrl = !$this->
object->isLaunchMethodOwnWin() ?
'' : str_replace(
190 $launchParameters = $this->
object->buildLaunchParameters(
199 $target = $this->
object->getLaunchMethod() ==
"newWin" ?
"_blank" :
"_self";
200 $button =
'<input class="btn btn-default ilPre" type="button" onClick="ltilaunch()" value = "' . $this->
lng->txt(
"show_content") .
'" />';
201 $output =
'<form id="lti_launch_form" name="lti_launch_form" action="' . $this->
object->getProvider()->getProviderUrl() .
'" method="post" target="' . $target .
'" encType="application/x-www-form-urlencoded">';
202 foreach ($launchParameters as $field => $value) {
203 $output .= sprintf(
'<input type="hidden" name="%s" value="%s" />', $field, $value) .
"\n";
206 $output .=
'</form>';
207 $output .=
'<span id ="lti_launched" style="display:none">' . $this->
lng->txt(
"launched") .
'</span>';
208 $output .=
'<script type="text/javascript"> 209 function ltilaunch() { 210 document.lti_launch_form.submit(); 211 document.getElementById("lti_launch_form").style.display = "none"; 212 document.getElementById("lti_launched").style.display = "inline"; 219 if ($this->
object->getOfflineStatus() ||
220 $this->
object->isLaunchMethodEmbedded() ||
225 $user_ident = $this->cmixUser->getUsrIdent();
227 $context = $ilLTIConsumerLaunch->getContext();
228 $contextType = $ilLTIConsumerLaunch::getLTIContextType($context[
"type"]);
229 $contextId = $context[
"id"];
230 $contextTitle = $context[
"title"];
233 $this->dic->user()->getId(),
234 $this->
object->getRefId(),
235 $this->
object->getId()
238 $returnUrl = !$this->
object->isLaunchMethodOwnWin() ?
'' : str_replace(
244 $target = $this->
object->getLaunchMethod() ==
"newWin" ?
"_blank" :
"_self";
245 $button =
'<input class="btn btn-default ilPre" type="button" onClick="ltilaunch()" value = "' . $this->
lng->txt(
"show_content") .
'" />';
248 $output =
'<form id="lti_launch_form" name="lti_launch_form" action="' . $this->
object->getProvider()->getInitiateLogin() .
'" method="post" target="' . $target .
'" encType="application/x-www-form-urlencoded">';
250 $output .= sprintf(
'<input type="hidden" name="%s" value="%s" />',
'target_link_uri', $this->
object->getProvider()->getProviderUrl()) .
"\n";
251 $output .= sprintf(
'<input type="hidden" name="%s" value="%s" />',
'login_hint', $user_ident) .
"\n";
252 $output .= sprintf(
'<input type="hidden" name="%s" value="%s" />',
'lti_message_hint',
$ltiMessageHint) .
"\n";
253 $output .= sprintf(
'<input type="hidden" name="%s" value="%s" />',
'client_id', $this->
object->getProvider()->getClientId()) .
"\n";
254 $output .= sprintf(
'<input type="hidden" name="%s" value="%s" />',
'lti_deployment_id', $this->
object->getProvider()->getId()) .
"\n";
256 $output .=
'</form>';
257 $output .=
'<span id ="lti_launched" style="display:none">' . $this->
lng->txt(
"launched") .
'</span>';
258 $output .=
'<script type="text/javascript"> 259 function ltilaunch() { 260 document.lti_launch_form.submit(); 261 document.getElementById("lti_launch_form").style.display = "none"; 262 document.getElementById("lti_launched").style.display = "inline"; 271 $user_ident = $this->cmixUser->getUsrIdent();
273 $context = $ilLTIConsumerLaunch->getContext();
274 $contextType = $ilLTIConsumerLaunch::getLTIContextType($context[
"type"]);
275 $contextId = $context[
"id"];
276 $contextTitle = $context[
"title"];
282 $output =
'<form id="lti_launch_form" name="lti_launch_form" action="' . $this->
object->getProvider()->getInitiateLogin() .
'" method="post" target="' . $target .
'" encType="application/x-www-form-urlencoded">';
284 $output .= sprintf(
'<input type="hidden" name="%s" value="%s" />',
'target_link_uri', $this->
object->getProvider()->getProviderUrl()) .
"\n";
285 $output .= sprintf(
'<input type="hidden" name="%s" value="%s" />',
'login_hint', $user_ident) .
"\n";
286 $output .= sprintf(
'<input type="hidden" name="%s" value="%s" />',
'lti_message_hint',
$ltiMessageHint) .
"\n";
287 $output .= sprintf(
'<input type="hidden" name="%s" value="%s" />',
'client_id', $this->
object->getProvider()->getClientId()) .
"\n";
288 $output .= sprintf(
'<input type="hidden" name="%s" value="%s" />',
'lti_deployment_id', $this->
object->getProvider()->getId()) .
"\n";
289 $output .=
'</form>';
291 $output .=
"<script type=\"text/javascript\">\n" .
293 "document.lti_launch_form.submit();\n" .
306 if ($this->
object->getProvider()->getLtiVersion() ==
"LTI-1p0") {
308 $tpl =
new ilTemplate(
'tpl.lti_embedded.html',
true,
true,
'Modules/LTIConsumer');
310 $tpl->setCurrentBlock(
'launch_parameter');
311 $tpl->setVariable(
'LAUNCH_PARAMETER', $field);
312 $tpl->setVariable(
'LAUNCH_PARAM_VALUE', $value);
313 $tpl->parseCurrentBlock();
317 $tpl->setVariable(
"DELOS_CSS_HREF",
'templates/default/delos.css' . $v);
318 $tpl->setVariable(
"JQUERY_SRC",
'libs/bower/bower_components/jquery/dist/jquery.js' . $v);
321 $tpl->setVariable(
'LAUNCH_URL', $this->
object->getProvider()->getProviderUrl());
323 #$DIC->ui()->mainTemplate()->getStandardTemplate(); 324 #$DIC->ui()->mainTemplate()->setContent($tpl->get()); 330 $this->dic->http()->saveResponse(
$response);
331 $this->dic->http()->sendResponse();
332 $this->dic->http()->close();
339 $launchContext = $ilLTIConsumerLaunch->
getContext();
342 $launchContextId = $launchContext[
"id"];
343 $launchContextTitle = $launchContext[
"title"];
346 $this->dic->user()->getId(),
347 $this->
object->getRefId(),
348 $this->
object->getId()
351 return $this->
object->buildLaunchParameters(
363 $launchContext = $ilLTIConsumerLaunch->
getContext();
366 $launchContextId = $launchContext[
"id"];
367 $launchContextTitle = $launchContext[
"title"];
369 $returnUrl = !$this->
object->isLaunchMethodOwnWin() ?
'' : str_replace(
376 return $this->
object->buildLaunchParametersLTI13(
393 if ($DIC->ctrl()->getNextClass() != strtolower(self::class)) {
397 if ($DIC->ctrl()->getCmd() != self::CMD_SHOW_EMBEDDED) {
406 $this->cmixUser =
new ilCmiXapiUser($this->
object->getId(), $this->dic->user()->getId(), $this->
object->getProvider()->getPrivacyIdent());
408 if ($user_ident ==
'' || $user_ident == null) {
410 $this->cmixUser->setUsrIdent($user_ident);
411 $this->cmixUser->save();
417 $scope = $loginData[
'scope'];
418 $responsetype = $loginData[
'response_type'];
419 $clientid = $loginData[
'client_id'];
420 $redirecturi = $loginData[
'redirect_uri'];
421 $loginhint = $loginData[
'login_hint'];
422 $ltimessagehint = $loginData[
'lti_message_hint'];
423 $state = $loginData[
'state'];
424 $responsemode = $loginData[
'response_mode'];
425 $nonce = $loginData[
'nonce'];
426 $prompt = $loginData[
'prompt'];
430 $ok = !empty(
$scope) && !empty($responsetype) && !empty($clientid) &&
431 !empty($redirecturi) && !empty($loginhint) &&
435 $error =
'invalid_request';
437 if ($ok && (
$scope !==
'openid')) {
439 $error =
'invalid_scope';
441 if ($ok && ($responsetype !==
'id_token')) {
443 $error =
'unsupported_response_type';
449 $error =
'invalid_request';
451 if ($this->
object->getProvider()->getClientId() !== $clientid) {
453 $error =
'unauthorized_client';
460 $this->
user->getId(),
461 $this->
object->getProvider()->getPrivacyIdent()
471 if ((
string) $loginhint !== $user_ident) {
473 $error =
'access_denied';
476 $uris = array_map(
"trim", explode(
",", $this->
object->getProvider()->getRedirectionUris()));
477 if (!in_array($redirecturi, $uris)) {
479 $error =
'invalid_request';
483 if (isset($responsemode)) {
484 $ok = ($responsemode ===
'form_post');
486 $error =
'invalid_request';
487 $desc =
'Invalid response_mode';
491 $error =
'invalid_request';
492 $desc =
'Missing response_mode';
495 if ($ok && !empty($prompt) && ($prompt !==
'none')) {
497 $error =
'invalid_request';
498 $desc =
'Invalid prompt';
504 $err =
"error '" . $error .
"'";
506 $err .=
" with description: " . $desc;
524 if (isset($DIC->http()->request()->getQueryParams()[
$key])) {
525 return $DIC->http()->request()->getQueryParams()[
$key];
528 if (isset($DIC->http()->request()->getParsedBody()[
$key])) {
529 return $DIC->http()->request()->getParsedBody()[
$key];
532 return $default ?? null;
static get(string $a_var)
getRequestValue(string $key, $default=null)
const ILIAS_VERSION_NUMERIC
static isEmbeddedLaunchRequest()
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Class ChatMainBarProvider .
getLaunchParametersLTI13(string $endpoint, string $clientId, int $deploymentId, string $nonce)
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
getContext(?array $a_valid_types=array('crs', 'grp', 'cat', 'root'))
get info about the context in which the link is used The most outer matching course or group is used ...
static fillToken(int $usrId, int $refId, int $objId, int $lrsTypeId=0)
static getIdent(int $userIdentMode, ilObjUser $user)
validateLTI13InitalLogin(array $loginData)
static getIliasHttpPath()
setUsrIdent(string $usrIdent)
__construct(ilObjLTIConsumer $object)
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
static getLTIContextType(string $a_type)
static clear(string $a_var)
static set(string $a_var, $a_val)
Set a value.
Class FlySystemFileAccessTest disabled disabled disabled.
getEmbeddedAutoStartFormular()