Ejemplo n.º 1
0
 /**
  * singleton get instance
  *
  * @access public
  * @static
  *
  */
 public static function _getInstance()
 {
     if (isset(self::$instance) and self::$instance) {
         return self::$instance;
     }
     return self::$instance = new ilRadiusSettings();
 }
 /**
  * Constructor
  *
  * @access public
  * 
  */
 public function __construct()
 {
     global $ilLog;
     $this->log = $ilLog;
     include_once 'Services/Radius/classes/class.ilRadiusSettings.php';
     $this->rad_settings = ilRadiusSettings::_getInstance();
     include_once './Services/Xml/classes/class.ilXmlWriter.php';
     $this->writer = new ilXmlWriter();
 }
 /**
  * Init login form
  */
 protected function initLoginForm()
 {
     global $rbacsystem, $lng, $ilSetting;
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $this->form = new ilPropertyFormGUI();
     $this->form->setFormAction($this->ctrl->getFormAction($this, 'saveLoginInfo'));
     $this->form->setTableWidth('80%');
     $this->form->setTitle($this->lng->txt('login_information'));
     $this->form->addCommandButton('saveLoginInfo', $this->lng->txt('save'));
     include_once 'Services/LDAP/classes/class.ilLDAPServer.php';
     include_once 'Services/Radius/classes/class.ilRadiusSettings.php';
     $rad_settings = ilRadiusSettings::_getInstance();
     if ($ldap_id = ilLDAPServer::_getFirstActiveServer() or $rad_settings->isActive()) {
         $select = new ilSelectInputGUI($this->lng->txt('default_auth_mode'), 'default_auth_mode');
         $select->setValue($ilSetting->get('default_auth_mode', AUTH_LOCAL));
         $select->setInfo($this->lng->txt('default_auth_mode_info'));
         $options[AUTH_LOCAL] = $this->lng->txt('auth_local');
         if ($ldap_id) {
             $options[AUTH_LDAP] = $this->lng->txt('auth_ldap');
         }
         if ($rad_settings->isActive()) {
             $options[AUTH_RADIUS] = $this->lng->txt('auth_radius');
         }
         $select->setOptions($options);
         $this->form->addItem($select);
     }
     if (!is_object($this->loginSettings)) {
         $this->loginSettings = new ilSetting("login_settings");
     }
     $login_settings = $this->loginSettings->getAll();
     $languages = $lng->getInstalledLanguages();
     $def_language = $lng->getDefaultLanguage();
     foreach ($this->setDefLangFirst($def_language, $languages) as $lang_key) {
         $add = "";
         if ($lang_key == $def_language) {
             $add = " (" . $lng->txt("default") . ")";
         }
         $textarea = new ilTextAreaInputGUI($lng->txt("meta_l_" . $lang_key) . $add, 'login_message_' . $lang_key);
         $textarea->setRows(10);
         $textarea->setValue($login_settings["login_message_" . $lang_key]);
         $textarea->setUseRte(true);
         $textarea->setRteTagSet("extended");
         $this->form->addItem($textarea);
         unset($login_settings["login_message_" . $lang_key]);
     }
     foreach ($login_settings as $key => $message) {
         $lang_key = substr($key, strrpos($key, "_") + 1, strlen($key) - strrpos($key, "_"));
         $textarea = new ilTextAreaInputGUI($lng->txt("meta_l_" . $lang_key) . $add, 'login_message_' . $lang_key);
         $textarea->setRows(10);
         $textarea->setValue($message);
         $textarea->setUseRte(true);
         $textarea->setRteTagSet("extended");
         if (!in_array($lang_key, $languages)) {
             $textarea->setAlert($lng->txt("not_installed"));
         }
         $this->form->addItem($textarea);
     }
 }
 /**
  * Init radius settings
  * @return void 
  */
 private function initSettings()
 {
     include_once 'Services/Radius/classes/class.ilRadiusSettings.php';
     $this->radius_settings = ilRadiusSettings::_getInstance();
 }
 /**
  * Read settings
  *
  * @access private
  * @param
  * 
  */
 private function read()
 {
     global $ilSetting;
     $this->kind = $this->settings->get('kind', self::TYPE_MANUAL);
     include_once 'Services/LDAP/classes/class.ilLDAPServer.php';
     $ldap_active = ilLDAPServer::_getFirstActiveServer();
     include_once 'Services/Radius/classes/class.ilRadiusSettings.php';
     $rad_settings = ilRadiusSettings::_getInstance();
     $rad_active = $rad_settings->isActive();
     $soap_active = $ilSetting->get('soap_auth_active', false);
     // apache settings
     $apache_settings = new ilSetting('apache_auth');
     $apache_active = $apache_settings->get('apache_enable_auth');
     // Check if active
     for ($i = 0; $i < 5; $i++) {
         if ($auth_mode = $this->settings->get((string) $i, 0)) {
             switch ($auth_mode) {
                 case AUTH_LOCAL:
                     $this->position[] = $auth_mode;
                     break;
                 case AUTH_LDAP:
                     if ($ldap_active) {
                         $this->position[] = $auth_mode;
                     }
                     break;
                 case AUTH_RADIUS:
                     if ($rad_active) {
                         $this->position[] = $auth_mode;
                     }
                     break;
                 case AUTH_SOAP:
                     if ($soap_active) {
                         $this->position[] = $auth_mode;
                     }
                     break;
                 case AUTH_APACHE:
                     if ($apache_active) {
                         $this->position[] = $auth_mode;
                     }
                     break;
             }
         }
     }
     // Append missing active auth modes
     if (!in_array(AUTH_LOCAL, $this->position)) {
         $this->position[] = AUTH_LOCAL;
     }
     if ($ldap_active) {
         if (!in_array(AUTH_LDAP, $this->position)) {
             $this->position[] = AUTH_LDAP;
         }
     }
     if ($rad_active) {
         if (!in_array(AUTH_RADIUS, $this->position)) {
             $this->position[] = AUTH_RADIUS;
         }
     }
     if ($soap_active) {
         if (!in_array(AUTH_SOAP, $this->position)) {
             $this->position[] = AUTH_SOAP;
         }
     }
     if ($apache_active) {
         if (!in_array(AUTH_APACHE, $this->position)) {
             $this->position[] = AUTH_APACHE;
         }
     }
 }
Ejemplo n.º 6
0
 public static function _getMultipleAuthModeOptions($lng)
 {
     global $ilSetting;
     // in the moment only ldap is activated as additional authentication method
     include_once 'Services/LDAP/classes/class.ilLDAPServer.php';
     $options[AUTH_LOCAL]['txt'] = $lng->txt('authenticate_ilias');
     // LDAP
     if ($ldap_id = ilLDAPServer::_getFirstActiveServer()) {
         $ldap_server = new ilLDAPServer($ldap_id);
         $options[AUTH_LDAP]['txt'] = $ldap_server->getName();
     }
     include_once 'Services/Radius/classes/class.ilRadiusSettings.php';
     $rad_settings = ilRadiusSettings::_getInstance();
     if ($rad_settings->isActive()) {
         $options[AUTH_RADIUS]['txt'] = $rad_settings->getName();
     }
     if ($ilSetting->get('apache_active')) {
         global $lng;
         $apache_settings = new ilSetting('apache_auth');
         $options[AUTH_APACHE]['txt'] = $apache_settings->get('name', $lng->txt('apache_auth'));
         $options[AUTH_APACHE]['hide_in_ui'] = true;
     }
     if ($ilSetting->get('auth_mode', AUTH_LOCAL) == AUTH_LDAP) {
         $default = AUTH_LDAP;
     } elseif ($ilSetting->get('auth_mode', AUTH_LOCAL) == AUTH_RADIUS) {
         $default = AUTH_RADIUS;
     } else {
         $default = AUTH_LOCAL;
     }
     $default = $ilSetting->get('default_auth_mode', $default);
     $default = (int) $_REQUEST['auth_mode'] ? (int) $_REQUEST['auth_mode'] : $default;
     // begin-patch auth_plugin
     $pls = ilAuthUtils::getAuthPlugins();
     foreach ($pls as $pl) {
         $auths = $pl->getAuthIds();
         foreach ($auths as $auth_id) {
             $pl_auth_option = $pl->getMultipleAuthModeOptions($auth_id);
             if ($pl_auth_option) {
                 $options = $options + $pl_auth_option;
             }
         }
     }
     // end-patch auth_plugins
     $options[$default]['checked'] = true;
     return $options ? $options : array();
 }