Rev 730 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
566 | daniel-mar | 1 | <?php |
2 | |||
3 | /* |
||
4 | * OIDplus 2.0 |
||
5 | * Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft |
||
6 | * |
||
7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
||
8 | * you may not use this file except in compliance with the License. |
||
9 | * You may obtain a copy of the License at |
||
10 | * |
||
11 | * http://www.apache.org/licenses/LICENSE-2.0 |
||
12 | * |
||
13 | * Unless required by applicable law or agreed to in writing, software |
||
14 | * distributed under the License is distributed on an "AS IS" BASIS, |
||
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||
16 | * See the License for the specific language governing permissions and |
||
17 | * limitations under the License. |
||
18 | */ |
||
19 | |||
1050 | daniel-mar | 20 | namespace ViaThinkSoft\OIDplus; |
566 | daniel-mar | 21 | |
730 | daniel-mar | 22 | abstract class OIDplusAuthContentStore extends OIDplusBaseClass implements OIDplusGetterSetterInterface { |
566 | daniel-mar | 23 | |
24 | // Getter / Setter |
||
25 | |||
569 | daniel-mar | 26 | public abstract function getValue($name, $default = NULL); |
566 | daniel-mar | 27 | |
569 | daniel-mar | 28 | public abstract function setValue($name, $value); |
566 | daniel-mar | 29 | |
569 | daniel-mar | 30 | public abstract function exists($name); |
31 | |||
32 | public abstract function delete($name); |
||
33 | |||
585 | daniel-mar | 34 | public abstract static function getActiveProvider(); |
566 | daniel-mar | 35 | |
585 | daniel-mar | 36 | public abstract function destroySession(); |
566 | daniel-mar | 37 | |
585 | daniel-mar | 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); |
||
47 | |||
48 | // RA authentication functions (low-level) |
||
49 | |||
566 | daniel-mar | 50 | public function raLogin($email) { |
51 | if (strpos($email, '|') !== false) return; |
||
52 | |||
585 | daniel-mar | 53 | $list = $this->getValue('oidplus_ra_logged_in'); |
566 | daniel-mar | 54 | if (is_null($list)) $list = ''; |
55 | |||
56 | $ary = ($list == '') ? array() : explode('|', $list); |
||
57 | if (!in_array($email, $ary)) $ary[] = $email; |
||
58 | $list = implode('|', $ary); |
||
59 | |||
585 | daniel-mar | 60 | $this->setValue('oidplus_ra_logged_in', $list); |
566 | daniel-mar | 61 | } |
62 | |||
63 | public function raLogout($email) { |
||
585 | daniel-mar | 64 | $list = $this->getValue('oidplus_ra_logged_in'); |
566 | daniel-mar | 65 | if (is_null($list)) $list = ''; |
66 | |||
67 | $ary = ($list == '') ? array() : explode('|', $list); |
||
68 | $key = array_search($email, $ary); |
||
69 | if ($key !== false) unset($ary[$key]); |
||
70 | $list = implode('|', $ary); |
||
71 | |||
585 | daniel-mar | 72 | $this->setValue('oidplus_ra_logged_in', $list); |
566 | daniel-mar | 73 | } |
74 | |||
75 | public function raNumLoggedIn() { |
||
585 | daniel-mar | 76 | return count($this->loggedInRaList()); |
566 | daniel-mar | 77 | } |
78 | |||
79 | public function loggedInRaList() { |
||
585 | daniel-mar | 80 | $list = $this->getValue('oidplus_ra_logged_in'); |
566 | daniel-mar | 81 | if (is_null($list)) $list = ''; |
82 | |||
83 | $res = array(); |
||
84 | foreach (array_unique(explode('|',$list)) as $ra_email) { |
||
85 | if ($ra_email == '') continue; |
||
86 | $res[] = new OIDplusRA($ra_email); |
||
87 | } |
||
88 | return $res; |
||
89 | } |
||
90 | |||
91 | public function isRaLoggedIn($email) { |
||
585 | daniel-mar | 92 | foreach ($this->loggedInRaList() as $ra) { |
566 | daniel-mar | 93 | if ($email == $ra->raEmail()) return true; |
94 | } |
||
95 | return false; |
||
96 | } |
||
97 | |||
585 | daniel-mar | 98 | // Admin authentication functions (low-level) |
566 | daniel-mar | 99 | |
100 | public function adminLogin() { |
||
570 | daniel-mar | 101 | $this->setValue('oidplus_admin_logged_in', 1); |
566 | daniel-mar | 102 | } |
103 | |||
104 | public function adminLogout() { |
||
570 | daniel-mar | 105 | $this->setValue('oidplus_admin_logged_in', 0); |
566 | daniel-mar | 106 | } |
107 | |||
108 | public function isAdminLoggedIn() { |
||
570 | daniel-mar | 109 | return $this->getValue('oidplus_admin_logged_in') == 1; |
566 | daniel-mar | 110 | } |
111 | |||
112 | } |