|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* @copyright 2018 Christoph Wurst <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* @author 2018 Christoph Wurst <[email protected]> |
|
8
|
|
|
* |
|
9
|
|
|
* @license GNU AGPL version 3 or any later version |
|
10
|
|
|
* |
|
11
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
12
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
13
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
14
|
|
|
* License, or (at your option) any later version. |
|
15
|
|
|
* |
|
16
|
|
|
* This program is distributed in the hope that it will be useful, |
|
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19
|
|
|
* GNU Affero General Public License for more details. |
|
20
|
|
|
* |
|
21
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
22
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
23
|
|
|
* |
|
24
|
|
|
*/ |
|
25
|
|
|
|
|
26
|
|
|
namespace OC\Authentication\TwoFactorAuth; |
|
27
|
|
|
|
|
28
|
|
|
use OCP\Authentication\TwoFactorAuth\IProvider; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Contains all two-factor provider information for the two-factor login challenge |
|
32
|
|
|
*/ |
|
33
|
|
|
class ProviderSet { |
|
34
|
|
|
|
|
35
|
|
|
/** @var IProvider */ |
|
36
|
|
|
private $providers; |
|
37
|
|
|
|
|
38
|
|
|
/** @var bool */ |
|
39
|
|
|
private $providerMissing; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param IProvider[] $providers |
|
43
|
|
|
* @param bool $providerMissing |
|
44
|
|
|
*/ |
|
45
|
|
|
public function __construct(array $providers, bool $providerMissing) { |
|
46
|
|
|
$this->providers = []; |
|
|
|
|
|
|
47
|
|
|
foreach ($providers as $provider) { |
|
48
|
|
|
$this->providers[$provider->getId()] = $provider; |
|
49
|
|
|
} |
|
50
|
|
|
$this->providerMissing = $providerMissing; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @param string $providerId |
|
55
|
|
|
* @return IProvider|null |
|
56
|
|
|
*/ |
|
57
|
|
|
public function getProvider(string $providerId) { |
|
58
|
|
|
return $this->providers[$providerId] ?? null; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @return IProvider[] |
|
63
|
|
|
*/ |
|
64
|
|
|
public function getProviders(): array { |
|
65
|
|
|
return $this->providers; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function isProviderMissing(): bool { |
|
69
|
|
|
return $this->providerMissing; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
} |
|
73
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..