diff --git a/apps/encryption/lib/Migration.php b/apps/encryption/lib/Migration.php
index 30567dd042d3..0c283c575a31 100644
--- a/apps/encryption/lib/Migration.php
+++ b/apps/encryption/lib/Migration.php
@@ -320,7 +320,7 @@ private function renameFileKeys($user, $path, $trash = false) {
* @return array
*/
protected function getSystemMountPoints() {
- return \OC_Mount_Config::getSystemMountPoints();
+ return \OC\Files\External\LegacyUtil::getSystemMountPoints();
}
/**
diff --git a/apps/files_external/appinfo/app.php b/apps/files_external/appinfo/app.php
index e0c9dbf413ee..f27b320541f8 100644
--- a/apps/files_external/appinfo/app.php
+++ b/apps/files_external/appinfo/app.php
@@ -46,5 +46,3 @@
"name" => $l->t('External storage')
]);
-$mountProvider = $appContainer->query('OCA\Files_External\Config\ConfigAdapter');
-\OC::$server->getMountProviderCollection()->registerProvider($mountProvider);
diff --git a/apps/files_external/appinfo/database.xml b/apps/files_external/appinfo/database.xml
deleted file mode 100644
index 54ee642ead65..000000000000
--- a/apps/files_external/appinfo/database.xml
+++ /dev/null
@@ -1,225 +0,0 @@
-
- *dbname*
- true
- false
- utf8
-
- *dbprefix*external_mounts
-
-
- mount_id
- integer
- 0
- true
- 1
- 6
-
-
- mount_point
- text
- 128
- true
-
-
- storage_backend
- text
- 64
- true
-
-
- auth_backend
- text
- 64
- true
-
-
- priority
- integer
- 100
- 4
- true
-
-
-
- type
- integer
- 4
- true
-
-
-
-
- *dbprefix*external_applicable
-
-
- applicable_id
- integer
- 0
- true
- 1
- 6
-
-
-
- mount_id
- integer
- true
- 6
-
-
-
- type
- integer
- 4
- true
-
-
-
- value
- text
- 64
-
-
-
- applicable_mount
-
- mount_id
- ascending
-
-
-
- applicable_type_value
-
- type
- ascending
-
-
- value
- ascending
-
-
-
- applicable_type_value_mount
- true
-
- type
- ascending
-
-
- value
- ascending
-
-
- mount_id
- ascending
-
-
-
-
-
-
- *dbprefix*external_config
-
-
- config_id
- integer
- 0
- true
- 1
- 6
-
-
-
- mount_id
- integer
- true
- 6
-
-
- key
- text
- true
- 64
-
-
- value
- text
- true
- 4096
-
-
-
- config_mount
-
- mount_id
- ascending
-
-
-
- config_mount_key
- true
-
- mount_id
- ascending
-
-
- key
- ascending
-
-
-
-
-
-
- *dbprefix*external_options
-
-
- option_id
- integer
- 0
- true
- 1
- 6
-
-
-
- mount_id
- integer
- true
- 6
-
-
- key
- text
- true
- 64
-
-
- value
- text
- true
- 256
-
-
-
- option_mount
-
- mount_id
- ascending
-
-
-
- option_mount_key
- true
-
- mount_id
- ascending
-
-
- key
- ascending
-
-
-
-
-
diff --git a/apps/files_external/appinfo/info.xml b/apps/files_external/appinfo/info.xml
index 842918f1925d..2571aef76b33 100644
--- a/apps/files_external/appinfo/info.xml
+++ b/apps/files_external/appinfo/info.xml
@@ -13,7 +13,7 @@
admin-external-storage
false
- 0.6.0
+ 0.7.0
diff --git a/apps/files_external/lib/AppInfo/Application.php b/apps/files_external/lib/AppInfo/Application.php
index ccdfcb2ffa80..991667735641 100644
--- a/apps/files_external/lib/AppInfo/Application.php
+++ b/apps/files_external/lib/AppInfo/Application.php
@@ -30,9 +30,9 @@
use \OCP\AppFramework\App;
use OCP\AppFramework\IAppContainer;
use \OCP\IContainer;
-use \OCA\Files_External\Service\BackendService;
-use \OCA\Files_External\Lib\Config\IBackendProvider;
-use \OCA\Files_External\Lib\Config\IAuthMechanismProvider;
+use \OCP\Files\External\IStoragesBackendService;
+use \OCP\Files\External\Config\IBackendProvider;
+use \OCP\Files\External\Config\IAuthMechanismProvider;
/**
* @package OCA\Files_External\AppInfo
@@ -47,28 +47,28 @@ public function __construct(array $urlParams = []) {
$container->registerService('OCP\Files\Config\IUserMountCache', function (IAppContainer $c) {
return $c->getServer()->query('UserMountCache');
});
+ $container->registerService('OCP\Files\External\IStoragesBackendService', function (IAppContainer $c) {
+ return $c->getServer()->query('StoragesBackendService');
+ });
+ $container->registerService('OCP\Files\External\Service\IGlobalStoragesService', function (IAppContainer $c) {
+ return $c->getServer()->query('OCP\Files\External\Service\IGlobalStoragesService');
+ });
+ $container->registerService('OCP\Files\External\Service\IUserGlobalStoragesService', function (IAppContainer $c) {
+ return $c->getServer()->query('OCP\Files\External\Service\IUserGlobalStoragesService');
+ });
+ $container->registerService('OCP\Files\External\Service\IUserStoragesService', function (IAppContainer $c) {
+ return $c->getServer()->query('OCP\Files\External\Service\IUserStoragesService');
+ });
- $backendService = $container->query('OCA\\Files_External\\Service\\BackendService');
+ $backendService = $container->getServer()->query('StoragesBackendService');
$backendService->registerBackendProvider($this);
$backendService->registerAuthMechanismProvider($this);
-
- // force-load auth mechanisms since some will register hooks
- // TODO: obsolete these and use the TokenProvider to get the user's password from the session
- $this->getAuthMechanisms();
-
- // app developers: do NOT depend on this! it will disappear with oC 9.0!
- \OC::$server->getEventDispatcher()->dispatch(
- 'OCA\\Files_External::loadAdditionalBackends'
- );
}
/**
* Register settings templates
*/
public function registerSettings() {
- $container = $this->getContainer();
- $backendService = $container->query('OCA\\Files_External\\Service\\BackendService');
-
\OCP\App::registerAdmin('files_external', 'settings');
\OCP\App::registerPersonal('files_external', 'personal');
}
@@ -103,16 +103,6 @@ public function getAuthMechanisms() {
$container = $this->getContainer();
return [
- // AuthMechanism::SCHEME_NULL mechanism
- $container->query('OCA\Files_External\Lib\Auth\NullMechanism'),
-
- // AuthMechanism::SCHEME_BUILTIN mechanism
- $container->query('OCA\Files_External\Lib\Auth\Builtin'),
-
- // AuthMechanism::SCHEME_PASSWORD mechanisms
- $container->query('OCA\Files_External\Lib\Auth\Password\Password'),
- $container->query('OCA\Files_External\Lib\Auth\Password\SessionCredentials'),
-
// AuthMechanism::SCHEME_OAUTH1 mechanisms
$container->query('OCA\Files_External\Lib\Auth\OAuth1\OAuth1'),
diff --git a/apps/files_external/lib/Command/Applicable.php b/apps/files_external/lib/Command/Applicable.php
index 05784ff587c3..ec63fe0cf377 100644
--- a/apps/files_external/lib/Command/Applicable.php
+++ b/apps/files_external/lib/Command/Applicable.php
@@ -23,9 +23,9 @@
namespace OCA\Files_External\Command;
use OC\Core\Command\Base;
-use OCA\Files_External\Lib\StorageConfig;
-use OCA\Files_External\NotFoundException;
-use OCA\Files_External\Service\GlobalStoragesService;
+use OCP\Files\External\IStorageConfig;
+use OCP\Files\External\NotFoundException;
+use OCP\Files\External\Service\IGlobalStoragesService;
use OCP\IGroupManager;
use OCP\IUserManager;
use Symfony\Component\Console\Input\InputArgument;
@@ -35,7 +35,7 @@
class Applicable extends Base {
/**
- * @var GlobalStoragesService
+ * @var IGlobalStoragesService
*/
protected $globalService;
@@ -50,7 +50,7 @@ class Applicable extends Base {
private $groupManager;
function __construct(
- GlobalStoragesService $globalService,
+ IGlobalStoragesService $globalService,
IUserManager $userManager,
IGroupManager $groupManager
) {
@@ -106,7 +106,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
return 404;
}
- if ($mount->getType() === StorageConfig::MOUNT_TYPE_PERSONAl) {
+ if ($mount->getType() === IStorageConfig::MOUNT_TYPE_PERSONAl) {
$output->writeln('Can\'t change applicables on personal mounts');
return 1;
}
diff --git a/apps/files_external/lib/Command/Backends.php b/apps/files_external/lib/Command/Backends.php
index c9f77bd3be8b..d288ab960dd8 100644
--- a/apps/files_external/lib/Command/Backends.php
+++ b/apps/files_external/lib/Command/Backends.php
@@ -22,10 +22,10 @@
namespace OCA\Files_External\Command;
use OC\Core\Command\Base;
-use OCA\Files_External\Lib\Auth\AuthMechanism;
-use OCA\Files_External\Lib\Backend\Backend;
-use OCA\Files_External\Lib\DefinitionParameter;
-use OCA\Files_External\Service\BackendService;
+use OCP\Files\External\Auth\AuthMechanism;
+use OCP\Files\External\Backend\Backend;
+use OCP\Files\External\DefinitionParameter;
+use OCP\Files\External\IStoragesBackendService;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Helper\TableHelper;
@@ -37,10 +37,10 @@
use Symfony\Component\Console\Output\OutputInterface;
class Backends extends Base {
- /** @var BackendService */
+ /** @var IStoragesBackendService */
private $backendService;
- function __construct(BackendService $backendService
+ function __construct(IStoragesBackendService $backendService
) {
parent::__construct();
diff --git a/apps/files_external/lib/Command/Config.php b/apps/files_external/lib/Command/Config.php
index 50a799115773..21b331d94f93 100644
--- a/apps/files_external/lib/Command/Config.php
+++ b/apps/files_external/lib/Command/Config.php
@@ -23,9 +23,9 @@
namespace OCA\Files_External\Command;
use OC\Core\Command\Base;
-use OCA\Files_External\Lib\StorageConfig;
-use OCA\Files_External\NotFoundException;
-use OCA\Files_External\Service\GlobalStoragesService;
+use OCP\Files\External\IStorageConfig;
+use OCP\Files\External\NotFoundException;
+use OCP\Files\External\Service\IGlobalStoragesService;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Helper\TableHelper;
@@ -36,11 +36,11 @@
class Config extends Base {
/**
- * @var GlobalStoragesService
+ * @var IGlobalStoragesService
*/
protected $globalService;
- function __construct(GlobalStoragesService $globalService) {
+ function __construct(IGlobalStoragesService $globalService) {
parent::__construct();
$this->globalService = $globalService;
}
@@ -84,11 +84,11 @@ protected function execute(InputInterface $input, OutputInterface $output) {
}
/**
- * @param StorageConfig $mount
+ * @param IStorageConfig $mount
* @param string $key
* @param OutputInterface $output
*/
- protected function getOption(StorageConfig $mount, $key, OutputInterface $output) {
+ protected function getOption(IStorageConfig $mount, $key, OutputInterface $output) {
if ($key === 'mountpoint' || $key === 'mount_point') {
$value = $mount->getMountPoint();
} else {
@@ -101,12 +101,12 @@ protected function getOption(StorageConfig $mount, $key, OutputInterface $output
}
/**
- * @param StorageConfig $mount
+ * @param IStorageConfig $mount
* @param string $key
* @param string $value
* @param OutputInterface $output
*/
- protected function setOption(StorageConfig $mount, $key, $value, OutputInterface $output) {
+ protected function setOption(IStorageConfig $mount, $key, $value, OutputInterface $output) {
$decoded = json_decode($value, true);
if (!is_null($decoded)) {
$value = $decoded;
diff --git a/apps/files_external/lib/Command/Create.php b/apps/files_external/lib/Command/Create.php
index c9d40eac073f..4ef9a92d0c80 100644
--- a/apps/files_external/lib/Command/Create.php
+++ b/apps/files_external/lib/Command/Create.php
@@ -25,13 +25,13 @@
use OC\Core\Command\Base;
use OC\Files\Filesystem;
use OC\User\NoUserException;
-use OCA\Files_External\Lib\Auth\AuthMechanism;
-use OCA\Files_External\Lib\Backend\Backend;
-use OCA\Files_External\Lib\DefinitionParameter;
-use OCA\Files_External\Lib\StorageConfig;
-use OCA\Files_External\Service\BackendService;
-use OCA\Files_External\Service\GlobalStoragesService;
-use OCA\Files_External\Service\UserStoragesService;
+use OCP\Files\External\Auth\AuthMechanism;
+use OCP\Files\External\Backend\Backend;
+use OCP\Files\External\DefinitionParameter;
+use OCP\Files\External\IStorageConfig;
+use OCP\Files\External\IStoragesBackendService;
+use OCP\Files\External\Service\IGlobalStoragesService;
+use OCP\Files\External\Service\IUserStoragesService;
use OCP\IUserManager;
use OCP\IUserSession;
use Symfony\Component\Console\Input\ArrayInput;
@@ -42,12 +42,12 @@
class Create extends Base {
/**
- * @var GlobalStoragesService
+ * @var IGlobalStoragesService
*/
private $globalService;
/**
- * @var UserStoragesService
+ * @var IUserStoragesService
*/
private $userService;
@@ -56,17 +56,17 @@ class Create extends Base {
*/
private $userManager;
- /** @var BackendService */
+ /** @var IStoragesBackendService */
private $backendService;
/** @var IUserSession */
private $userSession;
- function __construct(GlobalStoragesService $globalService,
- UserStoragesService $userService,
+ function __construct(IGlobalStoragesService $globalService,
+ IUserStoragesService $userService,
IUserManager $userManager,
IUserSession $userSession,
- BackendService $backendService
+ IStoragesBackendService $backendService
) {
parent::__construct();
$this->globalService = $globalService;
@@ -158,7 +158,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
$config[$key] = $value;
}
- $mount = new StorageConfig();
+ $mount = $this->getStorageService($user)->createConfig();
$mount->setMountPoint($mountPoint);
$mount->setBackend($storageBackend);
$mount->setAuthMechanism($authBackend);
@@ -199,7 +199,7 @@ private function validateParam($key, &$value, Backend $storageBackend, AuthMecha
return false;
}
- private function showMount($user, StorageConfig $mount, InputInterface $input, OutputInterface $output) {
+ private function showMount($user, IStorageConfig $mount, InputInterface $input, OutputInterface $output) {
$listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager);
$listInput = new ArrayInput([], $listCommand->getDefinition());
$listInput->setOption('output', $input->getOption('output'));
diff --git a/apps/files_external/lib/Command/Delete.php b/apps/files_external/lib/Command/Delete.php
index 43792c6ce0fa..cf0f2fd4a999 100644
--- a/apps/files_external/lib/Command/Delete.php
+++ b/apps/files_external/lib/Command/Delete.php
@@ -23,9 +23,9 @@
namespace OCA\Files_External\Command;
use OC\Core\Command\Base;
-use OCA\Files_External\NotFoundException;
-use OCA\Files_External\Service\GlobalStoragesService;
-use OCA\Files_External\Service\UserStoragesService;
+use OCP\Files\External\NotFoundException;
+use OCP\Files\External\Service\IGlobalStoragesService;
+use OCP\Files\External\Service\IUserStoragesService;
use OCP\IUserManager;
use OCP\IUserSession;
use Symfony\Component\Console\Input\ArrayInput;
@@ -37,12 +37,12 @@
class Delete extends Base {
/**
- * @var GlobalStoragesService
+ * @var IGlobalStoragesService
*/
protected $globalService;
/**
- * @var UserStoragesService
+ * @var IUserStoragesService
*/
protected $userService;
@@ -56,7 +56,7 @@ class Delete extends Base {
*/
protected $userManager;
- function __construct(GlobalStoragesService $globalService, UserStoragesService $userService, IUserSession $userSession, IUserManager $userManager) {
+ function __construct(IGlobalStoragesService $globalService, IUserStoragesService $userService, IUserSession $userSession, IUserManager $userManager) {
parent::__construct();
$this->globalService = $globalService;
$this->userService = $userService;
diff --git a/apps/files_external/lib/Command/Import.php b/apps/files_external/lib/Command/Import.php
index 4c1498342ba1..cf245a88e062 100644
--- a/apps/files_external/lib/Command/Import.php
+++ b/apps/files_external/lib/Command/Import.php
@@ -24,11 +24,10 @@
use OC\Core\Command\Base;
use OC\User\NoUserException;
-use OCA\Files_External\Lib\StorageConfig;
-use OCA\Files_External\Service\BackendService;
-use OCA\Files_External\Service\GlobalStoragesService;
-use OCA\Files_External\Service\ImportLegacyStoragesService;
-use OCA\Files_External\Service\UserStoragesService;
+use OCP\Files\External\IStorageConfig;
+use OCP\Files\External\IStoragesBackendService;
+use OCP\Files\External\Service\IGlobalStoragesService;
+use OCP\Files\External\Service\IUserStoragesService;
use OCP\IUserManager;
use OCP\IUserSession;
use Symfony\Component\Console\Input\ArrayInput;
@@ -36,15 +35,16 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
+use OCP\Files\External\Service\IStoragesService;
class Import extends Base {
/**
- * @var GlobalStoragesService
+ * @var IGlobalStoragesService
*/
private $globalService;
/**
- * @var UserStoragesService
+ * @var IUserStoragesService
*/
private $userService;
@@ -58,25 +58,20 @@ class Import extends Base {
*/
private $userManager;
- /** @var ImportLegacyStoragesService */
- private $importLegacyStorageService;
-
- /** @var BackendService */
+ /** @var IStoragesBackendService */
private $backendService;
- function __construct(GlobalStoragesService $globalService,
- UserStoragesService $userService,
+ function __construct(IGlobalStoragesService $globalService,
+ IUserStoragesService $userService,
IUserSession $userSession,
IUserManager $userManager,
- ImportLegacyStoragesService $importLegacyStorageService,
- BackendService $backendService
+ IStoragesBackendService $backendService
) {
parent::__construct();
$this->globalService = $globalService;
$this->userService = $userService;
$this->userSession = $userSession;
$this->userManager = $userManager;
- $this->importLegacyStorageService = $importLegacyStorageService;
$this->backendService = $backendService;
}
@@ -126,21 +121,19 @@ protected function execute(InputInterface $input, OutputInterface $output) {
return 1;
}
+ $storageService = $this->getStorageService($user);
+
$isLegacy = isset($data['user']) || isset($data['group']);
if ($isLegacy) {
- $this->importLegacyStorageService->setData($data);
- $mounts = $this->importLegacyStorageService->getAllStorages();
- foreach ($mounts as $mount) {
- if ($mount->getBackendOption('password') === false) {
- $output->writeln('Failed to decrypt password');
- return 1;
- }
- }
+ $output->writeln('Importing legacy mount.json format not supported any more');
+ return 1;
} else {
if (!isset($data[0])) { //normalize to an array of mounts
$data = [$data];
}
- $mounts = array_map([$this, 'parseData'], $data);
+ $mounts = array_map(function($entry) use ($storageService) {
+ return $this->parseData($entry, $storageService);
+ }, $data);
}
if ($user) {
@@ -151,8 +144,6 @@ protected function execute(InputInterface $input, OutputInterface $output) {
}
}
- $storageService = $this->getStorageService($user);
-
$existingMounts = $storageService->getAllStorages();
foreach ($mounts as $mount) {
@@ -187,8 +178,10 @@ protected function execute(InputInterface $input, OutputInterface $output) {
return 0;
}
- private function parseData(array $data) {
- $mount = new StorageConfig($data['mount_id']);
+ private function parseData(array $data, IStoragesService $storageService) {
+ // FIXME: use service to create config
+ $mount = $storageService->createConfig();
+ $mount->setId($data['mount_id']);
$mount->setMountPoint($data['mount_point']);
$mount->setBackend($this->getBackendByClass($data['storage']));
$authBackend = $this->backendService->getAuthMechanism($data['authentication_type']);
diff --git a/apps/files_external/lib/Command/ListCommand.php b/apps/files_external/lib/Command/ListCommand.php
index 71a31219e9c8..683c1088db02 100644
--- a/apps/files_external/lib/Command/ListCommand.php
+++ b/apps/files_external/lib/Command/ListCommand.php
@@ -24,9 +24,9 @@
use OC\Core\Command\Base;
use OC\User\NoUserException;
-use OCA\Files_External\Lib\StorageConfig;
-use OCA\Files_External\Service\GlobalStoragesService;
-use OCA\Files_External\Service\UserStoragesService;
+use OCP\Files\External\IStorageConfig;
+use OCP\Files\External\Service\IGlobalStoragesService;
+use OCP\Files\External\Service\IUserStoragesService;
use OCP\IUserManager;
use OCP\IUserSession;
use Symfony\Component\Console\Helper\Table;
@@ -37,12 +37,12 @@
class ListCommand extends Base {
/**
- * @var GlobalStoragesService
+ * @var IGlobalStoragesService
*/
protected $globalService;
/**
- * @var UserStoragesService
+ * @var IUserStoragesService
*/
protected $userService;
@@ -58,7 +58,7 @@ class ListCommand extends Base {
const ALL = -1;
- function __construct(GlobalStoragesService $globalService, UserStoragesService $userService, IUserSession $userSession, IUserManager $userManager) {
+ function __construct(IGlobalStoragesService $globalService, IUserStoragesService $userService, IUserSession $userSession, IUserManager $userManager) {
parent::__construct();
$this->globalService = $globalService;
$this->userService = $userService;
@@ -95,14 +95,14 @@ protected function configure() {
protected function execute(InputInterface $input, OutputInterface $output) {
if ($input->getOption('all')) {
- /** @var $mounts StorageConfig[] */
+ /** @var $mounts IStorageConfig[] */
$mounts = $this->globalService->getStorageForAllUsers();
$userId = self::ALL;
} else {
$userId = $input->getArgument('user_id');
$storageService = $this->getStorageService($userId);
- /** @var $mounts StorageConfig[] */
+ /** @var $mounts IStorageConfig[] */
$mounts = $storageService->getAllStorages();
}
@@ -111,7 +111,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
/**
* @param $userId $userId
- * @param StorageConfig[] $mounts
+ * @param IStorageConfig[] $mounts
* @param InputInterface $input
* @param OutputInterface $output
*/
@@ -159,7 +159,7 @@ public function listMounts($userId, array $mounts, InputInterface $input, Output
return strtolower(str_replace(' ', '_', $header));
}, $headers);
- $pairs = array_map(function (StorageConfig $config) use ($keys, $userId) {
+ $pairs = array_map(function (IStorageConfig $config) use ($keys, $userId) {
$values = [
$config->getId(),
$config->getMountPoint(),
@@ -173,7 +173,7 @@ public function listMounts($userId, array $mounts, InputInterface $input, Output
$values[] = $config->getApplicableGroups();
}
if ($userId === self::ALL) {
- $values[] = $config->getType() === StorageConfig::MOUNT_TYPE_ADMIN ? 'admin' : 'personal';
+ $values[] = $config->getType() === IStorageConfig::MOUNT_TYPE_ADMIN ? 'admin' : 'personal';
}
return array_combine($keys, $values);
@@ -192,7 +192,7 @@ public function listMounts($userId, array $mounts, InputInterface $input, Output
'enable_sharing' => false,
'encoding_compatibility' => false
];
- $rows = array_map(function (StorageConfig $config) use ($userId, $defaultMountOptions, $full) {
+ $rows = array_map(function (IStorageConfig $config) use ($userId, $defaultMountOptions, $full) {
$storageConfig = $config->getBackendOptions();
$keys = array_keys($storageConfig);
$values = array_values($storageConfig);
@@ -246,7 +246,7 @@ public function listMounts($userId, array $mounts, InputInterface $input, Output
$values[] = $applicableGroups;
}
if ($userId === self::ALL) {
- $values[] = $config->getType() === StorageConfig::MOUNT_TYPE_ADMIN ? 'Admin' : 'Personal';
+ $values[] = $config->getType() === IStorageConfig::MOUNT_TYPE_ADMIN ? 'Admin' : 'Personal';
}
return $values;
diff --git a/apps/files_external/lib/Command/Option.php b/apps/files_external/lib/Command/Option.php
index a7652f625fe2..378bd4e88c69 100644
--- a/apps/files_external/lib/Command/Option.php
+++ b/apps/files_external/lib/Command/Option.php
@@ -22,7 +22,7 @@
namespace OCA\Files_External\Command;
-use OCA\Files_External\Lib\StorageConfig;
+use OCP\Files\External\IStorageConfig;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Output\OutputInterface;
@@ -47,11 +47,11 @@ protected function configure() {
}
/**
- * @param StorageConfig $mount
+ * @param IStorageConfig $mount
* @param string $key
* @param OutputInterface $output
*/
- protected function getOption(StorageConfig $mount, $key, OutputInterface $output) {
+ protected function getOption(IStorageConfig $mount, $key, OutputInterface $output) {
$value = $mount->getMountOption($key);
if (!is_string($value)) { // show bools and objects correctly
$value = json_encode($value);
@@ -60,12 +60,12 @@ protected function getOption(StorageConfig $mount, $key, OutputInterface $output
}
/**
- * @param StorageConfig $mount
+ * @param IStorageConfig $mount
* @param string $key
* @param string $value
* @param OutputInterface $output
*/
- protected function setOption(StorageConfig $mount, $key, $value, OutputInterface $output) {
+ protected function setOption(IStorageConfig $mount, $key, $value, OutputInterface $output) {
$decoded = json_decode($value, true);
if (!is_null($decoded)) {
$value = $decoded;
diff --git a/apps/files_external/lib/Command/Verify.php b/apps/files_external/lib/Command/Verify.php
index 5e1c7b2ce073..25e47edafc73 100644
--- a/apps/files_external/lib/Command/Verify.php
+++ b/apps/files_external/lib/Command/Verify.php
@@ -23,12 +23,12 @@
namespace OCA\Files_External\Command;
use OC\Core\Command\Base;
-use OCA\Files_External\Lib\Auth\AuthMechanism;
-use OCA\Files_External\Lib\Backend\Backend;
-use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
-use OCA\Files_External\Lib\StorageConfig;
-use OCA\Files_External\NotFoundException;
-use OCA\Files_External\Service\GlobalStoragesService;
+use OCP\Files\External\Auth\AuthMechanism;
+use OCP\Files\External\Backend\Backend;
+use OCP\Files\External\InsufficientDataForMeaningfulAnswerException;
+use OCP\Files\External\IStorageConfig;
+use OCP\Files\External\NotFoundException;
+use OCP\Files\External\Service\IGlobalStoragesService;
use OCP\Files\StorageNotAvailableException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
@@ -37,11 +37,11 @@
class Verify extends Base {
/**
- * @var GlobalStoragesService
+ * @var IGlobalStoragesService
*/
protected $globalService;
- function __construct(GlobalStoragesService $globalService) {
+ function __construct(IGlobalStoragesService $globalService) {
parent::__construct();
$this->globalService = $globalService;
}
@@ -83,7 +83,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
]);
}
- private function manipulateStorageConfig(StorageConfig $storage) {
+ private function manipulateStorageConfig(IStorageConfig $storage) {
/** @var AuthMechanism */
$authMechanism = $storage->getAuthMechanism();
$authMechanism->manipulateStorageConfig($storage);
@@ -92,7 +92,7 @@ private function manipulateStorageConfig(StorageConfig $storage) {
$backend->manipulateStorageConfig($storage);
}
- private function updateStorageStatus(StorageConfig &$storage, $configInput, OutputInterface $output) {
+ private function updateStorageStatus(IStorageConfig &$storage, $configInput, OutputInterface $output) {
try {
try {
$this->manipulateStorageConfig($storage);
diff --git a/apps/files_external/lib/Controller/GlobalStoragesController.php b/apps/files_external/lib/Controller/GlobalStoragesController.php
index 1cb045096c6e..36042d7ca882 100644
--- a/apps/files_external/lib/Controller/GlobalStoragesController.php
+++ b/apps/files_external/lib/Controller/GlobalStoragesController.php
@@ -27,12 +27,12 @@
use OCP\ILogger;
-use \OCP\IRequest;
-use \OCP\IL10N;
-use \OCP\AppFramework\Http\DataResponse;
-use \OCP\AppFramework\Http;
-use OCA\Files_External\Service\GlobalStoragesService;
-use OCA\Files_External\NotFoundException;
+use OCP\IRequest;
+use OCP\IL10N;
+use OCP\AppFramework\Http\DataResponse;
+use OCP\AppFramework\Http;
+use OCP\Files\External\Service\IGlobalStoragesService;
+use OCP\Files\External\NotFoundException;
/**
* Global storages controller
@@ -44,14 +44,14 @@ class GlobalStoragesController extends StoragesController {
* @param string $AppName application name
* @param IRequest $request request object
* @param IL10N $l10n l10n service
- * @param GlobalStoragesService $globalStoragesService storage service
+ * @param IGlobalStoragesService $globalStoragesService storage service
* @param ILogger $logger
*/
public function __construct(
$AppName,
IRequest $request,
IL10N $l10n,
- GlobalStoragesService $globalStoragesService,
+ IGlobalStoragesService $globalStoragesService,
ILogger $logger
) {
parent::__construct(
diff --git a/apps/files_external/lib/Controller/StoragesController.php b/apps/files_external/lib/Controller/StoragesController.php
index 6e75390cc61a..b8b2ad9f6624 100644
--- a/apps/files_external/lib/Controller/StoragesController.php
+++ b/apps/files_external/lib/Controller/StoragesController.php
@@ -28,18 +28,18 @@
use OCP\ILogger;
-use \OCP\IRequest;
-use \OCP\IL10N;
-use \OCP\AppFramework\Http\DataResponse;
-use \OCP\AppFramework\Controller;
-use \OCP\AppFramework\Http;
-use OCA\Files_External\Service\StoragesService;
-use OCA\Files_External\NotFoundException;
-use OCA\Files_External\Lib\StorageConfig;
-use \OCA\Files_External\Lib\Backend\Backend;
-use \OCA\Files_External\Lib\Auth\AuthMechanism;
-use \OCP\Files\StorageNotAvailableException;
-use \OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
+use OCP\IRequest;
+use OCP\IL10N;
+use OCP\AppFramework\Http\DataResponse;
+use OCP\AppFramework\Controller;
+use OCP\AppFramework\Http;
+use OCP\Files\External\Service\IStoragesService;
+use OCP\Files\External\NotFoundException;
+use OCP\Files\External\IStorageConfig;
+use OCP\Files\External\Backend\Backend;
+use OCP\Files\External\Auth\AuthMechanism;
+use OCP\Files\StorageNotAvailableException;
+use OCP\Files\External\InsufficientDataForMeaningfulAnswerException;
/**
* Base class for storages controllers
@@ -56,7 +56,7 @@ abstract class StoragesController extends Controller {
/**
* Storages service
*
- * @var StoragesService
+ * @var IStoragesService
*/
protected $service;
@@ -71,14 +71,14 @@ abstract class StoragesController extends Controller {
* @param string $AppName application name
* @param IRequest $request request object
* @param IL10N $l10n l10n service
- * @param StoragesService $storagesService storage service
+ * @param IStoragesService $storagesService storage service
* @param ILogger $logger
*/
public function __construct(
$AppName,
IRequest $request,
IL10N $l10n,
- StoragesService $storagesService,
+ IStoragesService $storagesService,
ILogger $logger
) {
parent::__construct($AppName, $request);
@@ -99,7 +99,7 @@ public function __construct(
* @param array|null $applicableGroups groups for which to mount the storage
* @param int|null $priority priority
*
- * @return StorageConfig|DataResponse
+ * @return IStorageConfig|DataResponse
*/
protected function createStorage(
$mountPoint,
@@ -136,11 +136,11 @@ protected function createStorage(
/**
* Validate storage config
*
- * @param StorageConfig $storage storage config
+ * @param IStorageConfig $storage storage config
*1
* @return DataResponse|null returns response in case of validation error
*/
- protected function validate(StorageConfig $storage) {
+ protected function validate(IStorageConfig $storage) {
$mountPoint = $storage->getMountPoint();
if ($mountPoint === '' || $mountPoint === '/') {
return new DataResponse(
@@ -222,7 +222,7 @@ protected function validate(StorageConfig $storage) {
return null;
}
- protected function manipulateStorageConfig(StorageConfig $storage) {
+ protected function manipulateStorageConfig(IStorageConfig $storage) {
/** @var AuthMechanism */
$authMechanism = $storage->getAuthMechanism();
$authMechanism->manipulateStorageConfig($storage);
@@ -237,10 +237,10 @@ protected function manipulateStorageConfig(StorageConfig $storage) {
* Note that this operation can be time consuming depending
* on whether the remote storage is available or not.
*
- * @param StorageConfig $storage storage configuration
+ * @param IStorageConfig $storage storage configuration
* @param bool $testOnly whether to storage should only test the connection or do more things
*/
- protected function updateStorageStatus(StorageConfig &$storage, $testOnly = true) {
+ protected function updateStorageStatus(IStorageConfig &$storage, $testOnly = true) {
try {
$this->manipulateStorageConfig($storage);
diff --git a/apps/files_external/lib/Controller/UserGlobalStoragesController.php b/apps/files_external/lib/Controller/UserGlobalStoragesController.php
index 0b8b6a47b2a2..3c9744b554ed 100644
--- a/apps/files_external/lib/Controller/UserGlobalStoragesController.php
+++ b/apps/files_external/lib/Controller/UserGlobalStoragesController.php
@@ -24,18 +24,18 @@
namespace OCA\Files_External\Controller;
-use OCA\Files_External\Lib\Auth\AuthMechanism;
-use OCA\Files_External\Lib\Auth\IUserProvided;
-use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
+use OCP\Files\External\Auth\AuthMechanism;
+use OCP\Files\External\Auth\IUserProvided;
+use OCP\Files\External\InsufficientDataForMeaningfulAnswerException;
use OCP\ILogger;
-use \OCP\IRequest;
-use \OCP\IL10N;
-use \OCP\AppFramework\Http\DataResponse;
-use \OCP\AppFramework\Http;
-use OCA\Files_External\Service\UserGlobalStoragesService;
-use OCA\Files_External\NotFoundException;
-use OCA\Files_External\Lib\StorageConfig;
-use \OCA\Files_External\Lib\Backend\Backend;
+use OCP\IRequest;
+use OCP\IL10N;
+use OCP\AppFramework\Http\DataResponse;
+use OCP\AppFramework\Http;
+use OCP\Files\External\Service\IUserGlobalStoragesService;
+use OCP\Files\External\NotFoundException;
+use OCP\Files\External\IStorageConfig;
+use OCP\Files\External\Backend\Backend;
use OCP\IUserSession;
/**
@@ -53,14 +53,14 @@ class UserGlobalStoragesController extends StoragesController {
* @param string $AppName application name
* @param IRequest $request request object
* @param IL10N $l10n l10n service
- * @param UserGlobalStoragesService $userGlobalStoragesService storage service
+ * @param IUserGlobalStoragesService $userGlobalStoragesService storage service
* @param IUserSession $userSession
*/
public function __construct(
$AppName,
IRequest $request,
IL10N $l10n,
- UserGlobalStoragesService $userGlobalStoragesService,
+ IUserGlobalStoragesService $userGlobalStoragesService,
IUserSession $userSession,
ILogger $logger
) {
@@ -95,7 +95,7 @@ public function index() {
);
}
- protected function manipulateStorageConfig(StorageConfig $storage) {
+ protected function manipulateStorageConfig(IStorageConfig $storage) {
/** @var AuthMechanism */
$authMechanism = $storage->getAuthMechanism();
$authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser());
@@ -186,11 +186,11 @@ public function update(
}
/**
- * Remove sensitive data from a StorageConfig before returning it to the user
+ * Remove sensitive data from a IStorageConfig before returning it to the user
*
- * @param StorageConfig $storage
+ * @param IStorageConfig $storage
*/
- protected function sanitizeStorage(StorageConfig $storage) {
+ protected function sanitizeStorage(IStorageConfig $storage) {
$storage->setBackendOptions([]);
$storage->setMountOptions([]);
diff --git a/apps/files_external/lib/Controller/UserStoragesController.php b/apps/files_external/lib/Controller/UserStoragesController.php
index f80c6fbfd9e3..aa47650f5c24 100644
--- a/apps/files_external/lib/Controller/UserStoragesController.php
+++ b/apps/files_external/lib/Controller/UserStoragesController.php
@@ -26,17 +26,17 @@
namespace OCA\Files_External\Controller;
-use OCA\Files_External\Lib\Auth\AuthMechanism;
use OCP\ILogger;
-use \OCP\IUserSession;
-use \OCP\IRequest;
-use \OCP\IL10N;
-use \OCP\AppFramework\Http\DataResponse;
-use \OCP\AppFramework\Http;
-use OCA\Files_External\Service\UserStoragesService;
-use OCA\Files_External\NotFoundException;
-use OCA\Files_External\Lib\StorageConfig;
-use \OCA\Files_External\Lib\Backend\Backend;
+use OCP\IUserSession;
+use OCP\IRequest;
+use OCP\IL10N;
+use OCP\AppFramework\Http\DataResponse;
+use OCP\AppFramework\Http;
+use OCP\Files\External\Auth\AuthMechanism;
+use OCP\Files\External\Service\IUserStoragesService;
+use OCP\Files\External\NotFoundException;
+use OCP\Files\External\IStorageConfig;
+use OCP\Files\External\Lib\Backend\Backend;
/**
* User storages controller
@@ -53,7 +53,7 @@ class UserStoragesController extends StoragesController {
* @param string $AppName application name
* @param IRequest $request request object
* @param IL10N $l10n l10n service
- * @param UserStoragesService $userStoragesService storage service
+ * @param IUserStoragesService $userStoragesService storage service
* @param IUserSession $userSession
* @param ILogger $logger
*/
@@ -61,7 +61,7 @@ public function __construct(
$AppName,
IRequest $request,
IL10N $l10n,
- UserStoragesService $userStoragesService,
+ IUserStoragesService $userStoragesService,
IUserSession $userSession,
ILogger $logger
) {
@@ -75,7 +75,7 @@ public function __construct(
$this->userSession = $userSession;
}
- protected function manipulateStorageConfig(StorageConfig $storage) {
+ protected function manipulateStorageConfig(IStorageConfig $storage) {
/** @var AuthMechanism */
$authMechanism = $storage->getAuthMechanism();
$authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser());
diff --git a/apps/files_external/lib/Lib/Api.php b/apps/files_external/lib/Lib/Api.php
index fada53fdf49e..865fee7859d7 100644
--- a/apps/files_external/lib/Lib/Api.php
+++ b/apps/files_external/lib/Lib/Api.php
@@ -74,6 +74,7 @@ private static function formatMount($mountPoint, $mountConfig) {
* @return \OC_OCS_Result share information
*/
public static function getUserMounts($params) {
+ // FIXME: use the service API for this
$entries = [];
$user = \OC::$server->getUserSession()->getUser()->getUID();
diff --git a/apps/files_external/lib/Lib/Auth/AmazonS3/AccessKey.php b/apps/files_external/lib/Lib/Auth/AmazonS3/AccessKey.php
index 9119ff119a13..51bf6c1d99c8 100644
--- a/apps/files_external/lib/Lib/Auth/AmazonS3/AccessKey.php
+++ b/apps/files_external/lib/Lib/Auth/AmazonS3/AccessKey.php
@@ -21,9 +21,9 @@
namespace OCA\Files_External\Lib\Auth\AmazonS3;
-use \OCP\IL10N;
-use \OCA\Files_External\Lib\DefinitionParameter;
-use \OCA\Files_External\Lib\Auth\AuthMechanism;
+use OCP\IL10N;
+use OCP\Files\External\Auth\AuthMechanism;
+use OCP\Files\External\DefinitionParameter;
/**
* Amazon S3 access key authentication
diff --git a/apps/files_external/lib/Lib/Auth/OAuth1/OAuth1.php b/apps/files_external/lib/Lib/Auth/OAuth1/OAuth1.php
index 6c3640569520..a2a1e608d836 100644
--- a/apps/files_external/lib/Lib/Auth/OAuth1/OAuth1.php
+++ b/apps/files_external/lib/Lib/Auth/OAuth1/OAuth1.php
@@ -21,9 +21,9 @@
namespace OCA\Files_External\Lib\Auth\OAuth1;
-use \OCP\IL10N;
-use \OCA\Files_External\Lib\DefinitionParameter;
-use \OCA\Files_External\Lib\Auth\AuthMechanism;
+use OCP\IL10N;
+use OCP\Files\External\Auth\AuthMechanism;
+use OCP\Files\External\DefinitionParameter;
/**
* OAuth1 authentication
diff --git a/apps/files_external/lib/Lib/Auth/OAuth2/OAuth2.php b/apps/files_external/lib/Lib/Auth/OAuth2/OAuth2.php
index e9c5c01332b2..abcee5680e00 100644
--- a/apps/files_external/lib/Lib/Auth/OAuth2/OAuth2.php
+++ b/apps/files_external/lib/Lib/Auth/OAuth2/OAuth2.php
@@ -21,9 +21,9 @@
namespace OCA\Files_External\Lib\Auth\OAuth2;
-use \OCP\IL10N;
-use \OCA\Files_External\Lib\DefinitionParameter;
-use \OCA\Files_External\Lib\Auth\AuthMechanism;
+use OCP\IL10N;
+use OCP\Files\External\Auth\AuthMechanism;
+use OCP\Files\External\DefinitionParameter;
/**
* OAuth2 authentication
diff --git a/apps/files_external/lib/Lib/Auth/OpenStack/OpenStack.php b/apps/files_external/lib/Lib/Auth/OpenStack/OpenStack.php
index de85ad379c48..cbae1608a37d 100644
--- a/apps/files_external/lib/Lib/Auth/OpenStack/OpenStack.php
+++ b/apps/files_external/lib/Lib/Auth/OpenStack/OpenStack.php
@@ -21,9 +21,9 @@
namespace OCA\Files_External\Lib\Auth\OpenStack;
-use \OCP\IL10N;
-use \OCA\Files_External\Lib\DefinitionParameter;
-use \OCA\Files_External\Lib\Auth\AuthMechanism;
+use OCP\IL10N;
+use OCP\Files\External\Auth\AuthMechanism;
+use OCP\Files\External\DefinitionParameter;
/**
* OpenStack Keystone authentication
diff --git a/apps/files_external/lib/Lib/Auth/OpenStack/Rackspace.php b/apps/files_external/lib/Lib/Auth/OpenStack/Rackspace.php
index 09fec2712981..f36999899311 100644
--- a/apps/files_external/lib/Lib/Auth/OpenStack/Rackspace.php
+++ b/apps/files_external/lib/Lib/Auth/OpenStack/Rackspace.php
@@ -21,9 +21,9 @@
namespace OCA\Files_External\Lib\Auth\OpenStack;
-use \OCP\IL10N;
-use \OCA\Files_External\Lib\DefinitionParameter;
-use \OCA\Files_External\Lib\Auth\AuthMechanism;
+use OCP\IL10N;
+use OCP\Files\External\Auth\AuthMechanism;
+use OCP\Files\External\DefinitionParameter;
/**
* Rackspace authentication
diff --git a/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php b/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php
index 0c5f13ea056a..f640ceae023d 100644
--- a/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php
+++ b/apps/files_external/lib/Lib/Auth/PublicKey/RSA.php
@@ -21,11 +21,11 @@
namespace OCA\Files_External\Lib\Auth\PublicKey;
-use \OCP\IL10N;
-use \OCA\Files_External\Lib\DefinitionParameter;
-use \OCA\Files_External\Lib\Auth\AuthMechanism;
-use \OCA\Files_External\Lib\StorageConfig;
-use \OCP\IConfig;
+use OCP\IL10N;
+use OCP\Files\External\Auth\AuthMechanism;
+use OCP\Files\External\DefinitionParameter;
+use OCP\Files\External\IStorageConfig;
+use OCP\IConfig;
use OCP\IUser;
use \phpseclib\Crypt\RSA as RSACrypt;
@@ -56,7 +56,7 @@ public function __construct(IL10N $l, IConfig $config) {
;
}
- public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) {
+ public function manipulateStorageConfig(IStorageConfig &$storage, IUser $user = null) {
$auth = new RSACrypt();
$auth->setPassword($this->config->getSystemValue('secret', ''));
if (!$auth->loadKey($storage->getBackendOption('private_key'))) {
diff --git a/apps/files_external/lib/Lib/Backend/AmazonS3.php b/apps/files_external/lib/Lib/Backend/AmazonS3.php
index 132669016e59..6b5a32dff1bd 100644
--- a/apps/files_external/lib/Lib/Backend/AmazonS3.php
+++ b/apps/files_external/lib/Lib/Backend/AmazonS3.php
@@ -21,20 +21,19 @@
namespace OCA\Files_External\Lib\Backend;
-use \OCP\IL10N;
-use \OCA\Files_External\Lib\Backend\Backend;
-use \OCA\Files_External\Lib\DefinitionParameter;
-use \OCA\Files_External\Lib\Auth\AuthMechanism;
-use \OCA\Files_External\Service\BackendService;
-use \OCA\Files_External\Lib\LegacyDependencyCheckPolyfill;
+use OCP\IL10N;
+use OCP\Files\External\Auth\AuthMechanism;
+use OCP\Files\External\Backend\Backend;
+use OCP\Files\External\DefinitionParameter;
+use OCA\Files_External\Lib\LegacyDependencyCheckPolyfill;
-use \OCA\Files_External\Lib\Auth\AmazonS3\AccessKey;
+use OCA\Files_External\Lib\Auth\AmazonS3\AccessKey;
class AmazonS3 extends Backend {
use LegacyDependencyCheckPolyfill;
- public function __construct(IL10N $l, AccessKey $legacyAuth) {
+ public function __construct(IL10N $l) {
$this
->setIdentifier('amazons3')
->addIdentifierAlias('\OC\Files\Storage\AmazonS3') // legacy compat
@@ -53,8 +52,7 @@ public function __construct(IL10N $l, AccessKey $legacyAuth) {
(new DefinitionParameter('use_path_style', $l->t('Enable Path Style')))
->setType(DefinitionParameter::VALUE_BOOLEAN),
])
- ->addAuthScheme(AccessKey::SCHEME_AMAZONS3_ACCESSKEY)
- ->setLegacyAuthMechanism($legacyAuth)
+ ->addAuthScheme(AccessKey::SCHEME_AMAZONS3_ACCESSKEY);
;
}
diff --git a/apps/files_external/lib/Lib/Backend/Backend.php b/apps/files_external/lib/Lib/Backend/Backend.php
index 452e9c21cb22..148a6c6fd644 100644
--- a/apps/files_external/lib/Lib/Backend/Backend.php
+++ b/apps/files_external/lib/Lib/Backend/Backend.php
@@ -21,145 +21,10 @@
namespace OCA\Files_External\Lib\Backend;
-use \OCA\Files_External\Lib\StorageConfig;
-use \OCA\Files_External\Lib\VisibilityTrait;
-use \OCA\Files_External\Lib\FrontendDefinitionTrait;
-use \OCA\Files_External\Lib\PriorityTrait;
-use \OCA\Files_External\Lib\DependencyTrait;
-use \OCA\Files_External\Lib\StorageModifierTrait;
-use \OCA\Files_External\Lib\IdentifierTrait;
-use \OCA\Files_External\Lib\Auth\AuthMechanism;
-
/**
- * Storage backend
- *
- * A backend can have services injected during construction,
- * such as \OCP\IDB for database operations. This allows a backend
- * to perform advanced operations based on provided information.
- *
- * An authenication scheme defines the parameter interface, common to the
- * storage implementation, the backend and the authentication mechanism.
- * A storage implementation expects parameters according to the authentication
- * scheme, which are provided from the authentication mechanism.
- *
- * This class uses the following traits:
- * - VisibilityTrait
- * Restrict usage to admin-only/none
- * - FrontendDefinitionTrait
- * Specify configuration parameters and other definitions
- * - PriorityTrait
- * Allow objects to prioritize over others with the same mountpoint
- * - DependencyTrait
- * The object requires certain dependencies to be met
- * - StorageModifierTrait
- * Object can affect storage mounting
+ * @deprecated use \OCP\Files\External\Backend instead
*/
-class Backend implements \JsonSerializable {
-
- use VisibilityTrait;
- use FrontendDefinitionTrait;
- use PriorityTrait;
- use DependencyTrait;
- use StorageModifierTrait;
- use IdentifierTrait;
-
- /** @var string storage class */
- private $storageClass;
-
- /** @var array 'scheme' => true, supported authentication schemes */
- private $authSchemes = [];
-
- /** @var AuthMechanism|callable authentication mechanism fallback */
- private $legacyAuthMechanism;
-
- /**
- * @return string
- */
- public function getStorageClass() {
- return $this->storageClass;
- }
-
- /**
- * @param string $class
- * @return self
- */
- public function setStorageClass($class) {
- $this->storageClass = $class;
- return $this;
- }
-
- /**
- * @return array
- */
- public function getAuthSchemes() {
- if (empty($this->authSchemes)) {
- return [AuthMechanism::SCHEME_NULL => true];
- }
- return $this->authSchemes;
- }
-
- /**
- * @param string $scheme
- * @return self
- */
- public function addAuthScheme($scheme) {
- $this->authSchemes[$scheme] = true;
- return $this;
- }
-
- /**
- * @param array $parameters storage parameters, for dynamic mechanism selection
- * @return AuthMechanism
- */
- public function getLegacyAuthMechanism(array $parameters = []) {
- if (is_callable($this->legacyAuthMechanism)) {
- return call_user_func($this->legacyAuthMechanism, $parameters);
- }
- return $this->legacyAuthMechanism;
- }
-
- /**
- * @param AuthMechanism $authMechanism
- * @return self
- */
- public function setLegacyAuthMechanism(AuthMechanism $authMechanism) {
- $this->legacyAuthMechanism = $authMechanism;
- return $this;
- }
-
- /**
- * @param callable $callback dynamic auth mechanism selection
- * @return self
- */
- public function setLegacyAuthMechanismCallback(callable $callback) {
- $this->legacyAuthMechanism = $callback;
- }
-
- /**
- * Serialize into JSON for client-side JS
- *
- * @return array
- */
- public function jsonSerialize() {
- $data = $this->jsonSerializeDefinition();
- $data += $this->jsonSerializeIdentifier();
-
- $data['backend'] = $data['name']; // legacy compat
- $data['priority'] = $this->getPriority();
- $data['authSchemes'] = $this->getAuthSchemes();
-
- return $data;
- }
-
- /**
- * Check if parameters are satisfied in a StorageConfig
- *
- * @param StorageConfig $storage
- * @return bool
- */
- public function validateStorage(StorageConfig $storage) {
- return $this->validateStorageDefinition($storage);
- }
+class Backend extends \OCP\Files\External\Backend\Backend {
}
diff --git a/apps/files_external/lib/Lib/Backend/DAV.php b/apps/files_external/lib/Lib/Backend/DAV.php
index 516130066252..c95843fd8ed6 100644
--- a/apps/files_external/lib/Lib/Backend/DAV.php
+++ b/apps/files_external/lib/Lib/Backend/DAV.php
@@ -21,20 +21,17 @@
namespace OCA\Files_External\Lib\Backend;
-use \OCP\IL10N;
-use \OCA\Files_External\Lib\Backend\Backend;
-use \OCA\Files_External\Lib\DefinitionParameter;
-use \OCA\Files_External\Lib\Auth\AuthMechanism;
-use \OCA\Files_External\Service\BackendService;
-use \OCA\Files_External\Lib\LegacyDependencyCheckPolyfill;
-
-use \OCA\Files_External\Lib\Auth\Password\Password;
+use OCP\IL10N;
+use OCP\Files\External\DefinitionParameter;
+use OCP\Files\External\Auth\AuthMechanism;
+use OCP\Files\External\Backend\Backend;
+use OCA\Files_External\Lib\LegacyDependencyCheckPolyfill;
class DAV extends Backend {
use LegacyDependencyCheckPolyfill;
- public function __construct(IL10N $l, Password $legacyAuth) {
+ public function __construct(IL10N $l) {
$this
->setIdentifier('dav')
->addIdentifierAlias('\OC\Files\Storage\DAV') // legacy compat
@@ -47,8 +44,7 @@ public function __construct(IL10N $l, Password $legacyAuth) {
(new DefinitionParameter('secure', $l->t('Secure https://')))
->setType(DefinitionParameter::VALUE_BOOLEAN),
])
- ->addAuthScheme(AuthMechanism::SCHEME_PASSWORD)
- ->setLegacyAuthMechanism($legacyAuth)
+ ->addAuthScheme(AuthMechanism::SCHEME_PASSWORD);
;
}
diff --git a/apps/files_external/lib/Lib/Backend/Dropbox.php b/apps/files_external/lib/Lib/Backend/Dropbox.php
index 04ceb6f07241..818125c35abf 100644
--- a/apps/files_external/lib/Lib/Backend/Dropbox.php
+++ b/apps/files_external/lib/Lib/Backend/Dropbox.php
@@ -21,20 +21,17 @@
namespace OCA\Files_External\Lib\Backend;
-use \OCP\IL10N;
-use \OCA\Files_External\Lib\Backend\Backend;
-use \OCA\Files_External\Lib\DefinitionParameter;
-use \OCA\Files_External\Lib\Auth\AuthMechanism;
-use \OCA\Files_External\Service\BackendService;
-use \OCA\Files_External\Lib\LegacyDependencyCheckPolyfill;
-
-use \OCA\Files_External\Lib\Auth\OAuth1\OAuth1;
+use OCP\IL10N;
+use OCP\Files\External\DefinitionParameter;
+use OCP\Files\External\Auth\AuthMechanism;
+use OCP\Files\External\Backend\Backend;
+use OCA\Files_External\Lib\LegacyDependencyCheckPolyfill;
class Dropbox extends Backend {
use LegacyDependencyCheckPolyfill;
- public function __construct(IL10N $l, OAuth1 $legacyAuth) {
+ public function __construct(IL10N $l) {
$this
->setIdentifier('dropbox')
->addIdentifierAlias('\OC\Files\Storage\Dropbox') // legacy compat
@@ -45,7 +42,6 @@ public function __construct(IL10N $l, OAuth1 $legacyAuth) {
])
->addAuthScheme(AuthMechanism::SCHEME_OAUTH1)
->addCustomJs('dropbox')
- ->setLegacyAuthMechanism($legacyAuth)
;
}
diff --git a/apps/files_external/lib/Lib/Backend/Google.php b/apps/files_external/lib/Lib/Backend/Google.php
index 458e25c303bb..f05c73f03625 100644
--- a/apps/files_external/lib/Lib/Backend/Google.php
+++ b/apps/files_external/lib/Lib/Backend/Google.php
@@ -21,20 +21,17 @@
namespace OCA\Files_External\Lib\Backend;
-use \OCP\IL10N;
-use \OCA\Files_External\Lib\Backend\Backend;
-use \OCA\Files_External\Lib\DefinitionParameter;
-use \OCA\Files_External\Lib\Auth\AuthMechanism;
-use \OCA\Files_External\Service\BackendService;
-use \OCA\Files_External\Lib\LegacyDependencyCheckPolyfill;
-
-use \OCA\Files_External\Lib\Auth\OAuth2\OAuth2;
+use OCP\IL10N;
+use OCP\Files\External\DefinitionParameter;
+use OCP\Files\External\Auth\AuthMechanism;
+use OCP\Files\External\Backend\Backend;
+use OCA\Files_External\Lib\LegacyDependencyCheckPolyfill;
class Google extends Backend {
use LegacyDependencyCheckPolyfill;
- public function __construct(IL10N $l, OAuth2 $legacyAuth) {
+ public function __construct(IL10N $l) {
$this
->setIdentifier('googledrive')
->addIdentifierAlias('\OC\Files\Storage\Google') // legacy compat
@@ -45,7 +42,6 @@ public function __construct(IL10N $l, OAuth2 $legacyAuth) {
])
->addAuthScheme(AuthMechanism::SCHEME_OAUTH2)
->addCustomJs('gdrive')
- ->setLegacyAuthMechanism($legacyAuth)
;
}
diff --git a/apps/files_external/lib/Lib/Backend/LegacyBackend.php b/apps/files_external/lib/Lib/Backend/LegacyBackend.php
deleted file mode 100644
index 92239b774985..000000000000
--- a/apps/files_external/lib/Lib/Backend/LegacyBackend.php
+++ /dev/null
@@ -1,104 +0,0 @@
-
- *
- * @copyright Copyright (c) 2016, ownCloud GmbH.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see
- *
- */
-
-namespace OCA\Files_External\Lib\Backend;
-
-use \OCA\Files_External\Lib\DefinitionParameter;
-use \OCA\Files_External\Lib\Backend\Backend;
-use \OCA\Files_External\Lib\Auth\Builtin;
-use \OCA\Files_External\Lib\MissingDependency;
-use \OCA\Files_External\Lib\LegacyDependencyCheckPolyfill;
-
-/**
- * Legacy compatibility for OC_Mount_Config::registerBackend()
- */
-class LegacyBackend extends Backend {
-
- use LegacyDependencyCheckPolyfill {
- LegacyDependencyCheckPolyfill::checkDependencies as doCheckDependencies;
- }
-
- /** @var bool */
- protected $hasDependencies = false;
-
- /**
- * @param string $class
- * @param array $definition
- * @param Builtin $authMechanism
- */
- public function __construct($class, array $definition, Builtin $authMechanism) {
- $this
- ->setIdentifier($class)
- ->setStorageClass($class)
- ->setText($definition['backend'])
- ->addAuthScheme(Builtin::SCHEME_BUILTIN)
- ->setLegacyAuthMechanism($authMechanism)
- ;
-
- foreach ($definition['configuration'] as $name => $placeholder) {
- $flags = DefinitionParameter::FLAG_NONE;
- $type = DefinitionParameter::VALUE_TEXT;
- if ($placeholder[0] === '&') {
- $flags = DefinitionParameter::FLAG_OPTIONAL;
- $placeholder = substr($placeholder, 1);
- }
- switch ($placeholder[0]) {
- case '!':
- $type = DefinitionParameter::VALUE_BOOLEAN;
- $placeholder = substr($placeholder, 1);
- break;
- case '*':
- $type = DefinitionParameter::VALUE_PASSWORD;
- $placeholder = substr($placeholder, 1);
- break;
- case '#':
- $type = DefinitionParameter::VALUE_HIDDEN;
- $placeholder = substr($placeholder, 1);
- break;
- }
- $this->addParameter((new DefinitionParameter($name, $placeholder))
- ->setType($type)
- ->setFlags($flags)
- );
- }
-
- if (isset($definition['priority'])) {
- $this->setPriority($definition['priority']);
- }
- if (isset($definition['custom'])) {
- $this->addCustomJs($definition['custom']);
- }
- if (isset($definition['has_dependencies']) && $definition['has_dependencies']) {
- $this->hasDependencies = true;
- }
- }
-
- /**
- * @return MissingDependency[]
- */
- public function checkDependencies() {
- if ($this->hasDependencies) {
- return $this->doCheckDependencies();
- }
- return [];
- }
-
-}
diff --git a/apps/files_external/lib/Lib/Backend/Local.php b/apps/files_external/lib/Lib/Backend/Local.php
index f4d5ecab94f2..a5c742c725a9 100644
--- a/apps/files_external/lib/Lib/Backend/Local.php
+++ b/apps/files_external/lib/Lib/Backend/Local.php
@@ -21,16 +21,15 @@
namespace OCA\Files_External\Lib\Backend;
-use \OCP\IL10N;
-use \OCA\Files_External\Lib\Backend\Backend;
-use \OCA\Files_External\Lib\DefinitionParameter;
-use \OCA\Files_External\Lib\Auth\AuthMechanism;
-use \OCA\Files_External\Service\BackendService;
-use \OCA\Files_External\Lib\Auth\NullMechanism;
+use OCP\IL10N;
+use OCP\Files\External\Auth\AuthMechanism;
+use OCP\Files\External\Backend\Backend;
+use OCP\Files\External\DefinitionParameter;
+use OCP\Files\External\IStoragesBackendService;
class Local extends Backend {
- public function __construct(IL10N $l, NullMechanism $legacyAuth) {
+ public function __construct(IL10N $l) {
$this
->setIdentifier('local')
->addIdentifierAlias('\OC\Files\Storage\Local') // legacy compat
@@ -39,10 +38,9 @@ public function __construct(IL10N $l, NullMechanism $legacyAuth) {
->addParameters([
(new DefinitionParameter('datadir', $l->t('Location'))),
])
- ->setAllowedVisibility(BackendService::VISIBILITY_ADMIN)
- ->setPriority(BackendService::PRIORITY_DEFAULT + 50)
+ ->setAllowedVisibility(IStoragesBackendService::VISIBILITY_ADMIN)
+ ->setPriority(IStoragesBackendService::PRIORITY_DEFAULT + 50)
->addAuthScheme(AuthMechanism::SCHEME_NULL)
- ->setLegacyAuthMechanism($legacyAuth)
;
}
diff --git a/apps/files_external/lib/Lib/Backend/OwnCloud.php b/apps/files_external/lib/Lib/Backend/OwnCloud.php
index fbcb581aead8..181227e443fd 100644
--- a/apps/files_external/lib/Lib/Backend/OwnCloud.php
+++ b/apps/files_external/lib/Lib/Backend/OwnCloud.php
@@ -21,17 +21,14 @@
namespace OCA\Files_External\Lib\Backend;
-use \OCP\IL10N;
-use \OCA\Files_External\Lib\Backend\Backend;
-use \OCA\Files_External\Lib\DefinitionParameter;
-use \OCA\Files_External\Lib\Auth\AuthMechanism;
-use \OCA\Files_External\Service\BackendService;
-
-use \OCA\Files_External\Lib\Auth\Password\Password;
+use OCP\IL10N;
+use OCP\Files\External\DefinitionParameter;
+use OCP\Files\External\Auth\AuthMechanism;
+use OCP\Files\External\Backend\Backend;
class OwnCloud extends Backend {
- public function __construct(IL10N $l, Password $legacyAuth) {
+ public function __construct(IL10N $l) {
$this
->setIdentifier('owncloud')
->addIdentifierAlias('\OC\Files\Storage\OwnCloud') // legacy compat
@@ -45,7 +42,6 @@ public function __construct(IL10N $l, Password $legacyAuth) {
->setType(DefinitionParameter::VALUE_BOOLEAN),
])
->addAuthScheme(AuthMechanism::SCHEME_PASSWORD)
- ->setLegacyAuthMechanism($legacyAuth)
;
}
diff --git a/apps/files_external/lib/Lib/Backend/SFTP.php b/apps/files_external/lib/Lib/Backend/SFTP.php
index 9da13dc6110f..27b19cd3b18a 100644
--- a/apps/files_external/lib/Lib/Backend/SFTP.php
+++ b/apps/files_external/lib/Lib/Backend/SFTP.php
@@ -21,17 +21,14 @@
namespace OCA\Files_External\Lib\Backend;
-use \OCP\IL10N;
-use \OCA\Files_External\Lib\Backend\Backend;
-use \OCA\Files_External\Lib\DefinitionParameter;
-use \OCA\Files_External\Lib\Auth\AuthMechanism;
-use \OCA\Files_External\Service\BackendService;
-
-use \OCA\Files_External\Lib\Auth\Password\Password;
+use OCP\IL10N;
+use OCP\Files\External\DefinitionParameter;
+use OCP\Files\External\Auth\AuthMechanism;
+use OCP\Files\External\Backend\Backend;
class SFTP extends Backend {
- public function __construct(IL10N $l, Password $legacyAuth) {
+ public function __construct(IL10N $l) {
$this
->setIdentifier('sftp')
->addIdentifierAlias('\OC\Files\Storage\SFTP') // legacy compat
@@ -44,7 +41,6 @@ public function __construct(IL10N $l, Password $legacyAuth) {
])
->addAuthScheme(AuthMechanism::SCHEME_PASSWORD)
->addAuthScheme(AuthMechanism::SCHEME_PUBLICKEY)
- ->setLegacyAuthMechanism($legacyAuth)
;
}
diff --git a/apps/files_external/lib/Lib/Backend/SFTP_Key.php b/apps/files_external/lib/Lib/Backend/SFTP_Key.php
index 41c83c02275b..9752a54c58f6 100644
--- a/apps/files_external/lib/Lib/Backend/SFTP_Key.php
+++ b/apps/files_external/lib/Lib/Backend/SFTP_Key.php
@@ -21,17 +21,15 @@
namespace OCA\Files_External\Lib\Backend;
-use \OCP\IL10N;
-use \OCA\Files_External\Lib\Backend\Backend;
-use \OCA\Files_External\Lib\DefinitionParameter;
-use \OCA\Files_External\Lib\Auth\AuthMechanism;
-use \OCA\Files_External\Service\BackendService;
-use \OCA\Files_External\Lib\Auth\PublicKey\RSA;
-use \OCA\Files_External\Lib\Backend\SFTP;
+use OCP\IL10N;
+use OCP\Files\External\DefinitionParameter;
+use OCP\Files\External\Auth\AuthMechanism;
+use OCP\Files\External\Backend\Backend;
+use OCA\Files_External\Lib\Backend\SFTP;
class SFTP_Key extends Backend {
- public function __construct(IL10N $l, RSA $legacyAuth, SFTP $sftpBackend) {
+ public function __construct(IL10N $l, SFTP $sftpBackend) {
$this
->setIdentifier('\OC\Files\Storage\SFTP_Key')
->setStorageClass('\OCA\Files_External\Lib\Storage\SFTP')
@@ -42,7 +40,6 @@ public function __construct(IL10N $l, RSA $legacyAuth, SFTP $sftpBackend) {
->setFlag(DefinitionParameter::FLAG_OPTIONAL),
])
->addAuthScheme(AuthMechanism::SCHEME_PUBLICKEY)
- ->setLegacyAuthMechanism($legacyAuth)
->deprecateTo($sftpBackend)
;
}
diff --git a/apps/files_external/lib/Lib/Backend/SMB.php b/apps/files_external/lib/Lib/Backend/SMB.php
index c6f5390fd168..058bb6152c90 100644
--- a/apps/files_external/lib/Lib/Backend/SMB.php
+++ b/apps/files_external/lib/Lib/Backend/SMB.php
@@ -21,22 +21,20 @@
namespace OCA\Files_External\Lib\Backend;
-use \OCP\IL10N;
-use \OCA\Files_External\Lib\Backend\Backend;
-use \OCA\Files_External\Lib\DefinitionParameter;
-use \OCA\Files_External\Lib\Auth\AuthMechanism;
-use \OCA\Files_External\Service\BackendService;
-use \OCA\Files_External\Lib\StorageConfig;
-use \OCA\Files_External\Lib\LegacyDependencyCheckPolyfill;
+use OCP\IL10N;
+use OCP\Files\External\DefinitionParameter;
+use OCP\Files\External\Auth\AuthMechanism;
+use OCP\Files\External\Backend\Backend;
+use OCP\Files\External\IStorageConfig;
+use OCA\Files_External\Lib\LegacyDependencyCheckPolyfill;
-use \OCA\Files_External\Lib\Auth\Password\Password;
use OCP\IUser;
class SMB extends Backend {
use LegacyDependencyCheckPolyfill;
- public function __construct(IL10N $l, Password $legacyAuth) {
+ public function __construct(IL10N $l) {
$this
->setIdentifier('smb')
->addIdentifierAlias('\OC\Files\Storage\SMB') // legacy compat
@@ -51,7 +49,6 @@ public function __construct(IL10N $l, Password $legacyAuth) {
->setFlag(DefinitionParameter::FLAG_OPTIONAL),
])
->addAuthScheme(AuthMechanism::SCHEME_PASSWORD)
- ->setLegacyAuthMechanism($legacyAuth)
;
}
@@ -59,7 +56,7 @@ public function __construct(IL10N $l, Password $legacyAuth) {
* @param StorageConfig $storage
* @param IUser $user
*/
- public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) {
+ public function manipulateStorageConfig(IStorageConfig &$storage, IUser $user = null) {
$user = $storage->getBackendOption('user');
if ($domain = $storage->getBackendOption('domain')) {
$storage->setBackendOption('user', $domain.'\\'.$user);
diff --git a/apps/files_external/lib/Lib/Backend/SMB_OC.php b/apps/files_external/lib/Lib/Backend/SMB_OC.php
index d2b31c099e1b..11bff829c2de 100644
--- a/apps/files_external/lib/Lib/Backend/SMB_OC.php
+++ b/apps/files_external/lib/Lib/Backend/SMB_OC.php
@@ -21,15 +21,14 @@
namespace OCA\Files_External\Lib\Backend;
-use \OCP\IL10N;
-use \OCA\Files_External\Lib\Backend\Backend;
-use \OCA\Files_External\Lib\DefinitionParameter;
-use \OCA\Files_External\Lib\Auth\AuthMechanism;
-use \OCA\Files_External\Service\BackendService;
-use \OCA\Files_External\Lib\Auth\Password\SessionCredentials;
-use \OCA\Files_External\Lib\StorageConfig;
-use \OCA\Files_External\Lib\LegacyDependencyCheckPolyfill;
-use \OCA\Files_External\Lib\Backend\SMB;
+use OCP\IL10N;
+use OCP\Files\External\DefinitionParameter;
+use OCP\Files\External\Auth\AuthMechanism;
+use OCP\Files\External\Backend\Backend;
+use OCP\Files\External\IStoragesBackendService;
+use OCP\Files\External\IStorageConfig;
+use OCA\Files_External\Lib\LegacyDependencyCheckPolyfill;
+use OCA\Files_External\Lib\Backend\SMB;
use OCP\IUser;
/**
@@ -39,7 +38,7 @@ class SMB_OC extends Backend {
use LegacyDependencyCheckPolyfill;
- public function __construct(IL10N $l, SessionCredentials $legacyAuth, SMB $smbBackend) {
+ public function __construct(IL10N $l, SMB $smbBackend) {
$this
->setIdentifier('\OC\Files\Storage\SMB_OC')
->setStorageClass('\OCA\Files_External\Lib\Storage\SMB')
@@ -53,14 +52,13 @@ public function __construct(IL10N $l, SessionCredentials $legacyAuth, SMB $smbBa
(new DefinitionParameter('root', $l->t('Remote subfolder')))
->setFlag(DefinitionParameter::FLAG_OPTIONAL),
])
- ->setPriority(BackendService::PRIORITY_DEFAULT - 10)
+ ->setPriority(IStoragesBackendService::PRIORITY_DEFAULT - 10)
->addAuthScheme(AuthMechanism::SCHEME_PASSWORD)
- ->setLegacyAuthMechanism($legacyAuth)
->deprecateTo($smbBackend)
;
}
- public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) {
+ public function manipulateStorageConfig(IStorageConfig &$storage, IUser $user = null) {
$username_as_share = ($storage->getBackendOption('username_as_share') === true);
if ($username_as_share) {
diff --git a/apps/files_external/lib/Lib/Backend/Swift.php b/apps/files_external/lib/Lib/Backend/Swift.php
index 175a60453dfb..aacf96d15ced 100644
--- a/apps/files_external/lib/Lib/Backend/Swift.php
+++ b/apps/files_external/lib/Lib/Backend/Swift.php
@@ -21,20 +21,17 @@
namespace OCA\Files_External\Lib\Backend;
-use \OCP\IL10N;
-use \OCA\Files_External\Lib\Backend\Backend;
-use \OCA\Files_External\Lib\DefinitionParameter;
-use \OCA\Files_External\Lib\Auth\AuthMechanism;
-use \OCA\Files_External\Service\BackendService;
-use \OCA\Files_External\Lib\Auth\OpenStack\OpenStack;
-use \OCA\Files_External\Lib\Auth\OpenStack\Rackspace;
-use \OCA\Files_External\Lib\LegacyDependencyCheckPolyfill;
+use OCP\IL10N;
+use OCP\Files\External\DefinitionParameter;
+use OCP\Files\External\Auth\AuthMechanism;
+use OCP\Files\External\Backend\Backend;
+use OCA\Files_External\Lib\LegacyDependencyCheckPolyfill;
class Swift extends Backend {
use LegacyDependencyCheckPolyfill;
- public function __construct(IL10N $l, OpenStack $openstackAuth, Rackspace $rackspaceAuth) {
+ public function __construct(IL10N $l) {
$this
->setIdentifier('swift')
->addIdentifierAlias('\OC\Files\Storage\Swift') // legacy compat
@@ -50,12 +47,6 @@ public function __construct(IL10N $l, OpenStack $openstackAuth, Rackspace $racks
->setFlag(DefinitionParameter::FLAG_OPTIONAL),
])
->addAuthScheme(AuthMechanism::SCHEME_OPENSTACK)
- ->setLegacyAuthMechanismCallback(function(array $params) use ($openstackAuth, $rackspaceAuth) {
- if (isset($params['options']['key']) && $params['options']['key']) {
- return $rackspaceAuth;
- }
- return $openstackAuth;
- })
;
}
diff --git a/apps/files_external/lib/Lib/LegacyDependencyCheckPolyfill.php b/apps/files_external/lib/Lib/LegacyDependencyCheckPolyfill.php
index a61735bc1f01..acf96d65928b 100644
--- a/apps/files_external/lib/Lib/LegacyDependencyCheckPolyfill.php
+++ b/apps/files_external/lib/Lib/LegacyDependencyCheckPolyfill.php
@@ -21,7 +21,7 @@
namespace OCA\Files_External\Lib;
-use \OCA\Files_External\Lib\MissingDependency;
+use \OC\Files\External\MissingDependency;
/**
* Polyfill for checking dependencies using legacy Storage::checkDependencies()
diff --git a/apps/files_external/lib/Migration/StorageMigrator.php b/apps/files_external/lib/Migration/StorageMigrator.php
deleted file mode 100644
index 1a5ae28a34b1..000000000000
--- a/apps/files_external/lib/Migration/StorageMigrator.php
+++ /dev/null
@@ -1,147 +0,0 @@
-
- * @author Robin Appelman
- * @author Vincent Petry
- *
- * @copyright Copyright (c) 2016, ownCloud GmbH.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see
- *
- */
-
-namespace OCA\Files_External\Migration;
-
-use OCA\Files_External\Service\BackendService;
-use OCA\Files_External\Service\DBConfigService;
-use OCA\Files_External\Service\GlobalLegacyStoragesService;
-use OCA\Files_External\Service\GlobalStoragesService;
-use OCA\Files_External\Service\LegacyStoragesService;
-use OCA\Files_External\Service\StoragesService;
-use OCA\Files_External\Service\UserLegacyStoragesService;
-use OCA\Files_External\Service\UserStoragesService;
-use OCP\Files\Config\IUserMountCache;
-use OCP\IConfig;
-use OCP\IDBConnection;
-use OCP\ILogger;
-use OCP\IUser;
-
-/**
- * Migrate mount config from mount.json to the database
- */
-class StorageMigrator {
- /**
- * @var BackendService
- */
- private $backendService;
-
- /**
- * @var DBConfigService
- */
- private $dbConfig;
-
- /**
- * @var IConfig
- */
- private $config;
-
- /**
- * @var IDBConnection
- */
- private $connection;
-
- /**
- * @var ILogger
- */
- private $logger;
-
- /** @var IUserMountCache */
- private $userMountCache;
-
- /**
- * StorageMigrator constructor.
- *
- * @param BackendService $backendService
- * @param DBConfigService $dbConfig
- * @param IConfig $config
- * @param IDBConnection $connection
- * @param ILogger $logger
- * @param IUserMountCache $userMountCache
- */
- public function __construct(
- BackendService $backendService,
- DBConfigService $dbConfig,
- IConfig $config,
- IDBConnection $connection,
- ILogger $logger,
- IUserMountCache $userMountCache
- ) {
- $this->backendService = $backendService;
- $this->dbConfig = $dbConfig;
- $this->config = $config;
- $this->connection = $connection;
- $this->logger = $logger;
- $this->userMountCache = $userMountCache;
- }
-
- private function migrate(LegacyStoragesService $legacyService, StoragesService $storageService) {
- $existingStorage = $legacyService->getAllStorages();
-
- $this->connection->beginTransaction();
- try {
- foreach ($existingStorage as $storage) {
- $mountOptions = $storage->getMountOptions();
- if (!empty($mountOptions) && !isset($mountOptions['enable_sharing'])) {
- // existing mounts must have sharing enabled by default to avoid surprises
- $mountOptions['enable_sharing'] = true;
- $storage->setMountOptions($mountOptions);
- }
- $storageService->addStorage($storage);
- }
- $this->connection->commit();
- } catch (\Exception $e) {
- $this->logger->logException($e);
- $this->connection->rollBack();
- }
- }
-
- /**
- * Migrate admin configured storages
- */
- public function migrateGlobal() {
- $legacyService = new GlobalLegacyStoragesService($this->backendService);
- $storageService = new GlobalStoragesService($this->backendService, $this->dbConfig, $this->userMountCache);
-
- $this->migrate($legacyService, $storageService);
- }
-
- /**
- * Migrate personal storages configured by the current user
- *
- * @param IUser $user
- */
- public function migrateUser(IUser $user) {
- $dummySession = new DummyUserSession();
- $dummySession->setUser($user);
- $userId = $user->getUID();
- $userVersion = $this->config->getUserValue($userId, 'files_external', 'config_version', '0.0.0');
- if (version_compare($userVersion, '0.5.0', '<')) {
- $this->config->setUserValue($userId, 'files_external', 'config_version', '0.5.0');
- $legacyService = new UserLegacyStoragesService($this->backendService, $dummySession);
- $storageService = new UserStoragesService($this->backendService, $this->dbConfig, $dummySession, $this->userMountCache);
-
- $this->migrate($legacyService, $storageService);
- }
- }
-}
diff --git a/apps/files_external/lib/Service/LegacyStoragesService.php b/apps/files_external/lib/Service/LegacyStoragesService.php
deleted file mode 100644
index 487bdf1bf725..000000000000
--- a/apps/files_external/lib/Service/LegacyStoragesService.php
+++ /dev/null
@@ -1,211 +0,0 @@
-
- * @author Robin Appelman
- * @author Stefan Weil
- *
- * @copyright Copyright (c) 2016, ownCloud GmbH.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see
- *
- */
-
-namespace OCA\Files_External\Service;
-
-use OCA\Files_External\Lib\StorageConfig;
-
-/**
- * Read mount config from legacy mount.json
- */
-abstract class LegacyStoragesService {
- /** @var BackendService */
- protected $backendService;
-
- /**
- * Read legacy config data
- *
- * @return array list of mount configs
- */
- abstract protected function readLegacyConfig();
-
- /**
- * Copy legacy storage options into the given storage config object.
- *
- * @param StorageConfig $storageConfig storage config to populate
- * @param string $mountType mount type
- * @param string $applicable applicable user or group
- * @param array $storageOptions legacy storage options
- *
- * @return StorageConfig populated storage config
- */
- protected function populateStorageConfigWithLegacyOptions(
- &$storageConfig,
- $mountType,
- $applicable,
- $storageOptions
- ) {
- $backend = $this->backendService->getBackend($storageOptions['backend']);
- if (!$backend) {
- throw new \UnexpectedValueException('Invalid backend ' . $storageOptions['backend']);
- }
- $storageConfig->setBackend($backend);
- if (isset($storageOptions['authMechanism']) && $storageOptions['authMechanism'] !== 'builtin::builtin') {
- $authMechanism = $this->backendService->getAuthMechanism($storageOptions['authMechanism']);
- } else {
- $authMechanism = $backend->getLegacyAuthMechanism($storageOptions);
- $storageOptions['authMechanism'] = 'null'; // to make error handling easier
- }
- if (!$authMechanism) {
- throw new \UnexpectedValueException('Invalid authentication mechanism ' . $storageOptions['authMechanism']);
- }
- $storageConfig->setAuthMechanism($authMechanism);
- $storageConfig->setBackendOptions($storageOptions['options']);
- if (isset($storageOptions['mountOptions'])) {
- $storageConfig->setMountOptions($storageOptions['mountOptions']);
- }
- if (!isset($storageOptions['priority'])) {
- $storageOptions['priority'] = $backend->getPriority();
- }
- $storageConfig->setPriority($storageOptions['priority']);
- if ($mountType === \OC_Mount_Config::MOUNT_TYPE_USER) {
- $applicableUsers = $storageConfig->getApplicableUsers();
- if ($applicable !== 'all') {
- $applicableUsers[] = $applicable;
- $storageConfig->setApplicableUsers($applicableUsers);
- }
- } else if ($mountType === \OC_Mount_Config::MOUNT_TYPE_GROUP) {
- $applicableGroups = $storageConfig->getApplicableGroups();
- $applicableGroups[] = $applicable;
- $storageConfig->setApplicableGroups($applicableGroups);
- }
- return $storageConfig;
- }
-
- /**
- * Read the external storages config
- *
- * @return StorageConfig[] map of storage id to storage config
- */
- public function getAllStorages() {
- $mountPoints = $this->readLegacyConfig();
- /**
- * Here is the how the horribly messy mount point array looks like
- * from the mount.json file:
- *
- * $storageOptions = $mountPoints[$mountType][$applicable][$mountPath]
- *
- * - $mountType is either "user" or "group"
- * - $applicable is the name of a user or group (or the current user for personal mounts)
- * - $mountPath is the mount point path (where the storage must be mounted)
- * - $storageOptions is a map of storage options:
- * - "priority": storage priority
- * - "backend": backend identifier
- * - "class": LEGACY backend class name
- * - "options": backend-specific options
- * - "authMechanism": authentication mechanism identifier
- * - "mountOptions": mount-specific options (ex: disable previews, scanner, etc)
- */
- // group by storage id
- /** @var StorageConfig[] $storages */
- $storages = [];
- // for storages without id (legacy), group by config hash for
- // later processing
- $storagesWithConfigHash = [];
- foreach ($mountPoints as $mountType => $applicables) {
- foreach ($applicables as $applicable => $mountPaths) {
- foreach ($mountPaths as $rootMountPath => $storageOptions) {
- $currentStorage = null;
- /**
- * Flag whether the config that was read already has an id.
- * If not, it will use a config hash instead and generate
- * a proper id later
- *
- * @var boolean
- */
- $hasId = false;
- // the root mount point is in the format "/$user/files/the/mount/point"
- // we remove the "/$user/files" prefix
- $parts = explode('/', ltrim($rootMountPath, '/'), 3);
- if (count($parts) < 3) {
- // something went wrong, skip
- \OCP\Util::writeLog(
- 'files_external',
- 'Could not parse mount point "' . $rootMountPath . '"',
- \OCP\Util::ERROR
- );
- continue;
- }
- $relativeMountPath = rtrim($parts[2], '/');
- // note: we cannot do this after the loop because the decrypted config
- // options might be needed for the config hash
- $storageOptions['options'] = \OC_Mount_Config::decryptPasswords($storageOptions['options']);
- if (!isset($storageOptions['backend'])) {
- $storageOptions['backend'] = $storageOptions['class']; // legacy compat
- }
- if (!isset($storageOptions['authMechanism'])) {
- $storageOptions['authMechanism'] = null; // ensure config hash works
- }
- if (isset($storageOptions['id'])) {
- $configId = (int)$storageOptions['id'];
- if (isset($storages[$configId])) {
- $currentStorage = $storages[$configId];
- }
- $hasId = true;
- } else {
- // missing id in legacy config, need to generate
- // but at this point we don't know the max-id, so use
- // first group it by config hash
- $storageOptions['mountpoint'] = $rootMountPath;
- $configId = \OC_Mount_Config::makeConfigHash($storageOptions);
- if (isset($storagesWithConfigHash[$configId])) {
- $currentStorage = $storagesWithConfigHash[$configId];
- }
- }
- if (is_null($currentStorage)) {
- // create new
- $currentStorage = new StorageConfig($configId);
- $currentStorage->setMountPoint($relativeMountPath);
- }
- try {
- $this->populateStorageConfigWithLegacyOptions(
- $currentStorage,
- $mountType,
- $applicable,
- $storageOptions
- );
- if ($hasId) {
- $storages[$configId] = $currentStorage;
- } else {
- $storagesWithConfigHash[$configId] = $currentStorage;
- }
- } catch (\UnexpectedValueException $e) {
- // don't die if a storage backend doesn't exist
- \OCP\Util::writeLog(
- 'files_external',
- 'Could not load storage: "' . $e->getMessage() . '"',
- \OCP\Util::ERROR
- );
- }
- }
- }
- }
-
- // convert parameter values
- foreach ($storages as $storage) {
- $storage->getBackend()->validateStorageDefinition($storage);
- $storage->getAuthMechanism()->validateStorageDefinition($storage);
- }
- return $storages;
- }
-}
diff --git a/apps/files_external/lib/Service/UserLegacyStoragesService.php b/apps/files_external/lib/Service/UserLegacyStoragesService.php
deleted file mode 100644
index df6400baef7f..000000000000
--- a/apps/files_external/lib/Service/UserLegacyStoragesService.php
+++ /dev/null
@@ -1,55 +0,0 @@
-
- * @author Robin Appelman
- *
- * @copyright Copyright (c) 2016, ownCloud GmbH.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see
- *
- */
-
-namespace OCA\Files_External\Service;
-
-use OCP\IUserSession;
-
-/**
- * Read user defined mounts from the legacy mount.json
- */
-class UserLegacyStoragesService extends LegacyStoragesService {
- /**
- * @var IUserSession
- */
- private $userSession;
-
- /**
- * @param BackendService $backendService
- * @param IUserSession $userSession
- */
- public function __construct(BackendService $backendService, IUserSession $userSession) {
- $this->backendService = $backendService;
- $this->userSession = $userSession;
- }
-
- /**
- * Read legacy config data
- *
- * @return array list of storage configs
- */
- protected function readLegacyConfig() {
- // read user config
- $user = $this->userSession->getUser()->getUID();
- return \OC_Mount_Config::readData($user);
- }
-}
diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php
index b057f58e48f7..162e2536f667 100644
--- a/apps/files_external/lib/config.php
+++ b/apps/files_external/lib/config.php
@@ -33,242 +33,15 @@
*
*/
-use phpseclib\Crypt\AES;
use \OCA\Files_External\AppInfo\Application;
-use \OCA\Files_External\Lib\Backend\LegacyBackend;
-use \OCA\Files_External\Lib\StorageConfig;
-use \OCA\Files_External\Lib\Backend\Backend;
-use \OCP\Files\StorageNotAvailableException;
/**
* Class to configure mount.json globally and for users
*/
-class OC_Mount_Config {
- // TODO: make this class non-static and give it a proper namespace
-
- const MOUNT_TYPE_GLOBAL = 'global';
- const MOUNT_TYPE_GROUP = 'group';
- const MOUNT_TYPE_USER = 'user';
- const MOUNT_TYPE_PERSONAL = 'personal';
-
- // whether to skip backend test (for unit tests, as this static class is not mockable)
- public static $skipTest = false;
-
+class OC_Mount_Config extends \OC\Files\External\LegacyUtil {
/** @var Application */
public static $app;
- /**
- * @param string $class
- * @param array $definition
- * @return bool
- * @deprecated 8.2.0 use \OCA\Files_External\Service\BackendService::registerBackend()
- */
- public static function registerBackend($class, $definition) {
- $backendService = self::$app->getContainer()->query('OCA\Files_External\Service\BackendService');
- $auth = self::$app->getContainer()->query('OCA\Files_External\Lib\Auth\Builtin');
-
- $backendService->registerBackend(new LegacyBackend($class, $definition, $auth));
-
- return true;
- }
-
- /**
- * Returns the mount points for the given user.
- * The mount point is relative to the data directory.
- *
- * @param string $uid user
- * @return array of mount point string as key, mountpoint config as value
- *
- * @deprecated 8.2.0 use UserGlobalStoragesService::getStorages() and UserStoragesService::getStorages()
- */
- public static function getAbsoluteMountPoints($uid) {
- $mountPoints = [];
-
- $userGlobalStoragesService = self::$app->getContainer()->query('OCA\Files_External\Service\UserGlobalStoragesService');
- $userStoragesService = self::$app->getContainer()->query('OCA\Files_External\Service\UserStoragesService');
- $user = self::$app->getContainer()->query('OCP\IUserManager')->get($uid);
-
- $userGlobalStoragesService->setUser($user);
- $userStoragesService->setUser($user);
-
- foreach ($userGlobalStoragesService->getStorages() as $storage) {
- /** @var \OCA\Files_External\Lib\StorageConfig $storage */
- $mountPoint = '/'.$uid.'/files'.$storage->getMountPoint();
- $mountEntry = self::prepareMountPointEntry($storage, false);
- foreach ($mountEntry['options'] as &$option) {
- $option = self::setUserVars($uid, $option);
- }
- $mountPoints[$mountPoint] = $mountEntry;
- }
-
- foreach ($userStoragesService->getStorages() as $storage) {
- $mountPoint = '/'.$uid.'/files'.$storage->getMountPoint();
- $mountEntry = self::prepareMountPointEntry($storage, true);
- foreach ($mountEntry['options'] as &$option) {
- $option = self::setUserVars($uid, $option);
- }
- $mountPoints[$mountPoint] = $mountEntry;
- }
-
- $userGlobalStoragesService->resetUser();
- $userStoragesService->resetUser();
-
- return $mountPoints;
- }
-
- /**
- * Get the system mount points
- *
- * @return array
- *
- * @deprecated 8.2.0 use GlobalStoragesService::getStorages()
- */
- public static function getSystemMountPoints() {
- $mountPoints = [];
- $service = self::$app->getContainer()->query('OCA\Files_External\Service\GlobalStoragesService');
-
- foreach ($service->getStorages() as $storage) {
- $mountPoints[] = self::prepareMountPointEntry($storage, false);
- }
-
- return $mountPoints;
- }
-
- /**
- * Get the personal mount points of the current user
- *
- * @return array
- *
- * @deprecated 8.2.0 use UserStoragesService::getStorages()
- */
- public static function getPersonalMountPoints() {
- $mountPoints = [];
- $service = self::$app->getContainer()->query('OCA\Files_External\Service\UserStoragesService');
-
- foreach ($service->getStorages() as $storage) {
- $mountPoints[] = self::prepareMountPointEntry($storage, true);
- }
-
- return $mountPoints;
- }
-
- /**
- * Convert a StorageConfig to the legacy mountPoints array format
- * There's a lot of extra information in here, to satisfy all of the legacy functions
- *
- * @param StorageConfig $storage
- * @param bool $isPersonal
- * @return array
- */
- private static function prepareMountPointEntry(StorageConfig $storage, $isPersonal) {
- $mountEntry = [];
-
- $mountEntry['mountpoint'] = substr($storage->getMountPoint(), 1); // remove leading slash
- $mountEntry['class'] = $storage->getBackend()->getIdentifier();
- $mountEntry['backend'] = $storage->getBackend()->getText();
- $mountEntry['authMechanism'] = $storage->getAuthMechanism()->getIdentifier();
- $mountEntry['personal'] = $isPersonal;
- $mountEntry['options'] = self::decryptPasswords($storage->getBackendOptions());
- $mountEntry['mountOptions'] = $storage->getMountOptions();
- $mountEntry['priority'] = $storage->getPriority();
- $mountEntry['applicable'] = [
- 'groups' => $storage->getApplicableGroups(),
- 'users' => $storage->getApplicableUsers(),
- ];
- // if mountpoint is applicable to all users the old API expects ['all']
- if (empty($mountEntry['applicable']['groups']) && empty($mountEntry['applicable']['users'])) {
- $mountEntry['applicable']['users'] = ['all'];
- }
-
- $mountEntry['id'] = $storage->getId();
-
- return $mountEntry;
- }
-
- /**
- * fill in the correct values for $user
- *
- * @param string $user user value
- * @param string|array $input
- * @return string
- */
- public static function setUserVars($user, $input) {
- if (is_array($input)) {
- foreach ($input as $key => $value) {
- if (is_string($value)) {
- $input[$key] = str_replace('$user', $user, $value);
- }
- }
- } else {
- if (is_string($input)) {
- $input = str_replace('$user', $user, $input);
- }
- }
- return $input;
- }
-
- /**
- * Test connecting using the given backend configuration
- *
- * @param string $class backend class name
- * @param array $options backend configuration options
- * @param boolean $isPersonal
- * @return int see self::STATUS_*
- * @throws Exception
- */
- public static function getBackendStatus($class, $options, $isPersonal, $testOnly = true) {
- if (self::$skipTest) {
- return StorageNotAvailableException::STATUS_SUCCESS;
- }
- foreach ($options as $key => $option) {
- $options[$key] = self::setUserVars(OCP\User::getUser(), $option);
- }
- if (class_exists($class)) {
- try {
- /** @var \OC\Files\Storage\Common $storage */
- $storage = new $class($options);
-
- try {
- $result = $storage->test($isPersonal, $testOnly);
- $storage->setAvailability($result);
- if ($result) {
- return StorageNotAvailableException::STATUS_SUCCESS;
- }
- } catch (\Exception $e) {
- $storage->setAvailability(false);
- throw $e;
- }
- } catch (Exception $exception) {
- \OCP\Util::logException('files_external', $exception);
- throw $exception;
- }
- }
- return StorageNotAvailableException::STATUS_ERROR;
- }
-
- /**
- * Read the mount points in the config file into an array
- *
- * @param string|null $user If not null, personal for $user, otherwise system
- * @return array
- */
- public static function readData($user = null) {
- if (isset($user)) {
- $jsonFile = \OC::$server->getUserManager()->get($user)->getHome() . '/mount.json';
- } else {
- $config = \OC::$server->getConfig();
- $datadir = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data/');
- $jsonFile = $config->getSystemValue('mount_file', $datadir . '/mount.json');
- }
- if (is_file($jsonFile)) {
- $mountPoints = json_decode(file_get_contents($jsonFile), true);
- if (is_array($mountPoints)) {
- return $mountPoints;
- }
- }
- return [];
- }
-
/**
* Get backend dependency message
* TODO: move into AppFramework along with templates
@@ -317,96 +90,4 @@ private static function getSingleDependencyMessage(\OCP\IL10N $l, $module, $back
return (string)$l->t('Note: "%s" is not installed. Mounting of %s is not possible. Please ask your system administrator to install it.', [$module, $backend]);
}
}
-
- /**
- * Encrypt passwords in the given config options
- *
- * @param array $options mount options
- * @return array updated options
- */
- public static function encryptPasswords($options) {
- if (isset($options['password'])) {
- $options['password_encrypted'] = self::encryptPassword($options['password']);
- // do not unset the password, we want to keep the keys order
- // on load... because that's how the UI currently works
- $options['password'] = '';
- }
- return $options;
- }
-
- /**
- * Decrypt passwords in the given config options
- *
- * @param array $options mount options
- * @return array updated options
- */
- public static function decryptPasswords($options) {
- // note: legacy options might still have the unencrypted password in the "password" field
- if (isset($options['password_encrypted'])) {
- $options['password'] = self::decryptPassword($options['password_encrypted']);
- unset($options['password_encrypted']);
- }
- return $options;
- }
-
- /**
- * Encrypt a single password
- *
- * @param string $password plain text password
- * @return string encrypted password
- */
- private static function encryptPassword($password) {
- $cipher = self::getCipher();
- $iv = \OCP\Util::generateRandomBytes(16);
- $cipher->setIV($iv);
- return base64_encode($iv . $cipher->encrypt($password));
- }
-
- /**
- * Decrypts a single password
- *
- * @param string $encryptedPassword encrypted password
- * @return string plain text password
- */
- private static function decryptPassword($encryptedPassword) {
- $cipher = self::getCipher();
- $binaryPassword = base64_decode($encryptedPassword);
- $iv = substr($binaryPassword, 0, 16);
- $cipher->setIV($iv);
- $binaryPassword = substr($binaryPassword, 16);
- return $cipher->decrypt($binaryPassword);
- }
-
- /**
- * Returns the encryption cipher
- *
- * @return AES
- */
- private static function getCipher() {
- $cipher = new AES(AES::MODE_CBC);
- $cipher->setKey(\OC::$server->getConfig()->getSystemValue('passwordsalt', null));
- return $cipher;
- }
-
- /**
- * Computes a hash based on the given configuration.
- * This is mostly used to find out whether configurations
- * are the same.
- *
- * @param array $config
- * @return string
- */
- public static function makeConfigHash($config) {
- $data = json_encode(
- [
- 'c' => $config['backend'],
- 'a' => $config['authMechanism'],
- 'm' => $config['mountpoint'],
- 'o' => $config['options'],
- 'p' => isset($config['priority']) ? $config['priority'] : -1,
- 'mo' => isset($config['mountOptions']) ? $config['mountOptions'] : [],
- ]
- );
- return hash('md5', $data);
- }
}
diff --git a/apps/files_external/personal.php b/apps/files_external/personal.php
index a46a1aee210b..44bf8063873c 100644
--- a/apps/files_external/personal.php
+++ b/apps/files_external/personal.php
@@ -24,16 +24,16 @@
*
*/
-use \OCA\Files_External\Service\BackendService;
+use \OCP\Files\External\IStoragesBackendService;
// we must use the same container
$appContainer = \OC_Mount_Config::$app->getContainer();
-$backendService = $appContainer->query('OCA\Files_External\Service\BackendService');
-$userStoragesService = $appContainer->query('OCA\Files_External\Service\UserStoragesService');
+$backendService = \OC::$server->query('StoragesBackendService');
+$userStoragesService = \OC::$server->getUserStoragesService();
$tmpl = new OCP\Template('files_external', 'settings');
$tmpl->assign('encryptionEnabled', \OC::$server->getEncryptionManager()->isEnabled());
-$tmpl->assign('visibilityType', BackendService::VISIBILITY_PERSONAL);
+$tmpl->assign('visibilityType', IStoragesBackendService::VISIBILITY_PERSONAL);
$tmpl->assign('storages', $userStoragesService->getStorages());
$tmpl->assign('dependencies', OC_Mount_Config::dependencyMessage($backendService->getBackends()));
$tmpl->assign('backends', $backendService->getAvailableBackends());
diff --git a/apps/files_external/settings.php b/apps/files_external/settings.php
index 8b4325cba364..54e34d65c05f 100644
--- a/apps/files_external/settings.php
+++ b/apps/files_external/settings.php
@@ -24,21 +24,21 @@
*
*/
-use \OCA\Files_External\Service\BackendService;
+use OCP\Files\External\IStoragesBackendService;
\OCP\User::checkAdminUser();
// we must use the same container
$appContainer = \OC_Mount_Config::$app->getContainer();
-$backendService = $appContainer->query('OCA\Files_External\Service\BackendService');
-$globalStoragesService = $appContainer->query('OCA\Files_External\Service\GlobalStoragesService');
+$backendService = \OC::$server->query('StoragesBackendService');
+$globalStoragesService = \OC::$server->getGlobalStoragesService();
\OC_Util::addVendorScript('select2/select2');
\OC_Util::addVendorStyle('select2/select2');
$tmpl = new OCP\Template('files_external', 'settings');
$tmpl->assign('encryptionEnabled', \OC::$server->getEncryptionManager()->isEnabled());
-$tmpl->assign('visibilityType', BackendService::VISIBILITY_ADMIN);
+$tmpl->assign('visibilityType', IStoragesBackendService::VISIBILITY_ADMIN);
$tmpl->assign('storages', $globalStoragesService->getStorages());
$tmpl->assign('backends', $backendService->getAvailableBackends());
$tmpl->assign('authMechanisms', $backendService->getAuthMechanisms());
diff --git a/apps/files_external/templates/settings.php b/apps/files_external/templates/settings.php
index 6662f637039c..0c429d6862b6 100644
--- a/apps/files_external/templates/settings.php
+++ b/apps/files_external/templates/settings.php
@@ -1,8 +1,8 @@
t("Enable encryption");
$l->t("Enable previews");
@@ -87,7 +87,7 @@ function writeParameterInput($parameter, $options, $classes = []) {