ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilAuthModeDetermination.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
32include_once('Services/Authentication/classes/class.ilAuthUtils.php');
33
35{
36 const TYPE_MANUAL = 0;
37 const TYPE_AUTOMATIC = 1;
38
39 protected static $instance = null;
40
41 protected $db = null;
42 protected $settings = null;
43
44 protected $kind = 0;
45 protected $position = array();
46
47
54 private function __construct()
55 {
56 global $ilSetting,$ilDB;
57
58 $this->db = $ilDB;
59
60 include_once "./Services/Administration/classes/class.ilSetting.php";
61 $this->settings = new ilSetting("auth_mode_determination");
62 $this->read();
63 }
64
72 public static function _getInstance()
73 {
74 if(self::$instance)
75 {
76 return self::$instance;
77 }
78 return self::$instance = new ilAuthModeDetermination();
79 }
80
89 public function isManualSelection()
90 {
91 return $this->kind == self::TYPE_MANUAL;
92 }
93
100 public function getKind()
101 {
102 return $this->kind;
103 }
104
112 public function setKind($a_kind)
113 {
114 $this->kind = $a_kind;
115 }
116
123 public function getAuthModeSequence()
124 {
125 return $this->position ? $this->position : array();
126 }
127
134 public function getCountActiveAuthModes()
135 {
136 return count($this->position);
137 }
138
146 public function setAuthModeSequence($a_pos)
147 {
148 $this->position = $a_pos;
149 }
150
158 public function save()
159 {
160 $this->settings->deleteAll();
161
162 $this->settings->set('kind',$this->getKind());
163
164 $counter = 0;
165 foreach($this->position as $auth_mode)
166 {
167 $this->settings->set((string) $counter++,$auth_mode);
168 }
169 }
170
171
179 private function read()
180 {
181 global $ilSetting;
182
183 $this->kind = $this->settings->get('kind',self::TYPE_MANUAL);
184
185 include_once('Services/LDAP/classes/class.ilLDAPServer.php');
187
188 include_once('Services/Radius/classes/class.ilRadiusSettings.php');
189 $rad_settings = ilRadiusSettings::_getInstance();
190 $rad_active = $rad_settings->isActive();
191
192 $soap_active = $ilSetting->get('soap_auth_active',false);
193
194 // apache settings
195 $apache_settings = new ilSetting('apache_auth');
196 $apache_active = $apache_settings->get('apache_enable_auth');
197
198 // Check if active
199 for($i = 0; $i < 5; $i++)
200 {
201 if($auth_mode = $this->settings->get((string) $i,0))
202 {
203 switch($auth_mode)
204 {
205 case AUTH_LOCAL:
206 $this->position[] = $auth_mode;
207 break;
208
209 case AUTH_LDAP:
210 if($ldap_active)
211 {
212 $this->position[] = $auth_mode;
213 }
214 break;
215
216 case AUTH_RADIUS:
217 if($rad_active)
218 {
219 $this->position[] = $auth_mode;
220 }
221 break;
222
223 case AUTH_SOAP:
224 if($soap_active)
225 {
226 $this->position[] = $auth_mode;
227 }
228 break;
229
230 case AUTH_APACHE:
231 if($apache_active)
232 {
233 $this->position[] = $auth_mode;
234 }
235 break;
236
237 // begin-patch auth_plugin
238 default:
239 foreach(ilAuthUtils::getAuthPlugins() as $pl)
240 {
241 if($pl->isAuthActive($auth_mode))
242 {
243 $this->position[] = $auth_mode;
244 }
245 }
246 break;
247 // end-patch auth_plugin
248
249 }
250 }
251 }
252
253 // Append missing active auth modes
254 if(!in_array(AUTH_LOCAL,$this->position))
255 {
256 $this->position[] = AUTH_LOCAL;
257 }
258 if($ldap_active)
259 {
260 if(!in_array(AUTH_LDAP,$this->position))
261 {
262 $this->position[] = AUTH_LDAP;
263 }
264 }
265 if($rad_active)
266 {
267 if(!in_array(AUTH_RADIUS,$this->position))
268 {
269 $this->position[] = AUTH_RADIUS;
270 }
271
272 }
273 if($soap_active)
274 {
275 if(!in_array(AUTH_SOAP,$this->position))
276 {
277 $this->position[] = AUTH_SOAP;
278 }
279 }
280 if($apache_active)
281 {
282 if(!in_array(AUTH_APACHE,$this->position))
283 {
284 $this->position[] = AUTH_APACHE;
285 }
286 }
287 // begin-patch auth_plugin
288 foreach(ilAuthUtils::getAuthPlugins() as $pl)
289 {
290 foreach($pl->getAuthIds() as $auth_id)
291 {
292 if($pl->isAuthActive($auth_id))
293 {
294 if(!in_array($auth_id, $this->position))
295 {
296 $this->position[] = $auth_id;
297 }
298 }
299 }
300 }
301 // end-patch auth_plugin
302 }
303}
304
305
306?>
const AUTH_APACHE
const AUTH_LDAP
const AUTH_LOCAL
const AUTH_RADIUS
const AUTH_SOAP
getCountActiveAuthModes()
get number of auth modes
__construct()
Constructor (Singleton)
getAuthModeSequence()
get auth mode sequence
setKind($a_kind)
set kind of determination
setAuthModeSequence($a_pos)
set auth mode sequence
static getAuthPlugins()
Get active enabled auth plugins.
static _getFirstActiveServer()
Get first active server.
static _getInstance()
singleton get instance
ILIAS Setting Class.
global $ilSetting
Definition: privfeed.php:40
global $ilDB