19 declare(strict_types=1);
51 $this->db =
$GLOBALS[
'DIC']->database();
53 if ($this->idp_id > 0) {
60 $idps = self::getActiveIdpList();
62 return current($idps);
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);
74 return self::$instances[$a_idp_id];
77 private function read(): void
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)) {
91 if ($this->idp_id === 0) {
92 $this->
setIdpId($this->db->nextId(
'saml_idp_settings'));
117 public function delete():
void 122 $this->db->manipulateF(
123 'UPDATE usr_data SET auth_mode = %s WHERE auth_mode = %s',
128 $this->db->manipulate(
'DELETE FROM saml_idp_settings WHERE idp_id = ' . $this->db->quote(
140 self::PROP_IDP_ID => $this->idp_id,
157 $this->
setIdpId((
int) $record[self::PROP_IDP_ID]);
158 $this->
setActive((
bool) $record[self::PROP_IS_ACTIVE]);
160 $this->
setUidClaim((
string) $record[self::PROP_UID_CLAIM]);
161 $this->
setLoginClaim((
string) $record[self::PROP_LOGIN_CLAIM]);
165 $this->
setEntityId((
string) $record[self::PROP_ENTITY_ID]);
184 if (
'' === $a_auth_mode) {
188 $auth_arr = explode(
'_', $a_auth_mode);
190 count($auth_arr) === 2 &&
192 is_string($auth_arr[1]) && $auth_arr[1] !==
'' 198 if (self::isAuthModeSaml($a_auth_mode)) {
199 $auth_arr = explode(
'_', $a_auth_mode);
200 return (
int) $auth_arr[1];
208 foreach (self::getAllIdps() as $idp) {
209 if ($idp->isActive() && $idp->getEntityId() === $entityId) {
210 return $idp->getIdpId();
223 foreach (self::getAllIdps() as $idp) {
224 if ($idp->isActive()) {
239 $res = $DIC->database()->query(
'SELECT * FROM saml_idp_settings');
242 while ($row = $DIC->database()->fetchAssoc(
$res)) {
244 $idp->bindDbRecord($row);
254 $auth_arr = explode(
'_', $a_auth_key);
255 if (count($auth_arr) > 1) {
256 return 'saml_' . $auth_arr[1];
264 $auth_arr = explode(
'_', $a_auth_mode);
265 if (count($auth_arr) > 1) {
294 return $this->idp_id;
299 $this->idp_id = $idp_id;
309 $this->allow_local_auth = $status;
319 $this->default_role_id = $role_id;
324 $this->uid_claim = $claim;
334 $this->login_claim = $claim;
349 $this->sync_status = $sync;
359 $this->account_migration_status = $status;
bindDbRecord(array $record)
static isAuthModeSaml(string $a_auth_mode)
setActive(bool $is_active)
const PROP_ACCOUNT_MIGR_STATUS
setDefaultRoleId(int $role_id)
readonly ilDBInterface $db
static getInstanceByIdpId(int $a_idp_id)
static getIdpIdByAuthMode(string $a_auth_mode)
setEntityId(string $entity_id)
setLocalLocalAuthenticationStatus(bool $status)
setUidClaim(string $claim)
Class ilExternalAuthUserAttributeMapping.
setLoginClaim(string $claim)
const PROP_ALLOW_LOCAL_AUTH
__construct(protected int $idp_id=0)
static getKeyByAuthMode(string $a_auth_mode)
setAccountMigrationStatus(bool $status)
const PROP_DEFAULT_ROLE_ID
static getAuthModeByKey(string $a_auth_key)
isAccountMigrationEnabled()
static geIdpIdByEntityId(string $entityId)
allowLocalAuthentication()
static getActiveIdpList()
isSynchronizationEnabled()
setSynchronizationStatus(bool $sync)
bool $account_migration_status
static getFirstActiveIdp()