19 declare(strict_types=1);
49 $this->db =
$GLOBALS[
'DIC']->database();
51 if ($this->idp_id > 0) {
58 $idps = self::getActiveIdpList();
60 return current($idps);
68 if (!isset(self::$instances[$a_idp_id]) || !(self::$instances[$a_idp_id] instanceof
self)) {
69 self::$instances[$a_idp_id] =
new self($a_idp_id);
72 return self::$instances[$a_idp_id];
75 private function read(): void
77 $query =
'SELECT * FROM saml_idp_settings WHERE idp_id = ' . $this->db->quote($this->idp_id,
ilDBConstants::T_INTEGER);
78 $res = $this->db->query($query);
79 while ($record = $this->db->fetchAssoc(
$res)) {
89 if ($this->idp_id === 0) {
90 $this->
setIdpId($this->db->nextId(
'saml_idp_settings'));
115 public function delete():
void 120 $this->db->manipulateF(
121 'UPDATE usr_data SET auth_mode = %s WHERE auth_mode = %s',
126 $this->db->manipulate(
'DELETE FROM saml_idp_settings WHERE idp_id = ' . $this->db->quote(
138 self::PROP_IDP_ID => $this->idp_id,
155 $this->
setIdpId((
int) $record[self::PROP_IDP_ID]);
156 $this->
setActive((
bool) $record[self::PROP_IS_ACTIVE]);
158 $this->
setUidClaim((
string) $record[self::PROP_UID_CLAIM]);
159 $this->
setLoginClaim((
string) $record[self::PROP_LOGIN_CLAIM]);
163 $this->
setEntityId((
string) $record[self::PROP_ENTITY_ID]);
168 $data = $form->getData();
177 $sync_status_data =
$data[self::PROP_SYNC_STATUS];
178 $this->
setLoginClaim($sync_status_data[self::PROP_LOGIN_CLAIM]);
179 $this->
setDefaultRoleId((
int) $sync_status_data[self::PROP_DEFAULT_ROLE_ID]);
186 if (
'' === $a_auth_mode) {
190 $auth_arr = explode(
'_', $a_auth_mode);
192 count($auth_arr) === 2 &&
194 is_string($auth_arr[1]) && $auth_arr[1] !==
'' 200 if (self::isAuthModeSaml($a_auth_mode)) {
201 $auth_arr = explode(
'_', $a_auth_mode);
202 return (
int) $auth_arr[1];
210 foreach (self::getAllIdps() as $idp) {
211 if ($idp->isActive() && $idp->getEntityId() === $entityId) {
212 return $idp->getIdpId();
225 foreach (self::getAllIdps() as $idp) {
226 if ($idp->isActive()) {
241 $res = $DIC->database()->query(
'SELECT * FROM saml_idp_settings');
244 while ($row = $DIC->database()->fetchAssoc(
$res)) {
246 $idp->bindDbRecord($row);
256 $auth_arr = explode(
'_', $a_auth_key);
257 if (count($auth_arr) > 1) {
258 return 'saml_' . $auth_arr[1];
266 $auth_arr = explode(
'_', $a_auth_mode);
267 if (count($auth_arr) > 1) {
296 return $this->idp_id;
301 $this->idp_id = $idp_id;
311 $this->allow_local_auth = $status;
321 $this->default_role_id = $role_id;
326 $this->uid_claim = $claim;
336 $this->login_claim = $claim;
351 $this->sync_status = $sync;
361 $this->account_migration_status = $status;
bindDbRecord(array $record)
static isAuthModeSaml(string $a_auth_mode)
const string PROP_UID_CLAIM
setActive(bool $is_active)
bindForm(StandardForm $form)
const string PROP_DEFAULT_ROLE_ID
setDefaultRoleId(int $role_id)
readonly ilDBInterface $db
static getInstanceByIdpId(int $a_idp_id)
static getIdpIdByAuthMode(string $a_auth_mode)
const string PROP_IS_ACTIVE
setEntityId(string $entity_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setLocalLocalAuthenticationStatus(bool $status)
setUidClaim(string $claim)
setLoginClaim(string $claim)
__construct(protected int $idp_id=0)
const string PROP_ENTITY_ID
static getKeyByAuthMode(string $a_auth_mode)
const string PROP_ACCOUNT_MIGR_STATUS
const string PROP_ALLOW_LOCAL_AUTH
setAccountMigrationStatus(bool $status)
static getAuthModeByKey(string $a_auth_key)
isAccountMigrationEnabled()
static geIdpIdByEntityId(string $entityId)
const string PROP_LOGIN_CLAIM
allowLocalAuthentication()
static getActiveIdpList()
isSynchronizationEnabled()
setSynchronizationStatus(bool $sync)
bool $account_migration_status
static getFirstActiveIdp()
const string PROP_SYNC_STATUS