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"] !=
'external_wayf'
167 $this->tpl->setVariable(
"CHK_SHIB_LOGIN_INTERNAL_WAYF",
'checked="checked"');
168 $this->tpl->setVariable(
"CHK_SHIB_LOGIN_EXTERNAL_WAYF",
'');
170 $this->tpl->setVariable(
"CHK_SHIB_LOGIN_INTERNAL_WAYF",
'');
171 $this->tpl->setVariable(
"CHK_SHIB_LOGIN_EXTERNAL_WAYF",
'checked="checked"');
174 if (!isset($settings[
"shib_idp_list"]) || $settings[
"shib_idp_list"] ==
'')
176 $this->tpl->setVariable(
"SHIB_IDP_LIST",
"urn:mace:organization1:providerID, Example Organization 1\nurn:mace:organization2:providerID, Example Organization 2, /Shibboleth.sso/WAYF/SWITCHaai");
178 $this->tpl->setVariable(
"SHIB_IDP_LIST", stripslashes($settings[
"shib_idp_list"]));
181 $this->tpl->setVariable(
"SHIB_USER_DEFAULT_ROLE", $selectElement);
182 $this->tpl->setVariable(
"SHIB_LOGIN_BUTTON", $settings[
"shib_login_button"]);
183 $this->tpl->setVariable(
"SHIB_LOGIN_INSTRUCTIONS", stripslashes($settings[
"shib_login_instructions"]));
184 $this->tpl->setVariable(
"SHIB_FEDERATION_NAME", stripslashes($settings[
"shib_federation_name"]));
185 $this->tpl->setVariable(
"SHIB_DATA_CONV", $settings[
"shib_data_conv"]);
187 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
188 $this->tpl->setVariable(
"COLSPAN", 3);
189 $this->tpl->setVariable(
"TXT_SHIB_INSTRUCTIONS",
190 $this->lng->txt(
"auth_shib_instructions"));
191 $this->tpl->setVariable(
"LINK_SHIB_INSTRUCTIONS",
192 "./Services/AuthShibboleth/README.SHIBBOLETH.txt");
193 $this->tpl->setVariable(
"TXT_SHIB", $this->lng->txt(
"shib"));
194 $this->tpl->setVariable(
"TXT_OPTIONS", $this->lng->txt(
"options"));
195 $this->tpl->setVariable(
"TXT_SHIB_UPDATE", $this->lng->txt(
"shib_update"));
196 $this->tpl->setVariable(
"TXT_SHIB_ACTIVE", $this->lng->txt(
"shib_active"));
197 $this->tpl->setVariable(
"TXT_SHIB_USER_DEFAULT_ROLE", $this->lng->txt(
"shib_user_default_role"));
198 $this->tpl->setVariable(
"TXT_SHIB_LOGIN_BUTTON", $this->lng->txt(
"shib_login_button"));
199 $this->tpl->setVariable(
"TXT_SHIB_LOGIN_TYPE", $this->lng->txt(
"shib_login_type"));
200 $this->tpl->setVariable(
"TXT_SHIB_LOGIN_INTERNAL_WAYF", $this->lng->txt(
"shib_login_internal_wayf"));
201 $this->tpl->setVariable(
"TXT_SHIB_LOGIN_EXTERNAL_WAYF", $this->lng->txt(
"shib_login_external_wayf"));
202 $this->tpl->setVariable(
"TXT_SHIB_IDP_LIST", $this->lng->txt(
"shib_idp_list"));
203 $this->tpl->setVariable(
"TXT_SHIB_FEDERATION_NAME", $this->lng->txt(
"shib_federation_name"));
204 $this->tpl->setVariable(
"TXT_SHIB_LOGIN_INSTRUCTIONS", $this->lng->txt(
"auth_login_instructions"));
205 $this->tpl->setVariable(
"TXT_SHIB_DATA_CONV", $this->lng->txt(
"shib_data_conv"));
206 $this->tpl->setVariable(
"TXT_SHIB_AUTH_ALLOW_LOCAL", $this->lng->txt(
"auth_allow_local"));
207 foreach ($shib_settings as $setting)
209 $this->tpl->setVariable(
"TXT_".strtoupper($setting), $this->lng->txt($setting));
212 $this->tpl->setVariable(
"TXT_REQUIRED_FLD", $this->lng->txt(
"required_field"));
213 $this->tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
214 $this->tpl->setVariable(
"TXT_SUBMIT", $this->lng->txt(
"save"));
215 $this->tpl->setVariable(
"CMD_SUBMIT",
"save");
225 or !
$_POST[
"shib"][
"hos_type"]
226 or !
$_POST[
"shib"][
"firstname"]
227 or !
$_POST[
"shib"][
"lastname"]
228 or !
$_POST[
"shib"][
"email"]
229 or !
$_POST[
"shib"][
"user_default_role"]
230 or !
$_POST[
"shib"][
"federation_name"]
233 $this->ilias->raiseError($this->lng->txt(
"fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
238 $_POST[
"shib"][
"data_conv"]
239 and
$_POST[
"shib"][
"data_conv"] !=
''
240 and !is_readable(
$_POST[
"shib"][
"data_conv"]) )
242 $this->ilias->raiseError($this->lng->txt(
"shib_data_conv_warning"),$this->ilias->error_obj->MESSAGE);
246 $shib_settings = array(
265 foreach ($shib_settings as $setting)
267 $field = ereg_replace(
'shib_',
'',$setting);
268 if (
$_POST[
"shib"][
"update_".$field] !=
"1")
269 $_POST[
"shib"][
"update_".$field] =
"0";
270 $this->ilias->setSetting($setting, trim(
$_POST[
"shib"][$field]));
271 $this->ilias->setSetting(
"shib_update_".$field,
$_POST[
"shib"][
"update_".$field]);
274 if (
$_POST[
"shib"][
"active"] !=
"1")
276 $this->ilias->setSetting(
"shib_active",
"0");
280 $this->ilias->setSetting(
"shib_active",
"1");
283 $this->ilias->setSetting(
"shib_user_default_role",
$_POST[
"shib"][
"user_default_role"]);
284 $this->ilias->setSetting(
"shib_hos_type",
$_POST[
"shib"][
"hos_type"]);
285 $this->ilias->setSetting(
"shib_federation_name",
$_POST[
"shib"][
"federation_name"]);
286 $this->ilias->setSetting(
"shib_idp_list",
$_POST[
"shib"][
"idp_list"]);
287 $this->ilias->setSetting(
"shib_login_instructions",
$_POST[
"shib"][
"login_instructions"]);
288 $this->ilias->setSetting(
"shib_login_button",
$_POST[
"shib"][
"login_button"]);
289 $this->ilias->setSetting(
"shib_data_conv",
$_POST[
"shib"][
"data_conv"]);
290 $this->ilias->setSetting(
"shib_auth_allow_local", (
$_POST[
'shib'][
'auth_allow_local']==
'1') ?
'1' :
'0');
294 $this->ctrl->redirect($this,
'settings');
299 $this->tabs_gui->setSubTabActive(
'shib_role_assignment');
303 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.shib_role_assignment.html',
'Services/AuthShibboleth');
304 $this->tpl->setVariable(
'NEW_RULE_TABLE',$this->form->getHTML());
308 $this->tpl->setVariable(
'RULE_TABLE',$html);
316 include_once(
'./Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentRules.php');
321 include_once(
'./Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentTableGUI.php');
323 $rules_table->setTitle($this->lng->txt(
'shib_rules_tables'));
325 $rules_table->addMultiCommand(
"confirmDeleteRules", $this->lng->txt(
"delete"));
326 $rules_table->setSelectAllCheckbox(
"rule_id");
328 return $rules_table->getHTML();
340 if(!is_array(
$_POST[
'rule_ids']))
346 $this->tabs_gui->setSubTabActive(
'shib_role_assignment');
348 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
352 $c_gui->setFormAction($this->ctrl->getFormAction($this,
"deleteRules"));
353 $c_gui->setHeaderText($this->lng->txt(
"shib_confirm_del_role_ass"));
354 $c_gui->setCancel($this->lng->txt(
"cancel"),
"roleAssignment");
355 $c_gui->setConfirm($this->lng->txt(
"confirm"),
"deleteRules");
358 include_once(
'Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentRule.php');
359 foreach(
$_POST[
"rule_ids"] as $rule_id)
365 $info .= $rule->conditionToString();
367 $c_gui->addItem(
'rule_ids[]',$rule_id,$info);
369 $this->tpl->setContent($c_gui->getHTML());
380 if(!is_array(
$_POST[
'rule_ids']))
386 include_once(
'Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentRule.php');
387 foreach(
$_POST[
"rule_ids"] as $rule_id)
401 include_once(
'./Services/Form/classes/class.ilPropertyFormGUI.php');
403 $this->form->setFormAction($this->ctrl->getFormAction($this,
'cancel'));
404 $this->form->setTitle($this->lng->txt(
'shib_role_ass_table'));
406 if($a_mode ==
'default')
408 $this->form->setTitle($this->lng->txt(
'shib_role_ass_table'));
409 $this->form->addCommandButton(
'addRoleAssignmentRule',$this->lng->txt(
'shib_new_rule'));
410 $this->form->addCommandButton(
'settings',$this->lng->txt(
'cancel'));
414 $this->form->setTitle($this->lng->txt(
'shib_update_role_ass_table'));
415 $this->form->addCommandButton(
'updateRoleAssignmentRule',$this->lng->txt(
'save'));
416 $this->form->addCommandButton(
'roleAssignment',$this->lng->txt(
'cancel'));
423 $global =
new ilRadioOption($this->lng->txt(
'shib_global_role'),0);
424 $role->addOption($global);
428 $global->addSubItem($role_select);
430 $local =
new ilRadioOption($this->lng->txt(
'shib_local_role'),1);
431 $role->addOption($local);
433 include_once
'./Services/Form/classes/class.ilRoleAutoCompleteInputGUI.php';
435 $role_search->setSize(40);
436 $local->addSubItem($role_search);
438 include_once
'./Services/AccessControl/classes/class.ilRoleAutoComplete.php';
440 $role->setInfo($this->lng->txt(
'shib_role_name_info'));
441 $this->form->addItem($role);
445 $update->
setValue($this->lng->txt(
'shib_check_role_assignment'));
448 $add->setOptionTitle($this->lng->txt(
'shib_add_missing'));
450 $update->addSubItem($add);
453 $remove->setOptionTitle($this->lng->txt(
'shib_remove_deprecated'));
454 $remove->setValue(1);
455 $update->addSubItem($remove);
457 $this->form->addItem($update);
462 $kind->setRequired(
true);
464 $attr =
new ilRadioOption($this->lng->txt(
'shib_attribute'),1);
465 $attr->
setInfo($this->lng->txt(
'shib_attr_info'));
469 $attr->addSubItem(
$name);
471 $value =
new ilTextInputGUI($this->lng->txt(
'shib_attribute_value'),
'attr_value');
473 $attr->addSubItem($value);
474 $kind->addOption($attr);
479 $pl->
setInfo($this->lng->txt(
'shib_plugin_info'));
480 $pl->setDisabled(!$pl_active);
485 $id->setMaxLength(3);
486 $id->setMaxValue(999);
488 $pl->addSubItem($id);
490 $kind->addOption($pl);
492 $this->form->addItem($kind);
500 include_once(
"./Services/Form/classes/class.ilRoleAutoCompleteInputGUI.php");
509 if(!$ilAccess->checkAccess(
'write',
'',$this->ref_id))
524 $this->tabs_gui->setSubTabActive(
'shib_role_assignment');
526 $this->form->setValuesByPost();
527 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.shib_role_assignment.html',
'Services/AuthShibboleth');
528 $this->tpl->setVariable(
'NEW_RULE_TABLE',$this->form->getHTML());
532 $this->tpl->setVariable(
'RULE_TABLE',$html);
554 $this->ctrl->setParameter($this,
'rule_id',(
int)
$_GET[
'rule_id']);
557 $this->tabs_gui->setSubTabActive(
'shib_role_assignment');
561 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.shib_role_assignment.html',
'Services/AuthShibboleth');
562 $this->tpl->setVariable(
'NEW_RULE_TABLE',$this->form->getHTML());
570 if(!$ilAccess->checkAccess(
'write',
'',$this->ref_id))
578 if(!$this->form->checkInput() or (
$err = $this->
checkInput((
int) $_REQUEST[
'rule_id'])))
585 $this->tabs_gui->setSubTabActive(
'shib_role_assignment');
587 $this->form->setValuesByPost();
588 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.shib_role_assignment.html',
'Services/AuthShibboleth');
589 $this->tpl->setVariable(
'NEW_RULE_TABLE',$this->form->getHTML());
595 $this->rule->update();
603 include_once(
'./Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentRule.php');
606 if($this->form->getInput(
'role_name') == 0)
608 $this->rule->setRoleId($this->form->getInput(
'role_id'));
610 elseif($this->form->getInput(
'role_search'))
613 include_once
'./Services/Search/classes/class.ilQueryParser.php';
615 $parser =
new ilQueryParser($this->form->getInput(
'role_search'));
622 include_once
'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
624 $object_search->setFilter(array(
'role'));
625 $res = $object_search->performSearch();
627 $entries =
$res->getEntries();
628 if(count($entries) == 1)
630 $role = current($entries);
631 $this->rule->setRoleId($role[
'obj_id']);
633 elseif(count($entries) > 1)
635 $this->rule->setRoleId(-1);
638 $this->rule->setName($this->form->getInput(
'attr_name'));
639 $this->rule->setValue($this->form->getInput(
'attr_value'));
640 $this->rule->enableAddOnUpdate($this->form->getInput(
'add_missing'));
641 $this->rule->enableRemoveOnUpdate($this->form->getInput(
'remove_deprecated'));
642 $this->rule->enablePlugin($this->form->getInput(
'kind') == 2);
643 $this->rule->setPluginId($this->form->getInput(
'plugin_id'));
652 include_once
'./Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentRule.php';
654 $role = $rule->getRoleId();
656 if($rbacreview->isGlobalRole($role))
658 $values[
'role_name'] = 0;
659 $values[
'role_id'] = $role;
663 $values[
'role_name'] = 1;
667 $values[
'add_missing'] = (int) $rule->isAddOnUpdateEnabled();
668 $values[
'remove_deprecated'] = (int) $rule->isRemoveOnUpdateEnabled();
670 $values[
'attr_name'] = $rule->getName();
671 $values[
'attr_value'] = $rule->getValue();
673 if(!$rule->isPluginActive())
680 $values[
'plugin_id'] = $rule->getPluginId();
683 $this->form->setValuesByArray($values);
689 return $this->rule->validate();
694 if($this->rule->getRoleId() > 0)
699 $_SESSION[
'shib_role_ass'][
'rule_id'] = $_REQUEST[
'rule_id'] ? $_REQUEST[
'rule_id'] : 0;
700 $_SESSION[
'shib_role_ass'][
'search'] = $this->form->getInput(
'role_search');
701 $_SESSION[
'shib_role_ass'][
'add_on_update'] = $this->rule->isAddOnUpdateEnabled();
702 $_SESSION[
'shib_role_ass'][
'remove_on_update'] = $this->rule->isRemoveOnUpdateEnabled();
703 $_SESSION[
'shib_role_ass'][
'name'] = $this->rule->getName();
704 $_SESSION[
'shib_role_ass'][
'value'] = $this->rule->getValue();
705 $_SESSION[
'shib_role_ass'][
'plugin'] = $this->rule->isPluginActive();
706 $_SESSION[
'shib_role_ass'][
'plugin_id'] = $this->rule->getPluginId();
708 $this->ctrl->redirect($this,
'chooseRole');
713 $this->tabs_gui->setSubTabActive(
'shib_role_assignment');
715 include_once
'./Services/Search/classes/class.ilQueryParser.php';
717 $parser->setMinWordLength(1,
true);
721 include_once
'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
723 $object_search->setFilter(array(
'role'));
724 $res = $object_search->performSearch();
726 $entries =
$res->getEntries();
728 include_once
'./Services/AccessControl/classes/class.ilRoleSelectionTableGUI.php';
730 $table->setTitle($this->lng->txt(
'shib_role_selection'));
731 $table->addMultiCommand(
'saveRoleSelection',$this->lng->txt(
'shib_choose_role'));
732 $table->addCommandButton(
'roleAssignment',$this->lng->txt(
'cancel'));
733 $table->parse($entries);
735 $this->tpl->setContent($table->getHTML());
742 $rule->setRoleId((
int)
$_POST[
'role_id']);
743 $rule->setName(
$_SESSION[
'shib_role_ass'][
'name']);
744 $rule->setValue(
$_SESSION[
'shib_role_ass'][
'value']);
745 $rule->enablePlugin(
$_SESSION[
'shib_role_ass'][
'plugin']);
746 $rule->setPluginId(
$_SESSION[
'shib_role_ass'][
'plugin_id']);
747 $rule->enableAddOnUpdate(
$_SESSION[
'shib_role_ass'][
'add_on_update']);
748 $rule->enableRemoveOnUpdate(
$_SESSION[
'shib_role_ass'][
'remove_on_update']);
750 if($rule->getRuleId())
771 global $ilPluginAdmin;
773 return count($ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_SERVICE,
'AuthShibboleth',
'shibhk'));
780 global $rbacreview,$ilObjDataCache;
787 $select[0] = $this->lng->txt(
'links_select_one');
788 foreach($global_roles as $role_id)
801 include_once
'./Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentRules.php';
808 $this->tabs_gui->addSubTabTarget(
'shib_settings',
809 $this->ctrl->getLinkTarget($this,
'settings'));
811 $this->tabs_gui->addSubTabTarget(
'shib_role_assignment',
812 $this->ctrl->getLinkTarget($this,
'roleAssignment'));