19 declare(strict_types=1);
31 private int $kind = self::TYPE_MANUAL;
39 $this->
logger = $DIC->logger()->auth();
41 $this->commonSettings = $DIC->settings();
54 return $this->kind === self::TYPE_MANUAL;
68 public function setKind(
int $a_kind): void
70 if (!in_array($a_kind, [self::TYPE_MANUAL, self::TYPE_AUTOMATIC],
true)) {
74 $this->kind = $a_kind;
82 if ($a_username ===
'') {
87 foreach ($this->position as $auth_key) {
91 $this->
logger->debug(
'Validating username filter for ' .
$server->getName());
92 if (
$server->getUsernameFilter() !==
'') {
94 $pattern = str_replace(
'*',
'.*?',
$server->getUsernameFilter());
97 $this->
logger->debug(
'Trying pattern to match username:' . $pattern .
' => ' . $a_username);
98 set_error_handler(
static function (
int $severity,
string $message,
string $file,
int $line): never {
99 throw new ErrorException($message, $severity, $severity, $file, $line);
103 if (preg_match($delimiter .
'^' . $pattern .
'$' . $delimiter .
'i', $a_username) === 1) {
104 $this->
logger->debug(
'Filter matches for ' . $a_username);
105 array_unshift($sorted, $auth_key);
110 $this->
logger->warning(
'Error occurred in preg_match Ex.: ' . $ex->getMessage());
112 restore_error_handler();
116 $this->
logger->debug(
'Filter matches not for ' . $a_username .
' <-> ' .
$server->getUsernameFilter());
119 $sorted[] = $auth_key;
127 return count($this->position);
136 $this->position = $a_pos;
146 foreach ($this->position as $auth_mode) {
147 $this->
settings->set((
string) $counter++, (
string) $auth_mode);
154 $this->kind = (
int) $this->
settings->get(
'kind', (
string) self::TYPE_MANUAL);
156 $soap_active = (bool) $this->commonSettings->get(
'soap_auth_active',
'');
158 $apache_settings =
new ilSetting(
'apache_auth');
159 $apache_active = $apache_settings->get(
'apache_enable_auth');
165 if ($auth_mode ===
null) {
170 switch ((
int) $auth_mode) {
172 $this->position[] = (
int) $auth_mode;
177 if ($auth_id ===
null) {
183 $this->position[] = $auth_mode;
189 $this->position[] = (
int) $auth_mode;
194 if ($apache_active) {
195 $this->position[] = (
int) $auth_mode;
201 if ($pl->isAuthActive((
int) $auth_mode)) {
202 $this->position[] = (
int) $auth_mode;
230 foreach ($pl->getAuthIds() as $auth_id) {
231 if ($pl->isAuthActive($auth_id) && !in_array($auth_id, $this->position,
true)) {
232 $this->position[] = $auth_id;
static getInstanceByServerId(int $a_server_id)
Get instance by server id.
ilSetting $commonSettings
getAuthModeSequence(string $a_username='')
static _getActiveServerList()
Get active server list.
const array REGEX_DELIMITERS
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static getServerIdByAuthMode(string $a_auth_mode)
Get auth id by auth mode.
setAuthModeSequence(array $a_pos)
static ilAuthModeDetermination $instance
getCountActiveAuthModes()