ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilAuthContainerMultiple.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
24include_once 'Auth/Container.php';
25
26include_once './Services/Authentication/classes/class.ilAuthUtils.php';
27include_once './Services/Authentication/classes/class.ilAuthModeDetermination.php';
28
29
38{
39 protected $current_container = null;
40
45 public function __construct()
46 {
47 parent::__construct();
48
49 include_once './Services/Database/classes/class.ilAuthContainerMDB2.php';
50 $this->current_container = new ilAuthContainerMDB2();
51 }
52
56 public function failedLoginObserver($a_username, $a_auth)
57 {
58 $this->log('Auth_Container_Multiple: All containers rejected user credentials.', AUTH_LOG_DEBUG);
59 return false;
60 }
61
65 public function loginObserver($a_username, $a_auth)
66 {
67 $this->log('Container Multiple: loginObserver'.get_class($this->current_container),AUTH_LOG_DEBUG);
68 // Forward to current container
69 if($this->current_container instanceof Auth_Container)
70 {
71 $this->log('Container Multiple: Forwarding to '.get_class($this->current_container),AUTH_LOG_DEBUG);
72 return $this->current_container->loginObserver($a_username, $a_auth);
73 }
74 return false;
75 }
76
80 public function checkAuthObserver($a_username, $a_auth)
81 {
82 $this->log('Container Multiple: checkAuthObserver',AUTH_LOG_DEBUG);
83 // Forward to current container
84 if($this->current_container instanceof Auth_Container)
85 {
86 $this->log('Container Multiple: Forwarding to '.get_class($this->current_container),AUTH_LOG_DEBUG);
87 return $this->current_container->checkAuthObserver($a_username, $a_auth);
88 }
89 return false;
90 }
91
92
93 public function fetchData($user,$pass)
94 {
95 foreach(ilAuthModeDetermination::_getInstance()->getAuthModeSequence() as $auth_mode)
96 {
97 if ($_REQUEST['force_mode_apache'])
98 {
99 $this->log('Container Apache: Trying new container',AUTH_LOG_DEBUG);
100 include_once './Services/AuthApache/classes/class.ilAuthContainerApache.php';
101 $this->current_container = new ilAuthContainerApache();
102
103 $auth = new ilAuthApache($this->current_container);
104 }
105 else
106 {
107 switch($auth_mode)
108 {
109 case AUTH_LDAP:
110 $this->log('Container LDAP: Trying new container',AUTH_LOG_DEBUG);
111 include_once './Services/LDAP/classes/class.ilAuthContainerLDAP.php';
112 $this->current_container = new ilAuthContainerLDAP();
113 break;
114
115 case AUTH_LOCAL:
116 $this->log('Container MDB2: Trying new container',AUTH_LOG_DEBUG);
117 include_once './Services/Database/classes/class.ilAuthContainerMDB2.php';
118 $this->current_container = new ilAuthContainerMDB2();
119 break;
120
121 case AUTH_SOAP:
122 $this->log('Container SOAP: Trying new container',AUTH_LOG_DEBUG);
123 include_once './Services/SOAPAuth/classes/class.ilAuthContainerSOAP.php';
124 $this->current_container = new ilAuthContainerSOAP();
125 break;
126
127 case AUTH_RADIUS:
128 $this->log('Container Radius: Trying new container',AUTH_LOG_DEBUG);
129 include_once './Services/Radius/classes/class.ilAuthContainerRadius.php';
130 $this->current_container = new ilAuthContainerRadius();
131 break;
132
133 // begin-patch auth_plugin
134 default:
135 $this->log('Container Plugin: Trying new container',AUTH_LOG_DEBUG);
136 foreach(ilAuthUtils::getAuthPlugins() as $pl)
137 {
138 $container = $pl->getContainer($auth_mode);
139 if($container instanceof Auth_Container)
140 {
141 $this->current_container = $container;
142 break;
143 }
144 }
145 break;
146 // end-patch auth_plugin
147
148 }
149 }
150 $this->current_container->_auth_obj = $this->_auth_obj;
151
152 $result = $this->current_container->fetchData($user, $pass);
153
155 {
156 $this->log('Container '.$key.': '.$result->getMessage(), AUTH_LOG_ERR);
157 // Do not return here, otherwise wrong configured auth modes might block ilias database authentication
158 }
159 elseif ($result == true)
160 {
161 $this->log('Container '.$key.': Authentication successful.', AUTH_LOG_DEBUG);
162 return true;
163 }
164 else
165 {
166 $this->log('Container '.$key.': Authentication failed.', AUTH_LOG_DEBUG);
167 }
168 }
169 return false;
170 }
171
176 {
177 return true;
178 }
179}
180?>
const AUTH_LOG_DEBUG
Auth Log level - DEBUG.
Definition: Auth.php:59
$result
$_auth_obj
The Auth object this container is attached to.
Definition: Container.php:56
log($message, $level=AUTH_LOG_DEBUG)
Log a message to the Auth log.
Definition: Container.php:246
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:279
const AUTH_LDAP
const AUTH_LOCAL
const AUTH_RADIUS
const AUTH_SOAP
@classDescription Apache based authentication
Authentication against ILIAS database.
Overwritten Pear class AuthContainerLDAP This class is overwritten to support nested groups.
Authentication against ILIAS database.
failedLoginObserver($a_username, $a_auth)
@classDescription Overwritten Pear class AuthContainerRadius This class is overwritten to support to ...
@classDescription Authentication against external SOAP server
static getAuthPlugins()
Get active enabled auth plugins.
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7