19 declare(strict_types=1);
36 private int $kind = self::TYPE_MANUAL;
50 $this->
logger = $DIC->logger()->auth();
52 $this->commonSettings = $DIC->settings();
63 if (self::$instance) {
64 return self::$instance;
74 return $this->kind === self::TYPE_MANUAL;
91 public function setKind(
int $a_kind): void
94 $this->kind = $a_kind;
102 if ($a_username ===
'') {
103 return $this->position ?: array();
107 foreach ($this->position as $auth_key) {
111 $this->
logger->debug(
'Validating username filter for ' .
$server->getName());
112 if (
$server->getUsernameFilter() !==
'') {
114 $pattern = str_replace(
'*',
'.*?',
$server->getUsernameFilter());
117 $this->
logger->debug(
'Trying pattern to match username:' . $pattern .
' => ' . $a_username);
118 set_error_handler(
static function (
int $severity,
string $message,
string $file,
int $line): never {
119 throw new ErrorException($message, $severity, $severity, $file, $line);
123 if (preg_match($delimiter .
"^" . $pattern .
'$' . $delimiter .
'i', $a_username) === 1) {
124 $this->
logger->debug(
'Filter matches for ' . $a_username);
125 array_unshift($sorted, $auth_key);
130 $this->
logger->warning(
'Error occurred in preg_match Ex.: ' . $ex->getMessage());
132 restore_error_handler();
136 $this->
logger->debug(
'Filter matches not for ' . $a_username .
' <-> ' .
$server->getUsernameFilter());
139 $sorted[] = $auth_key;
150 return count($this->position);
161 $this->position = $a_pos;
174 foreach ($this->position as $auth_mode) {
175 $this->
settings->set((
string) $counter++, (
string) $auth_mode);
185 $this->kind = (
int) $this->
settings->get(
'kind', (
string) self::TYPE_MANUAL);
187 $soap_active = (bool) $this->commonSettings->get(
'soap_auth_active',
"");
190 $apache_settings =
new ilSetting(
'apache_auth');
191 $apache_active = $apache_settings->get(
'apache_enable_auth');
197 if ($auth_mode ===
null) {
201 switch ((
int) $auth_mode) {
203 $this->position[] = (
int) $auth_mode;
207 if ($auth_id ===
null) {
213 $this->position[] = $auth_mode;
219 $this->position[] = (
int) $auth_mode;
224 if ($apache_active) {
225 $this->position[] = (
int) $auth_mode;
231 if ($pl->isAuthActive((
int) $auth_mode)) {
232 $this->position[] = $auth_mode;
260 foreach ($pl->getAuthIds() as $auth_id) {
261 if ($pl->isAuthActive($auth_id) && !in_array($auth_id, $this->position,
true)) {
262 $this->position[] = $auth_id;
static getInstanceByServerId(int $a_server_id)
Get instance by server id.
ilSetting $commonSettings
getAuthModeSequence(string $a_username='')
get auth mode sequence
static _getActiveServerList()
Get active server list.
isManualSelection()
is manual selection
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static getServerIdByAuthMode(string $a_auth_mode)
Get auth id by auth mode.
static getAuthPlugins()
Get active enabled auth plugins.
setKind(int $a_kind)
set kind of determination
__construct()
Constructor (Singleton)
setAuthModeSequence(array $a_pos)
set auth mode sequence
static _getInstance()
Get instance.
static ilAuthModeDetermination $instance
getCountActiveAuthModes()
get number of auth modes