Rev 1086 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1086 | Rev 1116 | ||
---|---|---|---|
Line 25... | Line 25... | ||
25 | 25 | ||
26 | abstract class OIDplusAuthContentStore extends OIDplusBaseClass implements OIDplusGetterSetterInterface { |
26 | abstract class OIDplusAuthContentStore extends OIDplusBaseClass implements OIDplusGetterSetterInterface { |
27 | 27 | ||
28 | // Getter / Setter |
28 | // Getter / Setter |
29 | 29 | ||
- | 30 | /** |
|
- | 31 | * @param string $name |
|
- | 32 | * @param mixed|null $default |
|
- | 33 | * @return mixed|null |
|
- | 34 | */ |
|
30 | public abstract function getValue($name, $default = NULL); |
35 | public abstract function getValue(string $name, $default = NULL); |
31 | 36 | ||
- | 37 | /** |
|
- | 38 | * @param string $name |
|
- | 39 | * @param mixed $value |
|
- | 40 | * @return void |
|
- | 41 | */ |
|
32 | public abstract function setValue($name, $value); |
42 | public abstract function setValue(string $name, $value); |
33 | 43 | ||
- | 44 | /** |
|
- | 45 | * @param string $name |
|
- | 46 | * @return bool |
|
- | 47 | */ |
|
34 | public abstract function exists($name); |
48 | public abstract function exists(string $name): bool; |
35 | 49 | ||
- | 50 | /** |
|
- | 51 | * @param string $name |
|
- | 52 | * @return void |
|
- | 53 | */ |
|
36 | public abstract function delete($name); |
54 | public abstract function delete(string $name); |
37 | 55 | ||
- | 56 | /** |
|
- | 57 | * @return OIDplusAuthContentStore|null |
|
- | 58 | * @throws OIDplusException |
|
- | 59 | */ |
|
38 | public abstract static function getActiveProvider(); |
60 | public abstract static function getActiveProvider()/*: ?OIDplusAuthContentStore*/; |
39 | 61 | ||
- | 62 | /** |
|
- | 63 | * @return mixed |
|
- | 64 | */ |
|
40 | public abstract function destroySession(); |
65 | public abstract function destroySession(); |
41 | 66 | ||
- | 67 | /** |
|
- | 68 | * @return mixed |
|
- | 69 | */ |
|
42 | public abstract function activate(); |
70 | public abstract function activate(); |
43 | 71 | ||
- | 72 | /** |
|
- | 73 | * @param string $email |
|
- | 74 | * @param string $loginfo |
|
- | 75 | * @return void |
|
- | 76 | */ |
|
44 | public abstract function raLoginEx($email, &$loginfo); |
77 | public abstract function raLoginEx(string $email, string &$loginfo); |
45 | 78 | ||
- | 79 | /** |
|
- | 80 | * @param string $email |
|
- | 81 | * @param string $loginfo |
|
- | 82 | * @return void |
|
- | 83 | */ |
|
46 | public abstract function raLogoutEx($email, &$loginfo); |
84 | public abstract function raLogoutEx(string $email, string &$loginfo); |
47 | 85 | ||
- | 86 | /** |
|
- | 87 | * @param string $loginfo |
|
- | 88 | * @return void |
|
- | 89 | */ |
|
48 | public abstract function adminLoginEx(&$loginfo); |
90 | public abstract function adminLoginEx(string &$loginfo); |
49 | 91 | ||
- | 92 | /** |
|
- | 93 | * @param string $loginfo |
|
- | 94 | * @return void |
|
- | 95 | */ |
|
50 | public abstract function adminLogoutEx(&$loginfo); |
96 | public abstract function adminLogoutEx(string &$loginfo); |
51 | 97 | ||
52 | // RA authentication functions (low-level) |
98 | // RA authentication functions (low-level) |
53 | 99 | ||
- | 100 | /** |
|
- | 101 | * @param string $email |
|
- | 102 | * @return void |
|
- | 103 | */ |
|
54 | public function raLogin($email) { |
104 | public function raLogin(string $email) { |
55 | if (strpos($email, '|') !== false) return; |
105 | if (strpos($email, '|') !== false) return; |
56 | 106 | ||
57 | $list = $this->getValue('oidplus_ra_logged_in'); |
107 | $list = $this->getValue('oidplus_ra_logged_in'); |
58 | if (is_null($list)) $list = ''; |
108 | if (is_null($list)) $list = ''; |
59 | 109 | ||
Line 62... | Line 112... | ||
62 | $list = implode('|', $ary); |
112 | $list = implode('|', $ary); |
63 | 113 | ||
64 | $this->setValue('oidplus_ra_logged_in', $list); |
114 | $this->setValue('oidplus_ra_logged_in', $list); |
65 | } |
115 | } |
66 | 116 | ||
- | 117 | /** |
|
- | 118 | * @param string $email |
|
- | 119 | * @return void |
|
- | 120 | */ |
|
67 | public function raLogout($email) { |
121 | public function raLogout(string $email) { |
68 | $list = $this->getValue('oidplus_ra_logged_in'); |
122 | $list = $this->getValue('oidplus_ra_logged_in'); |
69 | if (is_null($list)) $list = ''; |
123 | if (is_null($list)) $list = ''; |
70 | 124 | ||
71 | $ary = ($list == '') ? array() : explode('|', $list); |
125 | $ary = ($list == '') ? array() : explode('|', $list); |
72 | $key = array_search($email, $ary); |
126 | $key = array_search($email, $ary); |
Line 74... | Line 128... | ||
74 | $list = implode('|', $ary); |
128 | $list = implode('|', $ary); |
75 | 129 | ||
76 | $this->setValue('oidplus_ra_logged_in', $list); |
130 | $this->setValue('oidplus_ra_logged_in', $list); |
77 | } |
131 | } |
78 | 132 | ||
- | 133 | /** |
|
- | 134 | * @return int |
|
- | 135 | */ |
|
79 | public function raNumLoggedIn() { |
136 | public function raNumLoggedIn(): int { |
80 | return count($this->loggedInRaList()); |
137 | return count($this->loggedInRaList()); |
81 | } |
138 | } |
82 | 139 | ||
- | 140 | /** |
|
- | 141 | * @return OIDplusRA[] |
|
- | 142 | */ |
|
83 | public function loggedInRaList() { |
143 | public function loggedInRaList(): array { |
84 | $list = $this->getValue('oidplus_ra_logged_in'); |
144 | $list = $this->getValue('oidplus_ra_logged_in'); |
85 | if (is_null($list)) $list = ''; |
145 | if (is_null($list)) $list = ''; |
86 | 146 | ||
87 | $res = array(); |
147 | $res = array(); |
88 | foreach (array_unique(explode('|',$list)) as $ra_email) { |
148 | foreach (array_unique(explode('|',$list)) as $ra_email) { |
Line 90... | Line 150... | ||
90 | $res[] = new OIDplusRA($ra_email); |
150 | $res[] = new OIDplusRA($ra_email); |
91 | } |
151 | } |
92 | return $res; |
152 | return $res; |
93 | } |
153 | } |
94 | 154 | ||
- | 155 | /** |
|
- | 156 | * @param string $email |
|
- | 157 | * @return bool |
|
- | 158 | */ |
|
95 | public function isRaLoggedIn($email) { |
159 | public function isRaLoggedIn(string $email) { |
96 | foreach ($this->loggedInRaList() as $ra) { |
160 | foreach ($this->loggedInRaList() as $ra) { |
97 | if ($email == $ra->raEmail()) return true; |
161 | if ($email == $ra->raEmail()) return true; |
98 | } |
162 | } |
99 | return false; |
163 | return false; |
100 | } |
164 | } |
101 | 165 | ||
102 | // Admin authentication functions (low-level) |
166 | // Admin authentication functions (low-level) |
103 | 167 | ||
- | 168 | /** |
|
- | 169 | * @return void |
|
- | 170 | */ |
|
104 | public function adminLogin() { |
171 | public function adminLogin() { |
105 | $this->setValue('oidplus_admin_logged_in', 1); |
172 | $this->setValue('oidplus_admin_logged_in', 1); |
106 | } |
173 | } |
107 | 174 | ||
- | 175 | /** |
|
- | 176 | * @return void |
|
- | 177 | */ |
|
108 | public function adminLogout() { |
178 | public function adminLogout() { |
109 | $this->setValue('oidplus_admin_logged_in', 0); |
179 | $this->setValue('oidplus_admin_logged_in', 0); |
110 | } |
180 | } |
111 | 181 | ||
- | 182 | /** |
|
- | 183 | * @return bool |
|
- | 184 | */ |
|
112 | public function isAdminLoggedIn() { |
185 | public function isAdminLoggedIn(): bool { |
113 | return $this->getValue('oidplus_admin_logged_in') == 1; |
186 | return $this->getValue('oidplus_admin_logged_in') == 1; |
114 | } |
187 | } |
115 | 188 | ||
116 | } |
189 | } |