ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilShibbolethRoleAssignmentRule Class Reference

Shibboleth role assignment rule. More...

+ Collaboration diagram for ilShibbolethRoleAssignmentRule:

Public Member Functions

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

Data Fields

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'
 

Protected Member Functions

 wildcardCompare ($a_str1, $a_str2)
 

Protected Attributes

 $db
 

Private Member Functions

 read ()
 

Private Attributes

 $rule_id = 0
 
 $role_id = 0
 
 $attribute_name = ''
 
 $attribute_value = ''
 
 $plugin_active = false
 
 $add_on_update = false
 
 $remove_on_update = false
 
 $plugin_id = 0
 

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

Constructor & Destructor Documentation

◆ __construct()

ilShibbolethRoleAssignmentRule::__construct (   $a_rule_id = 0)
Parameters
int$a_rule_id

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

83 {
84 global $ilDB;
85 $this->db = $ilDB;
86 $this->rule_id = $a_rule_id;
87 $this->read();
88 }
global $ilDB

References $ilDB, and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ add()

ilShibbolethRoleAssignmentRule::add ( )
Returns
bool

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

271 {
272 $next_id = $this->db->nextId(self::TABLE_NAME);
273 $query = 'INSERT INTO ' . self::TABLE_NAME . ' (rule_id,role_id,name,value,plugin,plugin_id,add_on_update,remove_on_update ) ' . 'VALUES( '
274 . $this->db->quote($next_id, 'integer') . ', ' . $this->db->quote($this->getRoleId(), 'integer') . ', '
275 . $this->db->quote($this->getName(), 'text') . ', ' . $this->db->quote($this->getValue(), 'text') . ', '
276 . $this->db->quote((int)$this->isPluginActive(), 'integer') . ', ' . $this->db->quote((int)$this->getPluginId(), 'integer') . ', '
277 . $this->db->quote((int)$this->isAddOnUpdateEnabled(), 'integer') . ', '
278 . $this->db->quote((int)$this->isRemoveOnUpdateEnabled(), 'integer') . ') ';
279 $this->db->manipulate($query);
280 $this->setRuleId($this->db->getLastInsertId());
281
282 return true;
283 }

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

+ Here is the call graph for this function:

◆ conditionToString()

ilShibbolethRoleAssignmentRule::conditionToString ( )
Returns
string

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

222 {
223 global $lng;
224 if ($this->isPluginActive()) {
225 return $lng->txt('shib_plugin_id') . ': ' . $this->getPluginId();
226 } else {
227 return $this->getName() . '=' . $this->getValue();
228 }
229 }
global $lng
Definition: privfeed.php:40

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

+ Here is the call graph for this function:

◆ delete()

ilShibbolethRoleAssignmentRule::delete ( )
Returns
bool

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

260 {
261 $query = 'DELETE FROM ' . self::TABLE_NAME . ' ' . 'WHERE rule_id = ' . $this->db->quote($this->getRuleId(), 'integer');
262 $this->db->manipulate($query);
263
264 return true;
265 }

References $query, and getRuleId().

+ Here is the call graph for this function:

◆ doesMatch()

ilShibbolethRoleAssignmentRule::doesMatch ( array  $a_data)
Parameters
array$a_data
Returns
bool

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

345 {
346 if ($this->isPluginActive()) {
348 }
349 if (! isset($a_data[$this->getName()])) {
350 return false;
351 }
352 $values = $a_data[$this->getName()];
353 if (is_array($values)) {
354 return in_array($this->getValue(), $values);
355 } else {
356 $pattern = str_replace('*', '.*?', $this->getValue());
357
358 return (bool)preg_match('/^' . $pattern . '$/us', $values);
359 }
360 }

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

+ Here is the call graph for this function:

◆ enableAddOnUpdate()

ilShibbolethRoleAssignmentRule::enableAddOnUpdate (   $a_status)
Parameters
$a_status

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

174 {
175 $this->add_on_update = $a_status;
176 }

Referenced by read().

+ Here is the caller graph for this function:

◆ enablePlugin()

ilShibbolethRoleAssignmentRule::enablePlugin (   $a_status)
Parameters
$a_status

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

158 {
159 $this->plugin_active = $a_status;
160 }

Referenced by read().

+ Here is the caller graph for this function:

◆ enableRemoveOnUpdate()

ilShibbolethRoleAssignmentRule::enableRemoveOnUpdate (   $a_status)
Parameters
$a_status

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

190 {
191 $this->remove_on_update = $a_status;
192 }

Referenced by read().

+ Here is the caller graph for this function:

◆ getName()

ilShibbolethRoleAssignmentRule::getName ( )
Returns
string

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

References $attribute_name.

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

+ Here is the caller graph for this function:

◆ getPluginId()

ilShibbolethRoleAssignmentRule::getPluginId ( )
Returns
int

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

References $plugin_id.

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

+ Here is the caller graph for this function:

◆ getRoleId()

ilShibbolethRoleAssignmentRule::getRoleId ( )
Returns
int

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

References $role_id.

Referenced by add(), update(), and validate().

+ Here is the caller graph for this function:

◆ getRuleId()

ilShibbolethRoleAssignmentRule::getRuleId ( )
Returns
int

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

References $rule_id.

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

+ Here is the caller graph for this function:

◆ getValue()

ilShibbolethRoleAssignmentRule::getValue ( )
Returns
string

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

References $attribute_value.

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

+ Here is the caller graph for this function:

◆ isAddOnUpdateEnabled()

ilShibbolethRoleAssignmentRule::isAddOnUpdateEnabled ( )
Returns
bool

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

References $add_on_update.

Referenced by add(), and update().

+ Here is the caller graph for this function:

◆ isPluginActive()

ilShibbolethRoleAssignmentRule::isPluginActive ( )
Returns
bool

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

References $plugin_active.

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

+ Here is the caller graph for this function:

◆ isRemoveOnUpdateEnabled()

ilShibbolethRoleAssignmentRule::isRemoveOnUpdateEnabled ( )
Returns
bool

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

References $remove_on_update.

Referenced by add(), and update().

+ Here is the caller graph for this function:

◆ matches()

ilShibbolethRoleAssignmentRule::matches (   $a_data)
Parameters
$a_data
Deprecated:
Returns
bool

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

309 {
310 if ($this->isPluginActive()) {
312 }
313 // No value
314 if (! isset($a_data[$this->getName()])) {
315 return false;
316 }
317 $values = $a_data[$this->getName()];
318 if (is_array($values)) {
319 return in_array($this->getValue(), $values);
320 } else {
321 return $this->wildcardCompare($this->getValue(), $values);
322 }
323 }

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

+ Here is the call graph for this function:

◆ read()

ilShibbolethRoleAssignmentRule::read ( )
private
Returns
bool

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

366 {
367 if (! $this->getRuleId()) {
368 return true;
369 }
370 $query = 'SELECT * FROM ' . self::TABLE_NAME . ' ' . 'WHERE rule_id = ' . $this->db->quote($this->getRuleId(), 'integer');
371 $res = $this->db->query($query);
372 while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
373 $this->setRoleId($row->role_id);
374 $this->setName($row->name);
375 $this->setValue($row->value);
376 $this->enablePlugin($row->plugin);
377 $this->setPluginId($row->plugin_id);
378 $this->enableAddOnUpdate($row->add_on_update);
379 $this->enableRemoveOnUpdate($row->remove_on_update);
380 }
381 }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11

References $query, $res, $row, DB_FETCHMODE_OBJECT, enableAddOnUpdate(), enablePlugin(), enableRemoveOnUpdate(), getRuleId(), setName(), setPluginId(), setRoleId(), and setValue().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setName()

ilShibbolethRoleAssignmentRule::setName (   $a_name)
Parameters
$a_name

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

126 {
127 $this->attribute_name = $a_name;
128 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setPluginId()

ilShibbolethRoleAssignmentRule::setPluginId (   $a_id)
Parameters
$a_id

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

206 {
207 $this->plugin_id = $a_id;
208 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setRoleId()

ilShibbolethRoleAssignmentRule::setRoleId (   $a_id)
Parameters
$a_id

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

110 {
111 $this->role_id = $a_id;
112 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setRuleId()

ilShibbolethRoleAssignmentRule::setRuleId (   $a_id)
Parameters
$a_id

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

94 {
95 $this->rule_id = $a_id;
96 }

Referenced by add().

+ Here is the caller graph for this function:

◆ setValue()

ilShibbolethRoleAssignmentRule::setValue (   $a_value)
Parameters
$a_value

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

142 {
143 $this->attribute_value = $a_value;
144 }

Referenced by read().

+ Here is the caller graph for this function:

◆ update()

ilShibbolethRoleAssignmentRule::update ( )
Returns
bool

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

289 {
290 $query = 'UPDATE ' . self::TABLE_NAME . ' ' . 'SET role_id = ' . $this->db->quote($this->getRoleId(), 'integer') . ', ' . 'name = '
291 . $this->db->quote($this->getName(), 'text') . ', ' . 'value = ' . $this->db->quote($this->getValue(), 'text') . ', ' . 'plugin = '
292 . $this->db->quote((int)$this->isPluginActive(), 'integer') . ', ' . 'plugin_id = '
293 . $this->db->quote((int)$this->getPluginId(), 'integer') . ', ' . 'add_on_update = '
294 . $this->db->quote((int)$this->isAddOnUpdateEnabled(), 'integer') . ', ' . 'remove_on_update = '
295 . $this->db->quote((int)$this->isRemoveOnUpdateEnabled(), 'integer') . ' '
296 . 'WHERE rule_id = ' . $this->db->quote($this->getRuleId(), 'integer');
297 $this->db->manipulate($query);
298
299 return true;
300 }

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

+ Here is the call graph for this function:

◆ validate()

ilShibbolethRoleAssignmentRule::validate ( )
Returns
string

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

235 {
236 if (! $this->getRoleId()) {
238 }
239 if (! $this->isPluginActive()) {
240 if (! $this->getName()) {
242 }
243 if (! $this->getValue()) {
245 }
246 } else {
247 // check plugin id is given
248 if (! $this->getPluginId()) {
250 }
251 }
252
253 return '';
254 }

References ERR_MISSING_NAME, ERR_MISSING_PLUGIN_ID, ERR_MISSING_ROLE, ERR_MISSING_VALUE, getName(), getPluginId(), getRoleId(), getValue(), and isPluginActive().

+ Here is the call graph for this function:

◆ wildcardCompare()

ilShibbolethRoleAssignmentRule::wildcardCompare (   $a_str1,
  $a_str2 
)
protected
Parameters
$a_str1
$a_str2
Deprecated:
Returns
bool

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

333 {
334 $pattern = str_replace('*', '.*?', $a_str1);
335
336 return (bool)preg_match("/" . $pattern . "/us", $a_str2);
337 }

Referenced by matches().

+ Here is the caller graph for this function:

Field Documentation

◆ $add_on_update

ilShibbolethRoleAssignmentRule::$add_on_update = false
private

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

Referenced by isAddOnUpdateEnabled().

◆ $attribute_name

ilShibbolethRoleAssignmentRule::$attribute_name = ''
private

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

Referenced by getName().

◆ $attribute_value

ilShibbolethRoleAssignmentRule::$attribute_value = ''
private

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

Referenced by getValue().

◆ $db

ilShibbolethRoleAssignmentRule::$db
protected

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

◆ $plugin_active

ilShibbolethRoleAssignmentRule::$plugin_active = false
private

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

Referenced by isPluginActive().

◆ $plugin_id

ilShibbolethRoleAssignmentRule::$plugin_id = 0
private

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

Referenced by getPluginId().

◆ $remove_on_update

ilShibbolethRoleAssignmentRule::$remove_on_update = false
private

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

Referenced by isRemoveOnUpdateEnabled().

◆ $role_id

ilShibbolethRoleAssignmentRule::$role_id = 0
private

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

Referenced by getRoleId().

◆ $rule_id

ilShibbolethRoleAssignmentRule::$rule_id = 0
private

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

Referenced by getRuleId().

◆ ERR_MISSING_NAME

const ilShibbolethRoleAssignmentRule::ERR_MISSING_NAME = 'shib_missing_attr_name'

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

Referenced by validate().

◆ ERR_MISSING_PLUGIN_ID

const ilShibbolethRoleAssignmentRule::ERR_MISSING_PLUGIN_ID = 'shib_missing_plugin_id'

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

Referenced by validate().

◆ ERR_MISSING_ROLE

const ilShibbolethRoleAssignmentRule::ERR_MISSING_ROLE = 'shib_missing_role'

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

Referenced by validate().

◆ ERR_MISSING_VALUE

const ilShibbolethRoleAssignmentRule::ERR_MISSING_VALUE = 'shib_missing_attr_value'

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

Referenced by validate().

◆ TABLE_NAME

const ilShibbolethRoleAssignmentRule::TABLE_NAME = 'shib_role_assignment'

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


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