ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  }
ILIAS Setting Class.
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 124 of file class.ilAuthModeDetermination.php.

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

125  {
126  if(!strlen($a_username))
127  {
128  return $this->position ? $this->position : array();
129  }
130  $sorted = array();
131 
132  foreach($this->position as $auth_key)
133  {
134  include_once './Services/LDAP/classes/class.ilLDAPServer.php';
135  $sid = ilLDAPServer::getServerIdByAuthMode($auth_key);
136  if($sid)
137  {
139  ilLoggerFactory::getLogger('auth')->debug('Validating username filter for ' . $server->getName());
140  if(strlen($server->getUsernameFilter()))
141  {
142  //#17731
143  $pattern = str_replace('*','.*?', $server->getUsernameFilter());
144 
145  if(preg_match('/^'.$pattern.'$/', $a_username))
146  {
147  ilLoggerFactory::getLogger('auth')->debug('Filter matches for ' . $a_username);
148  array_unshift($sorted, $auth_key);
149  continue;
150  }
151  ilLoggerFactory::getLogger('auth')->debug('Filter matches not for ' . $a_username. ' <-> ' . $server->getUsernameFilter());
152  }
153  }
154  $sorted[] = $auth_key;
155  }
156 
157  return (array) $sorted;
158  }
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
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 166 of file class.ilAuthModeDetermination.php.

167  {
168  return count($this->position);
169  }

◆ getKind()

ilAuthModeDetermination::getKind ( )

get kind

public

Definition at line 101 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 90 of file class.ilAuthModeDetermination.php.

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

◆ read()

ilAuthModeDetermination::read ( )
private

Read settings.

private

Parameters

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

References $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().

212  {
213  global $ilSetting;
214 
215  $this->kind = $this->settings->get('kind',self::TYPE_MANUAL);
216 
217  // begin-patch ldap_multiple
218  include_once('Services/LDAP/classes/class.ilLDAPServer.php');
219  // end-patch ldap_multiple
220 
221  include_once('Services/Radius/classes/class.ilRadiusSettings.php');
222  $rad_settings = ilRadiusSettings::_getInstance();
223  $rad_active = $rad_settings->isActive();
224 
225  $soap_active = $ilSetting->get('soap_auth_active',false);
226 
227  // apache settings
228  $apache_settings = new ilSetting('apache_auth');
229  $apache_active = $apache_settings->get('apache_enable_auth');
230 
231  // Check if active
232  // begin-patch ldap_multiple
233  $i = 0;
234  while(true)
235  {
236  $auth_mode = $this->settings->get((string) $i++,FALSE);
237  if($auth_mode === FALSE)
238  {
239  break;
240  }
241  if($auth_mode)
242  {
243  // begin-patch ldap_multiple
244  switch((int) $auth_mode)
245  {
246  case AUTH_LOCAL:
247  $this->position[] = $auth_mode;
248  break;
249 
250  case AUTH_LDAP:
251  $auth_id = ilLDAPServer::getServerIdByAuthMode($auth_mode);
253 
254  if($server->isActive())
255  {
256  $this->position[] = $auth_mode;
257  }
258  break;
259 
260  case AUTH_RADIUS:
261  if($rad_active)
262  {
263  $this->position[] = $auth_mode;
264  }
265  break;
266 
267  case AUTH_SOAP:
268  if($soap_active)
269  {
270  $this->position[] = $auth_mode;
271  }
272  break;
273 
274  case AUTH_APACHE:
275  if($apache_active)
276  {
277  $this->position[] = $auth_mode;
278  }
279  break;
280 
281  // begin-patch auth_plugin
282  default:
283  foreach(ilAuthUtils::getAuthPlugins() as $pl)
284  {
285  if($pl->isAuthActive($auth_mode))
286  {
287  $this->position[] = $auth_mode;
288  }
289  }
290  break;
291  // end-patch auth_plugin
292 
293  }
294  }
295  }
296  // end-patch ldap_multiple
297 
298  // Append missing active auth modes
299  if(!in_array(AUTH_LOCAL,$this->position))
300  {
301  $this->position[] = AUTH_LOCAL;
302  }
303  // begin-patch ldap_multiple
304  foreach(ilLDAPServer::_getActiveServerList() as $sid)
305  {
307  if($server->isActive())
308  {
309  if(!in_array(AUTH_LDAP.'_'.$sid, $this->position))
310  {
311  $this->position[] = (AUTH_LDAP.'_'.$sid);
312  }
313  }
314 
315  }
316  // end-patch ldap_multiple
317  if($rad_active)
318  {
319  if(!in_array(AUTH_RADIUS,$this->position))
320  {
321  $this->position[] = AUTH_RADIUS;
322  }
323 
324  }
325  if($soap_active)
326  {
327  if(!in_array(AUTH_SOAP,$this->position))
328  {
329  $this->position[] = AUTH_SOAP;
330  }
331  }
332  if($apache_active)
333  {
334  if(!in_array(AUTH_APACHE,$this->position))
335  {
336  $this->position[] = AUTH_APACHE;
337  }
338  }
339  // begin-patch auth_plugin
340  foreach(ilAuthUtils::getAuthPlugins() as $pl)
341  {
342  foreach($pl->getAuthIds() as $auth_id)
343  {
344  if($pl->isAuthActive($auth_id))
345  {
346  if(!in_array($auth_id, $this->position))
347  {
348  $this->position[] = $auth_id;
349  }
350  }
351  }
352  }
353  // end-patch auth_plugin
354  }
ILIAS Setting Class.
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.
const AUTH_SOAP
$server
settings()
Definition: settings.php:2
global $ilSetting
Definition: privfeed.php:17
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 190 of file class.ilAuthModeDetermination.php.

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

191  {
192  $this->settings->deleteAll();
193 
194  $this->settings->set('kind',$this->getKind());
195 
196  $counter = 0;
197  foreach($this->position as $auth_mode)
198  {
199  $this->settings->set((string) $counter++,$auth_mode);
200  }
201  }
$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 178 of file class.ilAuthModeDetermination.php.

179  {
180  $this->position = $a_pos;
181  }

◆ setKind()

ilAuthModeDetermination::setKind (   $a_kind)

set kind of determination

public

Parameters
intTYPE_MANUAL or TYPE_DETERMINATION

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

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

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: