Public Member Functions | Static Public Member Functions | Data Fields | Private Member Functions | Private Attributes | Static Private Attributes

ilRadiusSettings Class Reference
[ServicesRadius]

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.
 getDefaultRole ()
 Get default role for new radius users.
 setDefaultRole ($a_role)
 enabledCreation ()
 Enable creation of users.
 enableCreation ($a_status)
 Enable creation.
 enableAccountMigration ($a_status)
 Enable account migration.
 isAccountMigrationEnabled ()
 enabled account migration
 getCharset ()
 get charset
 setCharset ($a_charset)
 set charset
 save ()
 Save settings.
 validateRequired ()
 Validate required.
 validatePort ()
 Validate port.
 validateServers ()
 Validate servers.

Static Public Member Functions

static _getInstance ()
 singleton get instance

Data Fields

const RADIUS_CHARSET_UTF8 = 0
const RADIUS_CHARSET_LATIN1 = 1

Private Member Functions

 __construct ()
 singleton constructor
 read ()
 Read settings.

Private Attributes

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

Static Private Attributes

static $instance = null

Detailed Description

Author:
Stefan Meyer <smeyer@databay.de>
Version:
$Id$

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


Constructor & Destructor Documentation

ilRadiusSettings::__construct (  )  [private]

singleton constructor

private

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

References $ilSetting, and read().

        {
                global $ilSetting,$ilDB;
                
                $this->settings = $ilSetting;
                $this->db = $ilDB;
                
                $this->read();
        }

Here is the call graph for this function:


Member Function Documentation

static ilRadiusSettings::_getInstance (  )  [static]

singleton get instance

public

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

Referenced by ilRadiusAttributeToUser::__construct(), ilAuthUtils::_getMultipleAuthModeOptions(), ilAuthUtils::_hasMultipleAuthenticationMethods(), ilRadiusSettingsGUI::initSettings(), ilAuthRadius::initSettings(), and ilObjAuthSettingsGUI::loginInfoObject().

        {
                if(isset(self::$instance) and self::$instance)
                {
                        return self::$instance;
                }
                return self::$instance = new ilRadiusSettings();
        }

Here is the caller graph for this function:

ilRadiusSettings::enableAccountMigration ( a_status  ) 

Enable account migration.

public

Parameters:
bool status

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

Referenced by read().

        {
                $this->account_migration = $a_status;
        }

Here is the caller graph for this function:

ilRadiusSettings::enableCreation ( a_status  ) 

Enable creation.

public

Parameters:
 

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

Referenced by read().

        {
                $this->creation = $a_status;
        }

Here is the caller graph for this function:

ilRadiusSettings::enabledCreation (  ) 

Enable creation of users.

public

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

Referenced by save(), and validateRequired().

        {
                return $this->creation;
        }

Here is the caller graph for this function:

ilRadiusSettings::getCharset (  ) 

get charset

public

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

Referenced by save().

        {
                return $this->charset ? 1 : 0;
        }

Here is the caller graph for this function:

ilRadiusSettings::getDefaultRole (  ) 

Get default role for new radius users.

public

Returns:
int role_id

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

Referenced by save(), and validateRequired().

        {
                return $this->default_role;
        }

Here is the caller graph for this function:

ilRadiusSettings::getName (  ) 

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

Referenced by save(), and validateRequired().

        {
                return $this->name;
        }

Here is the caller graph for this function:

ilRadiusSettings::getPort (  ) 

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

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

        {
                return $this->port;
        }

Here is the caller graph for this function:

ilRadiusSettings::getSecret (  ) 

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

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

        {
                return $this->secret;
        }

Here is the caller graph for this function:

ilRadiusSettings::getServers (  ) 

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

Referenced by save(), and toPearAuthArray().

        {
                return $this->servers ? $this->servers : array();
        }

Here is the caller graph for this function:

ilRadiusSettings::getServersAsString (  ) 

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

Referenced by validateRequired().

        {
                return implode(',',$this->servers);
        }

Here is the caller graph for this function:

ilRadiusSettings::isAccountMigrationEnabled (  ) 

enabled account migration

public

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

Referenced by save().

        {
                return $this->account_migration ? true : false;
        }

Here is the caller graph for this function:

ilRadiusSettings::isActive (  ) 

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

Referenced by save().

        {
                return $this->active ? true : false;
        }

Here is the caller graph for this function:

ilRadiusSettings::read (  )  [private]

Read settings.

private

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

References $res, ilObjRole::_getRolesByAuthMode(), enableAccountMigration(), enableCreation(), setActive(), setCharset(), setName(), setPort(), and setSecret().

Referenced by __construct().

        {
                $all_settings = $this->settings->getAll();
                
                $this->setActive($all_settings['radius_active']);
                $this->setPort($all_settings['radius_port']);
                $this->setSecret($all_settings['radius_shared_secret']);
                $this->setName($all_settings['radius_name']);
                $this->enableCreation($all_settings['radius_creation']);
                $this->enableAccountMigration($all_settings['radius_migration']);
                $this->setCharset($all_settings['radius_charset']);
                
                $query = "SELECT value FROM settings WHERE keyword LIKE 'radius_server%' ORDER BY keyword ASC";
                $res = $this->db->query($query);
                
                while ($row = $res->fetchRow())
                {
                        $this->servers[] = $row[0];
                }
                
                include_once('classes/class.ilObjRole.php');
                $roles = ilObjRole::_getRolesByAuthMode('radius');
                $this->default_role = $roles[0] ? $roles[0] : 0;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilRadiusSettings::save (  ) 

Save settings.

public

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

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

        {
                // first delete old servers
                $query = "DELETE FROM settings WHERE keyword LIKE('radius_server%')";
                $this->db->query($query);
                
                $this->settings->set('radius_active',$this->isActive() ? 1 : 0);
                $this->settings->set('radius_port',$this->getPort());
                $this->settings->set('radius_shared_secret',$this->getSecret());
                $this->settings->set('radius_name',$this->getName());
                $this->settings->set('radius_creation',$this->enabledCreation() ? 1 : 0);
                $this->settings->set('radius_migration',$this->isAccountMigrationEnabled() ? 1 : 0);
                $this->settings->set('radius_charset',$this->getCharset() ? 1 : 0);
                
                $counter = 0;
                foreach($this->getServers() as $server)
                {
                        if(++$counter == 1)
                        {
                                $this->settings->set('radius_server',trim($server));
                        }
                        else
                        {
                                $this->settings->set('radius_server'.$counter,trim($server));
                        }
                }
                
                include_once('classes/class.ilObjRole.php');
                ilObjRole::_resetAuthMode('radius');
                
                if($this->getDefaultRole())
                {
                        ilObjRole::_updateAuthMode(array($this->getDefaultRole() => 'radius'));
                }
                return true;
        }

Here is the call graph for this function:

ilRadiusSettings::setActive ( a_status  ) 

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

Referenced by read().

        {
                $this->active = $a_status;
        }

Here is the caller graph for this function:

ilRadiusSettings::setCharset ( a_charset  ) 

set charset

public

Parameters:
int charset

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

Referenced by read().

        {
                $this->charset = $a_charset;
        }

Here is the caller graph for this function:

ilRadiusSettings::setDefaultRole ( a_role  ) 

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

        {
                $this->default_role = $a_role;
        }

ilRadiusSettings::setName ( a_name  ) 

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

Referenced by read().

        {
                $this->name = $a_name;
        }

Here is the caller graph for this function:

ilRadiusSettings::setPort ( a_port  ) 

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

Referenced by read().

        {
                $this->port = $a_port;
        }

Here is the caller graph for this function:

ilRadiusSettings::setSecret ( a_secret  ) 

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

Referenced by read().

        {
                $this->secret = $a_secret;
        }

Here is the caller graph for this function:

ilRadiusSettings::setServerString ( a_server_string  ) 

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

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

ilRadiusSettings::toPearAuthArray (  ) 

Create options array for PEAR Auth constructor.

public

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

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

        {
                foreach($this->getServers() as $server)
                {
                        $auth_params['servers'][] = array($server,$this->getPort(),$this->getSecret());
                }
                return $auth_params ? $auth_params : array();
        }

Here is the call graph for this function:

ilRadiusSettings::validatePort (  ) 

Validate port.

public

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

References getPort().

        {
                return preg_match("/^[0-9]{0,5}$/",$this->getPort()) == 1;
        }

Here is the call graph for this function:

ilRadiusSettings::validateRequired (  ) 

Validate required.

public

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

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

        {
                $ok = strlen($this->getServersAsString()) and strlen($this->getPort()) and strlen($this->getSecret()) and strlen($this->getName());
                
                $role_ok = true;
                if($this->enabledCreation() and !$this->getDefaultRole())
                {
                        $role_ok = false;
                }
                return $ok and $role_ok;
        }

Here is the call graph for this function:

ilRadiusSettings::validateServers (  ) 

Validate servers.

public

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

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

        {
                $servers = explode(",",$this->server_string);
                
                foreach ($servers as $server)
                {
                        $server = trim($server);

                        if (!ilUtil::isIPv4($server) and !ilUtil::isDN($server))
                        {
                                return false;
                        }
                }
                return true;
        }

Here is the call graph for this function:


Field Documentation

ilRadiusSettings::$account_migration = false [private]

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

ilRadiusSettings::$db [private]

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

ilRadiusSettings::$instance = null [static, private]

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

ilRadiusSettings::$servers = array() [private]

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

Referenced by validateServers().

ilRadiusSettings::$settings [private]

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


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