Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions apps/user_ldap/ajax/wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@
new \OCA\User_LDAP\LogWrapper(),
\OC::$server->getAvatarManager(),
new \OCP\Image(),
\OC::$server->getDatabaseConnection(),
\OC::$server->getUserManager(),
\OC::$server->getNotificationManager());
\OC::$server->getNotificationManager(),
\OC::$server->get(\OCP\Share\IManager::class)
);

$access = new \OCA\User_LDAP\Access(
$con,
Expand Down
10 changes: 3 additions & 7 deletions apps/user_ldap/lib/Access.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
use OC\ServerNotAvailableException;
use OCA\User_LDAP\Exceptions\ConstraintViolationException;
use OCA\User_LDAP\Mapping\AbstractMapping;
use OCA\User_LDAP\Mapping\UserMapping;
use OCA\User_LDAP\User\Manager;
use OCA\User_LDAP\User\OfflineUser;
use OCP\IConfig;
Expand All @@ -74,9 +75,7 @@ class Access extends LDAPUtility {
protected $pagedSearchedSuccessful;

/**
* protected $cookies = [];
*
* @var AbstractMapping $userMapper
* @var UserMapping $userMapper
*/
protected $userMapper;

Expand Down Expand Up @@ -123,12 +122,9 @@ public function setUserMapper(AbstractMapping $mapper) {
}

/**
* returns the User Mapper
*
* @return AbstractMapping
* @throws \Exception
*/
public function getUserMapper() {
public function getUserMapper(): UserMapping {
if (is_null($this->userMapper)) {
throw new \Exception('UserMapper was not assigned to this Access instance.');
}
Expand Down
7 changes: 2 additions & 5 deletions apps/user_ldap/lib/Jobs/CleanUp.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

use OC\BackgroundJob\TimedJob;
use OCA\User_LDAP\Helper;
use OCA\User_LDAP\LDAP;
use OCA\User_LDAP\Mapping\UserMapping;
use OCA\User_LDAP\User\DeletedUsersIndex;
use OCA\User_LDAP\User_LDAP;
Expand Down Expand Up @@ -68,11 +67,12 @@ class CleanUp extends TimedJob {
/** @var DeletedUsersIndex */
protected $dui;

public function __construct(User_Proxy $userBackend) {
public function __construct(User_Proxy $userBackend, DeletedUsersIndex $dui) {
$minutes = \OC::$server->getConfig()->getSystemValue(
'ldapUserCleanupInterval', (string)$this->defaultIntervalMin);
$this->setInterval((int)$minutes * 60);
$this->userBackend = $userBackend;
$this->dui = $dui;
}

/**
Expand Down Expand Up @@ -115,9 +115,6 @@ public function setArguments($arguments) {

if (isset($arguments['deletedUsersIndex'])) {
$this->dui = $arguments['deletedUsersIndex'];
} else {
$this->dui = new DeletedUsersIndex(
$this->ocConfig, $this->db, $this->mapping);
}
}

Expand Down
19 changes: 3 additions & 16 deletions apps/user_ldap/lib/Jobs/Sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,13 @@
use OCA\User_LDAP\AccessFactory;
use OCA\User_LDAP\Configuration;
use OCA\User_LDAP\ConnectionFactory;
use OCA\User_LDAP\FilesystemHelper;
use OCA\User_LDAP\Helper;
use OCA\User_LDAP\LDAP;
use OCA\User_LDAP\LogWrapper;
use OCA\User_LDAP\Mapping\UserMapping;
use OCA\User_LDAP\User\Manager;
use OCP\IAvatarManager;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Image;
use OCP\IUserManager;
use OCP\Notification\IManager;

Expand Down Expand Up @@ -68,7 +65,8 @@ class Sync extends TimedJob {
/** @var AccessFactory */
protected $accessFactory;

public function __construct() {
public function __construct(Manager $userManager) {
$this->userManager = $userManager;
$this->setInterval(
\OC::$server->getConfig()->getAppValue(
'user_ldap',
Expand Down Expand Up @@ -345,25 +343,14 @@ public function setArgument($argument) {

if (isset($argument['userManager'])) {
$this->userManager = $argument['userManager'];
} else {
$this->userManager = new Manager(
$this->config,
new FilesystemHelper(),
new LogWrapper(),
$this->avatarManager,
new Image(),
$this->dbc,
$this->ncUserManager,
$this->notificationManager
);
}

if (isset($argument['mapper'])) {
$this->mapper = $argument['mapper'];
} else {
$this->mapper = new UserMapping($this->dbc);
}

if (isset($argument['connectionFactory'])) {
$this->connectionFactory = $argument['connectionFactory'];
} else {
Expand Down
31 changes: 6 additions & 25 deletions apps/user_ldap/lib/LDAPProviderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,38 +26,19 @@

namespace OCA\User_LDAP;

use OCA\User_LDAP\Mapping\UserMapping;
use OCA\User_LDAP\User\DeletedUsersIndex;
use OCP\IServerContainer;
use OCP\LDAP\ILDAPProvider;
use OCP\LDAP\ILDAPProviderFactory;

class LDAPProviderFactory implements ILDAPProviderFactory {
/**
* Server container
*
* @var IServerContainer
*/
/** * @var IServerContainer */
private $serverContainer;

/**
* Constructor for the LDAP provider factory
*
* @param IServerContainer $serverContainer server container
*/

public function __construct(IServerContainer $serverContainer) {
$this->serverContainer = $serverContainer;
}

/**
* creates and returns an instance of the ILDAPProvider
*
* @return OCP\LDAP\ILDAPProvider
*/
public function getLDAPProvider() {
$dbConnection = $this->serverContainer->getDatabaseConnection();
$userMapping = new UserMapping($dbConnection);
return new LDAPProvider($this->serverContainer, new Helper($this->serverContainer->getConfig()),
new DeletedUsersIndex($this->serverContainer->getConfig(),
$dbConnection, $userMapping));

public function getLDAPProvider(): ILDAPProvider {
return $this->serverContainer->get(LDAPProvider::class);
}
}
8 changes: 5 additions & 3 deletions apps/user_ldap/lib/Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use OCA\User_LDAP\Mapping\GroupMapping;
use OCA\User_LDAP\Mapping\UserMapping;
use OCA\User_LDAP\User\Manager;
use OCP\Share\IManager;

abstract class Proxy {
private static $accesses = [];
Expand Down Expand Up @@ -67,7 +68,7 @@ private function addAccess($configPrefix) {
static $avatarM;
static $userMap;
static $groupMap;
static $db;
static $shareManager;
static $coreUserManager;
static $coreNotificationManager;
if ($fs === null) {
Expand All @@ -80,10 +81,11 @@ private function addAccess($configPrefix) {
$groupMap = new GroupMapping($db);
$coreUserManager = \OC::$server->getUserManager();
$coreNotificationManager = \OC::$server->getNotificationManager();
$shareManager = \OC::$server->get(IManager::class);
}
$userManager =
new Manager($ocConfig, $fs, $log, $avatarM, new \OCP\Image(), $db,
$coreUserManager, $coreNotificationManager);
new Manager($ocConfig, $fs, $log, $avatarM, new \OCP\Image(),
$coreUserManager, $coreNotificationManager, $shareManager);
$connector = new Connection($this->ldap, $configPrefix);
$access = new Access($connector, $this->ldap, $userManager, new Helper($ocConfig), $ocConfig, $coreUserManager);
$access->setUserMapper($userMap);
Expand Down
19 changes: 6 additions & 13 deletions apps/user_ldap/lib/User/DeletedUsersIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace OCA\User_LDAP\User;

use OCA\User_LDAP\Mapping\UserMapping;
use OCP\Share\IManager;

/**
* Class DeletedUsersIndex
Expand All @@ -37,11 +38,6 @@ class DeletedUsersIndex {
*/
protected $config;

/**
* @var \OCP\IDBConnection $db
*/
protected $db;

/**
* @var \OCA\User_LDAP\Mapping\UserMapping $mapping
*/
Expand All @@ -51,16 +47,13 @@ class DeletedUsersIndex {
* @var array $deletedUsers
*/
protected $deletedUsers;
/** @var IManager */
private $shareManager;

/**
* @param \OCP\IConfig $config
* @param \OCP\IDBConnection $db
* @param \OCA\User_LDAP\Mapping\UserMapping $mapping
*/
public function __construct(\OCP\IConfig $config, \OCP\IDBConnection $db, UserMapping $mapping) {
public function __construct(\OCP\IConfig $config, UserMapping $mapping, IManager $shareManager) {
$this->config = $config;
$this->db = $db;
$this->mapping = $mapping;
$this->shareManager = $shareManager;
}

/**
Expand All @@ -73,7 +66,7 @@ private function fetchDeletedUsers() {

$userObjects = [];
foreach ($deletedUsers as $user) {
$userObjects[] = new OfflineUser($user, $this->config, $this->db, $this->mapping);
$userObjects[] = new OfflineUser($user, $this->config, $this->mapping, $this->shareManager);
}
$this->deletedUsers = $userObjects;

Expand Down
35 changes: 17 additions & 18 deletions apps/user_ldap/lib/User/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
use OCP\Image;
use OCP\IUserManager;
use OCP\Notification\IManager as INotificationManager;
use OCP\Share\IManager;

/**
* Manager
Expand Down Expand Up @@ -82,32 +83,29 @@ class Manager {
* @var CappedMemoryCache $usersByUid
*/
protected $usersByUid;
/** @var IManager */
private $shareManager;

/**
* @param IConfig $ocConfig
* @param \OCA\User_LDAP\FilesystemHelper $ocFilesystem object that
* gives access to necessary functions from the OC filesystem
* @param \OCA\User_LDAP\LogWrapper $ocLog
* @param IAvatarManager $avatarManager
* @param Image $image an empty image instance
* @param IDBConnection $db
* @throws \Exception when the methods mentioned above do not exist
*/
public function __construct(IConfig $ocConfig,
FilesystemHelper $ocFilesystem, LogWrapper $ocLog,
IAvatarManager $avatarManager, Image $image,
IDBConnection $db, IUserManager $userManager,
INotificationManager $notificationManager) {
public function __construct(
IConfig $ocConfig,
FilesystemHelper $ocFilesystem,
LogWrapper $ocLog,
IAvatarManager $avatarManager,
Image $image,
IUserManager $userManager,
INotificationManager $notificationManager,
IManager $shareManager
) {
$this->ocConfig = $ocConfig;
$this->ocFilesystem = $ocFilesystem;
$this->ocLog = $ocLog;
$this->avatarManager = $avatarManager;
$this->image = $image;
$this->db = $db;
$this->userManager = $userManager;
$this->notificationManager = $notificationManager;
$this->usersByDN = new CappedMemoryCache();
$this->usersByUid = new CappedMemoryCache();
$this->shareManager = $shareManager;
}

/**
Expand Down Expand Up @@ -229,8 +227,9 @@ public function getDeletedUser($id) {
return new OfflineUser(
$id,
$this->ocConfig,
$this->db,
$this->access->getUserMapper());
$this->access->getUserMapper(),
$this->shareManager
);
}

/**
Expand Down
Loading