-
Notifications
You must be signed in to change notification settings - Fork 61
/
Abstract.php
executable file
·75 lines (64 loc) · 2.05 KB
/
Abstract.php
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
<?php
abstract class Xerte_Authentication_Abstract
{
/**
* List of strings (error messages thrown up somehow... for display to the end user
* @var array
*/
protected $_errors = array();
/**
* @var StdClass - see config.php.
*/
protected $xerte_toolkits_site = null;
/**
* @param string $username
* @param string $password
* @return boolean true on success; on failure, return false. You'll need to then call getErrors().
*/
abstract public function login($username, $password);
/**
* @return array of error messages (Strings); empty if there are none
*/
public function getErrors()
{
return array_unique($this->_errors);
}
public function addError($string)
{
$this->_errors[] = $string;
}
/**
* @return string user's firstname
*/
abstract public function getFirstname();
/**
* @return string user's surname
*/
abstract public function getSurname();
/**
* @param StdClass $xerte_toolkits_site
*/
public function __construct($xerte_toolkits_site)
{
$this->xerte_toolkits_site = $xerte_toolkits_site;
}
/**
*@return string $username provided by the end user or the auth mechanism (e.g. Moodle session contents etc)
*/
abstract public function getUsername();
/**
* Perform some sort of check to ensure stuff is configured correctly.... e.g. for LDAP make sure the user has the 'ldap_connect' function available etc
* If any errors are found; retrieve via getErrors();
* @return boolean true
*/
abstract public function check();
/**
*Change this to return FALSE in one of the other authenticators, and the end user shouldn't be shown the login box/dialogue - presumably
* because there's some sort of single sign on in place which we can test immediately without them needing to fill in a login box.
*
* @return boolean true if they need to login.
*/
public function needsLogin() {
return true;
}
}