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
00032 include_once('Services/Authentication/classes/class.ilAuthUtils.php');
00033
00034 class ilAuthModeDetermination
00035 {
00036 const TYPE_MANUAL = 0;
00037 const TYPE_AUTOMATIC = 1;
00038
00039 protected static $instance = null;
00040
00041 protected $db = null;
00042 protected $settings = null;
00043
00044 protected $kind = 0;
00045 protected $position = array();
00046
00047
00054 private function __construct()
00055 {
00056 global $ilSetting,$ilDB;
00057
00058 $this->db = $ilDB;
00059
00060 include_once "./Services/Administration/classes/class.ilSetting.php";
00061 $this->settings = new ilSetting("auth_mode_determination");
00062 $this->read();
00063 }
00064
00072 public static function _getInstance()
00073 {
00074 if(self::$instance)
00075 {
00076 return self::$instance;
00077 }
00078 return self::$instance = new ilAuthModeDetermination();
00079 }
00080
00089 public function isManualSelection()
00090 {
00091 return $this->kind == self::TYPE_MANUAL;
00092 }
00093
00100 public function getKind()
00101 {
00102 return $this->kind;
00103 }
00104
00112 public function setKind($a_kind)
00113 {
00114 $this->kind = $a_kind;
00115 }
00116
00123 public function getAuthModeSequence()
00124 {
00125 return $this->position ? $this->position : array();
00126 }
00127
00134 public function getCountActiveAuthModes()
00135 {
00136 return count($this->position);
00137 }
00138
00146 public function setAuthModeSequence($a_pos)
00147 {
00148 $this->position = $a_pos;
00149 }
00150
00158 public function save()
00159 {
00160 $this->settings->deleteAll();
00161
00162 $this->settings->set('kind',$this->getKind());
00163
00164 $counter = 0;
00165 foreach($this->position as $auth_mode)
00166 {
00167 $this->settings->set((string) $counter++,$auth_mode);
00168 }
00169 }
00170
00171
00179 private function read()
00180 {
00181 $this->kind = $this->settings->get('kind',self::TYPE_MANUAL);
00182
00183 include_once('Services/LDAP/classes/class.ilLDAPServer.php');
00184 $ldap_active = ilLDAPServer::_getFirstActiveServer();
00185
00186 include_once('Services/Radius/classes/class.ilRadiusSettings.php');
00187 $rad_settings = ilRadiusSettings::_getInstance();
00188 $rad_active = $rad_settings->isActive();
00189
00190
00191
00192 for($i = 0; $i < 3; $i++)
00193 {
00194 if($auth_mode = $this->settings->get((string) $i,0))
00195 {
00196 switch($auth_mode)
00197 {
00198 case AUTH_LOCAL:
00199 $this->position[] = $auth_mode;
00200 break;
00201 case AUTH_LDAP:
00202 if($ldap_active)
00203 {
00204 $this->position[] = $auth_mode;
00205 }
00206 break;
00207
00208 case AUTH_RADOIUS:
00209 if($rad_active)
00210 {
00211 $this->position[] = $auth_mode;
00212 }
00213 break;
00214 }
00215 }
00216 }
00217
00218
00219 if(!in_array(AUTH_LOCAL,$this->position))
00220 {
00221 $this->position[] = AUTH_LOCAL;
00222 }
00223 if($ldap_active)
00224 {
00225 if(!in_array(AUTH_LDAP,$this->position))
00226 {
00227 $this->position[] = AUTH_LDAP;
00228 }
00229 }
00230 if($rad_active)
00231 {
00232 if(!in_array(AUTH_RADIUS,$this->position))
00233 {
00234 $this->position[] = AUTH_RADIUS;
00235 }
00236
00237 }
00238 }
00239 }
00240
00241
00242 ?>