ILIAS  release_4-4 Revision
ilSoapAuthenticationCAS Class Reference
+ Inheritance diagram for ilSoapAuthenticationCAS:
+ Collaboration diagram for ilSoapAuthenticationCAS:

Public Member Functions

 ilSoapAuthenticationCAS ()
 
 setPT ($a_pt)
 
 getPT ()
 
 authenticate ()
 
 validateSession ()
 
 __buildAuth ()
 

Detailed Description

Definition at line 36 of file class.ilSoapAuthenticationCAS.php.

Member Function Documentation

◆ __buildAuth()

ilSoapAuthenticationCAS::__buildAuth ( )

Definition at line 235 of file class.ilSoapAuthenticationCAS.php.

References $GLOBALS, CAS_VERSION_2_0, ilDBWrapperFactory\getWrapper(), and phpCAS\setFixedServiceURL().

Referenced by authenticate(), and validateSession().

236  {
237 
238  if (!is_object($this->db))
239  {
240  require_once("./Services/Database/classes/class.ilDBWrapperFactory.php");
242  $ilDB->initFromIniFile();
243  $ilDB->connect();
244  $this->db = $ilDB;
245  }
246 
247  $GLOBALS["ilDB"] = $this->db;
248  $this->init->initSettings();
249 
250  $this->init->buildHTTPPath();
251  include_once './Services/Administration/classes/class.ilSetting.php';
252  $set = new ilSetting();
253 
254  /*$query = "SELECT * FROM sett ings WHERE ".
255  " keyword = ".$this->db->quote("cas_server")." OR ".
256  " keyword = ".$this->db->quote("cas_port")." OR ".
257  " keyword = ".$this->db->quote("cas_uri");
258  $res = $this->db->query($query);
259  $cas_set = array();
260  while ($rec = $res->fetchRow(DB_FETCHMODE_ASSOC))
261  {
262  $cas_set[$rec["keyword"]] = $rec["value"];
263  }*/
264  $cas_set["cas_server"] = $set->get("cas_server");
265  $cas_set["cas_port"] = $set->get("cas_port");
266  $cas_set["cas_uri"] = $set->get("cas_uri");
267 
268  $auth_params = array(
269  "server_version" => CAS_VERSION_2_0,
270  "server_hostname" => $cas_set["cas_server"],
271  "server_port" => $cas_set["cas_port"],
272  "server_uri" => $cas_set["cas_uri"]);
273 
274  include_once("Services/CAS/classes/class.ilCASAuth.php");
275  $this->auth = new ilCASAuth($auth_params);
276 
277  // HTTP path will return full path to server.php directory
278  phpCAS::setFixedServiceURL(ILIAS_HTTP_PATH."/webservice/soap/server.php");
279 
280  return true;
281  }
ILIAS Setting Class.
Class CASAuth.
setFixedServiceURL($url)
Set the fixed URL that will be set as the CAS service parameter.
Definition: CAS.php:1374
$GLOBALS['ct_recipient']
static getWrapper($a_type, $a_inactive_mysqli=null)
const CAS_VERSION_2_0
Definition: CAS.php:81
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ authenticate()

ilSoapAuthenticationCAS::authenticate ( )

Definition at line 89 of file class.ilSoapAuthenticationCAS.php.

References __buildAuth(), ilObjUser\_checkExternalAuthAccount(), and phpCAS\checkAuthentication().

90  {
91  include_once("./Services/Init/classes/class.ilInitialisation.php");
92  $this->init = new ilInitialisation();
93  $this->init->requireCommonIncludes();
94  //$init->initSettings();
95 
96 
97  if(!$this->getClient())
98  {
99  $this->__setMessage('No client given');
100  return false;
101  }
102 
103  if(!$this->getUsername())
104  {
105  $this->__setMessage('No username given');
106  return false;
107  }
108  // Read ilias ini
109  if(!$this->__buildDSN())
110  {
111  $this->__setMessage('Error building dsn/Wrong client Id?');
112  return false;
113  }
114 
115  if(!$this->__setSessionSaveHandler())
116  {
117  return false;
118  }
119  if(!$this->__checkAgreement('cas'))
120  {
121  return false;
122  }
123 
124  if(!$this->__buildAuth())
125  {
126  return false;
127  }
128 
129  if($this->soap_check and !$this->__checkSOAPEnabled())
130  {
131  $this->__setMessage('SOAP is not enabled in ILIAS administration for this client');
132  $this->__setMessageCode('Server');
133 
134  return false;
135  }
136 
137  // check whether authentication is valid
138  //if (!$this->auth->checkCASAuth())
140  {
141  $this->__setMessage('ilSOAPAuthenticationCAS::authenticate(): No valid CAS authentication.');
142  return false;
143  }
144 
145  $this->auth->forceCASAuth();
146 
147  if ($this->getUsername() != $this->auth->getCASUser())
148  {
149  $this->__setMessage('ilSOAPAuthenticationCAS::authenticate(): SOAP CAS user does not match to ticket user.');
150  return false;
151  }
152 
153  include_once('./Services/User/classes/class.ilObjUser.php');
154  $local_user = ilObjUser::_checkExternalAuthAccount("cas", $this->auth->getCASUser());
155  if ($local_user == "")
156  {
157  $this->__setMessage('ilSOAPAuthenticationCAS::authenticate(): SOAP CAS user authenticated but not existing in ILIAS user database.');
158  return false;
159  }
160 
161  /*
162  $init->initIliasIniFile();
163  $init->initSettings();
164  $ilias =& new ILIAS();
165  $GLOBALS['ilias'] =& $ilias;*/
166 
167  $this->auth->start();
168 
169  if(!$this->auth->getAuth())
170  {
171  $this->__getAuthStatus();
172 
173  return false;
174  }
175 
176  $this->setSid(session_id());
177 
178  return true;
179  }
checkAuthentication()
This method is called to check if the user is authenticated (use the gateway feature).
Definition: CAS.php:933
ILIAS Initialisation Utility Class perform basic setup: init database handler, load configuration fil...
static _checkExternalAuthAccount($a_auth, $a_account)
check whether external account and authentication method matches with a user
+ Here is the call graph for this function:

◆ getPT()

ilSoapAuthenticationCAS::getPT ( )

Definition at line 84 of file class.ilSoapAuthenticationCAS.php.

85  {
86  return $this->pt;
87  }

◆ ilSoapAuthenticationCAS()

ilSoapAuthenticationCAS::ilSoapAuthenticationCAS ( )

Definition at line 38 of file class.ilSoapAuthenticationCAS.php.

39  {
40  parent::ilSOAPAuthentication();
41  }

◆ setPT()

ilSoapAuthenticationCAS::setPT (   $a_pt)

Definition at line 79 of file class.ilSoapAuthenticationCAS.php.

References $_GET.

80  {
81  $this->pt = $a_pt;
82  $_GET['ticket'] = $a_pt;
83  }
$_GET["client_id"]

◆ validateSession()

ilSoapAuthenticationCAS::validateSession ( )

Definition at line 182 of file class.ilSoapAuthenticationCAS.php.

References __buildAuth().

183  {
184  if(!$this->getClient())
185  {
186  $this->__setMessage('No client given');
187  return false;
188  }
189  if(!$this->getSid())
190  {
191  $this->__setMessage('No session id given');
192  return false;
193  }
194 
195  if(!$this->__buildDSN())
196  {
197  $this->__setMessage('Error building dsn');
198  return false;
199  }
200  if(!$this->__setSessionSaveHandler())
201  {
202  return false;
203  }
204  if(!$this->__buildAuth())
205  {
206  return false;
207  }
208  if($this->soap_check and !$this->__checkSOAPEnabled())
209  {
210  $this->__setMessage('SOAP is not enabled in ILIAS administration for this client');
211  $this->__setMessageCode('Server');
212 
213  return false;
214  }
215 
216  // check whether authentication is valid
217  if (!$this->auth->checkCASAuth())
218  {
219  $this->__setMessage('ilSOAPAuthenticationCAS::authenticate(): No valid CAS authentication.');
220  return false;
221  }
222  $this->auth->forceCASAuth();
223 
224  $this->auth->start();
225  if(!$this->auth->getAuth())
226  {
227  $this->__setMessage('Session not valid');
228 
229  return false;
230  }
231 
232  return true;
233  }
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: