ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilSamlIdp Class Reference

Class ilSamlIdp. More...

+ Collaboration diagram for ilSamlIdp:

Public Member Functions

 __construct ($a_idp_id=0)
 
 persist ()
 
 delete ()
 Deletes an idp with all relvant mapping rules. More...
 
 toArray ()
 
 bindDbRecord (array $record)
 
 getEntityId ()
 
 setEntityId ($entity_id)
 
 isActive ()
 
 setActive ($is_active)
 
 getIdpId ()
 
 setIdpId ($idp_id)
 
 allowLocalAuthentication ()
 
 setLocalLocalAuthenticationStatus ($status)
 
 getDefaultRoleId ()
 
 setDefaultRoleId ($role_id)
 
 setUidClaim ($claim)
 
 getUidClaim ()
 
 setLoginClaim ($claim)
 
 getLoginClaim ()
 
 isSynchronizationEnabled ()
 
 setSynchronizationStatus ($sync)
 
 isAccountMigrationEnabled ()
 
 setAccountMigrationStatus ($status)
 

Static Public Member Functions

static getFirstActiveIdp ()
 
static getInstanceByIdpId ($a_idp_id)
 
static isAuthModeSaml ($a_auth_mode)
 
static getIdpIdByAuthMode ($a_auth_mode)
 
static getActiveIdpList ()
 
static getAllIdps ()
 
static getAuthModeByKey ($a_auth_key)
 
static getKeyByAuthMode ($a_auth_mode)
 

Protected Attributes

 $db
 
 $idp_id
 
 $is_active = false
 
 $allow_local_auth = false
 
 $default_role_id = false
 
 $uid_claim = ''
 
 $login_claim = ''
 
 $sync_status = false
 
 $entity_id = ''
 
 $account_migration_status = false
 

Static Protected Attributes

static $idp_as_data = array()
 

Private Member Functions

 read ()
 

Static Private Attributes

static $instances = array()
 

Detailed Description

Class ilSamlIdp.

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de

Definition at line 8 of file class.ilSamlIdp.php.

Constructor & Destructor Documentation

◆ __construct()

ilSamlIdp::__construct (   $a_idp_id = 0)
Parameters
int$a_idp_id

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

References $GLOBALS, and read().

74  {
75  $this->db = $GLOBALS['DIC']->database();
76  $this->idp_id = $a_idp_id;
77 
78  if ($this->idp_id > 0) {
79  $this->read();
80  }
81  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
+ Here is the call graph for this function:

Member Function Documentation

◆ allowLocalAuthentication()

ilSamlIdp::allowLocalAuthentication ( )
Returns
boolean

Definition at line 368 of file class.ilSamlIdp.php.

References $allow_local_auth.

Referenced by persist(), and toArray().

369  {
370  return (bool) $this->allow_local_auth;
371  }
+ Here is the caller graph for this function:

◆ bindDbRecord()

ilSamlIdp::bindDbRecord ( array  $record)
Parameters
array$record

Definition at line 192 of file class.ilSamlIdp.php.

References $form, $metadata, ilPropertyFormGUI\getInput(), ilPropertyFormGUI\getItemByPostVar(), setAccountMigrationStatus(), setActive(), setDefaultRoleId(), setEntityId(), setIdpId(), setLocalLocalAuthenticationStatus(), setLoginClaim(), setSynchronizationStatus(), and setUidClaim().

Referenced by read().

193  {
194  $this->setIdpId((int) $record['idp_id']);
195  $this->setActive((bool) $record['is_active']);
196  $this->setDefaultRoleId((int) $record['default_role_id']);
197  $this->setUidClaim($record['uid_claim']);
198  $this->setLoginClaim($record['login_claim']);
199  $this->setSynchronizationStatus((bool) $record['sync_status']);
200  $this->setAccountMigrationStatus((bool) $record['account_migr_status']);
201  $this->setLocalLocalAuthenticationStatus((bool) $record['allow_local_auth']);
202  $this->setEntityId($record['entity_id']);
203  }
setDefaultRoleId($role_id)
setLoginClaim($claim)
setEntityId($entity_id)
setSynchronizationStatus($sync)
setUidClaim($claim)
setActive($is_active)
setIdpId($idp_id)
setLocalLocalAuthenticationStatus($status)
setAccountMigrationStatus($status)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilSamlIdp::delete ( )

Deletes an idp with all relvant mapping rules.

Furthermore the auth_mode of the relevant user accounts will be switched to 'default'

Definition at line 156 of file class.ilSamlIdp.php.

References array, AUTH_SAML, and getIdpId().

157  {
158  require_once 'Services/Authentication/classes/External/UserAttributeMapping/class.ilExternalAuthUserAttributeMapping.php';
159  $mapping = new ilExternalAuthUserAttributeMapping('saml', $this->getIdpId());
160  $mapping->delete();
161 
162  $this->db->manipulateF(
163  'UPDATE usr_data SET auth_mode = %s WHERE auth_mode = %s',
164  array('text', 'text'),
165  array('default', AUTH_SAML . '_' . $this->getIdpId())
166  );
167 
168  $this->db->manipulate('DELETE FROM saml_idp_settings WHERE idp_id = ' . $this->db->quote($this->getIdpId(), 'integer'));
169  }
const AUTH_SAML
Class ilExternalAuthUserAttributeMapping.
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ getActiveIdpList()

static ilSamlIdp::getActiveIdpList ( )
static
Returns
self[]

Definition at line 256 of file class.ilSamlIdp.php.

References $idp, and array.

Referenced by ilAuthUtils\_getActiveAuthModes(), ilAuthUtils\_isExternalAccountEnabled(), ilStartUpGUI\doSamlAuthentication(), ilUserImportParser\importBeginTag(), ilStartUpGUI\showSamlLoginForm(), and ilUserImportParser\verifyBeginTag().

257  {
258  $idps = array();
259 
260  foreach (self::getAllIdps() as $idp) {
261  if ($idp->isActive()) {
262  $idps[] = $idp;
263  }
264  }
265 
266  return $idps;
267  }
Create styles array
The data for the language used.
$idp
Definition: prp.php:13
+ Here is the caller graph for this function:

◆ getAllIdps()

static ilSamlIdp::getAllIdps ( )
static
Returns
self[]

Definition at line 272 of file class.ilSamlIdp.php.

References $DIC, $idp, $res, $row, and array.

Referenced by ilAuthUtils\_getAllAuthModes(), and ilSamlIdpTableGUI\getItems().

273  {
274  global $DIC;
275 
276  $res = $DIC->database()->query('SELECT * FROM saml_idp_settings');
277 
278  $idps = array();
279  while ($row = $DIC->database()->fetchAssoc($res)) {
280  $idp = new self();
281  $idp->bindDbRecord($row);
282 
283  $idps[] = $idp;
284  }
285 
286  return $idps;
287  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
$idp
Definition: prp.php:13
+ Here is the caller graph for this function:

◆ getAuthModeByKey()

static ilSamlIdp::getAuthModeByKey (   $a_auth_key)
static
Parameters
string$a_auth_key
Returns
string

Definition at line 293 of file class.ilSamlIdp.php.

References array.

Referenced by ilAuthUtils\_getAuthModeName().

294  {
295  $auth_arr = explode('_', $a_auth_key);
296  if (count((array) $auth_arr) > 1) {
297  return 'saml_' . $auth_arr[1];
298  }
299 
300  return 'saml';
301  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getDefaultRoleId()

ilSamlIdp::getDefaultRoleId ( )
Returns
int

Definition at line 384 of file class.ilSamlIdp.php.

References $default_role_id.

Referenced by persist(), and toArray().

385  {
386  return (int) $this->default_role_id;
387  }
+ Here is the caller graph for this function:

◆ getEntityId()

ilSamlIdp::getEntityId ( )
Returns
string

Definition at line 320 of file class.ilSamlIdp.php.

References $entity_id.

Referenced by persist(), and toArray().

321  {
322  return $this->entity_id;
323  }
+ Here is the caller graph for this function:

◆ getFirstActiveIdp()

static ilSamlIdp::getFirstActiveIdp ( )
static
Returns
self
Exceptions

Definition at line 87 of file class.ilSamlIdp.php.

Referenced by ilAuthProviderSaml\__construct().

88  {
89  $idps = self::getActiveIdpList();
90  if (count($idps) > 0) {
91  return current($idps);
92  }
93 
94  require_once 'Services/Saml/exceptions/class.ilSamlException.php';
95  throw new \ilSamlException('No active SAML IDP found');
96  }
+ Here is the caller graph for this function:

◆ getIdpId()

ilSamlIdp::getIdpId ( )
Returns
int

Definition at line 352 of file class.ilSamlIdp.php.

References $idp_id.

Referenced by delete(), persist(), ilSamlSettingsGUI\populateWithMetadata(), read(), ilSamlSettingsGUI\storeMetadata(), and toArray().

353  {
354  return (int) $this->idp_id;
355  }
+ Here is the caller graph for this function:

◆ getIdpIdByAuthMode()

static ilSamlIdp::getIdpIdByAuthMode (   $a_auth_mode)
static
Parameters
string$a_auth_mode
Returns
null|int

Definition at line 243 of file class.ilSamlIdp.php.

Referenced by ilObjAuthSettingsGUI\authSettingsObject(), ilAuthUtils\getAuthModeTranslation(), ilAuthProviderFactory\getProviderByAuthMode(), ilAuthUtils\isLocalPasswordEnabledForAuthMode(), and ilAuthUtils\isPasswordModificationEnabled().

244  {
245  if (self::isAuthModeSaml($a_auth_mode)) {
246  $auth_arr = explode('_', $a_auth_mode);
247  return $auth_arr[1];
248  }
249 
250  return null;
251  }
+ Here is the caller graph for this function:

◆ getInstanceByIdpId()

static ilSamlIdp::getInstanceByIdpId (   $a_idp_id)
static
Parameters
int$a_idp_id
Returns
self

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

Referenced by ilAuthProviderSaml\__construct(), ilObjAuthSettingsGUI\authSettingsObject(), ilAuthUtils\getAuthModeTranslation(), ilSamlSettingsGUI\initIdp(), ilAuthUtils\isLocalPasswordEnabledForAuthMode(), and ilAuthUtils\isPasswordModificationEnabled().

103  {
104  if (!isset(self::$instances[$a_idp_id]) || !(self::$instances[$a_idp_id] instanceof self)) {
105  self::$instances[$a_idp_id] = new self($a_idp_id);
106  }
107 
108  return self::$instances[$a_idp_id];
109  }
+ Here is the caller graph for this function:

◆ getKeyByAuthMode()

static ilSamlIdp::getKeyByAuthMode (   $a_auth_mode)
static
Parameters
string$a_auth_mode
Returns
int|string

Definition at line 307 of file class.ilSamlIdp.php.

References array, and AUTH_SAML.

Referenced by ilAuthUtils\_getAuthMode().

308  {
309  $auth_arr = explode('_', $a_auth_mode);
310  if (count((array) $auth_arr) > 1) {
311  return AUTH_SAML . '_' . $auth_arr[1];
312  }
313 
314  return AUTH_SAML;
315  }
const AUTH_SAML
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getLoginClaim()

ilSamlIdp::getLoginClaim ( )
Returns
string

Definition at line 424 of file class.ilSamlIdp.php.

References $login_claim.

Referenced by persist(), and toArray().

425  {
426  return $this->login_claim;
427  }
+ Here is the caller graph for this function:

◆ getUidClaim()

ilSamlIdp::getUidClaim ( )
Returns
string

Definition at line 408 of file class.ilSamlIdp.php.

References $uid_claim.

Referenced by persist(), and toArray().

409  {
410  return $this->uid_claim;
411  }
+ Here is the caller graph for this function:

◆ isAccountMigrationEnabled()

ilSamlIdp::isAccountMigrationEnabled ( )
Returns
boolean

Definition at line 448 of file class.ilSamlIdp.php.

References $account_migration_status.

Referenced by persist(), and toArray().

449  {
450  return (bool) $this->account_migration_status;
451  }
+ Here is the caller graph for this function:

◆ isActive()

ilSamlIdp::isActive ( )
Returns
boolean

Definition at line 336 of file class.ilSamlIdp.php.

References $is_active.

Referenced by persist(), and toArray().

337  {
338  return (bool) $this->is_active;
339  }
+ Here is the caller graph for this function:

◆ isAuthModeSaml()

static ilSamlIdp::isAuthModeSaml (   $a_auth_mode)
static
Parameters
string$a_auth_mode
Returns
bool

Definition at line 228 of file class.ilSamlIdp.php.

References $GLOBALS, and AUTH_SAML.

Referenced by ilObjAuthSettingsGUI\authSettingsObject().

229  {
230  if (!$a_auth_mode) {
231  $GLOBALS['DIC']->logger()->auth()->write(__METHOD__ . ': No auth mode given..............');
232  return false;
233  }
234 
235  $auth_arr = explode('_', $a_auth_mode);
236  return count($auth_arr) == 2 && $auth_arr[0] == AUTH_SAML && strlen($auth_arr[1]);
237  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
const AUTH_SAML
+ Here is the caller graph for this function:

◆ isSynchronizationEnabled()

ilSamlIdp::isSynchronizationEnabled ( )
Returns
boolean

Definition at line 432 of file class.ilSamlIdp.php.

References $sync_status.

Referenced by persist(), and toArray().

433  {
434  return (bool) $this->sync_status;
435  }
+ Here is the caller graph for this function:

◆ persist()

ilSamlIdp::persist ( )

Definition at line 129 of file class.ilSamlIdp.php.

References allowLocalAuthentication(), array, getDefaultRoleId(), getEntityId(), getIdpId(), getLoginClaim(), getUidClaim(), isAccountMigrationEnabled(), isActive(), isSynchronizationEnabled(), and setIdpId().

130  {
131  if (!$this->getIdpId()) {
132  $this->setIdpId($this->db->nextId('saml_idp_settings'));
133  }
134 
135  $this->db->replace(
136  'saml_idp_settings',
137  array(
138  'idp_id' => array('integer', $this->getIdpId())
139  ),
140  array(
141  'is_active' => array('integer', $this->isActive()),
142  'default_role_id' => array('integer', $this->getDefaultRoleId()),
143  'uid_claim' => array('text', $this->getUidClaim()),
144  'login_claim' => array('text', $this->getLoginClaim()),
145  'entity_id' => array('text', $this->getEntityId()),
146  'sync_status' => array('integer', $this->isSynchronizationEnabled()),
147  'allow_local_auth' => array('integer', $this->allowLocalAuthentication()),
148  'account_migr_status' => array('integer', $this->isAccountMigrationEnabled())
149  )
150  );
151  }
Create styles array
The data for the language used.
setIdpId($idp_id)
isAccountMigrationEnabled()
allowLocalAuthentication()
isSynchronizationEnabled()
+ Here is the call graph for this function:

◆ read()

ilSamlIdp::read ( )
private
Exceptions
ilException

Definition at line 114 of file class.ilSamlIdp.php.

References $query, $res, bindDbRecord(), and getIdpId().

Referenced by __construct().

115  {
116  $query = 'SELECT * FROM saml_idp_settings WHERE idp_id = ' . $this->db->quote($this->getIdpId(), 'integer');
117  $res = $this->db->query($query);
118  while ($record = $this->db->fetchAssoc($res)) {
119  $this->bindDbRecord($record);
120  return;
121  }
122 
123  throw new \ilException('Could not find idp');
124  }
bindDbRecord(array $record)
foreach($_POST as $key=> $value) $res
$query
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAccountMigrationStatus()

ilSamlIdp::setAccountMigrationStatus (   $status)
Parameters
boolean$status

Definition at line 456 of file class.ilSamlIdp.php.

Referenced by bindDbRecord().

457  {
458  $this->account_migration_status = (int) $status;
459  }
+ Here is the caller graph for this function:

◆ setActive()

ilSamlIdp::setActive (   $is_active)
Parameters
boolean$is_active

Definition at line 344 of file class.ilSamlIdp.php.

References $is_active.

Referenced by bindDbRecord().

345  {
346  $this->is_active = (bool) $is_active;
347  }
+ Here is the caller graph for this function:

◆ setDefaultRoleId()

ilSamlIdp::setDefaultRoleId (   $role_id)
Parameters
int$role_id

Definition at line 392 of file class.ilSamlIdp.php.

Referenced by bindDbRecord().

393  {
394  $this->default_role_id = (int) $role_id;
395  }
+ Here is the caller graph for this function:

◆ setEntityId()

ilSamlIdp::setEntityId (   $entity_id)
Parameters
string$entity_id

Definition at line 328 of file class.ilSamlIdp.php.

References $entity_id.

Referenced by bindDbRecord().

329  {
330  $this->entity_id = $entity_id;
331  }
+ Here is the caller graph for this function:

◆ setIdpId()

ilSamlIdp::setIdpId (   $idp_id)
Parameters
int$idp_id

Definition at line 360 of file class.ilSamlIdp.php.

References $idp_id.

Referenced by bindDbRecord(), and persist().

361  {
362  $this->idp_id = (int) $idp_id;
363  }
+ Here is the caller graph for this function:

◆ setLocalLocalAuthenticationStatus()

ilSamlIdp::setLocalLocalAuthenticationStatus (   $status)
Parameters
$statusboolean

Definition at line 376 of file class.ilSamlIdp.php.

Referenced by bindDbRecord().

377  {
378  $this->allow_local_auth = (bool) $status;
379  }
+ Here is the caller graph for this function:

◆ setLoginClaim()

ilSamlIdp::setLoginClaim (   $claim)
Parameters
$claimstring

Definition at line 416 of file class.ilSamlIdp.php.

Referenced by bindDbRecord().

417  {
418  $this->login_claim = $claim;
419  }
+ Here is the caller graph for this function:

◆ setSynchronizationStatus()

ilSamlIdp::setSynchronizationStatus (   $sync)
Parameters
boolean$sync

Definition at line 440 of file class.ilSamlIdp.php.

References $sync.

Referenced by bindDbRecord().

441  {
442  $this->sync_status = (bool) $sync;
443  }
$sync
+ Here is the caller graph for this function:

◆ setUidClaim()

ilSamlIdp::setUidClaim (   $claim)
Parameters
$claimstring

Definition at line 400 of file class.ilSamlIdp.php.

Referenced by bindDbRecord().

401  {
402  $this->uid_claim = $claim;
403  }
+ Here is the caller graph for this function:

◆ toArray()

ilSamlIdp::toArray ( )
Returns
array

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

References allowLocalAuthentication(), array, getDefaultRoleId(), getEntityId(), getIdpId(), getLoginClaim(), getUidClaim(), isAccountMigrationEnabled(), isActive(), and isSynchronizationEnabled().

175  {
176  return array(
177  'idp_id' => $this->getIdpId(),
178  'is_active' => $this->isActive(),
179  'default_role_id' => $this->getDefaultRoleId(),
180  'uid_claim' => $this->getUidClaim(),
181  'login_claim' => $this->getLoginClaim(),
182  'sync_status' => $this->isSynchronizationEnabled(),
183  'account_migr_status' => $this->isAccountMigrationEnabled(),
184  'allow_local_auth' => $this->allowLocalAuthentication(),
185  'entity_id' => $this->getEntityId()
186  );
187  }
Create styles array
The data for the language used.
isAccountMigrationEnabled()
allowLocalAuthentication()
isSynchronizationEnabled()
+ Here is the call graph for this function:

Field Documentation

◆ $account_migration_status

ilSamlIdp::$account_migration_status = false
protected

Definition at line 63 of file class.ilSamlIdp.php.

Referenced by isAccountMigrationEnabled().

◆ $allow_local_auth

ilSamlIdp::$allow_local_auth = false
protected

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

Referenced by allowLocalAuthentication().

◆ $db

ilSamlIdp::$db
protected

Definition at line 13 of file class.ilSamlIdp.php.

◆ $default_role_id

ilSamlIdp::$default_role_id = false
protected

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

Referenced by getDefaultRoleId().

◆ $entity_id

ilSamlIdp::$entity_id = ''
protected

Definition at line 58 of file class.ilSamlIdp.php.

Referenced by getEntityId(), and setEntityId().

◆ $idp_as_data

ilSamlIdp::$idp_as_data = array()
staticprotected

Definition at line 68 of file class.ilSamlIdp.php.

◆ $idp_id

ilSamlIdp::$idp_id
protected

Definition at line 23 of file class.ilSamlIdp.php.

Referenced by getIdpId(), and setIdpId().

◆ $instances

ilSamlIdp::$instances = array()
staticprivate

Definition at line 18 of file class.ilSamlIdp.php.

◆ $is_active

ilSamlIdp::$is_active = false
protected

Definition at line 28 of file class.ilSamlIdp.php.

Referenced by isActive(), and setActive().

◆ $login_claim

ilSamlIdp::$login_claim = ''
protected

Definition at line 48 of file class.ilSamlIdp.php.

Referenced by getLoginClaim().

◆ $sync_status

ilSamlIdp::$sync_status = false
protected

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

Referenced by isSynchronizationEnabled().

◆ $uid_claim

ilSamlIdp::$uid_claim = ''
protected

Definition at line 43 of file class.ilSamlIdp.php.

Referenced by getUidClaim().


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