ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
24 include_once 'Auth/Container.php';
25 
26 include_once './Services/Authentication/classes/class.ilAuthUtils.php';
27 include_once './Services/Authentication/classes/class.ilAuthModeDetermination.php';
28 
29 
38 {
39  protected $current_container = null;
40 
45  public function __construct()
46  {
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  }
60 
64  public function loginObserver($a_username, $a_auth)
65  {
66  $this->log('Container Multiple: loginObserver'.get_class($this->current_container),AUTH_LOG_DEBUG);
67  // Forward to current container
68  if($this->current_container instanceof Auth_Container)
69  {
70  $this->log('Container Multiple: Forwarding to '.get_class($this->current_container),AUTH_LOG_DEBUG);
71  return $this->current_container->loginObserver($a_username, $a_auth);
72  }
73  return false;
74  }
75 
79  public function checkAuthObserver($a_username, $a_auth)
80  {
81  $this->log('Container Multiple: checkAuthObserver',AUTH_LOG_DEBUG);
82  // Forward to current container
83  if($this->current_container instanceof Auth_Container)
84  {
85  $this->log('Container Multiple: Forwarding to '.get_class($this->current_container),AUTH_LOG_DEBUG);
86  return $this->current_container->checkAuthObserver($a_username, $a_auth);
87  }
88  return false;
89  }
90 
91 
92  public function fetchData($user,$pass)
93  {
94  foreach(ilAuthModeDetermination::_getInstance()->getAuthModeSequence() as $auth_mode)
95  {
96  switch($auth_mode)
97  {
98  case AUTH_LDAP:
99  $this->log('Container LDAP: Trying new container',AUTH_LOG_DEBUG);
100  include_once './Services/LDAP/classes/class.ilAuthContainerLDAP.php';
101  $this->current_container = new ilAuthContainerLDAP();
102  break;
103 
104  case AUTH_LOCAL:
105  $this->log('Container MDB2: Trying new container',AUTH_LOG_DEBUG);
106  include_once './Services/Database/classes/class.ilAuthContainerMDB2.php';
107  $this->current_container = new ilAuthContainerMDB2();
108  break;
109 
110  case AUTH_SOAP:
111  $this->log('Container SOAP: Trying new container',AUTH_LOG_DEBUG);
112  include_once './Services/SOAPAuth/classes/class.ilAuthContainerSOAP.php';
113  $this->current_container = new ilAuthContainerSOAP();
114  break;
115 
116  case AUTH_RADIUS:
117  $this->log('Container Radius: Trying new container',AUTH_LOG_DEBUG);
118  include_once './Services/Radius/classes/class.ilAuthContainerRadius.php';
119  $this->current_container = new ilAuthContainerRadius();
120  break;
121 
122 
123  }
124  $this->current_container->_auth_obj = $this->_auth_obj;
125 
126  $result = $this->current_container->fetchData($user, $pass);
127 
128  if (PEAR::isError($result))
129  {
130  $this->log('Container '.$key.': '.$result->getMessage(), AUTH_LOG_ERR);
131  // Do not return here, otherwise wrong configured auth modes might block ilias database authentication
132  }
133  elseif ($result == true)
134  {
135  $this->log('Container '.$key.': Authentication successful.', AUTH_LOG_DEBUG);
136  return true;
137  }
138  else
139  {
140  $this->log('Container '.$key.': Authentication failed.', AUTH_LOG_DEBUG);
141  }
142  }
143  return false;
144  }
145 }
146 ?>