ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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...
 

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(), 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: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ _getInstance()

static ilAuthModeDetermination::_getInstance ( )
static

Get instance.

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

Referenced by ilStartUpGUI\buildStandardLoginForm(), ilStartUpGUI\doStandardAuthentication(), ilAuthProviderFactory\getProviders(), ilObjAuthSettingsGUI\initAuthModeDetermination(), and ilObjAuthSettingsGUI\updateAuthModeDeterminationObject().

62  {
63  if (self::$instance) {
64  return self::$instance;
65  }
66  return self::$instance = new ilAuthModeDetermination();
67  }
+ Here is the caller graph for this function:

◆ 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.
$server
$message
Definition: xapiexit.php:32
+ 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  }

◆ save()

ilAuthModeDetermination::save ( )

Save settings.

Definition at line 167 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(), getKind(), ilLDAPServer\getServerIdByAuthMode(), ILIAS\Repository\int(), 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

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


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