blob: d28cc3e7711d041593aab71f1857fb90523f4334 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
<?php
# Lifter007: TODO
# Lifter003: TODO
# Lifter010: TODO
/**
* Stud.IP authentication against CAS Server
*
* @access public
* @author Dennis Reil <dennis.reil@offis.de>
* @package
*/
require_once 'composer/jasig/phpcas/CAS.php';
require_once 'lib/classes/cas/CAS_PGTStorage_Cache.php';
class StudipAuthCAS extends StudipAuthSSO {
var $host;
var $port;
var $uri;
var $cacert;
var $cas;
var $userdata;
/**
* Constructor
*
*
* @access public
*
*/
function __construct() {
parent::__construct();
if (Request::option('sso')) {
$this->cas = new CAS_Client(CAS_VERSION_2_0, $this->proxy, $this->host, $this->port, $this->uri, false);
if ($this->proxy) {
URLHelper::setBaseUrl($GLOBALS['ABSOLUTE_URI_STUDIP']);
$this->cas->setPGTStorage(new CAS_PGTStorage_Cache($this->cas));
$this->cas->setCallbackURL(URLHelper::getURL('dispatch.php/cas/proxy'));
}
if (isset($this->cacert)) {
$this->cas->setCasServerCACert($this->cacert);
} else {
$this->cas->setNoCasServerValidation();
}
}
}
/**
* Return the current username.
*/
function getUser()
{
return $this->cas->getUser();
}
/**
* Validate the username passed to the auth plugin.
* Note: This triggers authentication if needed.
*/
function verifyUsername($username)
{
$this->cas->forceAuthentication();
return $this->getUser();
}
function getUserData($key){
$userdataclassname = $GLOBALS["STUDIP_AUTH_CONFIG_CAS"]["user_data_mapping_class"];
if (empty($userdataclassname)){
echo ("ERROR: no userdataclassname specified.");
return;
}
require_once($userdataclassname . ".class.php");
// get the userdata
if (empty($this->userdata)){
$this->userdata = new $userdataclassname();
}
$result = $this->userdata->getUserData($key, $this->cas->getUser());
return $result;
}
function logout(){
// do a global cas logout
$this->cas = new CAS_Client(CAS_VERSION_2_0, false, $this->host, $this->port, $this->uri, false);
$this->cas->logout();
}
}
|