ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilSamlSettingsGUI Class Reference

Class ilSamlSettingsGUI. More...

+ Collaboration diagram for ilSamlSettingsGUI:

Public Member Functions

 __construct (private readonly int $ref_id)
 
 getRefId ()
 
 executeCommand ()
 

Data Fields

const DEFAULT_CMD = 'listIdps'
 

Private Member Functions

 ensureAccess (string $operation)
 
 ensureWriteAccess ()
 
 ensureReadAccess ()
 
 getIdpIdOrZero ()
 
 initIdp ()
 
 listIdps ()
 
 deactivateIdp ()
 
 activateIdp ()
 
 setSubTabs (int $a_view_mode)
 
 initUserAttributeMapping ()
 
 getUserAttributeMappingForm ()
 
 addAttributeRuleFieldToForm (ilPropertyFormGUI $form, string $field_label, string $field_name)
 
 saveUserAttributeMapping ()
 
 showUserAttributeMappingForm (ilPropertyFormGUI $form=null)
 
 getSettingsForm ()
 
 prepareRoleSelection ()
 
 saveSettings ()
 
 showSettings (ilPropertyFormGUI $form=null)
 
 getIdpSettingsForm ()
 
 showIdpSettings (ilPropertyFormGUI $form=null)
 
 saveIdpSettings ()
 
 getIdpForm ()
 
 saveNewIdp ()
 
 showNewIdpForm (ilPropertyFormGUI $form=null)
 
 addMetadataElement (ilPropertyFormGUI $form)
 
 populateWithMetadata (ilSamlIdp $idp, array &$data)
 
 storeMetadata (ilSamlIdp $idp, string $metadata)
 
 confirmDeleteIdp ()
 
 deleteIdp ()
 

Private Attributes

const VIEW_MODE_GLOBAL = 1
 
const VIEW_MODE_SINGLE = 2
 
const PERMISSION_WRITE = 'write'
 
const REQUEST_PARAM_SAML_IDP_ID = 'saml_idp_id'
 
const MESSAGE_TYPE_FAILURE = 'failure'
 
const MESSAGE_TYPE_SUCCESS = 'success'
 
const LNG_SAVED_SUCCESSFULLY = 'saved_successfully'
 
const LNG_AUTH_SAML_USER_MAPPING = 'auth_saml_user_mapping'
 
const LNG_LOGIN_FORM = 'login_form'
 
const LNG_CANCEL = 'cancel'
 
const CMD_SAVE_NEW_IDP = 'saveNewIdp'
 
const CMD_SAVE_SETTINGS = 'saveSettings'
 
const CMD_SHOW_IDP_SETTINGS = 'showIdpSettings'
 
const CMT_SAVE_IDP_SETTINGS = 'saveIdpSettings'
 
const CMD_SAVE = 'save'
 
const CMD_SAVE_USER_ATTRIBUTE_MAPPING = 'saveUserAttributeMapping'
 
const PROP_UPDATE_SUFFIX = '_update'
 
const METADATA_STORAGE_KEY = 'metadata'
 
const GLOBAL_COMMANDS
 
const GLOBAL_ENTITY_COMMANDS
 
const IGNORED_USER_FIELDS
 
readonly ilCtrlInterface $ctrl
 
readonly ilLanguage $lng
 
readonly ilGlobalTemplateInterface $tpl
 
readonly ilAccessHandler $access
 
readonly RBACServices $rbac
 
readonly ilErrorHandling $error_handler
 
readonly ilTabsGUI $tabs
 
readonly ilToolbarGUI $toolbar
 
readonly GlobalHttpState $httpState
 
readonly Refinery $refinery
 
readonly ilHelpGUI $help
 
ilExternalAuthUserAttributeMapping $mapping = null
 
ilSamlIdp $idp = null
 
ilSamlAuth $samlAuth = null
 
readonly ILIAS UI Factory $ui_factory
 
readonly ILIAS UI Renderer $ui_renderer
 

Detailed Description

Class ilSamlSettingsGUI.

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de

Definition at line 30 of file class.ilSamlSettingsGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilSamlSettingsGUI::__construct ( private readonly int  $ref_id)

Definition at line 122 of file class.ilSamlSettingsGUI.php.

References $DIC, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\Repository\help(), ILIAS\Repository\lng(), ILIAS\Repository\rbac(), ILIAS\Repository\refinery(), ILIAS\Repository\tabs(), and ILIAS\Repository\toolbar().

123  {
124  global $DIC;
125 
126  $this->ctrl = $DIC->ctrl();
127  $this->tpl = $DIC->ui()->mainTemplate();
128  $this->lng = $DIC->language();
129  $this->access = $DIC->access();
130  $this->rbac = $DIC->rbac();
131  $this->error_handler = $DIC['ilErr'];
132  $this->tabs = $DIC->tabs();
133  $this->toolbar = $DIC['ilToolbar'];
134  $this->help = $DIC['ilHelp'];
135  $this->httpState = $DIC->http();
136  $this->refinery = $DIC->refinery();
137  $this->ui_factory = $DIC->ui()->factory();
138  $this->ui_renderer = $DIC->ui()->renderer();
139 
140  $this->lng->loadLanguageModule('auth');
141  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ activateIdp()

ilSamlSettingsGUI::activateIdp ( )
private

Definition at line 267 of file class.ilSamlSettingsGUI.php.

References ensureWriteAccess(), listIdps(), and ILIAS\Repository\lng().

267  : void
268  {
269  $this->ensureWriteAccess();
270 
271  $this->idp->setActive(true);
272  $this->idp->persist();
273 
274  $this->tpl->setOnScreenMessage(self::MESSAGE_TYPE_SUCCESS, $this->lng->txt(self::LNG_SAVED_SUCCESSFULLY));
275  $this->listIdps();
276  }
+ Here is the call graph for this function:

◆ addAttributeRuleFieldToForm()

ilSamlSettingsGUI::addAttributeRuleFieldToForm ( ilPropertyFormGUI  $form,
string  $field_label,
string  $field_name 
)
private

Definition at line 356 of file class.ilSamlSettingsGUI.php.

References ilPropertyFormGUI\addItem(), and ILIAS\Repository\lng().

Referenced by getUserAttributeMappingForm().

360  : void {
361  $field = new ilTextInputGUI($field_label, $field_name);
362  $form->addItem($field);
363 
364  $update_automatically = new ilCheckboxInputGUI('', $field_name . self::PROP_UPDATE_SUFFIX);
365  $update_automatically->setOptionTitle($this->lng->txt('auth_saml_update_field_info'));
366  $update_automatically->setValue('1');
367  $form->addItem($update_automatically);
368  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addMetadataElement()

ilSamlSettingsGUI::addMetadataElement ( ilPropertyFormGUI  $form)
private

Definition at line 633 of file class.ilSamlSettingsGUI.php.

References ilPropertyFormGUI\addItem(), ILIAS\Repository\lng(), and ilFormPropertyGUI\setInfo().

Referenced by getIdpForm(), and getIdpSettingsForm().

633  : void
634  {
635  $metadata = new ilSamlIdpMetadataInputGUI(
636  $this->lng->txt('auth_saml_add_idp_md_label'),
637  self::METADATA_STORAGE_KEY,
639  new Factory(),
641  )
642  );
643  $metadata->setInfo($this->lng->txt('auth_saml_add_idp_md_info'));
644  $metadata->setRows(20);
645  $metadata->setRequired(true);
646 
647  $purifier = new ilHtmlPurifierComposite();
648  $purifier->addPurifier(new ilSamlIdpMetadataPurifier());
649 
650  $metadata->setPurifier($purifier);
651  $metadata->usePurifier(true);
652  $form->addItem($metadata);
653  }
Composite for nesting multiple purifiers.
Class ilSamlIdpMetadataPurifier.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmDeleteIdp()

ilSamlSettingsGUI::confirmDeleteIdp ( )
private

Definition at line 668 of file class.ilSamlSettingsGUI.php.

References ILIAS\Repository\ctrl(), ensureWriteAccess(), and ILIAS\Repository\lng().

668  : void
669  {
670  $this->ensureWriteAccess();
671 
672  $confirmation = new ilConfirmationGUI();
673  $confirmation->setFormAction($this->ctrl->getFormAction($this, 'deleteIdp'));
674  $confirmation->setConfirm($this->lng->txt('confirm'), 'deleteIdp');
675  $confirmation->setCancel($this->lng->txt(self::LNG_CANCEL), self::DEFAULT_CMD);
676  $confirmation->setHeaderText($this->lng->txt('auth_saml_sure_delete_idp'));
677  $confirmation->addItem('saml_idp_ids', (string) $this->idp->getIdpId(), $this->idp->getEntityId());
678 
679  $this->tpl->setContent($confirmation->getHTML());
680  }
+ Here is the call graph for this function:

◆ deactivateIdp()

ilSamlSettingsGUI::deactivateIdp ( )
private

Definition at line 256 of file class.ilSamlSettingsGUI.php.

References ensureWriteAccess(), listIdps(), and ILIAS\Repository\lng().

256  : void
257  {
258  $this->ensureWriteAccess();
259 
260  $this->idp->setActive(false);
261  $this->idp->persist();
262 
263  $this->tpl->setOnScreenMessage(self::MESSAGE_TYPE_SUCCESS, $this->lng->txt(self::LNG_SAVED_SUCCESSFULLY));
264  $this->listIdps();
265  }
+ Here is the call graph for this function:

◆ deleteIdp()

ilSamlSettingsGUI::deleteIdp ( )
private

Definition at line 682 of file class.ilSamlSettingsGUI.php.

References ILIAS\Repository\ctrl(), ensureWriteAccess(), and ILIAS\Repository\lng().

682  : void
683  {
684  $this->ensureWriteAccess();
685 
686  $idpDisco = $this->samlAuth->getIdpDiscovery();
687  $idpDisco->deleteIdpMetadata($this->idp->getIdpId());
688 
689  $this->idp->delete();
690 
691  $this->tpl->setOnScreenMessage(self::MESSAGE_TYPE_SUCCESS, $this->lng->txt('auth_saml_deleted_idp'), true);
692 
693  $this->ctrl->setParameter($this, self::REQUEST_PARAM_SAML_IDP_ID, null);
694  $this->ctrl->redirect($this, self::DEFAULT_CMD);
695  }
+ Here is the call graph for this function:

◆ ensureAccess()

ilSamlSettingsGUI::ensureAccess ( string  $operation)
private

Definition at line 143 of file class.ilSamlSettingsGUI.php.

References ILIAS\Repository\lng(), and ILIAS\Repository\rbac().

Referenced by ensureReadAccess(), and ensureWriteAccess().

143  : void
144  {
145  if (!$this->rbac->system()->checkAccess($operation, $this->ref_id)) {
146  $this->error_handler->raiseError($this->lng->txt('msg_no_perm_read'), $this->error_handler->WARNING);
147  }
148  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ensureReadAccess()

ilSamlSettingsGUI::ensureReadAccess ( )
private

Definition at line 155 of file class.ilSamlSettingsGUI.php.

References ensureAccess().

Referenced by executeCommand().

155  : void
156  {
157  $this->ensureAccess('read');
158  }
ensureAccess(string $operation)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ensureWriteAccess()

ilSamlSettingsGUI::ensureWriteAccess ( )
private

Definition at line 150 of file class.ilSamlSettingsGUI.php.

References ensureAccess().

Referenced by activateIdp(), confirmDeleteIdp(), deactivateIdp(), deleteIdp(), saveIdpSettings(), saveNewIdp(), saveSettings(), saveUserAttributeMapping(), and showNewIdpForm().

150  : void
151  {
152  $this->ensureAccess(self::PERMISSION_WRITE);
153  }
ensureAccess(string $operation)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilSamlSettingsGUI::executeCommand ( )

Definition at line 194 of file class.ilSamlSettingsGUI.php.

References Vendor\Package\$e, ILIAS\Repository\ctrl(), ensureReadAccess(), getIdpIdOrZero(), ILIAS\Repository\help(), initIdp(), initUserAttributeMapping(), ILIAS\Repository\lng(), and setSubTabs().

194  : void
195  {
196  $this->ensureReadAccess();
197 
198  try {
199  $factory = new ilSamlAuthFactory();
200  $this->samlAuth = $factory->auth();
201  } catch (Throwable $e) {
202  if ('Database error: could not find driver' === $e->getMessage()) {
203  $this->tpl->setOnScreenMessage(self::MESSAGE_TYPE_FAILURE, $this->lng->txt('auth_saml_err_sqlite_driver'));
204  } else {
205  $this->tpl->setOnScreenMessage(self::MESSAGE_TYPE_FAILURE, $e->getMessage());
206  }
207  }
208 
209  $this->help->setScreenIdComponent('auth');
210  $cmd = $this->ctrl->getCmd();
211  if ($cmd === null || $cmd === '' || !method_exists($this, $cmd)) {
212  $cmd = self::DEFAULT_CMD;
213  }
214  $ipdId = $this->getIdpIdOrZero();
215  if ($ipdId > 0) {
216  $this->ctrl->saveParameter($this, self::REQUEST_PARAM_SAML_IDP_ID);
217  }
218  if (!in_array(strtolower($cmd), array_map('strtolower', self::GLOBAL_COMMANDS), true)) {
219  if (0 === $ipdId) {
220  $this->ctrl->redirect($this, self::DEFAULT_CMD);
221  }
222 
223  $this->initIdp();
224  $this->initUserAttributeMapping();
225  }
226  if (
227  in_array(strtolower($cmd), array_map('strtolower', self::GLOBAL_COMMANDS), true) ||
228  in_array(strtolower($cmd), array_map('strtolower', self::GLOBAL_ENTITY_COMMANDS), true)
229  ) {
230  $this->setSubTabs(self::VIEW_MODE_GLOBAL);
231  } else {
232  $this->setSubTabs(self::VIEW_MODE_SINGLE);
233  }
234  $this->$cmd();
235  }
setSubTabs(int $a_view_mode)
+ Here is the call graph for this function:

◆ getIdpForm()

ilSamlSettingsGUI::getIdpForm ( )
private

Definition at line 584 of file class.ilSamlSettingsGUI.php.

References addMetadataElement(), ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by saveNewIdp(), and showNewIdpForm().

585  {
586  $form = new ilPropertyFormGUI();
587  $form->setFormAction($this->ctrl->getFormAction($this, self::CMD_SAVE_NEW_IDP));
588  $form->setTitle($this->lng->txt('auth_saml_add_idp_btn'));
589 
590  $this->addMetadataElement($form);
591 
592  $form->addCommandButton(self::CMD_SAVE_NEW_IDP, $this->lng->txt(self::CMD_SAVE));
593  $form->addCommandButton('listIdps', $this->lng->txt(self::LNG_CANCEL));
594 
595  return $form;
596  }
addMetadataElement(ilPropertyFormGUI $form)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getIdpIdOrZero()

ilSamlSettingsGUI::getIdpIdOrZero ( )
private

Definition at line 165 of file class.ilSamlSettingsGUI.php.

References ILIAS\Repository\int(), and ILIAS\Repository\refinery().

Referenced by executeCommand(), and initIdp().

165  : int
166  {
167  $idpId = 0;
168  if ($this->httpState->wrapper()->query()->has(self::REQUEST_PARAM_SAML_IDP_ID)) {
169  $idpId = (int) $this->httpState->wrapper()->query()->retrieve(
170  self::REQUEST_PARAM_SAML_IDP_ID,
171  $this->refinery->kindlyTo()->int()
172  );
173  } elseif ($this->httpState->wrapper()->post()->has(self::REQUEST_PARAM_SAML_IDP_ID)) {
174  $idpId = (int) $this->httpState->wrapper()->post()->retrieve(
175  self::REQUEST_PARAM_SAML_IDP_ID,
176  $this->refinery->kindlyTo()->int()
177  );
178  }
179 
180  return $idpId;
181  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getIdpSettingsForm()

ilSamlSettingsGUI::getIdpSettingsForm ( )
private

Definition at line 496 of file class.ilSamlSettingsGUI.php.

References ILIAS\Repository\access(), addMetadataElement(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), prepareRoleSelection(), and ilSelectInputGUI\setOptions().

Referenced by saveIdpSettings(), and showIdpSettings().

497  {
498  $form = new ilPropertyFormGUI();
499  $form->setFormAction($this->ctrl->getFormAction($this, self::CMT_SAVE_IDP_SETTINGS));
500  $form->setTitle(sprintf($this->lng->txt('auth_saml_configure_idp'), $this->idp->getEntityId()));
501 
502  $idp = new ilTextInputGUI($this->lng->txt('auth_saml_idp'), 'entity_id');
503  $idp->setDisabled(true);
504  $form->addItem($idp);
505 
506  $this->addMetadataElement($form);
507 
508  $local = new ilCheckboxInputGUI($this->lng->txt('auth_allow_local'), 'allow_local_auth');
509  $local->setValue('1');
510  $local->setInfo($this->lng->txt('auth_allow_local_info'));
511  $form->addItem($local);
512 
513  $uid_claim = new ilTextInputGUI($this->lng->txt('auth_saml_uid_claim'), 'uid_claim');
514  $uid_claim->setInfo($this->lng->txt('auth_saml_uid_claim_info'));
515  $uid_claim->setRequired(true);
516  $form->addItem($uid_claim);
517 
518  $sync = new ilCheckboxInputGUI($this->lng->txt('auth_saml_sync'), 'sync_status');
519  $sync->setInfo($this->lng->txt('auth_saml_sync_info'));
520  $sync->setValue('1');
521 
522  $username_claim = new ilTextInputGUI($this->lng->txt('auth_saml_username_claim'), 'login_claim');
523  $username_claim->setInfo($this->lng->txt('auth_saml_username_claim_info'));
524  $username_claim->setRequired(true);
525  $sync->addSubItem($username_claim);
526 
527  $role = new ilSelectInputGUI($this->lng->txt('auth_saml_role_select'), 'default_role_id');
528  $role->setOptions($this->prepareRoleSelection());
529  $role->setRequired(true);
530  $sync->addSubItem($role);
531 
532  $migr = new ilCheckboxInputGUI($this->lng->txt('auth_saml_migration'), 'account_migr_status');
533  $migr->setInfo($this->lng->txt('auth_saml_migration_info'));
534  $migr->setValue('1');
535  $sync->addSubItem($migr);
536  $form->addItem($sync);
537 
538  if (!$this->access->checkAccess(self::PERMISSION_WRITE, '', $this->ref_id)) {
539  foreach ($form->getItems() as $item) {
540  $item->setDisabled(true);
541  }
542  } else {
543  $form->addCommandButton(self::CMT_SAVE_IDP_SETTINGS, $this->lng->txt(self::CMD_SAVE));
544  }
545  $form->addCommandButton(self::DEFAULT_CMD, $this->lng->txt(self::LNG_CANCEL));
546 
547  return $form;
548  }
This class represents a selection list property in a property form.
setOptions(array $a_options)
addMetadataElement(ilPropertyFormGUI $form)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRefId()

ilSamlSettingsGUI::getRefId ( )

Definition at line 160 of file class.ilSamlSettingsGUI.php.

References $ref_id.

160  : int
161  {
162  return $this->ref_id;
163  }
$ref_id
Definition: ltiauth.php:67

◆ getSettingsForm()

ilSamlSettingsGUI::getSettingsForm ( )
private

Definition at line 426 of file class.ilSamlSettingsGUI.php.

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by saveSettings(), and showSettings().

427  {
428  $form = new ilPropertyFormGUI();
429  $form->setFormAction($this->ctrl->getFormAction($this, self::CMD_SAVE_SETTINGS));
430  $form->setTitle($this->lng->txt('auth_saml_configure'));
431 
432  $show_login_form = new ilCheckboxInputGUI($this->lng->txt('auth_saml_login_form'), self::LNG_LOGIN_FORM);
433  $show_login_form->setInfo($this->lng->txt('auth_saml_login_form_info'));
434  $show_login_form->setValue('1');
435  $form->addItem($show_login_form);
436 
437  if (!$this->access->checkAccess(self::PERMISSION_WRITE, '', $this->ref_id)) {
438  foreach ($form->getItems() as $item) {
439  $item->setDisabled(true);
440  }
441  } else {
442  $form->addCommandButton(self::CMD_SAVE_SETTINGS, $this->lng->txt(self::CMD_SAVE));
443  }
444 
445  return $form;
446  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUserAttributeMappingForm()

ilSamlSettingsGUI::getUserAttributeMappingForm ( )
private

Definition at line 326 of file class.ilSamlSettingsGUI.php.

References $id, ilUserDefinedFields\_getInstance(), ILIAS\Repository\access(), addAttributeRuleFieldToForm(), ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by saveUserAttributeMapping(), and showUserAttributeMappingForm().

327  {
328  $form = new ilPropertyFormGUI();
329  $form->setFormAction($this->ctrl->getFormAction($this, self::CMD_SAVE_USER_ATTRIBUTE_MAPPING));
330  $form->setTitle($this->lng->txt(self::LNG_AUTH_SAML_USER_MAPPING));
331 
332  $usr_profile = new ilUserProfile();
333  foreach (array_keys($usr_profile->getStandardFields()) as $id) {
334  if (in_array($id, self::IGNORED_USER_FIELDS, true)) {
335  continue;
336  }
337 
338  $this->addAttributeRuleFieldToForm($form, $this->lng->txt($id), $id);
339  }
340 
341  foreach (ilUserDefinedFields::_getInstance()->getDefinitions() as $definition) {
342  $this->addAttributeRuleFieldToForm($form, $definition['field_name'], 'udf_' . $definition['field_id']);
343  }
344 
345  if (!$this->access->checkAccess(self::PERMISSION_WRITE, '', $this->ref_id)) {
346  foreach ($form->getItems() as $item) {
347  $item->setDisabled(true);
348  }
349  } else {
350  $form->addCommandButton(self::CMD_SAVE_USER_ATTRIBUTE_MAPPING, $this->lng->txt(self::CMD_SAVE));
351  }
352 
353  return $form;
354  }
Class ilUserProfile.
addAttributeRuleFieldToForm(ilPropertyFormGUI $form, string $field_label, string $field_name)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initIdp()

ilSamlSettingsGUI::initIdp ( )
private

Definition at line 183 of file class.ilSamlSettingsGUI.php.

References ILIAS\Repository\ctrl(), getIdpIdOrZero(), ilSamlIdp\getInstanceByIdpId(), and ILIAS\Repository\lng().

Referenced by executeCommand().

183  : void
184  {
185  try {
186  $this->idp = ilSamlIdp::getInstanceByIdpId($this->getIdpIdOrZero());
187  } catch (Exception) {
188  $this->tpl->setOnScreenMessage(self::MESSAGE_TYPE_FAILURE, $this->lng->txt('auth_saml_unknow_idp'), true);
189  $this->ctrl->setParameter($this, self::REQUEST_PARAM_SAML_IDP_ID, null);
190  $this->ctrl->redirect($this, self::DEFAULT_CMD);
191  }
192  }
static getInstanceByIdpId(int $a_idp_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initUserAttributeMapping()

ilSamlSettingsGUI::initUserAttributeMapping ( )
private

Definition at line 321 of file class.ilSamlSettingsGUI.php.

Referenced by executeCommand().

321  : void
322  {
323  $this->mapping = new ilExternalAuthUserAttributeMapping('saml', $this->idp->getIdpId());
324  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ listIdps()

ilSamlSettingsGUI::listIdps ( )
private

Definition at line 237 of file class.ilSamlSettingsGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\rbac(), and ILIAS\Repository\toolbar().

Referenced by activateIdp(), and deactivateIdp().

237  : void
238  {
239  if ($this->samlAuth && $this->rbac->system()->checkAccess(self::PERMISSION_WRITE, $this->ref_id)) {
240  $this->toolbar->addStickyItem($this->ui_factory->button()->standard(
241  $this->lng->txt('auth_saml_add_idp_btn'),
242  $this->ctrl->getLinkTarget($this, 'showNewIdpForm')
243  ));
244  }
245 
246  $table = new ilSamlIdpTableGUI(
247  $this,
248  $this->ui_factory,
249  $this->ui_renderer,
250  self::DEFAULT_CMD,
251  $this->rbac->system()->checkAccess(self::PERMISSION_WRITE, $this->ref_id)
252  );
253  $this->tpl->setContent($table->getHTML());
254  }
Class ilSamlIdpTableGUI.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateWithMetadata()

ilSamlSettingsGUI::populateWithMetadata ( ilSamlIdp  $idp,
array &  $data 
)
private

Definition at line 655 of file class.ilSamlSettingsGUI.php.

References ilSamlIdp\getIdpId().

Referenced by showIdpSettings().

655  : void
656  {
657  $idpDisco = $this->samlAuth->getIdpDiscovery();
658 
659  $data[self::METADATA_STORAGE_KEY] = $idpDisco->fetchIdpMetadata($idp->getIdpId());
660  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prepareRoleSelection()

ilSamlSettingsGUI::prepareRoleSelection ( )
private
Returns
array<int, string>

Definition at line 451 of file class.ilSamlSettingsGUI.php.

References ilObject\_lookupTitle(), ilUtil\_sortIds(), ILIAS\Repository\lng(), and ILIAS\Repository\rbac().

Referenced by getIdpSettingsForm().

451  : array
452  {
453  $select = [];
454  $global_roles = array_map('intval', ilUtil::_sortIds(
455  $this->rbac->review()->getGlobalRoles(),
456  'object_data',
457  'title',
458  'obj_id'
459  ));
460 
461  $select[0] = $this->lng->txt('links_select_one');
462  foreach ($global_roles as $role_id) {
463  $select[$role_id] = ilObject::_lookupTitle($role_id);
464  }
465 
466  return $select;
467  }
static _lookupTitle(int $obj_id)
static _sortIds(array $a_ids, string $a_table, string $a_field, string $a_id_name)
Function that sorts ids by a given table field using WHERE IN E.g: __sort(array(6,7),&#39;usr_data&#39;,&#39;lastname&#39;,&#39;usr_id&#39;) => sorts by lastname.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveIdpSettings()

ilSamlSettingsGUI::saveIdpSettings ( )
private

Definition at line 568 of file class.ilSamlSettingsGUI.php.

References ensureWriteAccess(), getIdpSettingsForm(), ILIAS\Repository\lng(), showIdpSettings(), and storeMetadata().

568  : void
569  {
570  $this->ensureWriteAccess();
571 
572  $form = $this->getIdpSettingsForm();
573  if ($form->checkInput()) {
574  $this->idp->bindForm($form);
575  $this->idp->persist();
576  $this->tpl->setOnScreenMessage(self::MESSAGE_TYPE_SUCCESS, $this->lng->txt(self::LNG_SAVED_SUCCESSFULLY));
577 
578  $this->storeMetadata($this->idp, $form->getInput(self::METADATA_STORAGE_KEY));
579  }
580 
581  $this->showIdpSettings($form);
582  }
storeMetadata(ilSamlIdp $idp, string $metadata)
showIdpSettings(ilPropertyFormGUI $form=null)
+ Here is the call graph for this function:

◆ saveNewIdp()

ilSamlSettingsGUI::saveNewIdp ( )
private

Definition at line 598 of file class.ilSamlSettingsGUI.php.

References ILIAS\Repository\ctrl(), ensureWriteAccess(), getIdpForm(), ilSamlIdp\getIdpId(), ILIAS\Repository\lng(), ilSamlIdp\persist(), showNewIdpForm(), and storeMetadata().

598  : void
599  {
600  $this->ensureWriteAccess();
601 
602  $form = $this->getIdpForm();
603  if ($form->checkInput()) {
604  $idp = new ilSamlIdp();
605  $idp->bindForm($form);
606  $idp->persist();
607 
608  $this->storeMetadata($idp, $form->getInput(self::METADATA_STORAGE_KEY));
609 
610  $this->tpl->setOnScreenMessage(self::MESSAGE_TYPE_SUCCESS, $this->lng->txt(self::LNG_SAVED_SUCCESSFULLY), true);
611  $this->ctrl->setParameter($this, self::REQUEST_PARAM_SAML_IDP_ID, $idp->getIdpId());
612  $this->ctrl->redirect($this, self::CMD_SHOW_IDP_SETTINGS);
613  }
614 
615  $this->showNewIdpForm($form);
616  }
showNewIdpForm(ilPropertyFormGUI $form=null)
storeMetadata(ilSamlIdp $idp, string $metadata)
Class ilSamlIdp.
+ Here is the call graph for this function:

◆ saveSettings()

ilSamlSettingsGUI::saveSettings ( )
private

Definition at line 469 of file class.ilSamlSettingsGUI.php.

References ensureWriteAccess(), ilSamlSettings\getInstance(), getSettingsForm(), ILIAS\Repository\lng(), and showSettings().

469  : void
470  {
471  $this->ensureWriteAccess();
472 
473  $form = $this->getSettingsForm();
474  if ($form->checkInput()) {
475  ilSamlSettings::getInstance()->setLoginFormStatus((bool) $form->getInput(self::LNG_LOGIN_FORM));
476  $this->tpl->setOnScreenMessage(self::MESSAGE_TYPE_SUCCESS, $this->lng->txt(self::LNG_SAVED_SUCCESSFULLY));
477  }
478 
479  $form->setValuesByPost();
480 
481  $this->showSettings($form);
482  }
showSettings(ilPropertyFormGUI $form=null)
+ Here is the call graph for this function:

◆ saveUserAttributeMapping()

ilSamlSettingsGUI::saveUserAttributeMapping ( )
private

Definition at line 370 of file class.ilSamlSettingsGUI.php.

References $id, ilUserDefinedFields\_getInstance(), ensureWriteAccess(), getUserAttributeMappingForm(), ILIAS\Repository\lng(), and showUserAttributeMappingForm().

370  : void
371  {
372  $this->ensureWriteAccess();
373 
374  $form = $this->getUserAttributeMappingForm();
375  if ($form->checkInput()) {
376  $this->mapping->delete();
377 
378  $usr_profile = new ilUserProfile();
379  foreach (array_keys($usr_profile->getStandardFields()) as $id) {
380  if (in_array($id, self::IGNORED_USER_FIELDS, true)) {
381  continue;
382  }
383 
384  $rule = $this->mapping->getEmptyRule();
385  $rule->setAttribute($id);
386  $rule->setExternalAttribute((string) $form->getInput($rule->getAttribute()));
387  $rule->updateAutomatically((bool) $form->getInput($rule->getAttribute() . self::PROP_UPDATE_SUFFIX));
388  $this->mapping[$rule->getAttribute()] = $rule;
389  }
390 
391  foreach (ilUserDefinedFields::_getInstance()->getDefinitions() as $definition) {
392  $rule = $this->mapping->getEmptyRule();
393  $rule->setAttribute('udf_' . $definition['field_id']);
394  $rule->setExternalAttribute((string) $form->getInput($rule->getAttribute()));
395  $rule->updateAutomatically((bool) $form->getInput($rule->getAttribute() . self::PROP_UPDATE_SUFFIX));
396  $this->mapping[$rule->getAttribute()] = $rule;
397  }
398 
399  $this->mapping->save();
400 
401  $this->tpl->setOnScreenMessage(self::MESSAGE_TYPE_SUCCESS, $this->lng->txt(self::LNG_SAVED_SUCCESSFULLY));
402  }
403 
404  $form->setValuesByPost();
405 
406  $this->showUserAttributeMappingForm($form);
407  }
Class ilUserProfile.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
showUserAttributeMappingForm(ilPropertyFormGUI $form=null)
+ Here is the call graph for this function:

◆ setSubTabs()

ilSamlSettingsGUI::setSubTabs ( int  $a_view_mode)
private

Definition at line 278 of file class.ilSamlSettingsGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\tabs().

Referenced by executeCommand().

278  : void
279  {
280  switch ($a_view_mode) {
281  case self::VIEW_MODE_GLOBAL:
282  $this->tabs->addSubTabTarget(
283  'auth_saml_idps',
284  $this->ctrl->getLinkTarget($this, self::DEFAULT_CMD),
285  array_merge(self::GLOBAL_ENTITY_COMMANDS, [self::DEFAULT_CMD, 'showNewIdpForm', self::CMD_SAVE_NEW_IDP]),
286  self::class
287  );
288 
289  $this->tabs->addSubTabTarget(
290  'settings',
291  $this->ctrl->getLinkTarget($this, 'showSettings'),
292  ['showSettings', self::CMD_SAVE_SETTINGS],
293  self::class
294  );
295  break;
296 
297  case self::VIEW_MODE_SINGLE:
298  $this->tabs->clearTargets();
299  $this->tabs->setBackTarget(
300  $this->lng->txt('back'),
301  $this->ctrl->getLinkTarget($this, self::DEFAULT_CMD)
302  );
303 
304  $this->tabs->addSubTabTarget(
305  'auth_saml_idp_settings',
306  $this->ctrl->getLinkTarget($this, self::CMD_SHOW_IDP_SETTINGS),
307  [self::CMD_SHOW_IDP_SETTINGS, self::CMT_SAVE_IDP_SETTINGS],
308  self::class
309  );
310 
311  $this->tabs->addSubTabTarget(
312  self::LNG_AUTH_SAML_USER_MAPPING,
313  $this->ctrl->getLinkTarget($this, 'showUserAttributeMappingForm'),
314  ['showUserAttributeMappingForm', self::CMD_SAVE_USER_ATTRIBUTE_MAPPING],
315  self::class
316  );
317  break;
318  }
319  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showIdpSettings()

ilSamlSettingsGUI::showIdpSettings ( ilPropertyFormGUI  $form = null)
private

Definition at line 550 of file class.ilSamlSettingsGUI.php.

References $data, getIdpSettingsForm(), ILIAS\Repository\help(), populateWithMetadata(), and ILIAS\Repository\tabs().

Referenced by saveIdpSettings().

550  : void
551  {
552  $this->tabs->setSubTabActive('auth_saml_idp_settings');
553 
554  if (null === $form) {
555  $form = $this->getIdpSettingsForm();
556  $data = $this->idp->toArray();
557  $this->populateWithMetadata($this->idp, $data);
558  $form->setValuesByArray($data);
559  } else {
560  $form->setValuesByPost();
561  }
562 
563  $this->help->setSubScreenId('edit_idp');
564 
565  $this->tpl->setContent($form->getHTML());
566  }
populateWithMetadata(ilSamlIdp $idp, array &$data)
setValuesByArray(array $a_values, bool $a_restrict_to_value_keys=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showNewIdpForm()

ilSamlSettingsGUI::showNewIdpForm ( ilPropertyFormGUI  $form = null)
private

Definition at line 618 of file class.ilSamlSettingsGUI.php.

References ensureWriteAccess(), getIdpForm(), and ILIAS\Repository\help().

Referenced by saveNewIdp().

618  : void
619  {
620  $this->ensureWriteAccess();
621 
622  if (null === $form) {
623  $form = $this->getIdpForm();
624  } else {
625  $form->setValuesByPost();
626  }
627 
628  $this->help->setSubScreenId('create_idp');
629 
630  $this->tpl->setContent($form->getHTML());
631  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showSettings()

ilSamlSettingsGUI::showSettings ( ilPropertyFormGUI  $form = null)
private

Definition at line 484 of file class.ilSamlSettingsGUI.php.

References ilSamlSettings\getInstance(), and getSettingsForm().

Referenced by saveSettings().

484  : void
485  {
486  if (!($form instanceof ilPropertyFormGUI)) {
487  $form = $this->getSettingsForm();
488  $form->setValuesByArray([
489  self::LNG_LOGIN_FORM => ilSamlSettings::getInstance()->isDisplayedOnLoginPage(),
490  ]);
491  }
492 
493  $this->tpl->setContent($form->getHTML());
494  }
setValuesByArray(array $a_values, bool $a_restrict_to_value_keys=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showUserAttributeMappingForm()

ilSamlSettingsGUI::showUserAttributeMappingForm ( ilPropertyFormGUI  $form = null)
private

Definition at line 409 of file class.ilSamlSettingsGUI.php.

References $data, getUserAttributeMappingForm(), and ILIAS\Repository\tabs().

Referenced by saveUserAttributeMapping().

409  : void
410  {
411  $this->tabs->setSubTabActive(self::LNG_AUTH_SAML_USER_MAPPING);
412 
413  if (!($form instanceof ilPropertyFormGUI)) {
414  $form = $this->getUserAttributeMappingForm();
415  $data = [];
416  foreach ($this->mapping as $rule) {
417  $data[$rule->getAttribute()] = $rule->getExternalAttribute();
418  $data[$rule->getAttribute() . self::PROP_UPDATE_SUFFIX] = $rule->isAutomaticallyUpdated();
419  }
420  $form->setValuesByArray($data);
421  }
422 
423  $this->tpl->setContent($form->getHTML());
424  }
setValuesByArray(array $a_values, bool $a_restrict_to_value_keys=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ storeMetadata()

ilSamlSettingsGUI::storeMetadata ( ilSamlIdp  $idp,
string  $metadata 
)
private

Definition at line 662 of file class.ilSamlSettingsGUI.php.

References ilSamlIdp\getIdpId().

Referenced by saveIdpSettings(), and saveNewIdp().

662  : void
663  {
664  $idpDisco = $this->samlAuth->getIdpDiscovery();
665  $idpDisco->storeIdpMetadata($idp->getIdpId(), $metadata);
666  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $access

readonly ilAccessHandler ilSamlSettingsGUI::$access
private

Definition at line 108 of file class.ilSamlSettingsGUI.php.

◆ $ctrl

readonly ilCtrlInterface ilSamlSettingsGUI::$ctrl
private

Definition at line 105 of file class.ilSamlSettingsGUI.php.

◆ $error_handler

readonly ilErrorHandling ilSamlSettingsGUI::$error_handler
private

Definition at line 110 of file class.ilSamlSettingsGUI.php.

◆ $help

readonly ilHelpGUI ilSamlSettingsGUI::$help
private

Definition at line 115 of file class.ilSamlSettingsGUI.php.

◆ $httpState

readonly GlobalHttpState ilSamlSettingsGUI::$httpState
private

Definition at line 113 of file class.ilSamlSettingsGUI.php.

◆ $idp

ilSamlIdp ilSamlSettingsGUI::$idp = null
private

Definition at line 117 of file class.ilSamlSettingsGUI.php.

◆ $lng

readonly ilLanguage ilSamlSettingsGUI::$lng
private

Definition at line 106 of file class.ilSamlSettingsGUI.php.

◆ $mapping

ilExternalAuthUserAttributeMapping ilSamlSettingsGUI::$mapping = null
private

Definition at line 116 of file class.ilSamlSettingsGUI.php.

◆ $rbac

readonly RBACServices ilSamlSettingsGUI::$rbac
private

Definition at line 109 of file class.ilSamlSettingsGUI.php.

◆ $refinery

readonly Refinery ilSamlSettingsGUI::$refinery
private

Definition at line 114 of file class.ilSamlSettingsGUI.php.

◆ $samlAuth

ilSamlAuth ilSamlSettingsGUI::$samlAuth = null
private

Definition at line 118 of file class.ilSamlSettingsGUI.php.

◆ $tabs

readonly ilTabsGUI ilSamlSettingsGUI::$tabs
private

Definition at line 111 of file class.ilSamlSettingsGUI.php.

◆ $toolbar

readonly ilToolbarGUI ilSamlSettingsGUI::$toolbar
private

Definition at line 112 of file class.ilSamlSettingsGUI.php.

◆ $tpl

readonly ilGlobalTemplateInterface ilSamlSettingsGUI::$tpl
private

Definition at line 107 of file class.ilSamlSettingsGUI.php.

◆ $ui_factory

readonly ILIAS UI Factory ilSamlSettingsGUI::$ui_factory
private

Definition at line 119 of file class.ilSamlSettingsGUI.php.

◆ $ui_renderer

readonly ILIAS UI Renderer ilSamlSettingsGUI::$ui_renderer
private

Definition at line 120 of file class.ilSamlSettingsGUI.php.

◆ CMD_SAVE

const ilSamlSettingsGUI::CMD_SAVE = 'save'
private

Definition at line 53 of file class.ilSamlSettingsGUI.php.

◆ CMD_SAVE_NEW_IDP

const ilSamlSettingsGUI::CMD_SAVE_NEW_IDP = 'saveNewIdp'
private

Definition at line 49 of file class.ilSamlSettingsGUI.php.

◆ CMD_SAVE_SETTINGS

const ilSamlSettingsGUI::CMD_SAVE_SETTINGS = 'saveSettings'
private

Definition at line 50 of file class.ilSamlSettingsGUI.php.

◆ CMD_SAVE_USER_ATTRIBUTE_MAPPING

const ilSamlSettingsGUI::CMD_SAVE_USER_ATTRIBUTE_MAPPING = 'saveUserAttributeMapping'
private

Definition at line 54 of file class.ilSamlSettingsGUI.php.

◆ CMD_SHOW_IDP_SETTINGS

const ilSamlSettingsGUI::CMD_SHOW_IDP_SETTINGS = 'showIdpSettings'
private

Definition at line 51 of file class.ilSamlSettingsGUI.php.

◆ CMT_SAVE_IDP_SETTINGS

const ilSamlSettingsGUI::CMT_SAVE_IDP_SETTINGS = 'saveIdpSettings'
private

Definition at line 52 of file class.ilSamlSettingsGUI.php.

◆ DEFAULT_CMD

const ilSamlSettingsGUI::DEFAULT_CMD = 'listIdps'

Definition at line 35 of file class.ilSamlSettingsGUI.php.

Referenced by ilObjAuthSettingsGUI\getTabs().

◆ GLOBAL_COMMANDS

const ilSamlSettingsGUI::GLOBAL_COMMANDS
private
Initial value:
= [
self::DEFAULT_CMD,
'showAddIdpForm',
'showSettings',
'saveSettings',
'showNewIdpForm',
'saveNewIdp',
]

Definition at line 63 of file class.ilSamlSettingsGUI.php.

◆ GLOBAL_ENTITY_COMMANDS

const ilSamlSettingsGUI::GLOBAL_ENTITY_COMMANDS
private
Initial value:
= [
'deactivateIdp',
'activateIdp',
'confirmDeleteIdp',
'deleteIdp',
]

Definition at line 75 of file class.ilSamlSettingsGUI.php.

◆ IGNORED_USER_FIELDS

const ilSamlSettingsGUI::IGNORED_USER_FIELDS
private
Initial value:
= [
'mail_incoming_mail',
'preferences',
'hide_own_online_status',
'show_users_online',
'hits_per_page',
'roles',
'upload',
'password',
'username',
'language',
'skin_style',
'interests_general',
'interests_help_offered',
'interests_help_looking',
'bs_allow_to_contact_me',
'chat_osc_accept_msg',
'chat_broadcast_typing',
]

Definition at line 85 of file class.ilSamlSettingsGUI.php.

◆ LNG_AUTH_SAML_USER_MAPPING

const ilSamlSettingsGUI::LNG_AUTH_SAML_USER_MAPPING = 'auth_saml_user_mapping'
private

Definition at line 45 of file class.ilSamlSettingsGUI.php.

◆ LNG_CANCEL

const ilSamlSettingsGUI::LNG_CANCEL = 'cancel'
private

Definition at line 47 of file class.ilSamlSettingsGUI.php.

◆ LNG_LOGIN_FORM

const ilSamlSettingsGUI::LNG_LOGIN_FORM = 'login_form'
private

Definition at line 46 of file class.ilSamlSettingsGUI.php.

◆ LNG_SAVED_SUCCESSFULLY

const ilSamlSettingsGUI::LNG_SAVED_SUCCESSFULLY = 'saved_successfully'
private

Definition at line 44 of file class.ilSamlSettingsGUI.php.

◆ MESSAGE_TYPE_FAILURE

const ilSamlSettingsGUI::MESSAGE_TYPE_FAILURE = 'failure'
private

Definition at line 41 of file class.ilSamlSettingsGUI.php.

◆ MESSAGE_TYPE_SUCCESS

const ilSamlSettingsGUI::MESSAGE_TYPE_SUCCESS = 'success'
private

Definition at line 42 of file class.ilSamlSettingsGUI.php.

◆ METADATA_STORAGE_KEY

const ilSamlSettingsGUI::METADATA_STORAGE_KEY = 'metadata'
private

Definition at line 58 of file class.ilSamlSettingsGUI.php.

◆ PERMISSION_WRITE

const ilSamlSettingsGUI::PERMISSION_WRITE = 'write'
private

Definition at line 37 of file class.ilSamlSettingsGUI.php.

◆ PROP_UPDATE_SUFFIX

const ilSamlSettingsGUI::PROP_UPDATE_SUFFIX = '_update'
private

Definition at line 56 of file class.ilSamlSettingsGUI.php.

◆ REQUEST_PARAM_SAML_IDP_ID

const ilSamlSettingsGUI::REQUEST_PARAM_SAML_IDP_ID = 'saml_idp_id'
private

Definition at line 39 of file class.ilSamlSettingsGUI.php.

◆ VIEW_MODE_GLOBAL

const ilSamlSettingsGUI::VIEW_MODE_GLOBAL = 1
private

Definition at line 32 of file class.ilSamlSettingsGUI.php.

◆ VIEW_MODE_SINGLE

const ilSamlSettingsGUI::VIEW_MODE_SINGLE = 2
private

Definition at line 33 of file class.ilSamlSettingsGUI.php.


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