• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/Radius/classes/class.ilAuthRadius.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2006 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00025 include_once('Auth/Auth.php');
00026 
00036 class ilAuthRadius extends Auth
00037 {
00038         private $radius_settings = null;        
00039         private $rad_to_user = null;
00040         private $log = null;
00041         
00042         private $force_creation = false;
00043         
00044         public function __construct()
00045         {
00046                 global $ilLog;
00047                 
00048                 $this->log = $ilLog;
00049                 
00050                 // Read setting of LDAP server
00051                 $this->initSettings();
00052                 
00053                 // Convert password to latin1
00054                 if($this->radius_settings->getCharset() == ilRadiusSettings::RADIUS_CHARSET_LATIN1)
00055                 {
00056                         #$_POST['username'] = utf8_decode($_POST['username']);
00057                         $_POST['password'] = utf8_decode($_POST['password']);
00058                         $this->log->write(__METHOD__.': Decoded username and password to latin1.');
00059                 }
00060                 
00061                 
00062                 parent::Auth('RADIUS',$this->radius_settings->toPearAuthArray(),'',false);
00063                 
00064                 // Set callbacks
00065                 $this->setCallbacks();
00066         }
00067         
00075         public function forceCreation($a_status)
00076         {
00077                 $this->force_creation = true;
00078         }
00079         
00080         
00086         protected function loginObserver($a_username)
00087         {
00088                 $user_data = array_change_key_case($this->getAuthData(),CASE_LOWER);
00089                 
00090                 $user_data['ilInternalAccount'] = ilObjUser::_checkExternalAuthAccount("radius",$a_username);
00091                 
00092                 if(!$user_data['ilInternalAccount'])
00093                 {
00094                         if($this->radius_settings->enabledCreation())
00095                         {
00096                                 if($this->radius_settings->isAccountMigrationEnabled() and !$this->force_creation)
00097                                 {
00098                                         $this->logout();
00099                                         $_SESSION['tmp_auth_mode'] = 'radius';
00100                                         $_SESSION['tmp_external_account'] = $a_username;
00101                                         $_SESSION['tmp_pass'] = $_POST['password'];
00102                                         $_SESSION['tmp_roles'] = array(0 => $this->radius_settings->getDefaultRole());
00103                                 
00104                                         ilUtil::redirect('ilias.php?baseClass=ilStartUpGUI&cmd=showAccountMigration');
00105                                 }
00106                                 $this->initAttributeToUser();
00107                                 $new_name = $this->radius_user->create($a_username);
00108                                 $this->setAuth($new_name);
00109                                 return true;
00110                         }
00111                         else
00112                         {
00113                                 // No syncronisation allowed => create Error
00114                                 $this->status = AUTH_RADIUS_NO_ILIAS_USER;
00115                                 $this->logout();
00116                                 return false;
00117                         }
00118                         
00119                 }
00120                 else
00121                 {
00122                         $this->setAuth($user_data['ilInternalAccount']);
00123                         return true;
00124                 }
00125         }
00126         
00132         protected function failedLoginObserver()
00133         {
00134                 #$this->log->write($this->logCache);
00135                 $this->logCache = '';
00136         }
00137         
00138         
00139         private function initSettings()
00140         {
00141                 include_once 'Services/Radius/classes/class.ilRadiusSettings.php';
00142                 $this->radius_settings = ilRadiusSettings::_getInstance();
00143         }
00144         
00145         private function initAttributeToUser()
00146         {
00147                 include_once('Services/Radius/classes/class.ilRadiusAttributeToUser.php');
00148                 $this->radius_user = new ilRadiusAttributeToUser();
00149         }
00150         
00155         private function setCallbacks() 
00156         {
00157                 $this->setLoginCallback(array($this,'loginObserver'));
00158                 $this->setFailedLoginCallback(array($this,'failedLoginObserver'));
00159         }
00160         
00161 }
00162 
00163 ?>

Generated on Fri Dec 13 2013 17:57:00 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1