ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
24require_once('Auth/Auth.php');
25require_once('./Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentRules.php');
26require_once('include/Unicode/UtfNormal.php');
27require_once('./Services/AuthShibboleth/classes/class.ilShibbolethPluginWrapper.php');
28require_once('./Services/AuthShibboleth/classes/Config/class.shibConfig.php');
29require_once('./Services/AuthShibboleth/classes/ServerData/class.shibServerData.php');
30require_once('./Services/AuthShibboleth/classes/User/class.shibUser.php');
31
42class ShibAuth extends Auth {
43
48 public function __construct($authParams, $updateUserData = false) {
49 if ($authParams['sessionName'] != '') {
50 parent::Auth('', array( 'sessionName' => $authParams['sessionName'] ));
51 } else {
52 parent::Auth('');
53 }
54 $this->updateUserData = $updateUserData;
55 if (! empty($authParams['sessionName'])) {
56 $this->setSessionName($authParams['sessionName']);
57 unset($authParams['sessionName']);
58 }
59 }
60
61
65 public function supportsRedirects() {
66 return true;
67 }
68
69
76 public function login() {
77 global $ilias, $ilSetting; // for backword compatibility of hook environment variables
78 $shibServerData = shibServerData::getInstance($_SERVER);
79 if ($shibServerData->getLogin()) {
80 $shibUser = shibUser::buildInstance($shibServerData);
81 // for backword compatibility of hook environment variables
82 $userObj =& $shibUser; // For shib_data_conv included Script
83 $newUser = $shibUser->isNew(); // For shib_data_conv included Script
84 if ($shibUser->isNew()) {
85 $shibUser->createFields();
86 $shibUser->setPref('hits_per_page', $ilSetting->get('hits_per_page'));
87
88 // Modify user data before creating the user
89 // Include custom code that can be used to further modify
90 // certain Shibboleth user attributes
91 if ($ilias->getSetting('shib_data_conv') AND $ilias->getSetting('shib_data_conv') != ''
92 AND is_readable($ilias->getSetting('shib_data_conv'))
93 ) {
94 include($ilias->getSetting('shib_data_conv'));
95 }
96 $shibUser = ilShibbolethPluginWrapper::getInstance()->beforeCreateUser($shibUser);
97 $shibUser->create();
98 $shibUser->updateOwner();
99 $shibUser->saveAsNew();
100 $shibUser->writePrefs();
101 $shibUser = ilShibbolethPluginWrapper::getInstance()->afterCreateUser($shibUser);
103 } else {
104 $shibUser->updateFields();
105 // Include custom code that can be used to further modify
106 // certain Shibboleth user attributes
107 if ($ilias->getSetting('shib_data_conv') AND $ilias->getSetting('shib_data_conv') != ''
108 AND is_readable($ilias->getSetting('shib_data_conv'))
109 ) {
110 include($ilias->getSetting('shib_data_conv'));
111 }
112 // $shibUser->update();
113 $shibUser = ilShibbolethPluginWrapper::getInstance()->beforeUpdateUser($shibUser);
114 $shibUser->update();
115 $shibUser = ilShibbolethPluginWrapper::getInstance()->afterUpdateUser($shibUser);
117 }
118 $this->setAuth($shibUser->getLogin(), $shibUser);
119 ilObjUser::_updateLastLogin($shibUser->getId());
120 if ($_GET['target'] != '') {
121 ilUtil::redirect('goto.php?target=' . $_GET['target'] . '&client_id=' . CLIENT_ID);
122 }
123 } else {
124 $this->status = AUTH_WRONG_LOGIN;
125 }
126 }
127
128
133 public function setAuth($username, ilObjUser $userObj = NULL) {
134 if ($userObj) {
135 ilShibbolethPluginWrapper::getInstance()->beforeLogin($userObj);
136 }
137 parent::setAuth($username);
138 if ($userObj) {
139 ilShibbolethPluginWrapper::getInstance()->afterLogin($userObj);
140 }
141 }
142
143
144 public function logout() {
145 global $ilUser;
147 parent::logout();
149 }
150}
151
152?>
const AUTH_WRONG_LOGIN
Returned if container is unable to authenticate user/password pair.
Definition: Auth.php:38
$_GET["client_id"]
$username
Definition: Auth.php:175
setSessionName($name='session')
Set name of the session to a customized value.
Definition: Auth.php:656
login()
Login function.
setAuth($username, ilObjUser $userObj=NULL)
__construct($authParams, $updateUserData=false)
logout()
Logout function.
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.
static redirect($a_script)
http redirect to other script
static getInstance()
static buildInstance(shibServerData $shibServerData)
global $ilSetting
Definition: privfeed.php:40
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
global $ilUser
Definition: imgupload.php:15