ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilSamlIdp Class Reference

Class ilSamlIdp. More...

+ Collaboration diagram for ilSamlIdp:

Public Member Functions

 __construct (protected int $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)
 

Private Member Functions

 read ()
 

Private Attributes

const PROP_IDP_ID = 'idp_id'
 
const PROP_IS_ACTIVE = 'is_active'
 
const PROP_DEFAULT_ROLE_ID = 'default_role_id'
 
const PROP_UID_CLAIM = 'uid_claim'
 
const PROP_LOGIN_CLAIM = 'login_claim'
 
const PROP_ENTITY_ID = 'entity_id'
 
const PROP_SYNC_STATUS = 'sync_status'
 
const PROP_ALLOW_LOCAL_AUTH = 'allow_local_auth'
 
const PROP_ACCOUNT_MIGR_STATUS = 'account_migr_status'
 
readonly ilDBInterface $db
 
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 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 ( protected int  $idp_id = 0)

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

References $GLOBALS, and read().

50  {
51  $this->db = $GLOBALS['DIC']->database();
52 
53  if ($this->idp_id > 0) {
54  $this->read();
55  }
56  }
$GLOBALS["DIC"]
Definition: wac.php:30
+ Here is the call graph for this function:

Member Function Documentation

◆ allowLocalAuthentication()

ilSamlIdp::allowLocalAuthentication ( )

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

References $allow_local_auth.

302  : bool
303  {
305  }
bool $allow_local_auth

◆ bindDbRecord()

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

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

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

Referenced by read().

155  : void
156  {
157  $this->setIdpId((int) $record[self::PROP_IDP_ID]);
158  $this->setActive((bool) $record[self::PROP_IS_ACTIVE]);
159  $this->setDefaultRoleId((int) $record[self::PROP_DEFAULT_ROLE_ID]);
160  $this->setUidClaim((string) $record[self::PROP_UID_CLAIM]);
161  $this->setLoginClaim((string) $record[self::PROP_LOGIN_CLAIM]);
162  $this->setSynchronizationStatus((bool) $record[self::PROP_SYNC_STATUS]);
163  $this->setAccountMigrationStatus((bool) $record[self::PROP_ACCOUNT_MIGR_STATUS]);
164  $this->setLocalLocalAuthenticationStatus((bool) $record[self::PROP_ALLOW_LOCAL_AUTH]);
165  $this->setEntityId((string) $record[self::PROP_ENTITY_ID]);
166  }
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 117 of file class.ilSamlIdp.php.

References ilAuthUtils\AUTH_SAML, ilDBConstants\T_INTEGER, and ilDBConstants\T_TEXT.

117  : void
118  {
119  $mapping = new ilExternalAuthUserAttributeMapping('saml', $this->idp_id);
120  $mapping->delete();
121 
122  $this->db->manipulateF(
123  'UPDATE usr_data SET auth_mode = %s WHERE auth_mode = %s',
125  ['default', ilAuthUtils::AUTH_SAML . '_' . $this->idp_id]
126  );
127 
128  $this->db->manipulate('DELETE FROM saml_idp_settings WHERE idp_id = ' . $this->db->quote(
129  $this->idp_id,
131  ));
132  }
Class ilExternalAuthUserAttributeMapping.

◆ geIdpIdByEntityId()

static ilSamlIdp::geIdpIdByEntityId ( string  $entityId)
static

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

Referenced by ilStartUpGUI\doSamlAuthentication().

206  : int
207  {
208  foreach (self::getAllIdps() as $idp) {
209  if ($idp->isActive() && $idp->getEntityId() === $entityId) {
210  return $idp->getIdpId();
211  }
212  }
213 
214  return 0;
215  }
+ Here is the caller graph for this function:

◆ getActiveIdpList()

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

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

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

220  : array
221  {
222  $idps = [];
223  foreach (self::getAllIdps() as $idp) {
224  if ($idp->isActive()) {
225  $idps[] = $idp;
226  }
227  }
228 
229  return $idps;
230  }
+ Here is the caller graph for this function:

◆ getAllIdps()

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

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

References $DIC, and $res.

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

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

◆ getAuthModeByKey()

static ilSamlIdp::getAuthModeByKey ( string  $a_auth_key)
static

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

Referenced by ilAuthUtils\_getAuthModeName().

252  : string
253  {
254  $auth_arr = explode('_', $a_auth_key);
255  if (count($auth_arr) > 1) {
256  return 'saml_' . $auth_arr[1];
257  }
258 
259  return 'saml';
260  }
+ Here is the caller graph for this function:

◆ getDefaultRoleId()

ilSamlIdp::getDefaultRoleId ( )

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

References $default_role_id.

312  : int
313  {
314  return $this->default_role_id;
315  }
int $default_role_id

◆ getEntityId()

ilSamlIdp::getEntityId ( )

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

References $entity_id.

Referenced by ilSamlIdpTableGUI\getRecords().

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

◆ getFirstActiveIdp()

static ilSamlIdp::getFirstActiveIdp ( )
static

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

Referenced by ilAuthProviderSaml\__construct().

58  : self
59  {
60  $idps = self::getActiveIdpList();
61  if ($idps !== []) {
62  return current($idps);
63  }
64 
65  throw new ilSamlException('No active SAML IDP found');
66  }
Class ilSamlException.
+ Here is the caller graph for this function:

◆ getIdpId()

ilSamlIdp::getIdpId ( )

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

Referenced by ilSamlSettingsGUI\populateWithMetadata(), ilSamlSettingsGUI\saveNewIdp(), and ilSamlSettingsGUI\storeMetadata().

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

◆ getIdpIdByAuthMode()

static ilSamlIdp::getIdpIdByAuthMode ( string  $a_auth_mode)
static

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

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

196  : ?int
197  {
198  if (self::isAuthModeSaml($a_auth_mode)) {
199  $auth_arr = explode('_', $a_auth_mode);
200  return (int) $auth_arr[1];
201  }
202 
203  return null;
204  }
+ Here is the caller graph for this function:

◆ getInstanceByIdpId()

static ilSamlIdp::getInstanceByIdpId ( int  $a_idp_id)
static

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

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

68  : self
69  {
70  if (!isset(self::$instances[$a_idp_id]) || !(self::$instances[$a_idp_id] instanceof self)) {
71  self::$instances[$a_idp_id] = new self($a_idp_id);
72  }
73 
74  return self::$instances[$a_idp_id];
75  }
+ Here is the caller graph for this function:

◆ getKeyByAuthMode()

static ilSamlIdp::getKeyByAuthMode ( string  $a_auth_mode)
static

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

References ilAuthUtils\AUTH_SAML.

Referenced by ilAuthUtils\_getAuthMode().

262  : string
263  {
264  $auth_arr = explode('_', $a_auth_mode);
265  if (count($auth_arr) > 1) {
266  return ilAuthUtils::AUTH_SAML . '_' . $auth_arr[1];
267  }
268 
269  return (string) ilAuthUtils::AUTH_SAML;
270  }
+ Here is the caller graph for this function:

◆ getLoginClaim()

ilSamlIdp::getLoginClaim ( )

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

References $login_claim.

337  : string
338  {
339  return $this->login_claim;
340  }
string $login_claim

◆ getUidClaim()

ilSamlIdp::getUidClaim ( )

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

References $uid_claim.

327  : string
328  {
329  return $this->uid_claim;
330  }
string $uid_claim

◆ isAccountMigrationEnabled()

ilSamlIdp::isAccountMigrationEnabled ( )

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

References $account_migration_status.

352  : bool
353  {
355  }
bool $account_migration_status

◆ isActive()

ilSamlIdp::isActive ( )

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

References $is_active.

Referenced by ilSamlIdpTableGUI\getRecords().

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

◆ isAuthModeSaml()

static ilSamlIdp::isAuthModeSaml ( string  $a_auth_mode)
static

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

References ilAuthUtils\AUTH_SAML.

Referenced by ilObjAuthSettingsGUI\authSettingsObject().

182  : bool
183  {
184  if ('' === $a_auth_mode) {
185  return false;
186  }
187 
188  $auth_arr = explode('_', $a_auth_mode);
189  return (
190  count($auth_arr) === 2 &&
191  (int) $auth_arr[0] === ilAuthUtils::AUTH_SAML &&
192  is_string($auth_arr[1]) && $auth_arr[1] !== ''
193  );
194  }
+ Here is the caller graph for this function:

◆ isSynchronizationEnabled()

ilSamlIdp::isSynchronizationEnabled ( )

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

References $sync_status.

342  : bool
343  {
344  return $this->sync_status;
345  }

◆ persist()

ilSamlIdp::persist ( )

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

References setIdpId(), ilDBConstants\T_INTEGER, and ilDBConstants\T_TEXT.

Referenced by ilSamlSettingsGUI\saveNewIdp().

89  : void
90  {
91  if ($this->idp_id === 0) {
92  $this->setIdpId($this->db->nextId('saml_idp_settings'));
93  }
94 
95  $this->db->replace(
96  'saml_idp_settings',
97  [
98  self::PROP_IDP_ID => [ilDBConstants::T_INTEGER, $this->idp_id]
99  ],
100  [
101  self::PROP_IS_ACTIVE => [ilDBConstants::T_INTEGER, (int) $this->is_active],
102  self::PROP_DEFAULT_ROLE_ID => [ilDBConstants::T_INTEGER, $this->default_role_id],
103  self::PROP_UID_CLAIM => [ilDBConstants::T_TEXT, $this->uid_claim],
104  self::PROP_LOGIN_CLAIM => [ilDBConstants::T_TEXT, $this->login_claim],
105  self::PROP_ENTITY_ID => [ilDBConstants::T_TEXT, $this->entity_id],
106  self::PROP_SYNC_STATUS => [ilDBConstants::T_INTEGER, (int) $this->sync_status],
107  self::PROP_ALLOW_LOCAL_AUTH => [ilDBConstants::T_INTEGER, (int) $this->allow_local_auth],
108  self::PROP_ACCOUNT_MIGR_STATUS => [ilDBConstants::T_INTEGER, (int) $this->account_migration_status]
109  ]
110  );
111  }
setIdpId(int $idp_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilSamlIdp::read ( )
private

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

References $res, bindDbRecord(), and ilDBConstants\T_INTEGER.

Referenced by __construct().

77  : void
78  {
79  $query = 'SELECT * FROM saml_idp_settings WHERE idp_id = ' . $this->db->quote($this->idp_id, ilDBConstants::T_INTEGER);
80  $res = $this->db->query($query);
81  while ($record = $this->db->fetchAssoc($res)) {
82  $this->bindDbRecord($record);
83  return;
84  }
85 
86  throw new ilException('Could not find idp');
87  }
bindDbRecord(array $record)
$res
Definition: ltiservices.php:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAccountMigrationStatus()

ilSamlIdp::setAccountMigrationStatus ( bool  $status)

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

Referenced by bindDbRecord().

357  : void
358  {
359  $this->account_migration_status = $status;
360  }
+ Here is the caller graph for this function:

◆ setActive()

ilSamlIdp::setActive ( bool  $is_active)

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

References $is_active.

Referenced by bindDbRecord().

287  : void
288  {
289  $this->is_active = $is_active;
290  }
+ Here is the caller graph for this function:

◆ setDefaultRoleId()

ilSamlIdp::setDefaultRoleId ( int  $role_id)

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

Referenced by bindDbRecord().

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

◆ setEntityId()

ilSamlIdp::setEntityId ( string  $entity_id)

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

References $entity_id.

Referenced by bindDbRecord().

277  : void
278  {
279  $this->entity_id = $entity_id;
280  }
string $entity_id
+ Here is the caller graph for this function:

◆ setIdpId()

ilSamlIdp::setIdpId ( int  $idp_id)

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

Referenced by bindDbRecord(), and persist().

297  : void
298  {
299  $this->idp_id = $idp_id;
300  }
+ Here is the caller graph for this function:

◆ setLocalLocalAuthenticationStatus()

ilSamlIdp::setLocalLocalAuthenticationStatus ( bool  $status)

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

Referenced by bindDbRecord().

307  : void
308  {
309  $this->allow_local_auth = $status;
310  }
+ Here is the caller graph for this function:

◆ setLoginClaim()

ilSamlIdp::setLoginClaim ( string  $claim)

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

Referenced by bindDbRecord().

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

◆ setSynchronizationStatus()

ilSamlIdp::setSynchronizationStatus ( bool  $sync)

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

Referenced by bindDbRecord().

347  : void
348  {
349  $this->sync_status = $sync;
350  }
+ Here is the caller graph for this function:

◆ setUidClaim()

ilSamlIdp::setUidClaim ( string  $claim)

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

Referenced by bindDbRecord().

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

◆ toArray()

ilSamlIdp::toArray ( )
Returns
array{idp_id: int, is_active: bool, default_role_id: int, uid_claim: string, login_claim: string, sync_status: bool, account_migr_status: bool, allow_local_auth: bool, entity_id: string}

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

References $account_migration_status, $allow_local_auth, $default_role_id, $entity_id, $is_active, $login_claim, $sync_status, and $uid_claim.

137  : array
138  {
139  return [
140  self::PROP_IDP_ID => $this->idp_id,
141  self::PROP_IS_ACTIVE => $this->is_active,
142  self::PROP_DEFAULT_ROLE_ID => $this->default_role_id,
143  self::PROP_UID_CLAIM => $this->uid_claim,
144  self::PROP_LOGIN_CLAIM => $this->login_claim,
145  self::PROP_SYNC_STATUS => $this->sync_status,
146  self::PROP_ACCOUNT_MIGR_STATUS => $this->account_migration_status,
147  self::PROP_ALLOW_LOCAL_AUTH => $this->allow_local_auth,
148  self::PROP_ENTITY_ID => $this->entity_id
149  ];
150  }
int $default_role_id
string $login_claim
string $uid_claim
string $entity_id
bool $allow_local_auth
bool $account_migration_status

Field Documentation

◆ $account_migration_status

bool ilSamlIdp::$account_migration_status = false
private

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

Referenced by isAccountMigrationEnabled(), and toArray().

◆ $allow_local_auth

bool ilSamlIdp::$allow_local_auth = false
private

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

Referenced by allowLocalAuthentication(), and toArray().

◆ $db

readonly ilDBInterface ilSamlIdp::$db
private

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

◆ $default_role_id

int ilSamlIdp::$default_role_id = 0
private

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

Referenced by getDefaultRoleId(), and toArray().

◆ $entity_id

string ilSamlIdp::$entity_id = ''
private

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

Referenced by getEntityId(), setEntityId(), and toArray().

◆ $instances

array ilSamlIdp::$instances = []
staticprivate

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

◆ $is_active

bool ilSamlIdp::$is_active = false
private

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

Referenced by isActive(), setActive(), and toArray().

◆ $login_claim

string ilSamlIdp::$login_claim = ''
private

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

Referenced by getLoginClaim(), and toArray().

◆ $sync_status

bool ilSamlIdp::$sync_status = false
private

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

Referenced by isSynchronizationEnabled(), and toArray().

◆ $uid_claim

string ilSamlIdp::$uid_claim = ''
private

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

Referenced by getUidClaim(), and toArray().

◆ PROP_ACCOUNT_MIGR_STATUS

const ilSamlIdp::PROP_ACCOUNT_MIGR_STATUS = 'account_migr_status'
private

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

◆ PROP_ALLOW_LOCAL_AUTH

const ilSamlIdp::PROP_ALLOW_LOCAL_AUTH = 'allow_local_auth'
private

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

◆ PROP_DEFAULT_ROLE_ID

const ilSamlIdp::PROP_DEFAULT_ROLE_ID = 'default_role_id'
private

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

◆ PROP_ENTITY_ID

const ilSamlIdp::PROP_ENTITY_ID = 'entity_id'
private

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

◆ PROP_IDP_ID

const ilSamlIdp::PROP_IDP_ID = 'idp_id'
private

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

◆ PROP_IS_ACTIVE

const ilSamlIdp::PROP_IS_ACTIVE = 'is_active'
private

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

◆ PROP_LOGIN_CLAIM

const ilSamlIdp::PROP_LOGIN_CLAIM = 'login_claim'
private

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

◆ PROP_SYNC_STATUS

const ilSamlIdp::PROP_SYNC_STATUS = 'sync_status'
private

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

◆ PROP_UID_CLAIM

const ilSamlIdp::PROP_UID_CLAIM = 'uid_claim'
private

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


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