ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilSoapAuthenticationCAS Class Reference
+ Inheritance diagram for ilSoapAuthenticationCAS:
+ Collaboration diagram for ilSoapAuthenticationCAS:

Public Member Functions

 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 211 of file class.ilSoapAuthenticationCAS.php.

References $GLOBALS, $ilDB, CAS_VERSION_2_0, init(), and phpCAS\setFixedServiceURL().

Referenced by authenticate(), and validateSession().

212  {
213  if (!is_object($this->db)) {
214  require_once("./Services/Database/classes/class.ilDBWrapperFactory.php");
215  $ilDB = ilDBWrapperFactory::getWrapper();
216  $ilDB->initFromIniFile();
217  $ilDB->connect();
218  $this->db = $ilDB;
219  }
220 
221  $GLOBALS['DIC']["ilDB"] = $this->db;
222  $this->init->initSettings();
223 
224  $this->init->buildHTTPPath();
225  include_once './Services/Administration/classes/class.ilSetting.php';
226  $set = new ilSetting();
227 
228  /*$query = "SELECT * FROM sett ings WHERE ".
229  " keyword = ".$this->db->quote("cas_server")." OR ".
230  " keyword = ".$this->db->quote("cas_port")." OR ".
231  " keyword = ".$this->db->quote("cas_uri");
232  $res = $this->db->query($query);
233  $cas_set = array();
234  while ($rec = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC))
235  {
236  $cas_set[$rec["keyword"]] = $rec["value"];
237  }*/
238  $cas_set["cas_server"] = $set->get("cas_server");
239  $cas_set["cas_port"] = $set->get("cas_port");
240  $cas_set["cas_uri"] = $set->get("cas_uri");
241 
242  $auth_params = array(
243  "server_version" => CAS_VERSION_2_0,
244  "server_hostname" => $cas_set["cas_server"],
245  "server_port" => $cas_set["cas_port"],
246  "server_uri" => $cas_set["cas_uri"]);
247 
248  include_once("Services/CAS/classes/class.ilCASAuth.php");
249  $this->auth = new ilCASAuth($auth_params);
250 
251  // HTTP path will return full path to server.php directory
252  phpCAS::setFixedServiceURL(ILIAS_HTTP_PATH . "/webservice/soap/server.php");
253 
254  return true;
255  }
Class CASAuth.
const CAS_VERSION_2_0
Definition: CAS.php:78
static setFixedServiceURL($url)
Set the fixed URL that will be set as the CAS service parameter.
Definition: CAS.php:1590
global $ilDB
while(count($oldTaskList) > 0) foreach(array_keys($newTaskList) as $task) init()
Definition: build.php:77
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ authenticate()

ilSoapAuthenticationCAS::authenticate ( )

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

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

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

◆ getPT()

ilSoapAuthenticationCAS::getPT ( )

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

80  {
81  return $this->pt;
82  }

◆ setPT()

ilSoapAuthenticationCAS::setPT (   $a_pt)

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

References $_GET.

75  {
76  $this->pt = $a_pt;
77  $_GET['ticket'] = $a_pt;
78  }
$_GET["client_id"]

◆ validateSession()

ilSoapAuthenticationCAS::validateSession ( )

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

References __buildAuth().

167  {
168  if (!$this->getClient()) {
169  $this->__setMessage('No client given');
170  return false;
171  }
172  if (!$this->getSid()) {
173  $this->__setMessage('No session id given');
174  return false;
175  }
176 
177  if (!$this->__buildDSN()) {
178  $this->__setMessage('Error building dsn');
179  return false;
180  }
181  if (!$this->__setSessionSaveHandler()) {
182  return false;
183  }
184  if (!$this->__buildAuth()) {
185  return false;
186  }
187  if ($this->soap_check and !$this->__checkSOAPEnabled()) {
188  $this->__setMessage('SOAP is not enabled in ILIAS administration for this client');
189  $this->__setMessageCode('Server');
190 
191  return false;
192  }
193 
194  // check whether authentication is valid
195  if (!$this->auth->checkCASAuth()) {
196  $this->__setMessage('ilSOAPAuthenticationCAS::authenticate(): No valid CAS authentication.');
197  return false;
198  }
199  $this->auth->forceCASAuth();
200 
201  $this->auth->start();
202  if (!$this->auth->getAuth()) {
203  $this->__setMessage('Session not valid');
204 
205  return false;
206  }
207 
208  return true;
209  }
+ Here is the call graph for this function:

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