ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilAuthModeDetermination Class Reference
+ Collaboration diagram for ilAuthModeDetermination:

Public Member Functions

 isManualSelection ()
 is manual selection More...
 
 getKind ()
 get kind More...
 
 setKind ($a_kind)
 set kind of determination More...
 
 getAuthModeSequence ($a_username='')
 get auth mode sequence More...
 
 getCountActiveAuthModes ()
 get number of auth modes More...
 
 setAuthModeSequence ($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
 

Protected Attributes

 $db = null
 
 $settings = null
 
 $kind = 0
 
 $position = array()
 

Static Protected Attributes

static $instance = null
 

Private Member Functions

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

Detailed Description

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

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

Constructor & Destructor Documentation

◆ __construct()

ilAuthModeDetermination::__construct ( )
private

Constructor (Singleton)

private

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

References $ilDB, $ilSetting, read(), and settings().

55  {
56  global $ilSetting,$ilDB;
57 
58  $this->db = $ilDB;
59 
60  include_once "./Services/Administration/classes/class.ilSetting.php";
61  $this->settings = new ilSetting("auth_mode_determination");
62  $this->read();
63  }
settings()
Definition: settings.php:2
global $ilSetting
Definition: privfeed.php:17
global $ilDB
+ Here is the call graph for this function:

Member Function Documentation

◆ _getInstance()

static ilAuthModeDetermination::_getInstance ( )
static

◆ getAuthModeSequence()

ilAuthModeDetermination::getAuthModeSequence (   $a_username = '')

get auth mode sequence

public

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

References $server, array, ilLDAPServer\getInstanceByServerId(), ilLoggerFactory\getLogger(), and ilLDAPServer\getServerIdByAuthMode().

124  {
125  if (!strlen($a_username)) {
126  return $this->position ? $this->position : array();
127  }
128  $sorted = array();
129 
130  foreach ($this->position as $auth_key) {
131  include_once './Services/LDAP/classes/class.ilLDAPServer.php';
132  $sid = ilLDAPServer::getServerIdByAuthMode($auth_key);
133  if ($sid) {
135  ilLoggerFactory::getLogger('auth')->debug('Validating username filter for ' . $server->getName());
136  if (strlen($server->getUsernameFilter())) {
137  //#17731
138  $pattern = str_replace('*', '.*?', $server->getUsernameFilter());
139 
140  if (preg_match('/^' . $pattern . '$/', $a_username)) {
141  ilLoggerFactory::getLogger('auth')->debug('Filter matches for ' . $a_username);
142  array_unshift($sorted, $auth_key);
143  continue;
144  }
145  ilLoggerFactory::getLogger('auth')->debug('Filter matches not for ' . $a_username . ' <-> ' . $server->getUsernameFilter());
146  }
147  }
148  $sorted[] = $auth_key;
149  }
150 
151  return (array) $sorted;
152  }
static getInstanceByServerId($a_server_id)
Get instance by server id.
static getServerIdByAuthMode($a_auth_mode)
Get auth id by auth mode.
Create styles array
The data for the language used.
$server
Definition: getUserInfo.php:12
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:

◆ getCountActiveAuthModes()

ilAuthModeDetermination::getCountActiveAuthModes ( )

get number of auth modes

public

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

161  {
162  return count($this->position);
163  }

◆ getKind()

ilAuthModeDetermination::getKind ( )

get kind

public

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

References $kind.

Referenced by save().

+ Here is the caller graph for this function:

◆ isManualSelection()

ilAuthModeDetermination::isManualSelection ( )

is manual selection

public

Parameters

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

90  {
91  return $this->kind == self::TYPE_MANUAL;
92  }

◆ read()

ilAuthModeDetermination::read ( )
private

Read settings.

private

Parameters

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

References $i, $ilSetting, $server, ilLDAPServer\_getActiveServerList(), ilRadiusSettings\_getInstance(), AUTH_APACHE, AUTH_LDAP, AUTH_LOCAL, AUTH_RADIUS, AUTH_SOAP, ilAuthUtils\getAuthPlugins(), ilLDAPServer\getInstanceByServerId(), ilLDAPServer\getServerIdByAuthMode(), and settings().

Referenced by __construct().

205  {
206  global $ilSetting;
207 
208  $this->kind = $this->settings->get('kind', self::TYPE_MANUAL);
209 
210  // begin-patch ldap_multiple
211  include_once('Services/LDAP/classes/class.ilLDAPServer.php');
212  // end-patch ldap_multiple
213 
214  include_once('Services/Radius/classes/class.ilRadiusSettings.php');
215  $rad_settings = ilRadiusSettings::_getInstance();
216  $rad_active = $rad_settings->isActive();
217 
218  $soap_active = $ilSetting->get('soap_auth_active', false);
219 
220  // apache settings
221  $apache_settings = new ilSetting('apache_auth');
222  $apache_active = $apache_settings->get('apache_enable_auth');
223 
224  // Check if active
225  // begin-patch ldap_multiple
226  $i = 0;
227  while (true) {
228  $auth_mode = $this->settings->get((string) $i++, false);
229  if ($auth_mode === false) {
230  break;
231  }
232  if ($auth_mode) {
233  // begin-patch ldap_multiple
234  switch ((int) $auth_mode) {
235  case AUTH_LOCAL:
236  $this->position[] = $auth_mode;
237  break;
238 
239  case AUTH_LDAP:
240  $auth_id = ilLDAPServer::getServerIdByAuthMode($auth_mode);
242 
243  if ($server->isActive()) {
244  $this->position[] = $auth_mode;
245  }
246  break;
247 
248  case AUTH_RADIUS:
249  if ($rad_active) {
250  $this->position[] = $auth_mode;
251  }
252  break;
253 
254  case AUTH_SOAP:
255  if ($soap_active) {
256  $this->position[] = $auth_mode;
257  }
258  break;
259 
260  case AUTH_APACHE:
261  if ($apache_active) {
262  $this->position[] = $auth_mode;
263  }
264  break;
265 
266  // begin-patch auth_plugin
267  default:
268  foreach (ilAuthUtils::getAuthPlugins() as $pl) {
269  if ($pl->isAuthActive($auth_mode)) {
270  $this->position[] = $auth_mode;
271  }
272  }
273  break;
274  // end-patch auth_plugin
275 
276  }
277  }
278  }
279  // end-patch ldap_multiple
280 
281  // Append missing active auth modes
282  if (!in_array(AUTH_LOCAL, $this->position)) {
283  $this->position[] = AUTH_LOCAL;
284  }
285  // begin-patch ldap_multiple
286  foreach (ilLDAPServer::_getActiveServerList() as $sid) {
288  if ($server->isActive()) {
289  if (!in_array(AUTH_LDAP . '_' . $sid, $this->position)) {
290  $this->position[] = (AUTH_LDAP . '_' . $sid);
291  }
292  }
293  }
294  // end-patch ldap_multiple
295  if ($rad_active) {
296  if (!in_array(AUTH_RADIUS, $this->position)) {
297  $this->position[] = AUTH_RADIUS;
298  }
299  }
300  if ($soap_active) {
301  if (!in_array(AUTH_SOAP, $this->position)) {
302  $this->position[] = AUTH_SOAP;
303  }
304  }
305  if ($apache_active) {
306  if (!in_array(AUTH_APACHE, $this->position)) {
307  $this->position[] = AUTH_APACHE;
308  }
309  }
310  // begin-patch auth_plugin
311  foreach (ilAuthUtils::getAuthPlugins() as $pl) {
312  foreach ($pl->getAuthIds() as $auth_id) {
313  if ($pl->isAuthActive($auth_id)) {
314  if (!in_array($auth_id, $this->position)) {
315  $this->position[] = $auth_id;
316  }
317  }
318  }
319  }
320  // end-patch auth_plugin
321  }
const AUTH_LDAP
static _getActiveServerList()
Get active server list.
const AUTH_APACHE
static getInstanceByServerId($a_server_id)
Get instance by server id.
static getAuthPlugins()
Get active enabled auth plugins.
static _getInstance()
singleton get instance
const AUTH_LOCAL
static getServerIdByAuthMode($a_auth_mode)
Get auth id by auth mode.
$server
Definition: getUserInfo.php:12
const AUTH_SOAP
settings()
Definition: settings.php:2
global $ilSetting
Definition: privfeed.php:17
$i
Definition: disco.tpl.php:19
const AUTH_RADIUS
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilAuthModeDetermination::save ( )

Save settings.

public

Parameters

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

References $counter, getKind(), and settings().

185  {
186  $this->settings->deleteAll();
187 
188  $this->settings->set('kind', $this->getKind());
189 
190  $counter = 0;
191  foreach ($this->position as $auth_mode) {
192  $this->settings->set((string) $counter++, $auth_mode);
193  }
194  }
$counter
settings()
Definition: settings.php:2
+ Here is the call graph for this function:

◆ setAuthModeSequence()

ilAuthModeDetermination::setAuthModeSequence (   $a_pos)

set auth mode sequence

public

Parameters
arrayposition => AUTH_MODE

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

173  {
174  $this->position = $a_pos;
175  }

◆ setKind()

ilAuthModeDetermination::setKind (   $a_kind)

set kind of determination

public

Parameters
intTYPE_MANUAL or TYPE_DETERMINATION

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

113  {
114  $this->kind = $a_kind;
115  }

Field Documentation

◆ $db

ilAuthModeDetermination::$db = null
protected

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

◆ $instance

ilAuthModeDetermination::$instance = null
staticprotected

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

◆ $kind

ilAuthModeDetermination::$kind = 0
protected

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

Referenced by getKind().

◆ $position

ilAuthModeDetermination::$position = array()
protected

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

◆ $settings

ilAuthModeDetermination::$settings = null
protected

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

◆ TYPE_AUTOMATIC

const ilAuthModeDetermination::TYPE_AUTOMATIC = 1

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

◆ TYPE_MANUAL

const ilAuthModeDetermination::TYPE_MANUAL = 0

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


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