summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib
diff options
context:
space:
mode:
authorBjörn Schießle <bjoern@schiessle.org>2017-04-12 16:01:07 +0200
committerGitHub <noreply@github.com>2017-04-12 16:01:07 +0200
commitb90e91144bc8d378f6f52025f04383ae2e7c647b (patch)
tree616619d3778182ac53e77dc605fc9bded595fc63 /apps/files_sharing/lib
parent3cf2f6e31bca4b704549e428d7fcbf6c4ecd6c37 (diff)
parent42f40659f664b4cdcdd5f19cf7300ad740aec6a4 (diff)
downloadnextcloud-server-b90e91144bc8d378f6f52025f04383ae2e7c647b.tar.gz
nextcloud-server-b90e91144bc8d378f6f52025f04383ae2e7c647b.zip
Merge pull request #3614 from nextcloud/discover-federatedsharing-endpoints
Discover federatedsharing endpoints
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r--apps/files_sharing/lib/AppInfo/Application.php6
-rw-r--r--apps/files_sharing/lib/External/Manager.php35
-rw-r--r--apps/files_sharing/lib/External/Storage.php16
-rw-r--r--apps/files_sharing/lib/Hooks.php6
4 files changed, 31 insertions, 32 deletions
diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php
index f9540df3ff2..f502d905fe8 100644
--- a/apps/files_sharing/lib/AppInfo/Application.php
+++ b/apps/files_sharing/lib/AppInfo/Application.php
@@ -92,17 +92,13 @@ class Application extends App {
$container->registerService('ExternalManager', function (SimpleContainer $c) use ($server) {
$user = $server->getUserSession()->getUser();
$uid = $user ? $user->getUID() : null;
- $discoveryManager = new DiscoveryManager(
- \OC::$server->getMemCacheFactory(),
- \OC::$server->getHTTPClientService()
- );
return new \OCA\Files_Sharing\External\Manager(
$server->getDatabaseConnection(),
\OC\Files\Filesystem::getMountManager(),
\OC\Files\Filesystem::getLoader(),
$server->getHTTPClientService(),
$server->getNotificationManager(),
- $discoveryManager,
+ $server->query(\OCP\OCS\IDiscoveryService::class),
$uid
);
});
diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php
index 0a57324c32f..2c348907384 100644
--- a/apps/files_sharing/lib/External/Manager.php
+++ b/apps/files_sharing/lib/External/Manager.php
@@ -32,8 +32,11 @@ namespace OCA\Files_Sharing\External;
use OC\Files\Filesystem;
use OCA\FederatedFileSharing\DiscoveryManager;
use OCP\Files;
+use OCP\Files\Storage\IStorageFactory;
use OCP\Http\Client\IClientService;
+use OCP\IDBConnection;
use OCP\Notification\IManager;
+use OCP\OCS\IDiscoveryService;
class Manager {
const STORAGE = '\OCA\Files_Sharing\External\Storage';
@@ -44,7 +47,7 @@ class Manager {
private $uid;
/**
- * @var \OCP\IDBConnection
+ * @var IDBConnection
*/
private $connection;
@@ -54,7 +57,7 @@ class Manager {
private $mountManager;
/**
- * @var \OCP\Files\Storage\IStorageFactory
+ * @var IStorageFactory
*/
private $storageLoader;
@@ -67,24 +70,27 @@ class Manager {
* @var IManager
*/
private $notificationManager;
- /** @var DiscoveryManager */
- private $discoveryManager;
/**
- * @param \OCP\IDBConnection $connection
+ * @var IDiscoveryService
+ */
+ private $discoveryService;
+
+ /**
+ * @param IDBConnection $connection
* @param \OC\Files\Mount\Manager $mountManager
- * @param \OCP\Files\Storage\IStorageFactory $storageLoader
+ * @param IStorageFactory $storageLoader
* @param IClientService $clientService
* @param IManager $notificationManager
- * @param DiscoveryManager $discoveryManager
+ * @param IDiscoveryService $discoveryService
* @param string $uid
*/
- public function __construct(\OCP\IDBConnection $connection,
+ public function __construct(IDBConnection $connection,
\OC\Files\Mount\Manager $mountManager,
- \OCP\Files\Storage\IStorageFactory $storageLoader,
+ IStorageFactory $storageLoader,
IClientService $clientService,
IManager $notificationManager,
- DiscoveryManager $discoveryManager,
+ IDiscoveryService $discoveryService,
$uid) {
$this->connection = $connection;
$this->mountManager = $mountManager;
@@ -92,7 +98,7 @@ class Manager {
$this->clientService = $clientService;
$this->uid = $uid;
$this->notificationManager = $notificationManager;
- $this->discoveryManager = $discoveryManager;
+ $this->discoveryService = $discoveryService;
}
/**
@@ -260,7 +266,10 @@ class Manager {
*/
private function sendFeedbackToRemote($remote, $token, $remoteId, $feedback) {
- $url = rtrim($remote, '/') . $this->discoveryManager->getShareEndpoint($remote) . '/' . $remoteId . '/' . $feedback . '?format=' . \OCP\Share::RESPONSE_FORMAT;
+ $federationEndpoints = $this->discoveryService->discover($remote, 'FEDERATED_SHARING');
+ $endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares';
+
+ $url = rtrim($remote, '/') . $endpoint . '/' . $remoteId . '/' . $feedback . '?format=' . \OCP\Share::RESPONSE_FORMAT;
$fields = array('token' => $token);
$client = $this->clientService->newClient();
@@ -376,7 +385,7 @@ class Manager {
/**
* remove re-shares from share table and mapping in the federated_reshares table
- *
+ *
* @param $mountPointId
*/
protected function removeReShares($mountPointId) {
diff --git a/apps/files_sharing/lib/External/Storage.php b/apps/files_sharing/lib/External/Storage.php
index 319735dcaf5..b84ba5d96ab 100644
--- a/apps/files_sharing/lib/External/Storage.php
+++ b/apps/files_sharing/lib/External/Storage.php
@@ -51,8 +51,6 @@ class Storage extends DAV implements ISharedStorage {
private $memcacheFactory;
/** @var \OCP\Http\Client\IClientService */
private $httpClient;
- /** @var \OCP\ICertificateManager */
- private $certificateManager;
/** @var bool */
private $updateChecked = false;
@@ -64,14 +62,11 @@ class Storage extends DAV implements ISharedStorage {
public function __construct($options) {
$this->memcacheFactory = \OC::$server->getMemCacheFactory();
$this->httpClient = $options['HttpClientService'];
- $discoveryManager = new DiscoveryManager(
- $this->memcacheFactory,
- $this->httpClient
- );
$this->manager = $options['manager'];
- $this->certificateManager = $options['certificateManager'];
$this->cloudId = $options['cloudId'];
+ $discoveryService = \OC::$server->query(\OCP\OCS\IDiscoveryService::class);
+
list($protocol, $remote) = explode('://', $this->cloudId->getRemote());
if (strpos($remote, '/')) {
list($host, $root) = explode('/', $remote, 2);
@@ -80,9 +75,12 @@ class Storage extends DAV implements ISharedStorage {
$root = '';
}
$secure = $protocol === 'https';
- $root = rtrim($root, '/') . $discoveryManager->getWebDavEndpoint($this->cloudId->getRemote());
+ $federatedSharingEndpoints = $discoveryService->discover($this->cloudId->getRemote(), 'FEDERATED_SHARING');
+ $webDavEndpoint = isset($federatedSharingEndpoints['webdav']) ? $federatedSharingEndpoints['webdav'] : '/public.php/webdav';
+ $root = rtrim($root, '/') . $webDavEndpoint;
$this->mountPoint = $options['mountpoint'];
$this->token = $options['token'];
+
parent::__construct(array(
'secure' => $secure,
'host' => $host,
@@ -350,7 +348,7 @@ class Storage extends DAV implements ISharedStorage {
}
return ($this->getPermissions($path) & \OCP\Constants::PERMISSION_SHARE);
}
-
+
public function getPermissions($path) {
$response = $this->propfind($path);
if (isset($response['{http://open-collaboration-services.org/ns}share-permissions'])) {
diff --git a/apps/files_sharing/lib/Hooks.php b/apps/files_sharing/lib/Hooks.php
index 2029e97d08b..821c3046595 100644
--- a/apps/files_sharing/lib/Hooks.php
+++ b/apps/files_sharing/lib/Hooks.php
@@ -32,17 +32,13 @@ use OCA\FederatedFileSharing\DiscoveryManager;
class Hooks {
public static function deleteUser($params) {
- $discoveryManager = new DiscoveryManager(
- \OC::$server->getMemCacheFactory(),
- \OC::$server->getHTTPClientService()
- );
$manager = new External\Manager(
\OC::$server->getDatabaseConnection(),
\OC\Files\Filesystem::getMountManager(),
\OC\Files\Filesystem::getLoader(),
\OC::$server->getHTTPClientService(),
\OC::$server->getNotificationManager(),
- $discoveryManager,
+ \OC::$server->query(\OCP\OCS\IDiscoveryService::class),
$params['uid']);
$manager->removeUserShares($params['uid']);