aboutsummaryrefslogtreecommitdiffstats
path: root/apps/federatedfilesharing/lib/Controller
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-03-12 14:21:12 +0100
committerMorris Jobke <hey@morrisjobke.de>2018-03-12 14:21:12 +0100
commit4cbcf6f92045c5779b5456b5fbd2f6391b7ecf45 (patch)
tree70292c11262683907760a25215219ec3d8848356 /apps/federatedfilesharing/lib/Controller
parentaf89db3407e599ea47d62a851759fa929cdd4713 (diff)
downloadnextcloud-server-4cbcf6f92045c5779b5456b5fbd2f6391b7ecf45.tar.gz
nextcloud-server-4cbcf6f92045c5779b5456b5fbd2f6391b7ecf45.zip
Remove old code to be compatible with Nextcloud 9 and before
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'apps/federatedfilesharing/lib/Controller')
-rw-r--r--apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php116
1 files changed, 2 insertions, 114 deletions
diff --git a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
index a54a3aa69a0..8d27f13bb9b 100644
--- a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
+++ b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
@@ -227,119 +227,7 @@ class MountPublicLinkController extends Controller {
// if we doesn't get the expected response we assume that we try to add
// a federated share from a Nextcloud <= 9 server
- return $this->legacyMountPublicLink($token, $remote, $password, $name, $owner, $ownerDisplayName);
+ $message = $this->l->t("Couldn't establish a federated share, it looks like the server to federate with is too old (Nextcloud <= 9).");
+ return new JSONResponse(['message' => $message], Http::STATUS_BAD_REQUEST);
}
-
- /**
- * Allow Nextcloud to mount a public link directly
- *
- * This code was copied from the apps/files_sharing/ajax/external.php with
- * minimal changes, just to guarantee backward compatibility
- *
- * ToDo: Remove this method once Nextcloud 9 reaches end of life
- *
- * @param string $token
- * @param string $remote
- * @param string $password
- * @param string $name
- * @param string $owner
- * @param string $ownerDisplayName
- * @return JSONResponse
- */
- private function legacyMountPublicLink($token, $remote, $password, $name, $owner, $ownerDisplayName) {
-
- // Check for invalid name
- if (!Util::isValidFileName($name)) {
- return new JSONResponse(['message' => $this->l->t('The mountpoint name contains invalid characters.')], Http::STATUS_BAD_REQUEST);
- }
- $currentUser = $this->userSession->getUser()->getUID();
- $currentServer = $this->addressHandler->generateRemoteURL();
- if (Helper::isSameUserOnSameServer($owner, $remote, $currentUser, $currentServer)) {
- return new JSONResponse(['message' => $this->l->t('Not allowed to create a federated share with the owner.')], Http::STATUS_BAD_REQUEST);
- }
- $externalManager = new Manager(
- \OC::$server->getDatabaseConnection(),
- Filesystem::getMountManager(),
- Filesystem::getLoader(),
- \OC::$server->getHTTPClientService(),
- \OC::$server->getNotificationManager(),
- \OC::$server->query(\OCP\OCS\IDiscoveryService::class),
- \OC::$server->getUserSession()->getUser()->getUID()
- );
-
- // check for ssl cert
-
- if (strpos($remote, 'https') === 0) {
- try {
- $client = $this->clientService->newClient();
- $client->get($remote, [
- 'timeout' => 10,
- 'connect_timeout' => 10,
- ])->getBody();
- } catch (\Exception $e) {
- return new JSONResponse(['message' => $this->l->t('Invalid or untrusted SSL certificate')], Http::STATUS_BAD_REQUEST);
- }
- }
- $mount = $externalManager->addShare($remote, $token, $password, $name, $ownerDisplayName, true);
- /**
- * @var \OCA\Files_Sharing\External\Storage $storage
- */
- $storage = $mount->getStorage();
- try {
- // check if storage exists
- $storage->checkStorageAvailability();
- } catch (StorageInvalidException $e) {
- // note: checkStorageAvailability will already remove the invalid share
- \OC::$server->getLogger()->logException($e, [
- 'message' => 'Invalid remote storage.',
- 'level' => \OCP\Util::DEBUG,
- 'app' => 'federatedfilesharing'
- ]);
- return new JSONResponse(['message' => $this->l->t('Could not authenticate to remote share, password might be wrong')], Http::STATUS_BAD_REQUEST);
- } catch (\Exception $e) {
- \OC::$server->getLogger()->logException($e, [
- 'message' => 'Invalid remote storage.',
- 'level' => \OCP\Util::DEBUG,
- 'app' => 'federatedfilesharing'
- ]);
- $externalManager->removeShare($mount->getMountPoint());
- return new JSONResponse(['message' => $this->l->t('Storage not valid')], Http::STATUS_BAD_REQUEST);
- }
- $result = $storage->file_exists('');
- if ($result) {
- try {
- $storage->getScanner()->scanAll();
- return new JSONResponse(
- [
- 'message' => $this->l->t('Federated share added'),
- 'legacyMount' => '1'
- ]
- );
- } catch (StorageInvalidException $e) {
- \OC::$server->getLogger()->logException($e, [
- 'message' => 'Invalid remote storage.',
- 'level' => \OCP\Util::DEBUG,
- 'app' => 'federatedfilesharing'
- ]);
- return new JSONResponse(['message' => $this->l->t('Storage not valid')], Http::STATUS_BAD_REQUEST);
- } catch (\Exception $e) {
- \OC::$server->getLogger()->logException($e, [
- 'message' => 'Invalid remote storage.',
- 'level' => \OCP\Util::DEBUG,
- 'app' => 'federatedfilesharing'
- ]);
- return new JSONResponse(['message' => $this->l->t('Couldn\'t add remote share')], Http::STATUS_BAD_REQUEST);
- }
- } else {
- $externalManager->removeShare($mount->getMountPoint());
- Util::writeLog(
- 'federatedfilesharing',
- 'Couldn\'t add remote share',
- Util::DEBUG
- );
- return new JSONResponse(['message' => $this->l->t('Couldn\'t add remote share')], Http::STATUS_BAD_REQUEST);
- }
-
- }
-
}