ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilShibboleth.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 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 require_once('Auth/Auth.php');
25 require_once('./Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentRules.php');
26 require_once('include/Unicode/UtfNormal.php');
27 require_once('./Services/AuthShibboleth/classes/class.ilShibbolethPluginWrapper.php');
28 require_once('./Services/AuthShibboleth/classes/Config/class.shibConfig.php');
29 require_once('./Services/AuthShibboleth/classes/ServerData/class.shibServerData.php');
30 require_once('./Services/AuthShibboleth/classes/User/class.shibUser.php');
31 
42 class ShibAuth extends Auth {
43 
44 // /**
45 // * @param $authParams
46 // * @param bool $updateUserData
47 // */
48 // public function __construct($authParams, $updateUserData = false) {
54 //
55 // parent::__construct($authParams, $updateUserData);
56 // $this->updateUserData = $updateUserData;
57 // if (! empty($authParams['sessionName'])) {
58 // $this->setSessionName($authParams['sessionName']);
59 // unset($authParams['sessionName']);
60 // }
61 // }
62 
63 
67  public function supportsRedirects() {
68  return true;
69  }
70 
71 
78  public function login() {
79  global $DIC; // for backword compatibility of hook environment variables
80  $ilias = $DIC['ilias'];
81  $ilSetting = $DIC['ilSetting'];
82  $shibServerData = shibServerData::getInstance();
83  if ($shibServerData->getLogin()) {
84  $shibUser = shibUser::buildInstance($shibServerData);
85  // for backword compatibility of hook environment variables
86  $userObj =& $shibUser; // For shib_data_conv included Script
87  $newUser = $shibUser->isNew(); // For shib_data_conv included Script
88  if ($shibUser->isNew()) {
89  $shibUser->createFields();
90  $shibUser->setPref('hits_per_page', $ilSetting->get('hits_per_page'));
91 
92  // Modify user data before creating the user
93  // Include custom code that can be used to further modify
94  // certain Shibboleth user attributes
95  if ($ilias->getSetting('shib_data_conv') AND $ilias->getSetting('shib_data_conv') != ''
96  AND is_readable($ilias->getSetting('shib_data_conv'))
97  ) {
98  include($ilias->getSetting('shib_data_conv'));
99  }
100  $shibUser = ilShibbolethPluginWrapper::getInstance()->beforeCreateUser($shibUser);
101  $shibUser->create();
102  $shibUser->updateOwner();
103  $shibUser->saveAsNew();
104  $shibUser->writePrefs();
105  $shibUser = ilShibbolethPluginWrapper::getInstance()->afterCreateUser($shibUser);
107  } else {
108  $shibUser->updateFields();
109  // Include custom code that can be used to further modify
110  // certain Shibboleth user attributes
111  if ($ilias->getSetting('shib_data_conv') AND $ilias->getSetting('shib_data_conv') != ''
112  AND is_readable($ilias->getSetting('shib_data_conv'))
113  ) {
114  include($ilias->getSetting('shib_data_conv'));
115  }
116  // $shibUser->update();
117  $shibUser = ilShibbolethPluginWrapper::getInstance()->beforeUpdateUser($shibUser);
118  $shibUser->update();
119  $shibUser = ilShibbolethPluginWrapper::getInstance()->afterUpdateUser($shibUser);
121  }
122  $this->setAuth($shibUser->getLogin(), $shibUser);
123  ilObjUser::_updateLastLogin($shibUser->getId());
124  if ($_GET['target'] != '') {
125  ilUtil::redirect('goto.php?target=' . $_GET['target'] . '&client_id=' . CLIENT_ID);
126  }
127  } else {
128  $this->status = AUTH_WRONG_LOGIN;
129  }
130  }
131 
132 
137  public function setAuth($username, ilObjUser $userObj = NULL) {
138  if ($userObj) {
139  ilShibbolethPluginWrapper::getInstance()->beforeLogin($userObj);
140  }
141  parent::setAuth($username);
142  if ($userObj) {
143  ilShibbolethPluginWrapper::getInstance()->afterLogin($userObj);
144  }
145  }
146 
147 
148  public function logout() {
149  global $DIC;
150  $ilUser = $DIC['ilUser'];
152  parent::logout();
154  }
155 }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
$_GET["client_id"]
$ilUser
Definition: imgupload.php:18
login()
Login function.
static buildInstance(shibServerData $shibServerData)
global $ilSetting
Definition: privfeed.php:17
setAuth($username, ilObjUser $userObj=NULL)
static _updateLastLogin($a_usr_id, $a_last_login=null)
STATIC METHOD updates the last_login field of user with given id to given or current date...
global $DIC
static redirect($a_script)
http redirect to other script