34 $this->tabs_gui = $ilTabs;
36 $this->lng->loadLanguageModule(
'shib');
41 $this->ref_id = $a_auth_ref_id;
53 $next_class = $this->ctrl->getNextClass($this);
54 $cmd = $this->ctrl->getCmd();
56 if(!$ilAccess->checkAccess(
'read',
'',$this->ref_id))
58 $ilErr->raiseError($this->lng->txt(
'msg_no_perm_read'),$ilErr->WARNING);
61 if(!$ilAccess->checkAccess(
'write',
'',$this->ref_id) &&
$cmd !=
"settings")
64 $ilCtrl->redirect($this,
"settings");
85 global $rbacsystem, $rbacreview;
87 $this->tabs_gui->setSubTabActive(
'shib_settings');
90 $settings = $this->ilias->getAllSettings();
93 $role_list = $rbacreview->getRolesByFilter(2);
94 $selectElement =
'<select name="shib[user_default_role]">';
96 if (!isset($settings[
"shib_user_default_role"]))
98 $settings[
"shib_user_default_role"] = 4;
101 foreach ($role_list as $role)
103 $selectElement .=
'<option value="'.$role[
'obj_id'].
'"';
104 if ($settings[
"shib_user_default_role"] == $role[
'obj_id'])
105 $selectElement .=
'selected="selected"';
107 $selectElement .=
'>'.$role[
'title'].
'</option>';
109 $selectElement .=
'</select>';
113 $shib_settings = array(
130 'shib_matriculation',
135 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.auth_shib.html');
137 foreach ($shib_settings as $setting)
139 $field = ereg_replace(
'shib_',
'',$setting);
140 $this->tpl->setVariable(strtoupper($setting), $settings[$setting]);
141 $this->tpl->setVariable(
'SHIB_UPDATE_'.strtoupper($field), $settings[
"shib_update_".$field]);
143 if ($settings[
"shib_update_".$field]) {
144 $this->tpl->setVariable(
'CHK_SHIB_UPDATE_'.strtoupper($field),
'checked="checked"');
150 if (!isset($settings[
"shib_login_button"]) || $settings[
"shib_login_button"] ==
''){
151 $this->tpl->setVariable(
"SHIB_LOGIN_BUTTON",
"templates/default/images/shib_login_button.png");
154 if (isset($settings[
"shib_active"]) && $settings[
"shib_active"])
156 $this->tpl->setVariable(
"chk_shib_active",
'checked="checked"');
158 if ($settings[
'shib_auth_allow_local'] ==
'1')
160 $this->tpl->setVariable(
'CHK_SHIB_AUTH_ALLOW_LOCAL',
'checked="checked"');
164 !isset($settings[
"shib_hos_type"])
165 || $settings[
"shib_hos_type"] ==
''
166 || $settings[
"shib_hos_type"] ==
'internal_wayf'
169 $this->tpl->setVariable(
"CHK_SHIB_LOGIN_INTERNAL_WAYF",
'checked="checked"');
170 $this->tpl->setVariable(
"CHK_SHIB_LOGIN_EXTERNAL_WAYF",
'');
171 $this->tpl->setVariable(
"CHK_SHIB_LOGIN_EMBEDDED_WAYF",
'');
172 } elseif($settings[
"shib_hos_type"] ==
'embedded_wayf'){
173 $this->tpl->setVariable(
"CHK_SHIB_LOGIN_INTERNAL_WAYF",
'');
174 $this->tpl->setVariable(
"CHK_SHIB_LOGIN_EXTERNAL_WAYF",
'');
175 $this->tpl->setVariable(
"CHK_SHIB_LOGIN_EMBEDDED_WAYF",
'checked="checked"');
177 $this->tpl->setVariable(
"CHK_SHIB_LOGIN_INTERNAL_WAYF",
'');
178 $this->tpl->setVariable(
"CHK_SHIB_LOGIN_EXTERNAL_WAYF",
'checked="checked"');
179 $this->tpl->setVariable(
"CHK_SHIB_LOGIN_EMBEDDED_WAYF",
'');
182 if (!isset($settings[
"shib_idp_list"]) || $settings[
"shib_idp_list"] ==
'')
184 $this->tpl->setVariable(
"SHIB_IDP_LIST",
"urn:mace:organization1:providerID, Example Organization 1\nurn:mace:organization2:providerID, Example Organization 2, /Shibboleth.sso/WAYF/SWITCHaai");
186 $this->tpl->setVariable(
"SHIB_IDP_LIST", stripslashes($settings[
"shib_idp_list"]));
189 $this->tpl->setVariable(
"SHIB_USER_DEFAULT_ROLE", $selectElement);
190 $this->tpl->setVariable(
"SHIB_LOGIN_BUTTON", $settings[
"shib_login_button"]);
191 $this->tpl->setVariable(
"SHIB_LOGIN_INSTRUCTIONS", stripslashes($settings[
"shib_login_instructions"]));
192 $this->tpl->setVariable(
"SHIB_FEDERATION_NAME", stripslashes($settings[
"shib_federation_name"]));
193 $this->tpl->setVariable(
"SHIB_DATA_CONV", $settings[
"shib_data_conv"]);
195 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
196 $this->tpl->setVariable(
"COLSPAN", 3);
197 $this->tpl->setVariable(
"TXT_SHIB_INSTRUCTIONS",
198 $this->lng->txt(
"auth_shib_instructions"));
199 $this->tpl->setVariable(
"LINK_SHIB_INSTRUCTIONS",
200 "./Services/AuthShibboleth/README.SHIBBOLETH.txt");
201 $this->tpl->setVariable(
"TXT_SHIB", $this->lng->txt(
"shib"));
202 $this->tpl->setVariable(
"TXT_OPTIONS", $this->lng->txt(
"options"));
203 $this->tpl->setVariable(
"TXT_SHIB_UPDATE", $this->lng->txt(
"shib_update"));
204 $this->tpl->setVariable(
"TXT_SHIB_ACTIVE", $this->lng->txt(
"shib_active"));
205 $this->tpl->setVariable(
"TXT_SHIB_USER_DEFAULT_ROLE", $this->lng->txt(
"shib_user_default_role"));
206 $this->tpl->setVariable(
"TXT_SHIB_LOGIN_BUTTON", $this->lng->txt(
"shib_login_button"));
207 $this->tpl->setVariable(
"TXT_SHIB_LOGIN_TYPE", $this->lng->txt(
"shib_login_type"));
208 $this->tpl->setVariable(
"TXT_SHIB_LOGIN_INTERNAL_WAYF", $this->lng->txt(
"shib_login_internal_wayf"));
209 $this->tpl->setVariable(
"TXT_SHIB_LOGIN_EXTERNAL_WAYF", $this->lng->txt(
"shib_login_external_wayf"));
210 $this->tpl->setVariable(
"TXT_SHIB_IDP_LIST", $this->lng->txt(
"shib_idp_list"));
211 $this->tpl->setVariable(
"TXT_SHIB_FEDERATION_NAME", $this->lng->txt(
"shib_federation_name"));
212 $this->tpl->setVariable(
"TXT_SHIB_LOGIN_EMBEDDED_WAYF", $this->lng->txt(
"shib_login_embedded_wayf"));
213 $this->tpl->setVariable(
"TXT_SHIB_LOGIN_EMBEDDED_WAYF_DESCRIPTION", $this->lng->txt(
"shib_login_embedded_wayf_description"));
214 $this->tpl->setVariable(
"TXT_SHIB_LOGIN_INSTRUCTIONS", $this->lng->txt(
"auth_login_instructions"));
215 $this->tpl->setVariable(
"TXT_SHIB_DATA_CONV", $this->lng->txt(
"shib_data_conv"));
216 $this->tpl->setVariable(
"TXT_SHIB_AUTH_ALLOW_LOCAL", $this->lng->txt(
"auth_allow_local"));
217 foreach ($shib_settings as $setting)
219 $this->tpl->setVariable(
"TXT_".strtoupper($setting), $this->lng->txt($setting));
222 $this->tpl->setVariable(
"TXT_REQUIRED_FLD", $this->lng->txt(
"required_field"));
223 $this->tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
224 $this->tpl->setVariable(
"TXT_SUBMIT", $this->lng->txt(
"save"));
225 $this->tpl->setVariable(
"CMD_SUBMIT",
"save");
235 or !
$_POST[
"shib"][
"hos_type"]
236 or !
$_POST[
"shib"][
"firstname"]
237 or !
$_POST[
"shib"][
"lastname"]
238 or !
$_POST[
"shib"][
"email"]
239 or !
$_POST[
"shib"][
"user_default_role"]
240 or !
$_POST[
"shib"][
"federation_name"]
243 $this->ilias->raiseError($this->lng->txt(
"fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
248 $_POST[
"shib"][
"data_conv"]
249 and
$_POST[
"shib"][
"data_conv"] !=
''
250 and !is_readable(
$_POST[
"shib"][
"data_conv"]) )
252 $this->ilias->raiseError($this->lng->txt(
"shib_data_conv_warning"),$this->ilias->error_obj->MESSAGE);
256 $shib_settings = array(
276 foreach ($shib_settings as $setting)
278 $field = ereg_replace(
'shib_',
'',$setting);
279 if (
$_POST[
"shib"][
"update_".$field] !=
"1")
280 $_POST[
"shib"][
"update_".$field] =
"0";
281 $this->ilias->setSetting($setting, trim(
$_POST[
"shib"][$field]));
282 $this->ilias->setSetting(
"shib_update_".$field,
$_POST[
"shib"][
"update_".$field]);
285 if (
$_POST[
"shib"][
"active"] !=
"1")
287 $this->ilias->setSetting(
"shib_active",
"0");
291 $this->ilias->setSetting(
"shib_active",
"1");
294 $this->ilias->setSetting(
"shib_user_default_role",
$_POST[
"shib"][
"user_default_role"]);
295 $this->ilias->setSetting(
"shib_hos_type",
$_POST[
"shib"][
"hos_type"]);
296 $this->ilias->setSetting(
"shib_federation_name",
$_POST[
"shib"][
"federation_name"]);
297 $this->ilias->setSetting(
"shib_idp_list",
$_POST[
"shib"][
"idp_list"]);
298 $this->ilias->setSetting(
"shib_login_instructions",
$_POST[
"shib"][
"login_instructions"]);
299 $this->ilias->setSetting(
"shib_login_button",
$_POST[
"shib"][
"login_button"]);
300 $this->ilias->setSetting(
"shib_data_conv",
$_POST[
"shib"][
"data_conv"]);
301 $this->ilias->setSetting(
"shib_auth_allow_local", (
$_POST[
'shib'][
'auth_allow_local']==
'1') ?
'1' :
'0');
305 $this->ctrl->redirect($this,
'settings');
310 $this->tabs_gui->setSubTabActive(
'shib_role_assignment');
314 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.shib_role_assignment.html',
'Services/AuthShibboleth');
315 $this->tpl->setVariable(
'NEW_RULE_TABLE',$this->form->getHTML());
319 $this->tpl->setVariable(
'RULE_TABLE',$html);
327 include_once(
'./Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentRules.php');
332 include_once(
'./Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentTableGUI.php');
334 $rules_table->setTitle($this->lng->txt(
'shib_rules_tables'));
336 $rules_table->addMultiCommand(
"confirmDeleteRules", $this->lng->txt(
"delete"));
337 $rules_table->setSelectAllCheckbox(
"rule_id");
339 return $rules_table->getHTML();
351 if(!is_array(
$_POST[
'rule_ids']))
357 $this->tabs_gui->setSubTabActive(
'shib_role_assignment');
359 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
363 $c_gui->setFormAction($this->ctrl->getFormAction($this,
"deleteRules"));
364 $c_gui->setHeaderText($this->lng->txt(
"shib_confirm_del_role_ass"));
365 $c_gui->setCancel($this->lng->txt(
"cancel"),
"roleAssignment");
366 $c_gui->setConfirm($this->lng->txt(
"confirm"),
"deleteRules");
369 include_once(
'Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentRule.php');
370 foreach(
$_POST[
"rule_ids"] as $rule_id)
376 $info .= $rule->conditionToString();
378 $c_gui->addItem(
'rule_ids[]',$rule_id,$info);
380 $this->tpl->setContent($c_gui->getHTML());
391 if(!is_array(
$_POST[
'rule_ids']))
397 include_once(
'Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentRule.php');
398 foreach(
$_POST[
"rule_ids"] as $rule_id)
412 include_once(
'./Services/Form/classes/class.ilPropertyFormGUI.php');
414 $this->form->setFormAction($this->ctrl->getFormAction($this,
'cancel'));
415 $this->form->setTitle($this->lng->txt(
'shib_role_ass_table'));
417 if($a_mode ==
'default')
419 $this->form->setTitle($this->lng->txt(
'shib_role_ass_table'));
420 $this->form->addCommandButton(
'addRoleAssignmentRule',$this->lng->txt(
'shib_new_rule'));
421 $this->form->addCommandButton(
'settings',$this->lng->txt(
'cancel'));
425 $this->form->setTitle($this->lng->txt(
'shib_update_role_ass_table'));
426 $this->form->addCommandButton(
'updateRoleAssignmentRule',$this->lng->txt(
'save'));
427 $this->form->addCommandButton(
'roleAssignment',$this->lng->txt(
'cancel'));
434 $global =
new ilRadioOption($this->lng->txt(
'shib_global_role'),0);
435 $role->addOption($global);
439 $global->addSubItem($role_select);
441 $local =
new ilRadioOption($this->lng->txt(
'shib_local_role'),1);
442 $role->addOption($local);
444 include_once
'./Services/Form/classes/class.ilRoleAutoCompleteInputGUI.php';
446 $role_search->setSize(40);
447 $local->addSubItem($role_search);
449 include_once
'./Services/AccessControl/classes/class.ilRoleAutoComplete.php';
451 $role->setInfo($this->lng->txt(
'shib_role_name_info'));
452 $this->form->addItem($role);
456 $update->
setValue($this->lng->txt(
'shib_check_role_assignment'));
459 $add->setOptionTitle($this->lng->txt(
'shib_add_missing'));
461 $update->addSubItem($add);
464 $remove->setOptionTitle($this->lng->txt(
'shib_remove_deprecated'));
465 $remove->setValue(1);
466 $update->addSubItem($remove);
468 $this->form->addItem($update);
473 $kind->setRequired(
true);
475 $attr =
new ilRadioOption($this->lng->txt(
'shib_attribute'),1);
476 $attr->
setInfo($this->lng->txt(
'shib_attr_info'));
478 $name =
new ilTextInputGUI($this->lng->txt(
'shib_attribute_name'),
'attr_name');
480 $attr->addSubItem($name);
482 $value =
new ilTextInputGUI($this->lng->txt(
'shib_attribute_value'),
'attr_value');
484 $attr->addSubItem($value);
485 $kind->addOption($attr);
490 $pl->
setInfo($this->lng->txt(
'shib_plugin_info'));
491 $pl->setDisabled(!$pl_active);
496 $id->setMaxLength(3);
497 $id->setMaxValue(999);
499 $pl->addSubItem($id);
501 $kind->addOption($pl);
503 $this->form->addItem($kind);
511 include_once(
"./Services/Form/classes/class.ilRoleAutoCompleteInputGUI.php");
520 if(!$ilAccess->checkAccess(
'write',
'',$this->ref_id))
528 if(!$this->form->checkInput() or ($err = $this->
checkInput()))
535 $this->tabs_gui->setSubTabActive(
'shib_role_assignment');
537 $this->form->setValuesByPost();
538 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.shib_role_assignment.html',
'Services/AuthShibboleth');
539 $this->tpl->setVariable(
'NEW_RULE_TABLE',$this->form->getHTML());
543 $this->tpl->setVariable(
'RULE_TABLE',$html);
565 $this->ctrl->setParameter($this,
'rule_id',(
int)
$_GET[
'rule_id']);
568 $this->tabs_gui->setSubTabActive(
'shib_role_assignment');
572 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.shib_role_assignment.html',
'Services/AuthShibboleth');
573 $this->tpl->setVariable(
'NEW_RULE_TABLE',$this->form->getHTML());
581 if(!$ilAccess->checkAccess(
'write',
'',$this->ref_id))
596 $this->tabs_gui->setSubTabActive(
'shib_role_assignment');
598 $this->form->setValuesByPost();
599 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.shib_role_assignment.html',
'Services/AuthShibboleth');
600 $this->tpl->setVariable(
'NEW_RULE_TABLE',$this->form->getHTML());
606 $this->rule->update();
614 include_once(
'./Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentRule.php');
617 if($this->form->getInput(
'role_name') == 0)
619 $this->rule->setRoleId($this->form->getInput(
'role_id'));
621 elseif($this->form->getInput(
'role_search'))
624 include_once
'./Services/Search/classes/class.ilQueryParser.php';
626 $parser =
new ilQueryParser($this->form->getInput(
'role_search'));
633 include_once
'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
635 $object_search->setFilter(array(
'role'));
636 $res = $object_search->performSearch();
638 $entries =
$res->getEntries();
639 if(count($entries) == 1)
641 $role = current($entries);
642 $this->rule->setRoleId($role[
'obj_id']);
644 elseif(count($entries) > 1)
646 $this->rule->setRoleId(-1);
649 $this->rule->setName($this->form->getInput(
'attr_name'));
650 $this->rule->setValue($this->form->getInput(
'attr_value'));
651 $this->rule->enableAddOnUpdate($this->form->getInput(
'add_missing'));
652 $this->rule->enableRemoveOnUpdate($this->form->getInput(
'remove_deprecated'));
653 $this->rule->enablePlugin($this->form->getInput(
'kind') == 2);
654 $this->rule->setPluginId($this->form->getInput(
'plugin_id'));
663 include_once
'./Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentRule.php';
665 $role = $rule->getRoleId();
667 if($rbacreview->isGlobalRole($role))
669 $values[
'role_name'] = 0;
670 $values[
'role_id'] = $role;
674 $values[
'role_name'] = 1;
678 $values[
'add_missing'] = (int) $rule->isAddOnUpdateEnabled();
679 $values[
'remove_deprecated'] = (int) $rule->isRemoveOnUpdateEnabled();
681 $values[
'attr_name'] = $rule->getName();
682 $values[
'attr_value'] = $rule->getValue();
684 if(!$rule->isPluginActive())
691 $values[
'plugin_id'] = $rule->getPluginId();
694 $this->form->setValuesByArray($values);
700 return $this->rule->validate();
705 if($this->rule->getRoleId() > 0)
711 $_SESSION[
'shib_role_ass'][
'search'] = $this->form->getInput(
'role_search');
712 $_SESSION[
'shib_role_ass'][
'add_on_update'] = $this->rule->isAddOnUpdateEnabled();
713 $_SESSION[
'shib_role_ass'][
'remove_on_update'] = $this->rule->isRemoveOnUpdateEnabled();
714 $_SESSION[
'shib_role_ass'][
'name'] = $this->rule->getName();
715 $_SESSION[
'shib_role_ass'][
'value'] = $this->rule->getValue();
716 $_SESSION[
'shib_role_ass'][
'plugin'] = $this->rule->isPluginActive();
717 $_SESSION[
'shib_role_ass'][
'plugin_id'] = $this->rule->getPluginId();
719 $this->ctrl->redirect($this,
'chooseRole');
724 $this->tabs_gui->setSubTabActive(
'shib_role_assignment');
726 include_once
'./Services/Search/classes/class.ilQueryParser.php';
728 $parser->setMinWordLength(1,
true);
732 include_once
'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
734 $object_search->setFilter(array(
'role'));
735 $res = $object_search->performSearch();
737 $entries =
$res->getEntries();
739 include_once
'./Services/AccessControl/classes/class.ilRoleSelectionTableGUI.php';
741 $table->setTitle($this->lng->txt(
'shib_role_selection'));
742 $table->addMultiCommand(
'saveRoleSelection',$this->lng->txt(
'shib_choose_role'));
743 $table->addCommandButton(
'roleAssignment',$this->lng->txt(
'cancel'));
744 $table->parse($entries);
746 $this->tpl->setContent($table->getHTML());
753 $rule->setRoleId((
int)
$_POST[
'role_id']);
754 $rule->setName(
$_SESSION[
'shib_role_ass'][
'name']);
755 $rule->setValue(
$_SESSION[
'shib_role_ass'][
'value']);
756 $rule->enablePlugin(
$_SESSION[
'shib_role_ass'][
'plugin']);
757 $rule->setPluginId(
$_SESSION[
'shib_role_ass'][
'plugin_id']);
758 $rule->enableAddOnUpdate(
$_SESSION[
'shib_role_ass'][
'add_on_update']);
759 $rule->enableRemoveOnUpdate(
$_SESSION[
'shib_role_ass'][
'remove_on_update']);
761 if($rule->getRuleId())
782 global $ilPluginAdmin;
784 return count($ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_SERVICE,
'AuthShibboleth',
'shibhk'));
791 global $rbacreview,$ilObjDataCache;
798 $select[0] = $this->lng->txt(
'links_select_one');
799 foreach($global_roles as $role_id)
812 include_once
'./Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentRules.php';
819 $this->tabs_gui->addSubTabTarget(
'shib_settings',
820 $this->ctrl->getLinkTarget($this,
'settings'));
822 $this->tabs_gui->addSubTabTarget(
'shib_role_assignment',
823 $this->ctrl->getLinkTarget($this,
'roleAssignment'));