ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilSoapAuthentication.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 
33 include_once 'Auth/Auth.php';
34 include_once './Services/Authentication/classes/class.ilBaseAuthentication.php';
35 
37 {
38  var $soap_check = true;
39 
40 
44  public function __construct()
45  {
46  // First unset all cookie inforamtions
47  unset($_COOKIE['PHPSESSID']);
48 
49  parent::__construct();
50  $this->__setMessageCode('Client');
51  }
52 
53  function disableSoapCheck()
54  {
55  $this->soap_check = false;
56  }
57 
58  function authenticate()
59  {
60  if(!$this->getClient())
61  {
62  $this->__setMessage('No client given');
63  return false;
64  }
65  if(!$this->getUsername())
66  {
67  $this->__setMessage('No username given');
68  return false;
69  }
70  // Read ilias ini
71  if(!$this->__buildDSN())
72  {
73  $this->__setMessage('Error building dsn/Wrong client Id?');
74  return false;
75  }
76  if(!$this->__setSessionSaveHandler())
77  {
78  return false;
79  }
80  if(!$this->__checkAgreement('local'))
81  {
82  return false;
83  }
84  if(!$this->__buildAuth())
85  {
86  return false;
87  }
88  if($this->soap_check and !$this->__checkSOAPEnabled())
89  {
90  $this->__setMessage('SOAP is not enabled in ILIAS administration for this client');
91  $this->__setMessageCode('Server');
92 
93  return false;
94  }
95 
96 
97  $this->auth->start();
98 
99  if(!$this->auth->getAuth())
100  {
101  $this->__getAuthStatus();
102 
103  return false;
104  }
105 
106  $this->setSid(session_id());
107 
108  return true;
109  }
110 
118  protected function __checkAgreement($a_auth_mode)
119  {
120  include_once('./Services/User/classes/class.ilObjUser.php');
121  include_once('./Services/Administration/classes/class.ilSetting.php');
122 
123  $GLOBALS['ilSetting'] = new ilSetting();
124 
125  if(!$login = ilObjUser::_checkExternalAuthAccount($a_auth_mode,$this->getUsername()))
126  {
127  return true;
128  }
129 
130  if(ilObjUser::hasUserToAcceptTermsOfService($login))
131  {
132  $this->__setMessage('User agreement no accepted.');
133  return false;
134  }
135 
136  return true;
137  }
138 
139 
140 
141  function validateSession()
142  {
143  if(!$this->getClient())
144  {
145  $this->__setMessage('No client given');
146  return false;
147  }
148  if(!$this->getSid())
149  {
150  $this->__setMessage('No session id given');
151  return false;
152  }
153 
154  if(!$this->__buildDSN())
155  {
156  $this->__setMessage('Error building dsn');
157  return false;
158  }
159  if(!$this->__checkClientEnabled())
160  {
161  $this->__setMessage('Client disabled.');
162  return false;
163  }
164 
165  if(!$this->__setSessionSaveHandler())
166  {
167  return false;
168  }
169  if(!$this->__buildAuth())
170  {
171  return false;
172  }
173  if($this->soap_check and !$this->__checkSOAPEnabled())
174  {
175  $this->__setMessage('SOAP is not enabled in ILIAS administration for this client');
176  $this->__setMessageCode('Server');
177 
178  return false;
179  }
180  $this->auth->start();
181  if(!$this->auth->getAuth())
182  {
183  $this->__setMessage('Session not valid');
184 
185  return false;
186  }
187 
188  return true;
189  }
190 
191  // PRIVATE
193  {
194  include_once './Services/Database/classes/MDB2/class.ilDB.php';
195 
196  //$db = new ilDB($this->dsn);
197  $ilDB = $this->db;
198  $ilDB->connect();
199 
200  $GLOBALS["ilDB"] = $ilDB;
201  include_once './Services/Administration/classes/class.ilSetting.php';
202  $set = new ilSetting();
203  return ($set->get("soap_user_administration") == 1);
204 
205  /*$query = "SELECT * FROM set tings WHERE keyword = 'soap_user_administration' AND value = 1";
206 
207  $res = $db->query($query);
208 
209  return $res->numRows() ? true : false;*/
210  }
211 
213  {
214  if(is_object($this->ini) and $this->ini->readVariable('client','access'))
215  {
216  return true;
217  }
218  return false;
219  }
220 }
221 ?>
ILIAS Setting Class.
__checkAgreement($a_auth_mode)
Check if user agreement is accepted.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static _checkExternalAuthAccount($a_auth, $a_account)
check whether external account and authentication method matches with a user
global $ilDB
$_COOKIE['ilClientId']
Definition: BPMN2Parser.php:15