ILIAS  trunk Revision v11.0_alpha-1851-ga8564da6fed
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilShibbolethRoleAssignmentRule Class Reference

Shibboleth role assignment rule. More...

+ Collaboration diagram for ilShibbolethRoleAssignmentRule:

Public Member Functions

 __construct (private int $rule_id=0)
 
 setRuleId (int $a_id)
 
 getRuleId ()
 
 setRoleId (int $a_id)
 
 getRoleId ()
 
 setName (string $a_name)
 
 getName ()
 
 setValue (string $a_value)
 
 getValue ()
 
 enablePlugin (bool $a_status)
 
 isPluginActive ()
 
 enableAddOnUpdate (bool $a_status)
 
 isAddOnUpdateEnabled ()
 
 enableRemoveOnUpdate (bool $a_status)
 
 isRemoveOnUpdateEnabled ()
 
 setPluginId (?string $a_id)
 
 getPluginId ()
 
 conditionToString ()
 
 validate ()
 
 delete ()
 
 add ()
 
 update ()
 
 matches (array $a_data)
 
 doesMatch (array $a_data)
 

Protected Member Functions

 wildcardCompare (string $a_str1, string $a_str2)
 

Private Member Functions

 read ()
 

Private Attributes

const ERR_MISSING_NAME = 'shib_missing_attr_name'
 
const ERR_MISSING_VALUE = 'shib_missing_attr_value'
 
const ERR_MISSING_ROLE = 'shib_missing_role'
 
const ERR_MISSING_PLUGIN_ID = 'shib_missing_plugin_id'
 
const TABLE_NAME = 'shib_role_assignment'
 
ilDBInterface $db
 
int $role_id = 0
 
string $attribute_name = ''
 
string $attribute_value = ''
 
bool $plugin_active = false
 
bool $add_on_update = false
 
bool $remove_on_update = false
 
string $plugin_id = null
 

Detailed Description

Shibboleth role assignment rule.

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 12 of file class.ilShibbolethRoleAssignmentRule.php.

Constructor & Destructor Documentation

◆ __construct()

ilShibbolethRoleAssignmentRule::__construct ( private int  $rule_id = 0)

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

References $DIC, and read().

45  {
46  global $DIC;
47  $this->db = $DIC->database();
48  $this->read();
49  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ add()

ilShibbolethRoleAssignmentRule::add ( )

Definition at line 172 of file class.ilShibbolethRoleAssignmentRule.php.

References getName(), getPluginId(), getRoleId(), getValue(), isAddOnUpdateEnabled(), isPluginActive(), isRemoveOnUpdateEnabled(), and setRuleId().

172  : bool
173  {
174  $next_id = $this->db->nextId(self::TABLE_NAME);
175  $query = 'INSERT INTO ' . self::TABLE_NAME . ' (rule_id,role_id,name,value,plugin,plugin_id,add_on_update,remove_on_update ) ' . 'VALUES( '
176  . $this->db->quote($next_id, 'integer') . ', ' . $this->db->quote($this->getRoleId(), 'integer') . ', '
177  . $this->db->quote($this->getName(), 'text') . ', ' . $this->db->quote($this->getValue(), 'text') . ', '
178  . $this->db->quote((int) $this->isPluginActive(), 'integer') . ', ' . $this->db->quote(
179  $this->getPluginId() ?? '0',
180  'integer'
181  ) . ', '
182  . $this->db->quote((int) $this->isAddOnUpdateEnabled(), 'integer') . ', '
183  . $this->db->quote((int) $this->isRemoveOnUpdateEnabled(), 'integer') . ') ';
184  $this->db->manipulate($query);
185  $this->setRuleId($this->db->getLastInsertId());
186 
187  return true;
188  }
+ Here is the call graph for this function:

◆ conditionToString()

ilShibbolethRoleAssignmentRule::conditionToString ( )

Definition at line 131 of file class.ilShibbolethRoleAssignmentRule.php.

References $DIC, $lng, getName(), getPluginId(), getValue(), and isPluginActive().

Referenced by ilAuthShibbolethSettingsGUI\confirmDeleteRules().

131  : ?string
132  {
133  global $DIC;
134  $lng = $DIC['lng'];
135  if ($this->isPluginActive()) {
136  return $lng->txt('shib_plugin_id') . ': ' . $this->getPluginId();
137  }
138 
139  return $this->getName() . '=' . $this->getValue();
140  }
global $DIC
Definition: shib_login.php:22
global $lng
Definition: privfeed.php:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilShibbolethRoleAssignmentRule::delete ( )

Definition at line 161 of file class.ilShibbolethRoleAssignmentRule.php.

References getRuleId().

Referenced by ilAuthShibbolethSettingsGUI\deleteRules().

161  : bool
162  {
163  $query = 'DELETE FROM ' . self::TABLE_NAME . ' ' . 'WHERE rule_id = ' . $this->db->quote(
164  $this->getRuleId(),
165  'integer'
166  );
167  $this->db->manipulate($query);
168 
169  return true;
170  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doesMatch()

ilShibbolethRoleAssignmentRule::doesMatch ( array  $a_data)

Definition at line 240 of file class.ilShibbolethRoleAssignmentRule.php.

References ilShibbolethRoleAssignmentRules\callPlugin(), getName(), getPluginId(), getValue(), and isPluginActive().

240  : bool
241  {
242  if ($this->isPluginActive()) {
244  }
245 
246  if (!isset($a_data[$this->getName()])) {
247  return false;
248  }
249 
250  $values = $a_data[$this->getName()];
251  if (is_array($values)) {
252  return in_array($this->getValue(), $values);
253  }
254 
255  $pattern = str_replace('*', '.*?', $this->getValue());
256 
257  return (bool) preg_match('/^' . $pattern . '$/us', (string) $values);
258  }
static callPlugin(string $a_plugin_id, array $a_user_data)
+ Here is the call graph for this function:

◆ enableAddOnUpdate()

ilShibbolethRoleAssignmentRule::enableAddOnUpdate ( bool  $a_status)

Definition at line 101 of file class.ilShibbolethRoleAssignmentRule.php.

Referenced by read().

101  : void
102  {
103  $this->add_on_update = $a_status;
104  }
+ Here is the caller graph for this function:

◆ enablePlugin()

ilShibbolethRoleAssignmentRule::enablePlugin ( bool  $a_status)

Definition at line 91 of file class.ilShibbolethRoleAssignmentRule.php.

Referenced by read().

91  : void
92  {
93  $this->plugin_active = $a_status;
94  }
+ Here is the caller graph for this function:

◆ enableRemoveOnUpdate()

ilShibbolethRoleAssignmentRule::enableRemoveOnUpdate ( bool  $a_status)

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

Referenced by read().

111  : void
112  {
113  $this->remove_on_update = $a_status;
114  }
+ Here is the caller graph for this function:

◆ getName()

ilShibbolethRoleAssignmentRule::getName ( )

Definition at line 76 of file class.ilShibbolethRoleAssignmentRule.php.

References $attribute_name.

Referenced by add(), conditionToString(), doesMatch(), ilAuthShibbolethSettingsGUI\getRuleValues(), matches(), update(), and validate().

76  : string
77  {
78  return $this->attribute_name;
79  }
+ Here is the caller graph for this function:

◆ getPluginId()

ilShibbolethRoleAssignmentRule::getPluginId ( )

Definition at line 126 of file class.ilShibbolethRoleAssignmentRule.php.

References $plugin_id.

Referenced by add(), conditionToString(), doesMatch(), ilAuthShibbolethSettingsGUI\getRuleValues(), matches(), update(), and validate().

126  : ?string
127  {
128  return $this->plugin_id;
129  }
+ Here is the caller graph for this function:

◆ getRoleId()

ilShibbolethRoleAssignmentRule::getRoleId ( )

Definition at line 66 of file class.ilShibbolethRoleAssignmentRule.php.

References $role_id.

Referenced by add(), ilAuthShibbolethSettingsGUI\confirmDeleteRules(), ilAuthShibbolethSettingsGUI\getRuleValues(), update(), and validate().

66  : int
67  {
68  return $this->role_id;
69  }
+ Here is the caller graph for this function:

◆ getRuleId()

ilShibbolethRoleAssignmentRule::getRuleId ( )

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

Referenced by delete(), read(), and update().

56  : int
57  {
58  return $this->rule_id;
59  }
+ Here is the caller graph for this function:

◆ getValue()

ilShibbolethRoleAssignmentRule::getValue ( )

Definition at line 86 of file class.ilShibbolethRoleAssignmentRule.php.

References $attribute_value.

Referenced by add(), conditionToString(), doesMatch(), ilAuthShibbolethSettingsGUI\getRuleValues(), matches(), update(), and validate().

86  : string
87  {
89  }
+ Here is the caller graph for this function:

◆ isAddOnUpdateEnabled()

ilShibbolethRoleAssignmentRule::isAddOnUpdateEnabled ( )

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

References $add_on_update.

Referenced by add(), ilAuthShibbolethSettingsGUI\getRuleValues(), and update().

106  : bool
107  {
108  return $this->add_on_update;
109  }
+ Here is the caller graph for this function:

◆ isPluginActive()

ilShibbolethRoleAssignmentRule::isPluginActive ( )

Definition at line 96 of file class.ilShibbolethRoleAssignmentRule.php.

References $plugin_active.

Referenced by add(), conditionToString(), doesMatch(), ilAuthShibbolethSettingsGUI\getRuleValues(), matches(), update(), and validate().

96  : bool
97  {
98  return $this->plugin_active;
99  }
+ Here is the caller graph for this function:

◆ isRemoveOnUpdateEnabled()

ilShibbolethRoleAssignmentRule::isRemoveOnUpdateEnabled ( )

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

References $remove_on_update.

Referenced by add(), ilAuthShibbolethSettingsGUI\getRuleValues(), and update().

116  : bool
117  {
119  }
+ Here is the caller graph for this function:

◆ matches()

ilShibbolethRoleAssignmentRule::matches ( array  $a_data)
Deprecated:

Definition at line 213 of file class.ilShibbolethRoleAssignmentRule.php.

References ilShibbolethRoleAssignmentRules\callPlugin(), getName(), getPluginId(), getValue(), isPluginActive(), and wildcardCompare().

213  : bool
214  {
215  if ($this->isPluginActive()) {
217  }
218  // No value
219  if (!isset($a_data[$this->getName()])) {
220  return false;
221  }
222  $values = $a_data[$this->getName()];
223  if (is_array($values)) {
224  return in_array($this->getValue(), $values);
225  }
226 
227  return $this->wildcardCompare($this->getValue(), $values);
228  }
static callPlugin(string $a_plugin_id, array $a_user_data)
+ Here is the call graph for this function:

◆ read()

ilShibbolethRoleAssignmentRule::read ( )
private

Definition at line 260 of file class.ilShibbolethRoleAssignmentRule.php.

References $res, enableAddOnUpdate(), enablePlugin(), enableRemoveOnUpdate(), ilDBConstants\FETCHMODE_OBJECT, getRuleId(), setName(), setPluginId(), setRoleId(), and setValue().

Referenced by __construct().

260  : void
261  {
262  if ($this->getRuleId() === 0) {
263  return;
264  }
265 
266  $query = 'SELECT * FROM ' . self::TABLE_NAME . ' ' . 'WHERE rule_id = ' . $this->db->quote(
267  $this->getRuleId(),
268  'integer'
269  );
270  $res = $this->db->query($query);
271  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
272  $this->setRoleId((int) $row->role_id);
273  $this->setName((string) $row->name);
274  $this->setValue((string) $row->value);
275  $this->enablePlugin((bool) $row->plugin);
276  $this->setPluginId($row->plugin_id);
277  $this->enableAddOnUpdate((bool) $row->add_on_update);
278  $this->enableRemoveOnUpdate((bool) $row->remove_on_update);
279  }
280  }
$res
Definition: ltiservices.php:66
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setName()

ilShibbolethRoleAssignmentRule::setName ( string  $a_name)

Definition at line 71 of file class.ilShibbolethRoleAssignmentRule.php.

Referenced by read().

71  : void
72  {
73  $this->attribute_name = $a_name;
74  }
+ Here is the caller graph for this function:

◆ setPluginId()

ilShibbolethRoleAssignmentRule::setPluginId ( ?string  $a_id)

Definition at line 121 of file class.ilShibbolethRoleAssignmentRule.php.

Referenced by read().

121  : void
122  {
123  $this->plugin_id = $a_id;
124  }
+ Here is the caller graph for this function:

◆ setRoleId()

ilShibbolethRoleAssignmentRule::setRoleId ( int  $a_id)

Definition at line 61 of file class.ilShibbolethRoleAssignmentRule.php.

Referenced by read().

61  : void
62  {
63  $this->role_id = $a_id;
64  }
+ Here is the caller graph for this function:

◆ setRuleId()

ilShibbolethRoleAssignmentRule::setRuleId ( int  $a_id)

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

Referenced by add().

51  : void
52  {
53  $this->rule_id = $a_id;
54  }
+ Here is the caller graph for this function:

◆ setValue()

ilShibbolethRoleAssignmentRule::setValue ( string  $a_value)

Definition at line 81 of file class.ilShibbolethRoleAssignmentRule.php.

Referenced by read().

81  : void
82  {
83  $this->attribute_value = $a_value;
84  }
+ Here is the caller graph for this function:

◆ update()

ilShibbolethRoleAssignmentRule::update ( )

Definition at line 190 of file class.ilShibbolethRoleAssignmentRule.php.

References getName(), getPluginId(), getRoleId(), getRuleId(), getValue(), isAddOnUpdateEnabled(), isPluginActive(), and isRemoveOnUpdateEnabled().

190  : bool
191  {
192  $query = 'UPDATE ' . self::TABLE_NAME . ' ' . 'SET role_id = ' . $this->db->quote(
193  $this->getRoleId(),
194  'integer'
195  ) . ', ' . 'name = '
196  . $this->db->quote($this->getName(), 'text') . ', ' . 'value = ' . $this->db->quote(
197  $this->getValue(),
198  'text'
199  ) . ', ' . 'plugin = '
200  . $this->db->quote((int) $this->isPluginActive(), 'integer') . ', ' . 'plugin_id = '
201  . $this->db->quote($this->getPluginId() ?? '0', 'integer') . ', ' . 'add_on_update = '
202  . $this->db->quote((int) $this->isAddOnUpdateEnabled(), 'integer') . ', ' . 'remove_on_update = '
203  . $this->db->quote((int) $this->isRemoveOnUpdateEnabled(), 'integer') . ' '
204  . 'WHERE rule_id = ' . $this->db->quote($this->getRuleId(), 'integer');
205  $this->db->manipulate($query);
206 
207  return true;
208  }
+ Here is the call graph for this function:

◆ validate()

ilShibbolethRoleAssignmentRule::validate ( )

Definition at line 142 of file class.ilShibbolethRoleAssignmentRule.php.

References getName(), getPluginId(), getRoleId(), getValue(), and isPluginActive().

142  : string
143  {
144  if ($this->getRoleId() === 0) {
145  return self::ERR_MISSING_ROLE;
146  }
147  if (!$this->isPluginActive()) {
148  if ($this->getName() === '' || $this->getName() === '0') {
149  return self::ERR_MISSING_NAME;
150  }
151  if ($this->getValue() === '' || $this->getValue() === '0') {
152  return self::ERR_MISSING_VALUE;
153  }
154  } elseif ($this->getPluginId() === 0) {
155  return self::ERR_MISSING_PLUGIN_ID;
156  }
157 
158  return '';
159  }
+ Here is the call graph for this function:

◆ wildcardCompare()

ilShibbolethRoleAssignmentRule::wildcardCompare ( string  $a_str1,
string  $a_str2 
)
protected
Deprecated:

Definition at line 233 of file class.ilShibbolethRoleAssignmentRule.php.

Referenced by matches().

233  : bool
234  {
235  $pattern = str_replace('*', '.*?', $a_str1);
236 
237  return (bool) preg_match("/" . $pattern . "/us", $a_str2);
238  }
+ Here is the caller graph for this function:

Field Documentation

◆ $add_on_update

bool ilShibbolethRoleAssignmentRule::$add_on_update = false
private

Definition at line 40 of file class.ilShibbolethRoleAssignmentRule.php.

Referenced by isAddOnUpdateEnabled().

◆ $attribute_name

string ilShibbolethRoleAssignmentRule::$attribute_name = ''
private

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

Referenced by getName().

◆ $attribute_value

string ilShibbolethRoleAssignmentRule::$attribute_value = ''
private

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

Referenced by getValue().

◆ $db

ilDBInterface ilShibbolethRoleAssignmentRule::$db
private

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

◆ $plugin_active

bool ilShibbolethRoleAssignmentRule::$plugin_active = false
private

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

Referenced by isPluginActive().

◆ $plugin_id

string ilShibbolethRoleAssignmentRule::$plugin_id = null
private

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

Referenced by getPluginId().

◆ $remove_on_update

bool ilShibbolethRoleAssignmentRule::$remove_on_update = false
private

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

Referenced by isRemoveOnUpdateEnabled().

◆ $role_id

int ilShibbolethRoleAssignmentRule::$role_id = 0
private

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

Referenced by getRoleId().

◆ ERR_MISSING_NAME

const ilShibbolethRoleAssignmentRule::ERR_MISSING_NAME = 'shib_missing_attr_name'
private

Definition at line 17 of file class.ilShibbolethRoleAssignmentRule.php.

◆ ERR_MISSING_PLUGIN_ID

const ilShibbolethRoleAssignmentRule::ERR_MISSING_PLUGIN_ID = 'shib_missing_plugin_id'
private

Definition at line 29 of file class.ilShibbolethRoleAssignmentRule.php.

◆ ERR_MISSING_ROLE

const ilShibbolethRoleAssignmentRule::ERR_MISSING_ROLE = 'shib_missing_role'
private

Definition at line 25 of file class.ilShibbolethRoleAssignmentRule.php.

◆ ERR_MISSING_VALUE

const ilShibbolethRoleAssignmentRule::ERR_MISSING_VALUE = 'shib_missing_attr_value'
private

Definition at line 21 of file class.ilShibbolethRoleAssignmentRule.php.

◆ TABLE_NAME

const ilShibbolethRoleAssignmentRule::TABLE_NAME = 'shib_role_assignment'
private

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


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