Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00034 include_once './webservice/soap/classes/class.ilSoapAuthentication.php';
00035
00036 class ilSoapAuthenticationCAS extends ilSOAPAuthentication
00037 {
00038 function ilSoapAuthenticationCAS()
00039 {
00040 parent::ilSOAPAuthentication();
00041 }
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 function setPT($a_pt)
00080 {
00081 $this->pt = $a_pt;
00082 $_GET['ticket'] = $a_pt;
00083 }
00084 function getPT()
00085 {
00086 return $this->pt;
00087 }
00088
00089 function authenticate()
00090 {
00091 include_once("./Services/Init/classes/class.ilInitialisation.php");
00092 $this->init = new ilInitialisation();
00093 $this->init->requireCommonIncludes();
00094
00095
00096
00097 if(!$this->getClient())
00098 {
00099 $this->__setMessage('No client given');
00100 return false;
00101 }
00102
00103 if(!$this->getUsername())
00104 {
00105 $this->__setMessage('No username given');
00106 return false;
00107 }
00108
00109 if(!$this->__buildDSN())
00110 {
00111 $this->__setMessage('Error building dsn/Wrong client Id?');
00112 return false;
00113 }
00114
00115 if(!$this->__setSessionSaveHandler())
00116 {
00117 return false;
00118 }
00119 if(!$this->__checkAgreement('cas'))
00120 {
00121 return false;
00122 }
00123
00124 if(!$this->__buildAuth())
00125 {
00126 return false;
00127 }
00128
00129 if($this->soap_check and !$this->__checkSOAPEnabled())
00130 {
00131 $this->__setMessage('SOAP is not enabled in ILIAS administration for this client');
00132 $this->__setMessageCode('Server');
00133
00134 return false;
00135 }
00136
00137
00138
00139 if (!phpCAS::checkAuthentication())
00140 {
00141 $this->__setMessage('ilSOAPAuthenticationCAS::authenticate(): No valid CAS authentication.');
00142 return false;
00143 }
00144
00145 $this->auth->forceCASAuth();
00146
00147 if ($this->getUsername() != $this->auth->getCASUser())
00148 {
00149 $this->__setMessage('ilSOAPAuthenticationCAS::authenticate(): SOAP CAS user does not match to ticket user.');
00150 return false;
00151 }
00152
00153 include_once('./Services/User/classes/class.ilObjUser.php');
00154 $local_user = ilObjUser::_checkExternalAuthAccount("cas", $this->auth->getCASUser());
00155 if ($local_user == "")
00156 {
00157 $this->__setMessage('ilSOAPAuthenticationCAS::authenticate(): SOAP CAS user authenticated but not existing in ILIAS user database.');
00158 return false;
00159 }
00160
00161
00162
00163
00164
00165
00166
00167 $this->auth->start();
00168
00169 if(!$this->auth->getAuth())
00170 {
00171 $this->__getAuthStatus();
00172
00173 return false;
00174 }
00175
00176 $this->setSid(session_id());
00177
00178 return true;
00179 }
00180
00181
00182 function validateSession()
00183 {
00184 if(!$this->getClient())
00185 {
00186 $this->__setMessage('No client given');
00187 return false;
00188 }
00189 if(!$this->getSid())
00190 {
00191 $this->__setMessage('No session id given');
00192 return false;
00193 }
00194
00195 if(!$this->__buildDSN())
00196 {
00197 $this->__setMessage('Error building dsn');
00198 return false;
00199 }
00200 if(!$this->__setSessionSaveHandler())
00201 {
00202 return false;
00203 }
00204 if(!$this->__buildAuth())
00205 {
00206 return false;
00207 }
00208 if($this->soap_check and !$this->__checkSOAPEnabled())
00209 {
00210 $this->__setMessage('SOAP is not enabled in ILIAS administration for this client');
00211 $this->__setMessageCode('Server');
00212
00213 return false;
00214 }
00215
00216
00217 if (!$this->auth->checkCASAuth())
00218 {
00219 $this->__setMessage('ilSOAPAuthenticationCAS::authenticate(): No valid CAS authentication.');
00220 return false;
00221 }
00222 $this->auth->forceCASAuth();
00223
00224 $this->auth->start();
00225 if(!$this->auth->getAuth())
00226 {
00227 $this->__setMessage('Session not valid');
00228
00229 return false;
00230 }
00231
00232 return true;
00233 }
00234
00235 function __buildAuth()
00236 {
00237
00238 if (!is_object($this->db))
00239 {
00240 include_once './classes/class.ilDBx.php';
00241 $this->db =& new ilDBx($this->dsn);
00242 }
00243
00244 $GLOBALS["ilDB"] = $this->db;
00245 $this->init->initSettings();
00246
00247 $this->init->buildHTTPPath();
00248
00249 $query = "SELECT * FROM settings WHERE ".
00250 " keyword = ".$this->db->quote("cas_server")." OR ".
00251 " keyword = ".$this->db->quote("cas_port")." OR ".
00252 " keyword = ".$this->db->quote("cas_uri");
00253 $res = $this->db->query($query);
00254 $cas_set = array();
00255 while ($rec = $res->fetchRow(DB_FETCHMODE_ASSOC))
00256 {
00257 $cas_set[$rec["keyword"]] = $rec["value"];
00258 }
00259
00260 $auth_params = array(
00261 "server_version" => CAS_VERSION_2_0,
00262 "server_hostname" => $cas_set["cas_server"],
00263 "server_port" => $cas_set["cas_port"],
00264 "server_uri" => $cas_set["cas_uri"]);
00265
00266 include_once("Services/CAS/classes/class.ilCASAuth.php");
00267 $this->auth = new ilCASAuth($auth_params);
00268
00269
00270 phpCAS::setFixedServiceURL(ILIAS_HTTP_PATH."/webservice/soap/server.php");
00271
00272 return true;
00273 }
00274 }
00275 ?>