25 define(
'AUTH_IDLED', -1);
26 define(
'AUTH_EXPIRED', -2);
27 define(
'AUTH_WRONG_LOGIN', -3);
96 function ShibAuth($authParams, $updateUserData =
false)
98 $this->updateUserData = $updateUserData;
100 if (!empty($authParams[
'sessionName'])) {
101 $this->_sessionName = $authParams[
'sessionName'];
102 unset($authParams[
'sessionName']);
116 if (!empty($session) &&
117 (isset($session[$this->_sessionName][
'registered']) &&
118 $session[$this->_sessionName][
'registered'] ===
true))
136 $this->idle += $time;
154 $this->expire += $time;
156 $this->expire = $time;
170 if (isset($session[$this->_sessionName])) {
172 if ($this->expire > 0 &&
173 isset($session[$this->_sessionName][
'timestamp']) &&
174 ($session[$this->_sessionName][
'timestamp'] + $this->expire) < time()) {
177 $this->expired =
true;
184 if ($this->idle > 0 &&
185 isset($session[$this->_sessionName][
'idle']) &&
186 ($session[$this->_sessionName][
'idle'] + $this->idle) < time()) {
195 if (isset($session[$this->_sessionName][
'registered']) &&
196 isset($session[$this->_sessionName][
'username']) &&
197 $session[$this->_sessionName][
'registered'] ==
true &&
198 $session[$this->_sessionName][
'username'] !=
'') {
233 global $ilias, $rbacadmin;
235 if (!empty($_SERVER[$ilias->getSetting(
'shib_login')]))
253 $newUser[
"firstname"] = $this->
getFirstString($_SERVER[$ilias->getSetting(
'shib_firstname')]);
254 $newUser[
"lastname"] = $this->
getFirstString($_SERVER[$ilias->getSetting(
'shib_lastname')]);
262 $ilias->getSetting(
'shib_update_gender')
263 && ($_SERVER[$ilias->getSetting(
'shib_gender')] ==
'm'
264 || $_SERVER[$ilias->getSetting(
'shib_gender')] ==
'f')
267 $newUser[
"gender"] = $_SERVER[$ilias->getSetting(
'shib_gender')];
271 $newUser[
"ext_account"] = $_SERVER[$ilias->getSetting(
'shib_login')];
274 $newUser[
"title"] = $_SERVER[$ilias->getSetting(
'shib_title')];
275 $newUser[
"institution"] = $_SERVER[$ilias->getSetting(
'shib_institution')];
276 $newUser[
"department"] = $_SERVER[$ilias->getSetting(
'shib_department')];
277 $newUser[
"street"] = $_SERVER[$ilias->getSetting(
'shib_street')];
278 $newUser[
"city"] = $_SERVER[$ilias->getSetting(
'shib_city')];
279 $newUser[
"zipcode"] = $_SERVER[$ilias->getSetting(
'shib_zipcode')];
280 $newUser[
"country"] = $_SERVER[$ilias->getSetting(
'shib_country')];
281 $newUser[
"phone_office"] = $this->
getFirstString($_SERVER[$ilias->getSetting(
'shib_phone_office')]);
282 $newUser[
"phone_home"] = $this->
getFirstString($_SERVER[$ilias->getSetting(
'shib_phone_home')]);
283 $newUser[
"phone_mobile"] = $this->
getFirstString($_SERVER[$ilias->getSetting(
'shib_phone_mobile')]);
284 $newUser[
"fax"] = $this->
getFirstString($_SERVER[$ilias->getSetting(
'shib_fax')]);
285 $newUser[
"matriculation"] = $_SERVER[$ilias->getSetting(
'shib_matriculation')];
286 $newUser[
"email"] = $this->
getFirstString($_SERVER[$ilias->getSetting(
'shib_email')]);
287 $newUser[
"hobby"] = $_SERVER[$ilias->getSetting(
'shib_hobby')];
288 $newUser[
"auth_mode"] =
"shibboleth";
292 $userObj->assignData($newUser);
293 $userObj->setTitle($userObj->getFullname());
294 $userObj->setDescription($userObj->getEmail());
295 $userObj->setLanguage($this->
getFirstString($_SERVER[$ilias->getSetting(
'shib_language')]));
298 $userObj->setTimeLimitOwner(7);
299 $userObj->setTimeLimitUnlimited(1);
300 $userObj->setTimeLimitFrom(time());
301 $userObj->setTimeLimitUntil(time());
306 if ( $ilias->getSetting(
'shib_data_conv')
307 && $ilias->getSetting(
'shib_data_conv') !=
''
308 && is_readable($ilias->getSetting(
'shib_data_conv'))
311 include($ilias->getSetting(
'shib_data_conv'));
316 $userObj->setActive(1, 6);
318 $userObj->updateOwner();
321 $userObj->saveAsNew();
327 $userObj->writePrefs();
330 $rbacadmin->assignUser($ilias->getSetting(
'shib_user_default_role'), $userObj->getId(),
true);
338 $userObj->checkUserId();
342 $ilias->getSetting(
'shib_update_gender')
343 && ($_SERVER[$ilias->getSetting(
'shib_gender')] ==
'm'
344 || $_SERVER[$ilias->getSetting(
'shib_gender')] ==
'f')
346 $userObj->setGender($_SERVER[$ilias->getSetting(
'shib_gender')]);
348 if ($ilias->getSetting(
'shib_update_title'))
349 $userObj->setTitle($_SERVER[$ilias->getSetting(
'shib_title')]);
351 $userObj->setFirstname($this->
getFirstString($_SERVER[$ilias->getSetting(
'shib_firstname')]));
352 $userObj->setLastname($this->
getFirstString($_SERVER[$ilias->getSetting(
'shib_lastname')]));
353 $userObj->setFullname();
354 if ($ilias->getSetting(
'shib_update_institution'))
355 $userObj->setInstitution($_SERVER[$ilias->getSetting(
'shib_institution')]);
356 if ($ilias->getSetting(
'shib_update_department'))
357 $userObj->setDepartment($_SERVER[$ilias->getSetting(
'shib_department')]);
358 if ($ilias->getSetting(
'shib_update_street'))
359 $userObj->setStreet($_SERVER[$ilias->getSetting(
'shib_street')]);
360 if ($ilias->getSetting(
'shib_update_city'))
361 $userObj->setCity($_SERVER[$ilias->getSetting(
'shib_city')]);
362 if ($ilias->getSetting(
'shib_update_zipcode'))
363 $userObj->setZipcode($_SERVER[$ilias->getSetting(
'shib_zipcode')]);
364 if ($ilias->getSetting(
'shib_update_country'))
365 $userObj->setCountry($_SERVER[$ilias->getSetting(
'shib_country')]);
366 if ($ilias->getSetting(
'shib_update_phone_office'))
367 $userObj->setPhoneOffice($this->getFirstString($_SERVER[$ilias->getSetting(
'shib_phone_office')]));
368 if ($ilias->getSetting(
'shib_update_phone_home'))
369 $userObj->setPhoneHome($this->getFirstString($_SERVER[$ilias->getSetting(
'shib_phone_home')]));
370 if ($ilias->getSetting(
'shib_update_phone_mobile'))
371 $userObj->setPhoneMobile($this->getFirstString($_SERVER[$ilias->getSetting(
'shib_phone_mobile')]));
372 if ($ilias->getSetting(
'shib_update_fax'))
373 $userObj->setFax($_SERVER[$ilias->getSetting(
'shib_fax')]);
374 if ($ilias->getSetting(
'shib_update_matriculation'))
375 $userObj->setMatriculation($_SERVER[$ilias->getSetting(
'shib_matriculation')]);
376 if ($ilias->getSetting(
'shib_update_email'))
377 $userObj->setEmail($this->getFirstString($_SERVER[$ilias->getSetting(
'shib_email')]));
378 if ($ilias->getSetting(
'shib_update_hobby'))
379 $userObj->setHobby($_SERVER[$ilias->getSetting(
'shib_hobby')]);
381 if ($ilias->getSetting(
'shib_update_language'))
382 $userObj->setLanguage($_SERVER[$ilias->getSetting(
'shib_language')]);
386 if ( $ilias->getSetting(
'shib_data_conv')
387 && $ilias->getSetting(
'shib_data_conv') !=
''
388 && is_readable($ilias->getSetting(
'shib_data_conv'))
391 include($ilias->getSetting(
'shib_data_conv'));
400 if (
$_GET[
"target"] !=
"")
424 if (!isset($session[$this->_sessionName]) && !isset(
$_SESSION)) {
425 session_register($this->_sessionName);
428 if (!isset($session[$this->_sessionName]) || !is_array($session[$this->_sessionName])) {
432 if(!isset($session[$this->_sessionName][
'data'])){
456 $this->username =
'';
460 unset($session[$this->_sessionName]);
462 session_unregister($this->_sessionName);
475 if (!isset($session[$this->_sessionName][
'username'])) {
504 switch (strtolower($variable)) {
507 if (isset($_SERVER)) {
510 $var = &
$GLOBALS[
'HTTP_SERVER_VARS'];
518 $var = &
$GLOBALS[
'HTTP_SESSION_VARS'];
534 $var = &
$GLOBALS[
'HTTP_COOKIE_VARS'];
563 global $ilias, $ilDB;
565 $shibID = $_SERVER[$ilias->getSetting(
'shib_login')];
566 $lastname = $this->
getFirstString($_SERVER[$ilias->getSetting(
'shib_lastname')]);
567 $firstname = $this->
getFirstString($_SERVER[$ilias->getSetting(
'shib_firstname')]);
569 if (trim($shibID) ==
"")
578 $ilias->db->query(
"UPDATE usr_data SET auth_mode='shibboleth', passwd=".$ilDB->quote(md5(end(
ilUtil::generatePasswords(1)))).
", ext_account=".$ilDB->quote($shibID).
" WHERE passwd=".$ilDB->quote($shibID));
599 $ln_arr=preg_split(
"/[ '-;]/", $lastname);
600 $login=substr($this->
toAscii($firstname),0,1) .
"." . $this->
toAscii($ln_arr[0]);
601 if (strlen($login) < 6) $login .= $this->
toAscii($ln_arr[1]);
602 $prefix = strtolower($login);
606 if (strlen($prefix) == 0) {
607 $prefix =
'shibboleth';
628 return $prefix.$number;
640 $list = split(
';', $string);
641 $clean_string = rtrim($list[0]);
643 return $clean_string;
655 require_once(
'include/Unicode/UtfNormal.php');
663 $string = preg_replace(
'/([aouAOU])\\xcc\\x88/',
'\\1e', $string);
666 $string = preg_replace(
'/\\xc3\\x86/',
'AE', $string);
667 $string = preg_replace(
'/\\xc3\\xa6/',
'ae', $string);
670 $string = preg_replace(
'/\\xc3\\x9e/',
'TH', $string);
671 $string = preg_replace(
'/\\xc3\\xbe/',
'th', $string);
674 $string = preg_replace(
'/\\xc3\\x90/',
'D', $string);
675 $string = preg_replace(
'/\\xc4\\x91/',
'd', $string);
676 $string = preg_replace(
'/\\xc4\\x90/',
'D', $string);
679 $string = preg_replace(
'/\\xc3\\x9f/',
'ss', $string);
682 $string = preg_replace(
'/[^a-zA-Z\-]/i',
'', $string);