ILIAS  release_8 Revision v8.24
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)

@access private

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

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 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28

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

+ 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.

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 if (preg_match('/^' . $pattern . '$/', $a_username)) {
117 $this->logger->debug('Filter matches for ' . $a_username);
118 array_unshift($sorted, $auth_key);
119 continue;
120 }
121 $this->logger->debug('Filter matches not for ' . $a_username . ' <-> ' . $server->getUsernameFilter());
122 }
123 }
124 $sorted[] = $auth_key;
125 }
126
127 return $sorted;
128 }
static getInstanceByServerId(int $a_server_id)
Get instance by server id.
static getServerIdByAuthMode(string $a_auth_mode)
Get auth id by auth mode.
$server

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

+ Here is the call graph for this function:

◆ getCountActiveAuthModes()

ilAuthModeDetermination::getCountActiveAuthModes ( )

get number of auth modes

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

133 : int
134 {
135 return count($this->position);
136 }

◆ getKind()

ilAuthModeDetermination::getKind ( )

get kind

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

80 : int
81 {
82 return $this->kind;
83 }

References $kind.

Referenced by save().

+ 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 }

References TYPE_MANUAL.

◆ read()

ilAuthModeDetermination::read ( )
private

Read settings.

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

168 : void
169 {
170 $this->kind = (int) $this->settings->get('kind', (string) self::TYPE_MANUAL);
171
172 $soap_active = (bool) $this->commonSettings->get('soap_auth_active', "");
173
174 // apache settings
175 $apache_settings = new ilSetting('apache_auth');
176 $apache_active = $apache_settings->get('apache_enable_auth');
177
178 // Check if active
179 $i = 0;
180 while (true) {
181 $auth_mode = $this->settings->get((string) $i++, null);
182 if ($auth_mode === null) {
183 break;
184 }
185 if ($auth_mode) {
186 switch ((int) $auth_mode) {
188 $this->position[] = (int) $auth_mode;
189 break;
191 $auth_id = ilLDAPServer::getServerIdByAuthMode($auth_mode);
192 if ($auth_id === null) {
193 break;
194 }
196
197 if ($server->isActive()) {
198 $this->position[] = $auth_mode;
199 }
200 break;
201
203 if ($soap_active) {
204 $this->position[] = (int) $auth_mode;
205 }
206 break;
207
209 if ($apache_active) {
210 $this->position[] = (int) $auth_mode;
211 }
212 break;
213
214 default:
215 foreach (ilAuthUtils::getAuthPlugins() as $pl) {
216 if ($pl->isAuthActive((int) $auth_mode)) {
217 $this->position[] = $auth_mode;
218 }
219 }
220 break;
221 }
222 }
223 }
224
225 // Append missing active auth modes
226 if (!in_array(ilAuthUtils::AUTH_LOCAL, $this->position, true)) {
227 $this->position[] = ilAuthUtils::AUTH_LOCAL;
228 }
229 // begin-patch ldap_multiple
230 foreach (ilLDAPServer::_getActiveServerList() as $sid) {
232 if ($server->isActive() && !in_array(ilAuthUtils::AUTH_LDAP . '_' . $sid, $this->position, true)) {
233 $this->position[] = (ilAuthUtils::AUTH_LDAP . '_' . $sid);
234 }
235 }
236 // end-patch ldap_multiple
237 if ($soap_active && !in_array(ilAuthUtils::AUTH_SOAP, $this->position, true)) {
238 $this->position[] = ilAuthUtils::AUTH_SOAP;
239 }
240 if ($apache_active && !in_array(ilAuthUtils::AUTH_APACHE, $this->position, true)) {
241 $this->position[] = ilAuthUtils::AUTH_APACHE;
242 }
243 // begin-patch auth_plugin
244 foreach (ilAuthUtils::getAuthPlugins() as $pl) {
245 foreach ($pl->getAuthIds() as $auth_id) {
246 if ($pl->isAuthActive($auth_id) && !in_array($auth_id, $this->position, true)) {
247 $this->position[] = $auth_id;
248 }
249 }
250 }
251 // end-patch auth_plugin
252 }
static getAuthPlugins()
Get active enabled auth plugins.
static _getActiveServerList()
Get active server list.
$i
Definition: metadata.php:41

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

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilAuthModeDetermination::save ( )

Save settings.

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

152 : void
153 {
154 $this->settings->deleteAll();
155
156 $this->settings->set('kind', (string) $this->getKind());
157
158 $counter = 0;
159 foreach ($this->position as $auth_mode) {
160 $this->settings->set((string) $counter++, (string) $auth_mode);
161 }
162 }

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

+ 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 144 of file class.ilAuthModeDetermination.php.

144 : void
145 {
146 $this->position = $a_pos;
147 }

◆ 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.

Referenced by _getInstance().

◆ $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.

Referenced by isManualSelection(), and read().


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