ILIAS  release_8 Revision v8.23
ilSamlIdp Class Reference

Class ilSamlIdp. More...

+ Collaboration diagram for ilSamlIdp:

Public Member Functions

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

Static Public Member Functions

static getFirstActiveIdp ()
 
static getInstanceByIdpId (int $a_idp_id)
 
static isAuthModeSaml (string $a_auth_mode)
 
static getIdpIdByAuthMode (string $a_auth_mode)
 
static geIdpIdByEntityId (string $entityId)
 
static getActiveIdpList ()
 
static getAllIdps ()
 
static getAuthModeByKey (string $a_auth_key)
 
static getKeyByAuthMode (string $a_auth_mode)
 

Protected Attributes

ilDBInterface $db
 
int $idp_id
 
bool $is_active = false
 
bool $allow_local_auth = false
 
int $default_role_id = 0
 
string $uid_claim = ''
 
string $login_claim = ''
 
bool $sync_status = false
 
string $entity_id = ''
 
bool $account_migration_status = false
 

Static Protected Attributes

static array $idp_as_data = []
 

Private Member Functions

 read ()
 

Static Private Attributes

static array $instances = []
 

Detailed Description

Class ilSamlIdp.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilSamlIdp::__construct ( int  $a_idp_id = 0)

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

References $GLOBALS, and read().

43  {
44  $this->db = $GLOBALS['DIC']->database();
45  $this->idp_id = $a_idp_id;
46 
47  if ($this->idp_id > 0) {
48  $this->read();
49  }
50  }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
+ Here is the call graph for this function:

Member Function Documentation

◆ allowLocalAuthentication()

ilSamlIdp::allowLocalAuthentication ( )

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

References $allow_local_auth.

Referenced by persist(), and toArray().

297  : bool
298  {
300  }
bool $allow_local_auth
+ Here is the caller graph for this function:

◆ bindDbRecord()

ilSamlIdp::bindDbRecord ( array  $record)
Parameters
array<string,mixed>$record

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

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

Referenced by read().

149  : void
150  {
151  $this->setIdpId((int) $record['idp_id']);
152  $this->setActive((bool) $record['is_active']);
153  $this->setDefaultRoleId((int) $record['default_role_id']);
154  $this->setUidClaim((string) $record['uid_claim']);
155  $this->setLoginClaim((string) $record['login_claim']);
156  $this->setSynchronizationStatus((bool) $record['sync_status']);
157  $this->setAccountMigrationStatus((bool) $record['account_migr_status']);
158  $this->setLocalLocalAuthenticationStatus((bool) $record['allow_local_auth']);
159  $this->setEntityId((string) $record['entity_id']);
160  }
setActive(bool $is_active)
setDefaultRoleId(int $role_id)
setEntityId(string $entity_id)
setLocalLocalAuthenticationStatus(bool $status)
setUidClaim(string $claim)
setLoginClaim(string $claim)
setAccountMigrationStatus(bool $status)
setIdpId(int $idp_id)
setSynchronizationStatus(bool $sync)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilSamlIdp::delete ( )

Deletes an idp with all relevant mapping rules.

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

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

References ilAuthUtils\AUTH_SAML, and getIdpId().

111  : void
112  {
113  $mapping = new ilExternalAuthUserAttributeMapping('saml', $this->getIdpId());
114  $mapping->delete();
115 
116  $this->db->manipulateF(
117  'UPDATE usr_data SET auth_mode = %s WHERE auth_mode = %s',
118  array('text', 'text'),
119  array('default', ilAuthUtils::AUTH_SAML . '_' . $this->getIdpId())
120  );
121 
122  $this->db->manipulate('DELETE FROM saml_idp_settings WHERE idp_id = ' . $this->db->quote(
123  $this->getIdpId(),
124  'integer'
125  ));
126  }
Class ilExternalAuthUserAttributeMapping.
+ Here is the call graph for this function:

◆ geIdpIdByEntityId()

static ilSamlIdp::geIdpIdByEntityId ( string  $entityId)
static

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

References $entityId.

Referenced by ilStartUpGUI\doSamlAuthentication().

200  : int
201  {
202  foreach (self::getAllIdps() as $idp) {
203  if ($idp->isActive() && $idp->getEntityId() === $entityId) {
204  return $idp->getIdpId();
205  }
206  }
207 
208  return 0;
209  }
if($source===null) if(!($source instanceof SP)) $entityId
Definition: metadata.php:105
+ Here is the caller graph for this function:

◆ getActiveIdpList()

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

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

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

214  : array
215  {
216  $idps = [];
217 
218  foreach (self::getAllIdps() as $idp) {
219  if ($idp->isActive()) {
220  $idps[] = $idp;
221  }
222  }
223 
224  return $idps;
225  }
+ Here is the caller graph for this function:

◆ getAllIdps()

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

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

References $DIC, and $res.

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

230  : array
231  {
232  global $DIC;
233 
234  $res = $DIC->database()->query('SELECT * FROM saml_idp_settings');
235 
236  $idps = [];
237  while ($row = $DIC->database()->fetchAssoc($res)) {
238  $idp = new self();
239  $idp->bindDbRecord($row);
240 
241  $idps[] = $idp;
242  }
243 
244  return $idps;
245  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ getAuthModeByKey()

static ilSamlIdp::getAuthModeByKey ( string  $a_auth_key)
static

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

Referenced by ilAuthUtils\_getAuthModeName().

247  : string
248  {
249  $auth_arr = explode('_', $a_auth_key);
250  if (count((array) $auth_arr) > 1) {
251  return 'saml_' . $auth_arr[1];
252  }
253 
254  return 'saml';
255  }
+ Here is the caller graph for this function:

◆ getDefaultRoleId()

ilSamlIdp::getDefaultRoleId ( )

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

References $default_role_id.

Referenced by persist(), and toArray().

307  : int
308  {
309  return $this->default_role_id;
310  }
int $default_role_id
+ Here is the caller graph for this function:

◆ getEntityId()

ilSamlIdp::getEntityId ( )

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

References $entity_id.

Referenced by persist(), and toArray().

267  : string
268  {
269  return $this->entity_id;
270  }
string $entity_id
+ Here is the caller graph for this function:

◆ getFirstActiveIdp()

static ilSamlIdp::getFirstActiveIdp ( )
static

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

Referenced by ilAuthProviderSaml\__construct().

52  : self
53  {
54  $idps = self::getActiveIdpList();
55  if (count($idps) > 0) {
56  return current($idps);
57  }
58 
59  throw new ilSamlException('No active SAML IDP found');
60  }
Class ilSamlException.
+ Here is the caller graph for this function:

◆ getIdpId()

ilSamlIdp::getIdpId ( )

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

References $idp_id.

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

287  : int
288  {
289  return $this->idp_id;
290  }
+ Here is the caller graph for this function:

◆ getIdpIdByAuthMode()

static ilSamlIdp::getIdpIdByAuthMode ( string  $a_auth_mode)
static

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

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

190  : ?int
191  {
192  if (self::isAuthModeSaml($a_auth_mode)) {
193  $auth_arr = explode('_', $a_auth_mode);
194  return (int) $auth_arr[1];
195  }
196 
197  return null;
198  }
+ Here is the caller graph for this function:

◆ getInstanceByIdpId()

static ilSamlIdp::getInstanceByIdpId ( int  $a_idp_id)
static

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

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

62  : self
63  {
64  if (!isset(self::$instances[$a_idp_id]) || !(self::$instances[$a_idp_id] instanceof self)) {
65  self::$instances[$a_idp_id] = new self($a_idp_id);
66  }
67 
68  return self::$instances[$a_idp_id];
69  }
+ Here is the caller graph for this function:

◆ getKeyByAuthMode()

static ilSamlIdp::getKeyByAuthMode ( string  $a_auth_mode)
static

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

References ilAuthUtils\AUTH_SAML.

Referenced by ilAuthUtils\_getAuthMode().

257  : string
258  {
259  $auth_arr = explode('_', $a_auth_mode);
260  if (count((array) $auth_arr) > 1) {
261  return ilAuthUtils::AUTH_SAML . '_' . $auth_arr[1];
262  }
263 
264  return (string) ilAuthUtils::AUTH_SAML;
265  }
+ Here is the caller graph for this function:

◆ getLoginClaim()

ilSamlIdp::getLoginClaim ( )

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

References $login_claim.

Referenced by persist(), and toArray().

332  : string
333  {
334  return $this->login_claim;
335  }
string $login_claim
+ Here is the caller graph for this function:

◆ getUidClaim()

ilSamlIdp::getUidClaim ( )

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

References $uid_claim.

Referenced by persist(), and toArray().

322  : string
323  {
324  return $this->uid_claim;
325  }
string $uid_claim
+ Here is the caller graph for this function:

◆ isAccountMigrationEnabled()

ilSamlIdp::isAccountMigrationEnabled ( )

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

References $account_migration_status.

Referenced by persist(), and toArray().

347  : bool
348  {
350  }
bool $account_migration_status
+ Here is the caller graph for this function:

◆ isActive()

ilSamlIdp::isActive ( )

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

References $is_active.

Referenced by persist(), and toArray().

277  : bool
278  {
279  return $this->is_active;
280  }
+ Here is the caller graph for this function:

◆ isAuthModeSaml()

static ilSamlIdp::isAuthModeSaml ( string  $a_auth_mode)
static

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

References ilAuthUtils\AUTH_SAML.

Referenced by ilObjAuthSettingsGUI\authSettingsObject().

176  : bool
177  {
178  if ('' === $a_auth_mode) {
179  return false;
180  }
181 
182  $auth_arr = explode('_', $a_auth_mode);
183  return (
184  count($auth_arr) === 2 &&
185  (int) $auth_arr[0] === ilAuthUtils::AUTH_SAML &&
186  is_string($auth_arr[1]) && $auth_arr[1] !== ''
187  );
188  }
+ Here is the caller graph for this function:

◆ isSynchronizationEnabled()

ilSamlIdp::isSynchronizationEnabled ( )

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

References $sync_status.

Referenced by persist(), and toArray().

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

◆ persist()

ilSamlIdp::persist ( )

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

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

Referenced by ilSamlSettingsGUI\saveNewIdp().

83  : void
84  {
85  if (!$this->getIdpId()) {
86  $this->setIdpId($this->db->nextId('saml_idp_settings'));
87  }
88 
89  $this->db->replace(
90  'saml_idp_settings',
91  [
92  'idp_id' => ['integer', $this->getIdpId()]
93  ],
94  [
95  'is_active' => ['integer', (int) $this->isActive()],
96  'default_role_id' => ['integer', $this->getDefaultRoleId()],
97  'uid_claim' => ['text', $this->getUidClaim()],
98  'login_claim' => ['text', $this->getLoginClaim()],
99  'entity_id' => ['text', $this->getEntityId()],
100  'sync_status' => ['integer', (int) $this->isSynchronizationEnabled()],
101  'allow_local_auth' => ['integer', (int) $this->allowLocalAuthentication()],
102  'account_migr_status' => ['integer', (int) $this->isAccountMigrationEnabled()]
103  ]
104  );
105  }
isAccountMigrationEnabled()
setIdpId(int $idp_id)
allowLocalAuthentication()
isSynchronizationEnabled()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilSamlIdp::read ( )
private

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

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

Referenced by __construct().

71  : void
72  {
73  $query = 'SELECT * FROM saml_idp_settings WHERE idp_id = ' . $this->db->quote($this->getIdpId(), 'integer');
74  $res = $this->db->query($query);
75  while ($record = $this->db->fetchAssoc($res)) {
76  $this->bindDbRecord($record);
77  return;
78  }
79 
80  throw new ilException('Could not find idp');
81  }
bindDbRecord(array $record)
$res
Definition: ltiservices.php:69
$query
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAccountMigrationStatus()

ilSamlIdp::setAccountMigrationStatus ( bool  $status)

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

Referenced by bindDbRecord().

352  : void
353  {
354  $this->account_migration_status = $status;
355  }
+ Here is the caller graph for this function:

◆ setActive()

ilSamlIdp::setActive ( bool  $is_active)

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

References $is_active.

Referenced by bindDbRecord().

282  : void
283  {
284  $this->is_active = $is_active;
285  }
+ Here is the caller graph for this function:

◆ setDefaultRoleId()

ilSamlIdp::setDefaultRoleId ( int  $role_id)

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

Referenced by bindDbRecord().

312  : void
313  {
314  $this->default_role_id = $role_id;
315  }
+ Here is the caller graph for this function:

◆ setEntityId()

ilSamlIdp::setEntityId ( string  $entity_id)

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

References $entity_id.

Referenced by bindDbRecord().

272  : void
273  {
274  $this->entity_id = $entity_id;
275  }
string $entity_id
+ Here is the caller graph for this function:

◆ setIdpId()

ilSamlIdp::setIdpId ( int  $idp_id)

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

References $idp_id.

Referenced by bindDbRecord(), and persist().

292  : void
293  {
294  $this->idp_id = $idp_id;
295  }
+ Here is the caller graph for this function:

◆ setLocalLocalAuthenticationStatus()

ilSamlIdp::setLocalLocalAuthenticationStatus ( bool  $status)

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

Referenced by bindDbRecord().

302  : void
303  {
304  $this->allow_local_auth = $status;
305  }
+ Here is the caller graph for this function:

◆ setLoginClaim()

ilSamlIdp::setLoginClaim ( string  $claim)

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

Referenced by bindDbRecord().

327  : void
328  {
329  $this->login_claim = $claim;
330  }
+ Here is the caller graph for this function:

◆ setSynchronizationStatus()

ilSamlIdp::setSynchronizationStatus ( bool  $sync)

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

Referenced by bindDbRecord().

342  : void
343  {
344  $this->sync_status = $sync;
345  }
+ Here is the caller graph for this function:

◆ setUidClaim()

ilSamlIdp::setUidClaim ( string  $claim)

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

Referenced by bindDbRecord().

317  : void
318  {
319  $this->uid_claim = $claim;
320  }
+ Here is the caller graph for this function:

◆ toArray()

ilSamlIdp::toArray ( )
Returns
array<string, mixed>

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

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

131  : array
132  {
133  return [
134  'idp_id' => $this->getIdpId(),
135  'is_active' => $this->isActive(),
136  'default_role_id' => $this->getDefaultRoleId(),
137  'uid_claim' => $this->getUidClaim(),
138  'login_claim' => $this->getLoginClaim(),
139  'sync_status' => $this->isSynchronizationEnabled(),
140  'account_migr_status' => $this->isAccountMigrationEnabled(),
141  'allow_local_auth' => $this->allowLocalAuthentication(),
142  'entity_id' => $this->getEntityId()
143  ];
144  }
isAccountMigrationEnabled()
allowLocalAuthentication()
isSynchronizationEnabled()
+ Here is the call graph for this function:

Field Documentation

◆ $account_migration_status

bool ilSamlIdp::$account_migration_status = false
protected

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

Referenced by isAccountMigrationEnabled().

◆ $allow_local_auth

bool ilSamlIdp::$allow_local_auth = false
protected

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

Referenced by allowLocalAuthentication().

◆ $db

ilDBInterface ilSamlIdp::$db
protected

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

◆ $default_role_id

int ilSamlIdp::$default_role_id = 0
protected

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

Referenced by getDefaultRoleId().

◆ $entity_id

string ilSamlIdp::$entity_id = ''
protected

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

Referenced by getEntityId(), and setEntityId().

◆ $idp_as_data

array ilSamlIdp::$idp_as_data = []
staticprotected

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

◆ $idp_id

int ilSamlIdp::$idp_id
protected

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

Referenced by getIdpId(), and setIdpId().

◆ $instances

array ilSamlIdp::$instances = []
staticprivate

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

◆ $is_active

bool ilSamlIdp::$is_active = false
protected

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

Referenced by isActive(), and setActive().

◆ $login_claim

string ilSamlIdp::$login_claim = ''
protected

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

Referenced by getLoginClaim().

◆ $sync_status

bool ilSamlIdp::$sync_status = false
protected

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

Referenced by isSynchronizationEnabled().

◆ $uid_claim

string ilSamlIdp::$uid_claim = ''
protected

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

Referenced by getUidClaim().


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