ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilShibbolethRoleAssignmentRules Class Reference

Shibboleth role assignment rules. More...

+ Collaboration diagram for ilShibbolethRoleAssignmentRules:

Static Public Member Functions

static getCountRules ()
 
static updateAssignments ($a_usr_id, $a_data)
 
static doAssignments ($a_usr_id, $a_data)
 
static callPlugin ($a_plugin_id, $a_user_data)
 

Static Protected Attributes

static $active_plugins = NULL
 

Detailed Description

Shibboleth role assignment rules.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Fabian Schmid fabia.nosp@m.n.sc.nosp@m.hmid@.nosp@m.ilub.nosp@m..unib.nosp@m.e.ch
Version
$Id$

Definition at line 36 of file class.ilShibbolethRoleAssignmentRules.php.

Member Function Documentation

◆ callPlugin()

static ilShibbolethRoleAssignmentRules::callPlugin (   $a_plugin_id,
  $a_user_data 
)
static
Parameters
$a_plugin_id
$a_user_data
Returns
bool

Definition at line 141 of file class.ilShibbolethRoleAssignmentRules.php.

References $ok, and IL_COMP_SERVICE.

Referenced by ilShibbolethRoleAssignmentRule\matches().

141  {
142  global $ilPluginAdmin;
143  if (self::$active_plugins == NULL) {
144  self::$active_plugins = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, 'AuthShibboleth', 'shibhk');
145  }
146  $assigned = false;
147  foreach (self::$active_plugins as $plugin_name) {
148  $ok = false;
149  $plugin_obj = $ilPluginAdmin->getPluginObject(IL_COMP_SERVICE, 'AuthShibboleth', 'shibhk', $plugin_name);
150  if ($plugin_obj instanceof ilShibbolethRoleAssignmentPlugin) {
151  $ok = $plugin_obj->checkRoleAssignment($a_plugin_id, $a_user_data);
152  }
153  if ($ok) {
154  $assigned = true;
155  }
156  }
157 
158  return $assigned;
159  }
Interface for shibboleth role assignment plugins.
const IL_COMP_SERVICE
+ Here is the caller graph for this function:

◆ doAssignments()

static ilShibbolethRoleAssignmentRules::doAssignments (   $a_usr_id,
  $a_data 
)
static
Parameters
$a_usr_id
$a_data
Returns
bool

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

References $ilLog, $ilSetting, $query, $res, $row, ilObject\_lookupTitle(), and DB_FETCHMODE_OBJECT.

Referenced by ShibAuth\login().

111  {
112  global $ilDB, $ilSetting, $rbacadmin, $ilLog;
113  $query = "SELECT rule_id FROM shib_role_assignment ";
114  $num_matches = 0;
115  $res = $ilDB->query($query);
116  while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
117  $rule = new ilShibbolethRoleAssignmentRule($row->rule_id);
118  if ($rule->matches($a_data)) {
119  $num_matches ++;
120  $ilLog->write(__METHOD__ . ': Assigned to role ' . ilObject::_lookupTitle($rule->getRoleId()));
121  $rbacadmin->assignUser($rule->getRoleId(), $a_usr_id);
122  }
123  }
124  // Assign to default if no matching found
125  if (! $num_matches) {
126  $ilLog->write(__METHOD__ . ': Assigned to default role '
127  . ilObject::_lookupTitle($ilSetting->get('shib_user_default_role')));
128  $rbacadmin->assignUser($ilSetting->get('shib_user_default_role'), $a_usr_id);
129  }
130 
131  return true;
132  }
static _lookupTitle($a_id)
lookup object title
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilSetting
Definition: privfeed.php:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCountRules()

static ilShibbolethRoleAssignmentRules::getCountRules ( )
static

Definition at line 60 of file class.ilShibbolethRoleAssignmentRules.php.

References $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilAuthShibbolethSettingsGUI\parseRulesTable(), and ilAuthShibbolethSettingsGUI\setSubTabs().

60  {
61  global $ilDB;
62  $query = "SELECT COUNT(*) num FROM shib_role_assignment ";
63  $res = $ilDB->query($query);
64  while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
65  return $row->num;
66  }
67 
68  return 0;
69  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the caller graph for this function:

◆ updateAssignments()

static ilShibbolethRoleAssignmentRules::updateAssignments (   $a_usr_id,
  $a_data 
)
static
Parameters
$a_usr_id
$a_data
Returns
bool

Definition at line 78 of file class.ilShibbolethRoleAssignmentRules.php.

References $ilLog, $ilSetting, $query, $res, $row, ilObject\_lookupTitle(), and DB_FETCHMODE_OBJECT.

Referenced by ShibAuth\login().

78  {
79  global $ilDB, $rbacadmin, $rbacreview, $ilSetting, $ilLog;
80  $query = "SELECT rule_id,add_on_update,remove_on_update FROM shib_role_assignment " . "WHERE add_on_update = 1 OR remove_on_update = 1";
81  $res = $ilDB->query($query);
82  while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
83  $rule = new ilShibbolethRoleAssignmentRule($row->rule_id);
84  $matches = $rule->matches($a_data);
85  if ($matches and $row->add_on_update) {
86  $ilLog->write(__METHOD__ . ': Assigned to role ' . ilObject::_lookupTitle($rule->getRoleId()));
87  $rbacadmin->assignUser($rule->getRoleId(), $a_usr_id);
88  }
89  if (! $matches and $row->remove_on_update) {
90  $ilLog->write(__METHOD__ . ': Deassigned from role ' . ilObject::_lookupTitle($rule->getRoleId()));
91  $rbacadmin->deassignUser($rule->getRoleId(), $a_usr_id);
92  }
93  }
94  // check if is assigned to minimum one global role
95  if (! array_intersect($rbacreview->assignedRoles($a_usr_id), $rbacreview->getGlobalRoles())) {
96  $ilLog->write(__METHOD__ . ': Assigned to default role '
97  . ilObject::_lookupTitle($ilSetting->get('shib_user_default_role')));
98  $rbacadmin->assignUser($ilSetting->get('shib_user_default_role'), $a_usr_id);
99  }
100 
101  return true;
102  }
static _lookupTitle($a_id)
lookup object title
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilSetting
Definition: privfeed.php:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $active_plugins

ilShibbolethRoleAssignmentRules::$active_plugins = NULL
staticprotected

Definition at line 38 of file class.ilShibbolethRoleAssignmentRules.php.


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