-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Expand file tree
/
Copy pathAccessFactory.php
More file actions
65 lines (56 loc) · 1.65 KB
/
Copy pathAccessFactory.php
File metadata and controls
65 lines (56 loc) · 1.65 KB
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
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\User_LDAP;
use OCA\User_LDAP\Mapping\GroupMapping;
use OCA\User_LDAP\Mapping\UserMapping;
use OCA\User_LDAP\User\Manager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IAppConfig;
use OCP\IUserManager;
use OCP\Server;
use Psr\Log\LoggerInterface;
class AccessFactory {
/** @var array<string,Access> */
private array $accesses = [];
public function __construct(
private ILDAPWrapper $ldap,
private Helper $helper,
private IAppConfig $appConfig,
private IUserManager $ncUserManager,
private LoggerInterface $logger,
private IEventDispatcher $dispatcher,
private UserMapping $userMapping,
private GroupMapping $groupMapping,
) {
}
public function get(Connection $connection): Access {
/* Each Access instance gets its own Manager instance, see OCA\User_LDAP\AppInfo\Application::register() */
return new Access(
$this->ldap,
$connection,
Server::get(Manager::class),
$this->helper,
$this->ncUserManager,
$this->logger,
$this->appConfig,
$this->dispatcher,
);
}
public function getAccessForPrefix(string $configPrefix): Access {
if (!isset(self::$accesses[$configPrefix])) {
$this->addAccess($configPrefix);
}
return $this->accesses[$configPrefix];
}
private function addAccess(string $configPrefix): void {
$connector = new Connection($this->ldap, $configPrefix);
$access = $this->get($connector);
$access->setUserMapper($this->userMapping);
$access->setGroupMapper($this->groupMapping);
$this->accesses[$configPrefix] = $access;
}
}