summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2014-12-20 16:09:04 +0100
committerArthur Schiwon <blizzz@owncloud.com>2014-12-20 16:09:04 +0100
commit144d95de7dde29cd85e795cdcd7ac1576639d641 (patch)
tree67de63f5c3c43b49cbb29cffcd6eb855eff68cb1 /apps
parent4fa39250e714b3ee5aa16a5f9ce8c77daa44311b (diff)
downloadnextcloud-server-144d95de7dde29cd85e795cdcd7ac1576639d641.tar.gz
nextcloud-server-144d95de7dde29cd85e795cdcd7ac1576639d641.zip
basic adjustments for OC 8. I.e. no visible issues, LDAP tests pass.
Diffstat (limited to 'apps')
-rw-r--r--apps/user_ldap/appinfo/register_command.php10
-rw-r--r--apps/user_ldap/command/showremnants.php31
-rw-r--r--apps/user_ldap/lib/access.php28
-rw-r--r--apps/user_ldap/lib/jobs.php3
-rw-r--r--apps/user_ldap/lib/user/deletedusersindex.php12
-rw-r--r--apps/user_ldap/lib/user/iusertools.php4
-rw-r--r--apps/user_ldap/lib/user/manager.php2
-rw-r--r--apps/user_ldap/lib/user/offlineuser.php12
-rw-r--r--apps/user_ldap/tests/user_ldap.php10
-rw-r--r--apps/user_ldap/user_ldap.php2
10 files changed, 73 insertions, 41 deletions
diff --git a/apps/user_ldap/appinfo/register_command.php b/apps/user_ldap/appinfo/register_command.php
index 55a187d9654..314c73e6c4a 100644
--- a/apps/user_ldap/appinfo/register_command.php
+++ b/apps/user_ldap/appinfo/register_command.php
@@ -9,6 +9,7 @@
use OCA\user_ldap\lib\Helper;
use OCA\user_ldap\lib\LDAP;
use OCA\user_ldap\User_Proxy;
+use OCA\User_LDAP\Mapping\UserMapping;
$application->add(new OCA\user_ldap\Command\ShowConfig());
$application->add(new OCA\user_ldap\Command\SetConfig());
@@ -16,11 +17,12 @@ $application->add(new OCA\user_ldap\Command\TestConfig());
$application->add(new OCA\user_ldap\Command\CreateEmptyConfig());
$application->add(new OCA\user_ldap\Command\DeleteConfig());
$application->add(new OCA\user_ldap\Command\Search());
-$application->add(new OCA\user_ldap\Command\ShowRemnants());
-$helper = new OCA\user_ldap\lib\Helper();
-$uBackend = new OCA\user_ldap\User_Proxy(
+$userMapping = new UserMapping(\OC::$server->getDatabaseConnection());
+$application->add(new OCA\user_ldap\Command\ShowRemnants($userMapping));
+$helper = new Helper();
+$uBackend = new User_Proxy(
$helper->getServerConfigurationPrefixes(true),
- new OCA\user_ldap\lib\LDAP()
+ new LDAP()
);
$application->add(new OCA\user_ldap\Command\CheckUser(
$uBackend, $helper, \OC::$server->getConfig()
diff --git a/apps/user_ldap/command/showremnants.php b/apps/user_ldap/command/showremnants.php
index 3d39f977421..fb9fc54ff6a 100644
--- a/apps/user_ldap/command/showremnants.php
+++ b/apps/user_ldap/command/showremnants.php
@@ -16,9 +16,21 @@ use Symfony\Component\Console\Output\OutputInterface;
use OCA\user_ldap\lib\user\DeletedUsersIndex;
use OCA\User_LDAP\lib\Connection;
-use OCA\User_LDAP\lib\Access;
+use OCA\User_LDAP\Mapping\UserMapping;
class ShowRemnants extends Command {
+ /** @var OCA\User_LDAP\Mapping\UserMapping */
+ protected $mapping;
+
+ /**
+ * @param OCA\user_ldap\User_Proxy $uBackend
+ * @param OCA\User_LDAP\lib\Helper $helper
+ * @param OCP\IConfig $config
+ */
+ public function __construct(UserMapping $mapper) {
+ $this->mapper = $mapper;
+ parent::__construct();
+ }
protected function configure() {
$this
@@ -31,7 +43,7 @@ class ShowRemnants extends Command {
$dui = new DeletedUsersIndex(
new \OC\Preferences(\OC_DB::getConnection()),
\OC::$server->getDatabaseConnection(),
- $this->getAccess()
+ $this->mapper
);
/** @var \Symfony\Component\Console\Helper\Table $table */
@@ -63,19 +75,4 @@ class ShowRemnants extends Command {
$table->setRows($rows);
$table->render($output);
}
-
- protected function getAccess() {
- $ldap = new \OCA\user_ldap\lib\LDAP();
- $dummyConnection = new Connection($ldap, '', null);
- $userManager = new \OCA\user_ldap\lib\user\Manager(
- \OC::$server->getConfig(),
- new \OCA\user_ldap\lib\FilesystemHelper(),
- new \OCA\user_ldap\lib\LogWrapper(),
- \OC::$server->getAvatarManager(),
- new \OCP\Image()
- );
- $access = new Access($dummyConnection, $ldap, $userManager);
- return $access;
- }
-
}
diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php
index 692afb98f99..3e9869b4d71 100644
--- a/apps/user_ldap/lib/access.php
+++ b/apps/user_ldap/lib/access.php
@@ -76,6 +76,18 @@ class Access extends LDAPUtility implements user\IUserTools {
}
/**
+ * returns the User Mapper
+ * @throws \Exception
+ * @return AbstractMapping
+ */
+ public function getUserMapper() {
+ if(is_null($this->userMapper)) {
+ throw new \Exception('UserMapper was not assigned to this Access instance.');
+ }
+ return $this->userMapper;
+ }
+
+ /**
* sets the Group Mapper
* @param AbstractMapping $mapper
*/
@@ -84,6 +96,18 @@ class Access extends LDAPUtility implements user\IUserTools {
}
/**
+ * returns the Group Mapper
+ * @throws \Exception
+ * @return AbstractMapping
+ */
+ public function getGroupMapper() {
+ if(is_null($this->groupMapper)) {
+ throw new \Exception('GroupMapper was not assigned to this Access instance.');
+ }
+ return $this->groupMapper;
+ }
+
+ /**
* @return bool
*/
private function checkConnection() {
@@ -333,10 +357,10 @@ class Access extends LDAPUtility implements user\IUserTools {
*/
public function dn2ocname($fdn, $ldapName = null, $isUser = true) {
if($isUser) {
- $mapper = $this->userMapper;
+ $mapper = $this->getUserMapper();
$nameAttribute = $this->connection->ldapUserDisplayName;
} else {
- $mapper = $this->groupMapper;
+ $mapper = $this->getGroupMapper();
$nameAttribute = $this->connection->ldapGroupDisplayName;
}
diff --git a/apps/user_ldap/lib/jobs.php b/apps/user_ldap/lib/jobs.php
index 30f09cdc8f8..391a10d31f8 100644
--- a/apps/user_ldap/lib/jobs.php
+++ b/apps/user_ldap/lib/jobs.php
@@ -23,6 +23,8 @@
namespace OCA\user_ldap\lib;
+use OCA\User_LDAP\Mapping\GroupMapping;
+
class Jobs extends \OC\BackgroundJob\TimedJob {
static private $groupsFromDB;
@@ -169,6 +171,7 @@ class Jobs extends \OC\BackgroundJob\TimedJob {
new \OCP\Image());
$connector = new Connection($ldapWrapper, $configPrefixes[0]);
$ldapAccess = new Access($connector, $ldapWrapper, $userManager);
+ $groupMapper = new GroupMapping(\OC::$server->getDatabaseConnection());
self::$groupBE = new \OCA\user_ldap\GROUP_LDAP($ldapAccess);
} else {
self::$groupBE = new \OCA\user_ldap\Group_Proxy($configPrefixes, $ldapWrapper);
diff --git a/apps/user_ldap/lib/user/deletedusersindex.php b/apps/user_ldap/lib/user/deletedusersindex.php
index 0d8bacffe94..e544d29bad5 100644
--- a/apps/user_ldap/lib/user/deletedusersindex.php
+++ b/apps/user_ldap/lib/user/deletedusersindex.php
@@ -24,7 +24,7 @@
namespace OCA\user_ldap\lib\user;
use OCA\user_ldap\lib\user\OfflineUser;
-use OCA\user_ldap\lib\Access;
+use OCA\User_LDAP\Mapping\UserMapping;
/**
* Class DeletedUsersIndex
@@ -42,9 +42,9 @@ class DeletedUsersIndex {
protected $db;
/**
- * @var \OCA\user_ldap\lib\Access $access
+ * @var \OCA\User_LDAP\Mapping\UserMapping $mapping
*/
- protected $access;
+ protected $mapping;
/**
* @var int $limit
@@ -56,10 +56,10 @@ class DeletedUsersIndex {
*/
protected $deletedUsers = false;
- public function __construct(\OC\Preferences $preferences, \OCP\IDBConnection $db, Access $access) {
+ public function __construct(\OC\Preferences $preferences, \OCP\IDBConnection $db, UserMapping $mapping) {
$this->preferences = $preferences;
$this->db = $db;
- $this->access = $access;
+ $this->mapping = $mapping;
}
/**
@@ -84,7 +84,7 @@ class DeletedUsersIndex {
$userObjects = array();
foreach($deletedUsers as $user) {
- $userObjects[] = new OfflineUser($user, $this->preferences, $this->db, $this->access);
+ $userObjects[] = new OfflineUser($user, $this->preferences, $this->db, $this->mapping);
}
$this->deletedUsers[$key] = $userObjects;
diff --git a/apps/user_ldap/lib/user/iusertools.php b/apps/user_ldap/lib/user/iusertools.php
index ffdef62410d..fcb00d2f746 100644
--- a/apps/user_ldap/lib/user/iusertools.php
+++ b/apps/user_ldap/lib/user/iusertools.php
@@ -38,8 +38,4 @@ interface IUserTools {
public function dn2username($dn, $ldapname = null);
public function username2dn($name);
-
- //temporary hack for LDAP user cleanup, will be removed in OC 8.
- public function ocname2dn($name, $isUser);
-
}
diff --git a/apps/user_ldap/lib/user/manager.php b/apps/user_ldap/lib/user/manager.php
index 1bcc9b96d8a..cd4f4441e1d 100644
--- a/apps/user_ldap/lib/user/manager.php
+++ b/apps/user_ldap/lib/user/manager.php
@@ -154,7 +154,7 @@ class Manager {
$id,
new \OC\Preferences(\OC_DB::getConnection()),
\OC::$server->getDatabaseConnection(),
- $this->access);
+ $this->access->getUserMapper());
}
protected function createInstancyByUserName($id) {
diff --git a/apps/user_ldap/lib/user/offlineuser.php b/apps/user_ldap/lib/user/offlineuser.php
index 7750348a280..7cf48bc05b1 100644
--- a/apps/user_ldap/lib/user/offlineuser.php
+++ b/apps/user_ldap/lib/user/offlineuser.php
@@ -23,7 +23,7 @@
namespace OCA\user_ldap\lib\user;
-use OCA\user_ldap\lib\Access;
+use OCA\User_LDAP\Mapping\UserMapping;
class OfflineUser {
/**
@@ -67,15 +67,15 @@ class OfflineUser {
*/
protected $db;
/**
- * @var \OCA\user_ldap\lib\Access
+ * @var OCA\User_LDAP\Mapping\UserMapping
*/
- protected $access;
+ protected $mapping;
- public function __construct($ocName, \OC\Preferences $preferences, \OCP\IDBConnection $db, Access $access) {
+ public function __construct($ocName, \OC\Preferences $preferences, \OCP\IDBConnection $db, UserMapping $mapping) {
$this->ocName = $ocName;
$this->preferences = $preferences;
$this->db = $db;
- $this->access = $access;
+ $this->mapping = $mapping;
$this->fetchDetails();
}
@@ -176,7 +176,7 @@ class OfflineUser {
$this->$property = $this->preferences->getValue($this->ocName, $app, $property, '');
}
- $dn = $this->access->ocname2dn($this->ocName, true);
+ $dn = $this->mapping->getDNByName($this->ocName);
$this->dn = ($dn !== false) ? $dn : '';
$this->determineShares();
diff --git a/apps/user_ldap/tests/user_ldap.php b/apps/user_ldap/tests/user_ldap.php
index 876b3d0903a..fdda35b63c9 100644
--- a/apps/user_ldap/tests/user_ldap.php
+++ b/apps/user_ldap/tests/user_ldap.php
@@ -239,6 +239,16 @@ class Test_User_Ldap_Direct extends \Test\TestCase {
public function testDeleteUserSuccess() {
$access = $this->getAccessMock();
+ $mapping = $this->getMockBuilder('\OCA\User_LDAP\Mapping\UserMapping')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $mapping->expects($this->once())
+ ->method('unmap')
+ ->will($this->returnValue(true));
+ $access->expects($this->once())
+ ->method('getUserMapper')
+ ->will($this->returnValue($mapping));
+
$backend = new UserLDAP($access);
$pref = \OC::$server->getConfig();
diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php
index 2274e4156cc..c2d0f387b9c 100644
--- a/apps/user_ldap/user_ldap.php
+++ b/apps/user_ldap/user_ldap.php
@@ -229,7 +229,7 @@ class USER_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
//necessary for removing directories as done by OC_User.
$home = $pref->getUserValue($uid, 'user_ldap', 'homePath', '');
$this->homesToKill[$uid] = $home;
- $this->access->unmapUser($uid);
+ $this->access->getUserMapper()->unmap($uid);
return true;
}