Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
00051 $this->initSettings();
00052
00053
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
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
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 ?>