ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilAuthModeDetermination Class Reference
+ Collaboration diagram for ilAuthModeDetermination:

Public Member Functions

 isManualSelection ()
 is manual selection More...
 
 getKind ()
 get kind More...
 
 setKind (int $a_kind)
 set kind of determination More...
 
 getAuthModeSequence (string $a_username='')
 get auth mode sequence More...
 
 getCountActiveAuthModes ()
 get number of auth modes More...
 
 setAuthModeSequence (array $a_pos)
 set auth mode sequence More...
 
 save ()
 Save settings. More...
 

Static Public Member Functions

static _getInstance ()
 Get instance. More...
 

Data Fields

const TYPE_MANUAL = 0
 
const TYPE_AUTOMATIC = 1
 

Private Member Functions

 __construct ()
 Constructor (Singleton) More...
 
 read ()
 Read settings. More...
 

Private Attributes

ilLogger $logger
 
ilSetting $settings
 
ilSetting $commonSettings
 
int $kind = self::TYPE_MANUAL
 
array $position = []
 

Static Private Attributes

static ilAuthModeDetermination $instance = null
 

Detailed Description

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 24 of file class.ilAuthModeDetermination.php.

Constructor & Destructor Documentation

◆ __construct()

ilAuthModeDetermination::__construct ( )
private

Constructor (Singleton)

private

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

References $DIC, ILIAS\Repository\logger(), read(), and ILIAS\Repository\settings().

47  {
48  global $DIC;
49 
50  $this->logger = $DIC->logger()->auth();
51 
52  $this->commonSettings = $DIC->settings();
53 
54  $this->settings = new ilSetting("auth_mode_determination");
55  $this->read();
56  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ _getInstance()

static ilAuthModeDetermination::_getInstance ( )
static

◆ getAuthModeSequence()

ilAuthModeDetermination::getAuthModeSequence ( string  $a_username = '')

get auth mode sequence

Definition at line 100 of file class.ilAuthModeDetermination.php.

References $message, $server, ilLDAPServer\getInstanceByServerId(), ilLDAPServer\getServerIdByAuthMode(), ILIAS\Repository\logger(), and ilAuthUtils\REGEX_DELIMITERS.

100  : array
101  {
102  if ($a_username === '') {
103  return $this->position ?: array();
104  }
105  $sorted = array();
106 
107  foreach ($this->position as $auth_key) {
108  $sid = ilLDAPServer::getServerIdByAuthMode((string) $auth_key);
109  if ($sid) {
111  $this->logger->debug('Validating username filter for ' . $server->getName());
112  if ($server->getUsernameFilter() !== '') {
113  //#17731
114  $pattern = str_replace('*', '.*?', $server->getUsernameFilter());
115 
116  foreach (ilAuthUtils::REGEX_DELIMITERS as $delimiter) {
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);
120  });
121 
122  try {
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);
126  continue 2;
127  }
128  break;
129  } catch (Exception $ex) {
130  $this->logger->warning('Error occurred in preg_match Ex.: ' . $ex->getMessage());
131  } finally {
132  restore_error_handler();
133  }
134  }
135 
136  $this->logger->debug('Filter matches not for ' . $a_username . ' <-> ' . $server->getUsernameFilter());
137  }
138  }
139  $sorted[] = $auth_key;
140  }
141 
142  return $sorted;
143  }
static getInstanceByServerId(int $a_server_id)
Get instance by server id.
static getServerIdByAuthMode(string $a_auth_mode)
Get auth id by auth mode.
$message
Definition: xapiexit.php:31
$server
Definition: shib_login.php:24
+ Here is the call graph for this function:

◆ getCountActiveAuthModes()

ilAuthModeDetermination::getCountActiveAuthModes ( )

get number of auth modes

Definition at line 148 of file class.ilAuthModeDetermination.php.

148  : int
149  {
150  return count($this->position);
151  }

◆ getKind()

ilAuthModeDetermination::getKind ( )

get kind

Definition at line 80 of file class.ilAuthModeDetermination.php.

References $kind.

Referenced by save().

80  : int
81  {
82  return $this->kind;
83  }
+ Here is the caller graph for this function:

◆ isManualSelection()

ilAuthModeDetermination::isManualSelection ( )

is manual selection

Definition at line 72 of file class.ilAuthModeDetermination.php.

72  : bool
73  {
74  return $this->kind === self::TYPE_MANUAL;
75  }

◆ read()

ilAuthModeDetermination::read ( )
private

Read settings.

Definition at line 183 of file class.ilAuthModeDetermination.php.

References $server, ilLDAPServer\_getActiveServerList(), ilAuthUtils\AUTH_APACHE, ilAuthUtils\AUTH_LDAP, ilAuthUtils\AUTH_LOCAL, ilAuthUtils\AUTH_SOAP, ilAuthUtils\getAuthPlugins(), ilLDAPServer\getInstanceByServerId(), ilLDAPServer\getServerIdByAuthMode(), ILIAS\Repository\int(), null, and ILIAS\Repository\settings().

Referenced by __construct().

183  : void
184  {
185  $this->kind = (int) $this->settings->get('kind', (string) self::TYPE_MANUAL);
186 
187  $soap_active = (bool) $this->commonSettings->get('soap_auth_active', "");
188 
189  // apache settings
190  $apache_settings = new ilSetting('apache_auth');
191  $apache_active = $apache_settings->get('apache_enable_auth');
192 
193  // Check if active
194  $i = 0;
195  while (true) {
196  $auth_mode = $this->settings->get((string) $i++, null);
197  if ($auth_mode === null) {
198  break;
199  }
200  if ($auth_mode) {
201  switch ((int) $auth_mode) {
203  $this->position[] = (int) $auth_mode;
204  break;
206  $auth_id = ilLDAPServer::getServerIdByAuthMode($auth_mode);
207  if ($auth_id === null) {
208  break;
209  }
211 
212  if ($server->isActive()) {
213  $this->position[] = $auth_mode;
214  }
215  break;
216 
218  if ($soap_active) {
219  $this->position[] = (int) $auth_mode;
220  }
221  break;
222 
224  if ($apache_active) {
225  $this->position[] = (int) $auth_mode;
226  }
227  break;
228 
229  default:
230  foreach (ilAuthUtils::getAuthPlugins() as $pl) {
231  if ($pl->isAuthActive((int) $auth_mode)) {
232  $this->position[] = $auth_mode;
233  }
234  }
235  break;
236  }
237  }
238  }
239 
240  // Append missing active auth modes
241  if (!in_array(ilAuthUtils::AUTH_LOCAL, $this->position, true)) {
242  $this->position[] = ilAuthUtils::AUTH_LOCAL;
243  }
244  // begin-patch ldap_multiple
245  foreach (ilLDAPServer::_getActiveServerList() as $sid) {
247  if ($server->isActive() && !in_array(ilAuthUtils::AUTH_LDAP . '_' . $sid, $this->position, true)) {
248  $this->position[] = (ilAuthUtils::AUTH_LDAP . '_' . $sid);
249  }
250  }
251  // end-patch ldap_multiple
252  if ($soap_active && !in_array(ilAuthUtils::AUTH_SOAP, $this->position, true)) {
253  $this->position[] = ilAuthUtils::AUTH_SOAP;
254  }
255  if ($apache_active && !in_array(ilAuthUtils::AUTH_APACHE, $this->position, true)) {
256  $this->position[] = ilAuthUtils::AUTH_APACHE;
257  }
258  // begin-patch auth_plugin
259  foreach (ilAuthUtils::getAuthPlugins() as $pl) {
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;
263  }
264  }
265  }
266  // end-patch auth_plugin
267  }
static getInstanceByServerId(int $a_server_id)
Get instance by server id.
static _getActiveServerList()
Get active server list.
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.
$server
Definition: shib_login.php:24
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilAuthModeDetermination::save ( )

Save settings.

Definition at line 167 of file class.ilAuthModeDetermination.php.

References getKind(), and ILIAS\Repository\settings().

167  : void
168  {
169  $this->settings->deleteAll();
170 
171  $this->settings->set('kind', (string) $this->getKind());
172 
173  $counter = 0;
174  foreach ($this->position as $auth_mode) {
175  $this->settings->set((string) $counter++, (string) $auth_mode);
176  }
177  }
+ Here is the call graph for this function:

◆ setAuthModeSequence()

ilAuthModeDetermination::setAuthModeSequence ( array  $a_pos)

set auth mode sequence

Parameters
arrayposition => AUTH_MODE

Definition at line 159 of file class.ilAuthModeDetermination.php.

159  : void
160  {
161  $this->position = $a_pos;
162  }

◆ setKind()

ilAuthModeDetermination::setKind ( int  $a_kind)

set kind of determination

Parameters
intTYPE_MANUAL or TYPE_DETERMINATION

Definition at line 91 of file class.ilAuthModeDetermination.php.

91  : void
92  {
93  // TODO check value range
94  $this->kind = $a_kind;
95  }

Field Documentation

◆ $commonSettings

ilSetting ilAuthModeDetermination::$commonSettings
private

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

◆ $instance

ilAuthModeDetermination ilAuthModeDetermination::$instance = null
staticprivate

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

◆ $kind

int ilAuthModeDetermination::$kind = self::TYPE_MANUAL
private

Definition at line 36 of file class.ilAuthModeDetermination.php.

Referenced by getKind().

◆ $logger

ilLogger ilAuthModeDetermination::$logger
private

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

◆ $position

array ilAuthModeDetermination::$position = []
private

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

◆ $settings

ilSetting ilAuthModeDetermination::$settings
private

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

◆ TYPE_AUTOMATIC

const ilAuthModeDetermination::TYPE_AUTOMATIC = 1

◆ TYPE_MANUAL

const ilAuthModeDetermination::TYPE_MANUAL = 0

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