ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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(), ilRadiusSettingsGUI\initSettings(), and ilAuthModeDetermination\read().

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

◆ enableAccountMigration()

ilRadiusSettings::enableAccountMigration (   $a_status)

Enable account migration.

public

Parameters
boolstatus

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

190  {
191  $this->account_migration = $a_status;
192  }

◆ enableCreation()

ilRadiusSettings::enableCreation (   $a_status)

Enable creation.

public

Parameters

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

178  {
179  $this->creation = $a_status;
180  }

◆ enabledCreation()

ilRadiusSettings::enabledCreation ( )

Enable creation of users.

public

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

Referenced by save(), and validateRequired().

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

◆ getCharset()

ilRadiusSettings::getCharset ( )

get charset

public

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

Referenced by save().

212  {
213  return $this->charset ? 1 : 0;
214  }
+ 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 149 of file class.ilRadiusSettings.php.

Referenced by save(), and validateRequired().

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

◆ getName()

ilRadiusSettings::getName ( )

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

References $name.

Referenced by save(), and validateRequired().

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

◆ getPort()

ilRadiusSettings::getPort ( )

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

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

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

◆ getSecret()

ilRadiusSettings::getSecret ( )

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

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

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

◆ getServers()

ilRadiusSettings::getServers ( )

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

Referenced by save(), and toPearAuthArray().

116  {
117  return $this->servers ? $this->servers : array();
118  }
+ Here is the caller graph for this function:

◆ getServersAsString()

ilRadiusSettings::getServersAsString ( )

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

Referenced by validateRequired().

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

◆ isAccountMigrationEnabled()

ilRadiusSettings::isAccountMigrationEnabled ( )

enabled account migration

public

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

Referenced by save().

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

◆ isActive()

ilRadiusSettings::isActive ( )

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

Referenced by save().

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

◆ read()

ilRadiusSettings::read ( )
private

Read settings.

private

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

References $m, $s, $sets, ilObjRole\_getRolesByAuthMode(), and settings().

Referenced by __construct().

321  {
322  $all_settings = $this->settings->getAll();
323 
324  $sets = array("radius_active" => "setActive",
325  "radius_port" => "setPort",
326  "radius_shared_secret" => "setSecret",
327  "radius_name" => "setName",
328  "radius_creation" => "enableCreation",
329  "radius_migration" => "enableAccountMigration",
330  "radius_charset" => "setCharset"
331  );
332  foreach ($sets as $s => $m) {
333  if (isset($all_settings[$s])) {
334  $this->$m($all_settings[$s]);
335  }
336  }
337 
338  reset($all_settings);
339  foreach ($all_settings as $k => $v) {
340  if (substr($k, 0, 13) == "radius_server") {
341  $this->servers[] = $v;
342  }
343  }
344 
345  include_once('./Services/AccessControl/classes/class.ilObjRole.php');
346  $roles = ilObjRole::_getRolesByAuthMode('radius');
347  $this->default_role = 0;
348  if (isset($roles[0]) && $roles[0]) {
349  $this->default_role = $roles[0];
350  }
351  }
settings()
Definition: settings.php:2
$s
Definition: pwgen.php:45
static _getRolesByAuthMode($a_auth_mode)
Get roles by auth mode.
$sets
Definition: fetch.php:11
+ 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 234 of file class.ilRadiusSettings.php.

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

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

◆ setActive()

ilRadiusSettings::setActive (   $a_status)

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

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

◆ setCharset()

ilRadiusSettings::setCharset (   $a_charset)

set charset

public

Parameters
intcharset

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

224  {
225  $this->charset = $a_charset;
226  }

◆ setDefaultRole()

ilRadiusSettings::setDefaultRole (   $a_role)

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

155  {
156  $this->default_role = $a_role;
157  }

◆ setName()

ilRadiusSettings::setName (   $a_name)

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

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

◆ setPort()

ilRadiusSettings::setPort (   $a_port)

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

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

◆ setSecret()

ilRadiusSettings::setSecret (   $a_secret)

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

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

◆ setServerString()

ilRadiusSettings::setServerString (   $a_server_string)

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

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

◆ toPearAuthArray()

ilRadiusSettings::toPearAuthArray ( )

Create options array for PEAR Auth constructor.

public

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

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

135  {
136  foreach ($this->getServers() as $server) {
137  $auth_params['servers'][] = array($server,$this->getPort(),$this->getSecret());
138  }
139  return $auth_params ? $auth_params : array();
140  }
$server
Definition: sabredav.php:48
+ Here is the call graph for this function:

◆ validatePort()

ilRadiusSettings::validatePort ( )

Validate port.

public

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

References getPort().

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

◆ validateRequired()

ilRadiusSettings::validateRequired ( )

Validate required.

public

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

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

272  {
273  $ok = strlen($this->getServersAsString()) and strlen($this->getPort()) and strlen($this->getSecret()) and strlen($this->getName());
274 
275  $role_ok = true;
276  if ($this->enabledCreation() and !$this->getDefaultRole()) {
277  $role_ok = false;
278  }
279  return $ok and $role_ok;
280  }
getDefaultRole()
Get default role for new radius users.
if(!file_exists(getcwd() . '/ilias.ini.php'))
registration confirmation script for ilias
Definition: confirmReg.php:12
enabledCreation()
Enable creation of users.
+ Here is the call graph for this function:

◆ validateServers()

ilRadiusSettings::validateServers ( )

Validate servers.

public

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

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

300  {
301  $servers = explode(",", $this->server_string);
302 
303  foreach ($servers as $server) {
304  $server = trim($server);
305 
306  if (!ilUtil::isIPv4($server) and !ilUtil::isDN($server)) {
307  return false;
308  }
309  }
310  return true;
311  }
static isDN($a_str)
static isIPv4($a_str)
$server
Definition: sabredav.php:48
+ 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: