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(
133 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.auth_shib.html');
135 foreach ($shib_settings as $setting)
137 $field = ereg_replace(
'shib_',
'',$setting);
138 $this->tpl->setVariable(strtoupper($setting), $settings[$setting]);
139 $this->tpl->setVariable(
'SHIB_UPDATE_'.strtoupper($field), $settings[
"shib_update_".$field]);
141 if ($settings[
"shib_update_".$field]) {
142 $this->tpl->setVariable(
'CHK_SHIB_UPDATE_'.strtoupper($field),
'checked="checked"');
148 if (!isset($settings[
"shib_login_button"]) || $settings[
"shib_login_button"] ==
''){
149 $this->tpl->setVariable(
"SHIB_LOGIN_BUTTON",
"templates/default/images/shib_login_button.png");
152 if (isset($settings[
"shib_active"]) && $settings[
"shib_active"])
154 $this->tpl->setVariable(
"chk_shib_active",
'checked="checked"');
156 if ($settings[
'shib_auth_allow_local'] ==
'1')
158 $this->tpl->setVariable(
'CHK_SHIB_AUTH_ALLOW_LOCAL',
'checked="checked"');
162 !isset($settings[
"shib_hos_type"])
163 || $settings[
"shib_hos_type"] ==
''
164 || $settings[
"shib_hos_type"] ==
'internal_wayf'
167 $this->tpl->setVariable(
"CHK_SHIB_LOGIN_INTERNAL_WAYF",
'checked="checked"');
168 $this->tpl->setVariable(
"CHK_SHIB_LOGIN_EXTERNAL_WAYF",
'');
169 $this->tpl->setVariable(
"CHK_SHIB_LOGIN_EMBEDDED_WAYF",
'');
170 } elseif($settings[
"shib_hos_type"] ==
'embedded_wayf'){
171 $this->tpl->setVariable(
"CHK_SHIB_LOGIN_INTERNAL_WAYF",
'');
172 $this->tpl->setVariable(
"CHK_SHIB_LOGIN_EXTERNAL_WAYF",
'');
173 $this->tpl->setVariable(
"CHK_SHIB_LOGIN_EMBEDDED_WAYF",
'checked="checked"');
175 $this->tpl->setVariable(
"CHK_SHIB_LOGIN_INTERNAL_WAYF",
'');
176 $this->tpl->setVariable(
"CHK_SHIB_LOGIN_EXTERNAL_WAYF",
'checked="checked"');
177 $this->tpl->setVariable(
"CHK_SHIB_LOGIN_EMBEDDED_WAYF",
'');
180 if (!isset($settings[
"shib_idp_list"]) || $settings[
"shib_idp_list"] ==
'')
182 $this->tpl->setVariable(
"SHIB_IDP_LIST",
"urn:mace:organization1:providerID, Example Organization 1\nurn:mace:organization2:providerID, Example Organization 2, /Shibboleth.sso/WAYF/SWITCHaai");
184 $this->tpl->setVariable(
"SHIB_IDP_LIST", stripslashes($settings[
"shib_idp_list"]));
187 $this->tpl->setVariable(
"SHIB_USER_DEFAULT_ROLE", $selectElement);
188 $this->tpl->setVariable(
"SHIB_LOGIN_BUTTON", $settings[
"shib_login_button"]);
189 $this->tpl->setVariable(
"SHIB_LOGIN_INSTRUCTIONS", stripslashes($settings[
"shib_login_instructions"]));
190 $this->tpl->setVariable(
"SHIB_FEDERATION_NAME", stripslashes($settings[
"shib_federation_name"]));
191 $this->tpl->setVariable(
"SHIB_DATA_CONV", $settings[
"shib_data_conv"]);
193 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
194 $this->tpl->setVariable(
"COLSPAN", 3);
195 $this->tpl->setVariable(
"TXT_SHIB_INSTRUCTIONS",
196 $this->lng->txt(
"auth_shib_instructions"));
197 $this->tpl->setVariable(
"LINK_SHIB_INSTRUCTIONS",
198 "./Services/AuthShibboleth/README.SHIBBOLETH.txt");
199 $this->tpl->setVariable(
"TXT_SHIB", $this->lng->txt(
"shib"));
200 $this->tpl->setVariable(
"TXT_OPTIONS", $this->lng->txt(
"options"));
201 $this->tpl->setVariable(
"TXT_SHIB_UPDATE", $this->lng->txt(
"shib_update"));
202 $this->tpl->setVariable(
"TXT_SHIB_ACTIVE", $this->lng->txt(
"shib_active"));
203 $this->tpl->setVariable(
"TXT_SHIB_USER_DEFAULT_ROLE", $this->lng->txt(
"shib_user_default_role"));
204 $this->tpl->setVariable(
"TXT_SHIB_LOGIN_BUTTON", $this->lng->txt(
"shib_login_button"));
205 $this->tpl->setVariable(
"TXT_SHIB_LOGIN_TYPE", $this->lng->txt(
"shib_login_type"));
206 $this->tpl->setVariable(
"TXT_SHIB_LOGIN_INTERNAL_WAYF", $this->lng->txt(
"shib_login_internal_wayf"));
207 $this->tpl->setVariable(
"TXT_SHIB_LOGIN_EXTERNAL_WAYF", $this->lng->txt(
"shib_login_external_wayf"));
208 $this->tpl->setVariable(
"TXT_SHIB_IDP_LIST", $this->lng->txt(
"shib_idp_list"));
209 $this->tpl->setVariable(
"TXT_SHIB_FEDERATION_NAME", $this->lng->txt(
"shib_federation_name"));
210 $this->tpl->setVariable(
"TXT_SHIB_LOGIN_EMBEDDED_WAYF", $this->lng->txt(
"shib_login_embedded_wayf"));
211 $this->tpl->setVariable(
"TXT_SHIB_LOGIN_EMBEDDED_WAYF_DESCRIPTION", $this->lng->txt(
"shib_login_embedded_wayf_description"));
212 $this->tpl->setVariable(
"TXT_SHIB_LOGIN_INSTRUCTIONS", $this->lng->txt(
"auth_login_instructions"));
213 $this->tpl->setVariable(
"TXT_SHIB_DATA_CONV", $this->lng->txt(
"shib_data_conv"));
214 $this->tpl->setVariable(
"TXT_SHIB_AUTH_ALLOW_LOCAL", $this->lng->txt(
"auth_allow_local"));
215 foreach ($shib_settings as $setting)
217 $this->tpl->setVariable(
"TXT_".strtoupper($setting), $this->lng->txt($setting));
220 $this->tpl->setVariable(
"TXT_REQUIRED_FLD", $this->lng->txt(
"required_field"));
221 $this->tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
222 $this->tpl->setVariable(
"TXT_SUBMIT", $this->lng->txt(
"save"));
223 $this->tpl->setVariable(
"CMD_SUBMIT",
"save");
233 or !
$_POST[
"shib"][
"hos_type"]
234 or !
$_POST[
"shib"][
"firstname"]
235 or !
$_POST[
"shib"][
"lastname"]
236 or !
$_POST[
"shib"][
"email"]
237 or !
$_POST[
"shib"][
"user_default_role"]
238 or !
$_POST[
"shib"][
"federation_name"]
241 $this->ilias->raiseError($this->lng->txt(
"fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
246 $_POST[
"shib"][
"data_conv"]
247 and
$_POST[
"shib"][
"data_conv"] !=
''
248 and !is_readable(
$_POST[
"shib"][
"data_conv"]) )
250 $this->ilias->raiseError($this->lng->txt(
"shib_data_conv_warning"),$this->ilias->error_obj->MESSAGE);
254 $shib_settings = array(
273 foreach ($shib_settings as $setting)
275 $field = ereg_replace(
'shib_',
'',$setting);
276 if (
$_POST[
"shib"][
"update_".$field] !=
"1")
277 $_POST[
"shib"][
"update_".$field] =
"0";
278 $this->ilias->setSetting($setting, trim(
$_POST[
"shib"][$field]));
279 $this->ilias->setSetting(
"shib_update_".$field,
$_POST[
"shib"][
"update_".$field]);
282 if (
$_POST[
"shib"][
"active"] !=
"1")
284 $this->ilias->setSetting(
"shib_active",
"0");
288 $this->ilias->setSetting(
"shib_active",
"1");
291 $this->ilias->setSetting(
"shib_user_default_role",
$_POST[
"shib"][
"user_default_role"]);
292 $this->ilias->setSetting(
"shib_hos_type",
$_POST[
"shib"][
"hos_type"]);
293 $this->ilias->setSetting(
"shib_federation_name",
$_POST[
"shib"][
"federation_name"]);
294 $this->ilias->setSetting(
"shib_idp_list",
$_POST[
"shib"][
"idp_list"]);
295 $this->ilias->setSetting(
"shib_login_instructions",
$_POST[
"shib"][
"login_instructions"]);
296 $this->ilias->setSetting(
"shib_login_button",
$_POST[
"shib"][
"login_button"]);
297 $this->ilias->setSetting(
"shib_data_conv",
$_POST[
"shib"][
"data_conv"]);
298 $this->ilias->setSetting(
"shib_auth_allow_local", (
$_POST[
'shib'][
'auth_allow_local']==
'1') ?
'1' :
'0');
302 $this->ctrl->redirect($this,
'settings');
307 $this->tabs_gui->setSubTabActive(
'shib_role_assignment');
311 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.shib_role_assignment.html',
'Services/AuthShibboleth');
312 $this->tpl->setVariable(
'NEW_RULE_TABLE',$this->form->getHTML());
316 $this->tpl->setVariable(
'RULE_TABLE',$html);
324 include_once(
'./Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentRules.php');
329 include_once(
'./Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentTableGUI.php');
331 $rules_table->setTitle($this->lng->txt(
'shib_rules_tables'));
333 $rules_table->addMultiCommand(
"confirmDeleteRules", $this->lng->txt(
"delete"));
334 $rules_table->setSelectAllCheckbox(
"rule_id");
336 return $rules_table->getHTML();
348 if(!is_array(
$_POST[
'rule_ids']))
354 $this->tabs_gui->setSubTabActive(
'shib_role_assignment');
356 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
360 $c_gui->setFormAction($this->ctrl->getFormAction($this,
"deleteRules"));
361 $c_gui->setHeaderText($this->lng->txt(
"shib_confirm_del_role_ass"));
362 $c_gui->setCancel($this->lng->txt(
"cancel"),
"roleAssignment");
363 $c_gui->setConfirm($this->lng->txt(
"confirm"),
"deleteRules");
366 include_once(
'Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentRule.php');
367 foreach(
$_POST[
"rule_ids"] as $rule_id)
373 $info .= $rule->conditionToString();
375 $c_gui->addItem(
'rule_ids[]',$rule_id,$info);
377 $this->tpl->setContent($c_gui->getHTML());
388 if(!is_array(
$_POST[
'rule_ids']))
394 include_once(
'Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentRule.php');
395 foreach(
$_POST[
"rule_ids"] as $rule_id)
409 include_once(
'./Services/Form/classes/class.ilPropertyFormGUI.php');
411 $this->form->setFormAction($this->ctrl->getFormAction($this,
'cancel'));
412 $this->form->setTitle($this->lng->txt(
'shib_role_ass_table'));
414 if($a_mode ==
'default')
416 $this->form->setTitle($this->lng->txt(
'shib_role_ass_table'));
417 $this->form->addCommandButton(
'addRoleAssignmentRule',$this->lng->txt(
'shib_new_rule'));
418 $this->form->addCommandButton(
'settings',$this->lng->txt(
'cancel'));
422 $this->form->setTitle($this->lng->txt(
'shib_update_role_ass_table'));
423 $this->form->addCommandButton(
'updateRoleAssignmentRule',$this->lng->txt(
'save'));
424 $this->form->addCommandButton(
'roleAssignment',$this->lng->txt(
'cancel'));
431 $global =
new ilRadioOption($this->lng->txt(
'shib_global_role'),0);
432 $role->addOption($global);
436 $global->addSubItem($role_select);
438 $local =
new ilRadioOption($this->lng->txt(
'shib_local_role'),1);
439 $role->addOption($local);
441 include_once
'./Services/Form/classes/class.ilRoleAutoCompleteInputGUI.php';
443 $role_search->setSize(40);
444 $local->addSubItem($role_search);
446 include_once
'./Services/AccessControl/classes/class.ilRoleAutoComplete.php';
448 $role->setInfo($this->lng->txt(
'shib_role_name_info'));
449 $this->form->addItem($role);
453 $update->
setValue($this->lng->txt(
'shib_check_role_assignment'));
456 $add->setOptionTitle($this->lng->txt(
'shib_add_missing'));
458 $update->addSubItem($add);
461 $remove->setOptionTitle($this->lng->txt(
'shib_remove_deprecated'));
462 $remove->setValue(1);
463 $update->addSubItem($remove);
465 $this->form->addItem($update);
470 $kind->setRequired(
true);
472 $attr =
new ilRadioOption($this->lng->txt(
'shib_attribute'),1);
473 $attr->
setInfo($this->lng->txt(
'shib_attr_info'));
475 $name =
new ilTextInputGUI($this->lng->txt(
'shib_attribute_name'),
'attr_name');
477 $attr->addSubItem($name);
479 $value =
new ilTextInputGUI($this->lng->txt(
'shib_attribute_value'),
'attr_value');
481 $attr->addSubItem($value);
482 $kind->addOption($attr);
487 $pl->
setInfo($this->lng->txt(
'shib_plugin_info'));
488 $pl->setDisabled(!$pl_active);
493 $id->setMaxLength(3);
494 $id->setMaxValue(999);
496 $pl->addSubItem($id);
498 $kind->addOption($pl);
500 $this->form->addItem($kind);
508 include_once(
"./Services/Form/classes/class.ilRoleAutoCompleteInputGUI.php");
517 if(!$ilAccess->checkAccess(
'write',
'',$this->ref_id))
525 if(!$this->form->checkInput() or ($err = $this->
checkInput()))
532 $this->tabs_gui->setSubTabActive(
'shib_role_assignment');
534 $this->form->setValuesByPost();
535 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.shib_role_assignment.html',
'Services/AuthShibboleth');
536 $this->tpl->setVariable(
'NEW_RULE_TABLE',$this->form->getHTML());
540 $this->tpl->setVariable(
'RULE_TABLE',$html);
562 $this->ctrl->setParameter($this,
'rule_id',(
int)
$_GET[
'rule_id']);
565 $this->tabs_gui->setSubTabActive(
'shib_role_assignment');
569 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.shib_role_assignment.html',
'Services/AuthShibboleth');
570 $this->tpl->setVariable(
'NEW_RULE_TABLE',$this->form->getHTML());
578 if(!$ilAccess->checkAccess(
'write',
'',$this->ref_id))
593 $this->tabs_gui->setSubTabActive(
'shib_role_assignment');
595 $this->form->setValuesByPost();
596 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.shib_role_assignment.html',
'Services/AuthShibboleth');
597 $this->tpl->setVariable(
'NEW_RULE_TABLE',$this->form->getHTML());
603 $this->rule->update();
611 include_once(
'./Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentRule.php');
614 if($this->form->getInput(
'role_name') == 0)
616 $this->rule->setRoleId($this->form->getInput(
'role_id'));
618 elseif($this->form->getInput(
'role_search'))
621 include_once
'./Services/Search/classes/class.ilQueryParser.php';
623 $parser =
new ilQueryParser($this->form->getInput(
'role_search'));
630 include_once
'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
632 $object_search->setFilter(array(
'role'));
633 $res = $object_search->performSearch();
635 $entries =
$res->getEntries();
636 if(count($entries) == 1)
638 $role = current($entries);
639 $this->rule->setRoleId($role[
'obj_id']);
641 elseif(count($entries) > 1)
643 $this->rule->setRoleId(-1);
646 $this->rule->setName($this->form->getInput(
'attr_name'));
647 $this->rule->setValue($this->form->getInput(
'attr_value'));
648 $this->rule->enableAddOnUpdate($this->form->getInput(
'add_missing'));
649 $this->rule->enableRemoveOnUpdate($this->form->getInput(
'remove_deprecated'));
650 $this->rule->enablePlugin($this->form->getInput(
'kind') == 2);
651 $this->rule->setPluginId($this->form->getInput(
'plugin_id'));
660 include_once
'./Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentRule.php';
662 $role = $rule->getRoleId();
664 if($rbacreview->isGlobalRole($role))
666 $values[
'role_name'] = 0;
667 $values[
'role_id'] = $role;
671 $values[
'role_name'] = 1;
675 $values[
'add_missing'] = (int) $rule->isAddOnUpdateEnabled();
676 $values[
'remove_deprecated'] = (int) $rule->isRemoveOnUpdateEnabled();
678 $values[
'attr_name'] = $rule->getName();
679 $values[
'attr_value'] = $rule->getValue();
681 if(!$rule->isPluginActive())
688 $values[
'plugin_id'] = $rule->getPluginId();
691 $this->form->setValuesByArray($values);
697 return $this->rule->validate();
702 if($this->rule->getRoleId() > 0)
708 $_SESSION[
'shib_role_ass'][
'search'] = $this->form->getInput(
'role_search');
709 $_SESSION[
'shib_role_ass'][
'add_on_update'] = $this->rule->isAddOnUpdateEnabled();
710 $_SESSION[
'shib_role_ass'][
'remove_on_update'] = $this->rule->isRemoveOnUpdateEnabled();
711 $_SESSION[
'shib_role_ass'][
'name'] = $this->rule->getName();
712 $_SESSION[
'shib_role_ass'][
'value'] = $this->rule->getValue();
713 $_SESSION[
'shib_role_ass'][
'plugin'] = $this->rule->isPluginActive();
714 $_SESSION[
'shib_role_ass'][
'plugin_id'] = $this->rule->getPluginId();
716 $this->ctrl->redirect($this,
'chooseRole');
721 $this->tabs_gui->setSubTabActive(
'shib_role_assignment');
723 include_once
'./Services/Search/classes/class.ilQueryParser.php';
725 $parser->setMinWordLength(1,
true);
729 include_once
'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
731 $object_search->setFilter(array(
'role'));
732 $res = $object_search->performSearch();
734 $entries =
$res->getEntries();
736 include_once
'./Services/AccessControl/classes/class.ilRoleSelectionTableGUI.php';
738 $table->setTitle($this->lng->txt(
'shib_role_selection'));
739 $table->addMultiCommand(
'saveRoleSelection',$this->lng->txt(
'shib_choose_role'));
740 $table->addCommandButton(
'roleAssignment',$this->lng->txt(
'cancel'));
741 $table->parse($entries);
743 $this->tpl->setContent($table->getHTML());
750 $rule->setRoleId((
int)
$_POST[
'role_id']);
751 $rule->setName(
$_SESSION[
'shib_role_ass'][
'name']);
752 $rule->setValue(
$_SESSION[
'shib_role_ass'][
'value']);
753 $rule->enablePlugin(
$_SESSION[
'shib_role_ass'][
'plugin']);
754 $rule->setPluginId(
$_SESSION[
'shib_role_ass'][
'plugin_id']);
755 $rule->enableAddOnUpdate(
$_SESSION[
'shib_role_ass'][
'add_on_update']);
756 $rule->enableRemoveOnUpdate(
$_SESSION[
'shib_role_ass'][
'remove_on_update']);
758 if($rule->getRuleId())
779 global $ilPluginAdmin;
781 return count($ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_SERVICE,
'AuthShibboleth',
'shibhk'));
788 global $rbacreview,$ilObjDataCache;
795 $select[0] = $this->lng->txt(
'links_select_one');
796 foreach($global_roles as $role_id)
809 include_once
'./Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentRules.php';
816 $this->tabs_gui->addSubTabTarget(
'shib_settings',
817 $this->ctrl->getLinkTarget($this,
'settings'));
819 $this->tabs_gui->addSubTabTarget(
'shib_role_assignment',
820 $this->ctrl->getLinkTarget($this,
'roleAssignment'));