Subversion Repositories oidplus

Rev

Rev 571 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 571 Rev 585
Line 19... Line 19...
19
 
19
 
20
if (!defined('INSIDE_OIDPLUS')) die();
20
if (!defined('INSIDE_OIDPLUS')) die();
21
 
21
 
22
abstract class OIDplusAuthContentStore implements OIDplusGetterSetterInterface {
22
abstract class OIDplusAuthContentStore implements OIDplusGetterSetterInterface {
23
 
23
 
24
        protected $content = array();
-
 
25
 
-
 
26
        // Getter / Setter
24
        // Getter / Setter
27
 
25
 
28
        public abstract function getValue($name, $default = NULL);
26
        public abstract function getValue($name, $default = NULL);
29
 
27
 
30
        public abstract function setValue($name, $value);
28
        public abstract function setValue($name, $value);
31
 
29
 
32
        public abstract function exists($name);
30
        public abstract function exists($name);
33
 
31
 
34
        public abstract function delete($name);
32
        public abstract function delete($name);
35
 
33
 
-
 
34
        public abstract static function getActiveProvider();
-
 
35
 
36
        protected abstract function destroySession();
36
        public abstract function destroySession();
-
 
37
 
-
 
38
        public abstract function activate();
-
 
39
 
-
 
40
        public abstract function raLoginEx($email, &$loginfo);
-
 
41
 
-
 
42
        public abstract function raLogoutEx($email, &$loginfo);
-
 
43
 
-
 
44
        public abstract function adminLoginEx(&$loginfo);
-
 
45
 
-
 
46
        public abstract function adminLogoutEx(&$loginfo);
37
 
47
 
38
        // RA authentication functions
48
        // RA authentication functions (low-level)
39
 
49
 
40
        public function raLogin($email) {
50
        public function raLogin($email) {
41
                if (strpos($email, '|') !== false) return;
51
                if (strpos($email, '|') !== false) return;
42
 
52
 
43
                $list = $this->getValue('oidplus_logged_in');
53
                $list = $this->getValue('oidplus_ra_logged_in');
44
                if (is_null($list)) $list = '';
54
                if (is_null($list)) $list = '';
45
 
55
 
46
                $ary = ($list == '') ? array() : explode('|', $list);
56
                $ary = ($list == '') ? array() : explode('|', $list);
47
                if (!in_array($email, $ary)) $ary[] = $email;
57
                if (!in_array($email, $ary)) $ary[] = $email;
48
                $list = implode('|', $ary);
58
                $list = implode('|', $ary);
49
 
59
 
50
                $this->setValue('oidplus_logged_in', $list);
60
                $this->setValue('oidplus_ra_logged_in', $list);
51
        }
61
        }
52
 
62
 
53
        public function raLogout($email) {
63
        public function raLogout($email) {
54
                $list = $this->getValue('oidplus_logged_in');
64
                $list = $this->getValue('oidplus_ra_logged_in');
55
                if (is_null($list)) $list = '';
65
                if (is_null($list)) $list = '';
56
 
66
 
57
                $ary = ($list == '') ? array() : explode('|', $list);
67
                $ary = ($list == '') ? array() : explode('|', $list);
58
                $key = array_search($email, $ary);
68
                $key = array_search($email, $ary);
59
                if ($key !== false) unset($ary[$key]);
69
                if ($key !== false) unset($ary[$key]);
60
                $list = implode('|', $ary);
70
                $list = implode('|', $ary);
61
 
71
 
62
                $this->setValue('oidplus_logged_in', $list);
72
                $this->setValue('oidplus_ra_logged_in', $list);
63
 
-
 
64
                if (($list == '') && (!self::isAdminLoggedIn())) {
-
 
65
                        // Nobody logged in anymore. Destroy session cookie to make GDPR people happy
-
 
66
                        $this->destroySession();
-
 
67
                }
-
 
68
        }
73
        }
69
 
74
 
70
        public function raNumLoggedIn() {
75
        public function raNumLoggedIn() {
71
                return count(self::loggedInRaList());
76
                return count($this->loggedInRaList());
72
        }
-
 
73
 
-
 
74
        public function raLogoutAll() {
-
 
75
                $this->setValue('oidplus_logged_in', '');
-
 
76
        }
77
        }
77
 
78
 
78
        public function loggedInRaList() {
79
        public function loggedInRaList() {
79
                $list = $this->getValue('oidplus_logged_in');
80
                $list = $this->getValue('oidplus_ra_logged_in');
80
                if (is_null($list)) $list = '';
81
                if (is_null($list)) $list = '';
81
 
82
 
82
                $res = array();
83
                $res = array();
83
                foreach (array_unique(explode('|',$list)) as $ra_email) {
84
                foreach (array_unique(explode('|',$list)) as $ra_email) {
84
                        if ($ra_email == '') continue;
85
                        if ($ra_email == '') continue;
Line 86... Line 87...
86
                }
87
                }
87
                return $res;
88
                return $res;
88
        }
89
        }
89
 
90
 
90
        public function isRaLoggedIn($email) {
91
        public function isRaLoggedIn($email) {
91
                foreach (self::loggedInRaList() as $ra) {
92
                foreach ($this->loggedInRaList() as $ra) {
92
                        if ($email == $ra->raEmail()) return true;
93
                        if ($email == $ra->raEmail()) return true;
93
                }
94
                }
94
                return false;
95
                return false;
95
        }
96
        }
96
 
97
 
97
        // Admin authentication functions
98
        // Admin authentication functions (low-level)
98
 
99
 
99
        public function adminLogin() {
100
        public function adminLogin() {
100
                $this->setValue('oidplus_admin_logged_in', 1);
101
                $this->setValue('oidplus_admin_logged_in', 1);
101
        }
102
        }
102
 
103
 
103
        public function adminLogout() {
104
        public function adminLogout() {
104
                $this->setValue('oidplus_admin_logged_in', 0);
105
                $this->setValue('oidplus_admin_logged_in', 0);
105
 
-
 
106
                if (self::raNumLoggedIn() == 0) {
-
 
107
                        // Nobody logged in anymore. Destroy session cookie to make GDPR people happy
-
 
108
                        $this->destroySession();
-
 
109
                }
-
 
110
        }
106
        }
111
 
107
 
112
        public function isAdminLoggedIn() {
108
        public function isAdminLoggedIn() {
113
                return $this->getValue('oidplus_admin_logged_in') == 1;
109
                return $this->getValue('oidplus_admin_logged_in') == 1;
114
        }
110
        }