ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilRadiusSettings Class Reference
+ Collaboration diagram for ilRadiusSettings:

Public Member Functions

 isActive ()
 
 setActive ($a_status)
 
 setPort ($a_port)
 
 getPort ()
 
 setSecret ($a_secret)
 
 getSecret ()
 
 setServerString ($a_server_string)
 
 getServersAsString ()
 
 getServers ()
 
 setName ($a_name)
 
 getName ()
 
 toPearAuthArray ()
 Create options array for PEAR Auth constructor. More...
 
 getDefaultRole ()
 Get default role for new radius users. More...
 
 setDefaultRole ($a_role)
 
 enabledCreation ()
 Enable creation of users. More...
 
 enableCreation ($a_status)
 Enable creation. More...
 
 enableAccountMigration ($a_status)
 Enable account migration. More...
 
 isAccountMigrationEnabled ()
 enabled account migration More...
 
 getCharset ()
 get charset More...
 
 setCharset ($a_charset)
 set charset More...
 
 save ()
 Save settings. More...
 
 validateRequired ()
 Validate required. More...
 
 validatePort ()
 Validate port. More...
 
 validateServers ()
 Validate servers. More...
 

Static Public Member Functions

static _getInstance ()
 singleton get instance More...
 

Data Fields

const RADIUS_CHARSET_UTF8 = 0
 
const RADIUS_CHARSET_LATIN1 = 1
 
const SYNC_DISABLED = 0
 
const SYNC_RADIUS = 1
 
const SYNC_LDAP = 2
 
 $active = false
 

Private Member Functions

 __construct ()
 singleton constructor More...
 
 read ()
 Read settings. More...
 

Private Attributes

 $settings
 
 $db
 
 $account_migration = false
 
 $servers = array()
 

Static Private Attributes

static $instance = null
 

Detailed Description

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

Definition at line 32 of file class.ilRadiusSettings.php.

Constructor & Destructor Documentation

◆ __construct()

ilRadiusSettings::__construct ( )
private

singleton constructor

private

Definition at line 57 of file class.ilRadiusSettings.php.

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

58  {
59  global $ilSetting,$ilDB;
60 
61  $this->settings = $ilSetting;
62  $this->db = $ilDB;
63 
64  $this->read();
65  }
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 ilRadiusSettings::_getInstance ( )
static

singleton get instance

public

Definition at line 74 of file class.ilRadiusSettings.php.

Referenced by ilAuthProviderRadius\__construct(), ilRadiusAttributeToUser\__construct(), ilAuthUtils\_getMultipleAuthModeOptions(), ilAuthUtils\_hasMultipleAuthenticationMethods(), ilAuthLoginPageEditorGUI\initLoginForm(), ilAuthContainerRadius\initSettings(), ilRadiusSettingsGUI\initSettings(), and ilAuthModeDetermination\read().

75  {
76  if(isset(self::$instance) and self::$instance)
77  {
78  return self::$instance;
79  }
80  return self::$instance = new ilRadiusSettings();
81  }
+ Here is the caller graph for this function:

◆ enableAccountMigration()

ilRadiusSettings::enableAccountMigration (   $a_status)

Enable account migration.

public

Parameters
boolstatus

Definition at line 191 of file class.ilRadiusSettings.php.

192  {
193  $this->account_migration = $a_status;
194  }

◆ enableCreation()

ilRadiusSettings::enableCreation (   $a_status)

Enable creation.

public

Parameters

Definition at line 179 of file class.ilRadiusSettings.php.

180  {
181  $this->creation = $a_status;
182  }

◆ enabledCreation()

ilRadiusSettings::enabledCreation ( )

Enable creation of users.

public

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

Referenced by save(), and validateRequired().

168  {
169  return $this->creation;
170  }
+ Here is the caller graph for this function:

◆ getCharset()

ilRadiusSettings::getCharset ( )

get charset

public

Definition at line 213 of file class.ilRadiusSettings.php.

Referenced by save().

214  {
215  return $this->charset ? 1 : 0;
216  }
+ Here is the caller graph for this function:

◆ getDefaultRole()

ilRadiusSettings::getDefaultRole ( )

Get default role for new radius users.

public

Returns
int role_id

Definition at line 151 of file class.ilRadiusSettings.php.

Referenced by save(), and validateRequired().

152  {
153  return $this->default_role;
154  }
+ Here is the caller graph for this function:

◆ getName()

ilRadiusSettings::getName ( )

Definition at line 124 of file class.ilRadiusSettings.php.

Referenced by save(), and validateRequired().

125  {
126  return $this->name;
127  }
+ Here is the caller graph for this function:

◆ getPort()

ilRadiusSettings::getPort ( )

Definition at line 95 of file class.ilRadiusSettings.php.

Referenced by save(), toPearAuthArray(), validatePort(), and validateRequired().

96  {
97  return $this->port;
98  }
+ Here is the caller graph for this function:

◆ getSecret()

ilRadiusSettings::getSecret ( )

Definition at line 103 of file class.ilRadiusSettings.php.

Referenced by save(), toPearAuthArray(), and validateRequired().

104  {
105  return $this->secret;
106  }
+ Here is the caller graph for this function:

◆ getServers()

ilRadiusSettings::getServers ( )

Definition at line 116 of file class.ilRadiusSettings.php.

References array.

Referenced by save(), and toPearAuthArray().

117  {
118  return $this->servers ? $this->servers : array();
119  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getServersAsString()

ilRadiusSettings::getServersAsString ( )

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

Referenced by validateRequired().

113  {
114  return implode(',',$this->servers);
115  }
+ Here is the caller graph for this function:

◆ isAccountMigrationEnabled()

ilRadiusSettings::isAccountMigrationEnabled ( )

enabled account migration

public

Definition at line 202 of file class.ilRadiusSettings.php.

Referenced by save().

203  {
204  return $this->account_migration ? true : false;
205  }
+ Here is the caller graph for this function:

◆ isActive()

ilRadiusSettings::isActive ( )

Definition at line 83 of file class.ilRadiusSettings.php.

Referenced by save().

84  {
85  return $this->active ? true : false;
86  }
+ Here is the caller graph for this function:

◆ read()

ilRadiusSettings::read ( )
private

Read settings.

private

Definition at line 330 of file class.ilRadiusSettings.php.

References ilObjRole\_getRolesByAuthMode(), array, and settings().

Referenced by __construct().

331  {
332  $all_settings = $this->settings->getAll();
333 
334  $sets = array("radius_active" => "setActive",
335  "radius_port" => "setPort",
336  "radius_shared_secret" => "setSecret",
337  "radius_name" => "setName",
338  "radius_creation" => "enableCreation",
339  "radius_migration" => "enableAccountMigration",
340  "radius_charset" => "setCharset"
341  );
342  foreach ($sets as $s => $m)
343  {
344  if (isset($all_settings[$s]))
345  {
346  $this->$m($all_settings[$s]);
347  }
348  }
349 
350  reset($all_settings);
351  foreach($all_settings as $k => $v)
352  {
353  if (substr($k, 0, 13) == "radius_server")
354  {
355  $this->servers[] = $v;
356  }
357  }
358 
359  include_once('./Services/AccessControl/classes/class.ilObjRole.php');
360  $roles = ilObjRole::_getRolesByAuthMode('radius');
361  $this->default_role = 0;
362  if (isset($roles[0]) && $roles[0])
363  {
364  $this->default_role = $roles[0];
365  }
366  }
static _getRolesByAuthMode($a_auth_mode)
Get roles by auth mode.
Create styles array
The data for the language used.
settings()
Definition: settings.php:2
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilRadiusSettings::save ( )

Save settings.

public

Definition at line 236 of file class.ilRadiusSettings.php.

References $counter, $server, ilObjRole\_resetAuthMode(), ilObjRole\_updateAuthMode(), array, enabledCreation(), getCharset(), getDefaultRole(), getName(), getPort(), getSecret(), getServers(), isAccountMigrationEnabled(), isActive(), and settings().

237  {
238  // first delete old servers
239  $this->settings->deleteLike('radius_server%');
240 
241  $this->settings->set('radius_active',$this->isActive() ? 1 : 0);
242  $this->settings->set('radius_port',$this->getPort());
243  $this->settings->set('radius_shared_secret',$this->getSecret());
244  $this->settings->set('radius_name',$this->getName());
245  $this->settings->set('radius_creation',$this->enabledCreation() ? 1 : 0);
246  $this->settings->set('radius_migration',$this->isAccountMigrationEnabled() ? 1 : 0);
247  $this->settings->set('radius_charset',$this->getCharset() ? 1 : 0);
248 
249  $counter = 0;
250  foreach($this->getServers() as $server)
251  {
252  if(++$counter == 1)
253  {
254  $this->settings->set('radius_server',trim($server));
255  }
256  else
257  {
258  $this->settings->set('radius_server'.$counter,trim($server));
259  }
260  }
261 
262  include_once('./Services/AccessControl/classes/class.ilObjRole.php');
263  ilObjRole::_resetAuthMode('radius');
264 
265  if($this->getDefaultRole())
266  {
267  ilObjRole::_updateAuthMode(array($this->getDefaultRole() => 'radius'));
268  }
269  return true;
270  }
static _updateAuthMode($a_roles)
static _resetAuthMode($a_auth_mode)
Reset auth mode to default.
isAccountMigrationEnabled()
enabled account migration
$counter
getDefaultRole()
Get default role for new radius users.
enabledCreation()
Enable creation of users.
Create styles array
The data for the language used.
$server
settings()
Definition: settings.php:2
+ Here is the call graph for this function:

◆ setActive()

ilRadiusSettings::setActive (   $a_status)

Definition at line 87 of file class.ilRadiusSettings.php.

88  {
89  $this->active = $a_status;
90  }

◆ setCharset()

ilRadiusSettings::setCharset (   $a_charset)

set charset

public

Parameters
intcharset

Definition at line 225 of file class.ilRadiusSettings.php.

226  {
227  $this->charset = $a_charset;
228  }

◆ setDefaultRole()

ilRadiusSettings::setDefaultRole (   $a_role)

Definition at line 156 of file class.ilRadiusSettings.php.

157  {
158  $this->default_role = $a_role;
159  }

◆ setName()

ilRadiusSettings::setName (   $a_name)

Definition at line 120 of file class.ilRadiusSettings.php.

121  {
122  $this->name = $a_name;
123  }

◆ setPort()

ilRadiusSettings::setPort (   $a_port)

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

92  {
93  $this->port = $a_port;
94  }

◆ setSecret()

ilRadiusSettings::setSecret (   $a_secret)

Definition at line 99 of file class.ilRadiusSettings.php.

100  {
101  $this->secret = $a_secret;
102  }

◆ setServerString()

ilRadiusSettings::setServerString (   $a_server_string)

Definition at line 107 of file class.ilRadiusSettings.php.

108  {
109  $this->server_string = $a_server_string;
110  $this->servers = explode(',',$this->server_string);
111  }

◆ toPearAuthArray()

ilRadiusSettings::toPearAuthArray ( )

Create options array for PEAR Auth constructor.

public

Definition at line 135 of file class.ilRadiusSettings.php.

References $server, array, getPort(), getSecret(), and getServers().

136  {
137  foreach($this->getServers() as $server)
138  {
139  $auth_params['servers'][] = array($server,$this->getPort(),$this->getSecret());
140  }
141  return $auth_params ? $auth_params : array();
142  }
Create styles array
The data for the language used.
$server
+ Here is the call graph for this function:

◆ validatePort()

ilRadiusSettings::validatePort ( )

Validate port.

public

Definition at line 296 of file class.ilRadiusSettings.php.

References getPort().

297  {
298  return preg_match("/^[0-9]{0,5}$/",$this->getPort()) == 1;
299  }
+ Here is the call graph for this function:

◆ validateRequired()

ilRadiusSettings::validateRequired ( )

Validate required.

public

Definition at line 278 of file class.ilRadiusSettings.php.

References $ok, enabledCreation(), getDefaultRole(), getName(), getPort(), getSecret(), and getServersAsString().

279  {
280  $ok = strlen($this->getServersAsString()) and strlen($this->getPort()) and strlen($this->getSecret()) and strlen($this->getName());
281 
282  $role_ok = true;
283  if($this->enabledCreation() and !$this->getDefaultRole())
284  {
285  $role_ok = false;
286  }
287  return $ok and $role_ok;
288  }
getDefaultRole()
Get default role for new radius users.
enabledCreation()
Enable creation of users.
PHPExcel root directory.
Definition: Database.php:30
+ Here is the call graph for this function:

◆ validateServers()

ilRadiusSettings::validateServers ( )

Validate servers.

public

Definition at line 307 of file class.ilRadiusSettings.php.

References $server, $servers, ilUtil\isDN(), and ilUtil\isIPv4().

308  {
309  $servers = explode(",",$this->server_string);
310 
311  foreach ($servers as $server)
312  {
313  $server = trim($server);
314 
315  if (!ilUtil::isIPv4($server) and !ilUtil::isDN($server))
316  {
317  return false;
318  }
319  }
320  return true;
321  }
static isDN($a_str)
static isIPv4($a_str)
$server
+ Here is the call graph for this function:

Field Documentation

◆ $account_migration

ilRadiusSettings::$account_migration = false
private

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

◆ $active

ilRadiusSettings::$active = false

Definition at line 49 of file class.ilRadiusSettings.php.

◆ $db

ilRadiusSettings::$db
private

Definition at line 43 of file class.ilRadiusSettings.php.

◆ $instance

ilRadiusSettings::$instance = null
staticprivate

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

◆ $servers

ilRadiusSettings::$servers = array()
private

Definition at line 48 of file class.ilRadiusSettings.php.

Referenced by validateServers().

◆ $settings

ilRadiusSettings::$settings
private

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

◆ RADIUS_CHARSET_LATIN1

const ilRadiusSettings::RADIUS_CHARSET_LATIN1 = 1

◆ RADIUS_CHARSET_UTF8

const ilRadiusSettings::RADIUS_CHARSET_UTF8 = 0

◆ SYNC_DISABLED

const ilRadiusSettings::SYNC_DISABLED = 0

◆ SYNC_LDAP

const ilRadiusSettings::SYNC_LDAP = 2

◆ SYNC_RADIUS

const ilRadiusSettings::SYNC_RADIUS = 1

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