start implementing federated sharing 2.0
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
This commit is contained in:
parent
22bb834c48
commit
5cfe20675d
|
@ -14,6 +14,7 @@ return array(
|
|||
'OCA\\FederatedFileSharing\\FederatedShareProvider' => $baseDir . '/../lib/FederatedShareProvider.php',
|
||||
'OCA\\FederatedFileSharing\\Notifications' => $baseDir . '/../lib/Notifications.php',
|
||||
'OCA\\FederatedFileSharing\\Notifier' => $baseDir . '/../lib/Notifier.php',
|
||||
'OCA\\FederatedFileSharing\\OCM\\CloudFederationProviderFiles' => $baseDir . '/../lib/ocm/CloudFederationProviderFiles.php',
|
||||
'OCA\\FederatedFileSharing\\Settings\\Admin' => $baseDir . '/../lib/Settings/Admin.php',
|
||||
'OCA\\FederatedFileSharing\\Settings\\Personal' => $baseDir . '/../lib/Settings/Personal.php',
|
||||
'OCA\\FederatedFileSharing\\Settings\\PersonalSection' => $baseDir . '/../lib/Settings/PersonalSection.php',
|
||||
|
|
|
@ -29,6 +29,7 @@ class ComposerStaticInitFederatedFileSharing
|
|||
'OCA\\FederatedFileSharing\\FederatedShareProvider' => __DIR__ . '/..' . '/../lib/FederatedShareProvider.php',
|
||||
'OCA\\FederatedFileSharing\\Notifications' => __DIR__ . '/..' . '/../lib/Notifications.php',
|
||||
'OCA\\FederatedFileSharing\\Notifier' => __DIR__ . '/..' . '/../lib/Notifier.php',
|
||||
'OCA\\FederatedFileSharing\\OCM\\CloudFederationProviderFiles' => __DIR__ . '/..' . '/../lib/ocm/CloudFederationProviderFiles.php',
|
||||
'OCA\\FederatedFileSharing\\Settings\\Admin' => __DIR__ . '/..' . '/../lib/Settings/Admin.php',
|
||||
'OCA\\FederatedFileSharing\\Settings\\Personal' => __DIR__ . '/..' . '/../lib/Settings/Personal.php',
|
||||
'OCA\\FederatedFileSharing\\Settings\\PersonalSection' => __DIR__ . '/..' . '/../lib/Settings/PersonalSection.php',
|
||||
|
|
|
@ -32,6 +32,7 @@ use OCA\FederatedFileSharing\AddressHandler;
|
|||
use OCA\FederatedFileSharing\Controller\RequestHandlerController;
|
||||
use OCA\FederatedFileSharing\FederatedShareProvider;
|
||||
use OCA\FederatedFileSharing\Notifications;
|
||||
use OCA\FederatedFileSharing\OCM\CloudFederationProvider;
|
||||
use OCP\AppFramework\App;
|
||||
use OCP\GlobalScale\IConfig;
|
||||
|
||||
|
@ -46,6 +47,13 @@ class Application extends App {
|
|||
$container = $this->getContainer();
|
||||
$server = $container->getServer();
|
||||
|
||||
$cloudFederationManager = $server->getCloudFederationProviderManager();
|
||||
$cloudFederationManager->addCloudFederationProvider('file',
|
||||
'Federated Files Sharing',
|
||||
function() use ($container) {
|
||||
return new CloudFederationProvider('file');
|
||||
});
|
||||
|
||||
$container->registerService('RequestHandlerController', function(SimpleContainer $c) use ($server) {
|
||||
$addressHandler = new AddressHandler(
|
||||
$server->getURLGenerator(),
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
namespace OCA\FederatedFileSharing;
|
||||
|
||||
use OC\Share20\Share;
|
||||
use OCA\FederatedFileSharing\OCM\CloudFederationProvider;
|
||||
use OCP\Federation\ICloudIdManager;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
use OCP\Files\Folder;
|
||||
|
@ -91,6 +92,9 @@ class FederatedShareProvider implements IShareProvider {
|
|||
/** @var \OCP\GlobalScale\IConfig */
|
||||
private $gsConfig;
|
||||
|
||||
/** @var CloudFederationProvider */
|
||||
private $cloudFederationProvider;
|
||||
|
||||
/**
|
||||
* DefaultShareProvider constructor.
|
||||
*
|
||||
|
@ -105,6 +109,7 @@ class FederatedShareProvider implements IShareProvider {
|
|||
* @param IUserManager $userManager
|
||||
* @param ICloudIdManager $cloudIdManager
|
||||
* @param \OCP\GlobalScale\IConfig $globalScaleConfig
|
||||
* @param CloudFederationProvider $cloudFederationProvider
|
||||
*/
|
||||
public function __construct(
|
||||
IDBConnection $connection,
|
||||
|
@ -117,7 +122,8 @@ class FederatedShareProvider implements IShareProvider {
|
|||
IConfig $config,
|
||||
IUserManager $userManager,
|
||||
ICloudIdManager $cloudIdManager,
|
||||
\OCP\GlobalScale\IConfig $globalScaleConfig
|
||||
\OCP\GlobalScale\IConfig $globalScaleConfig,
|
||||
CloudFederationProvider $cloudFederationProvider
|
||||
) {
|
||||
$this->dbConnection = $connection;
|
||||
$this->addressHandler = $addressHandler;
|
||||
|
@ -130,6 +136,8 @@ class FederatedShareProvider implements IShareProvider {
|
|||
$this->userManager = $userManager;
|
||||
$this->cloudIdManager = $cloudIdManager;
|
||||
$this->gsConfig = $globalScaleConfig;
|
||||
$this->cloudFederationProvider = $cloudFederationProvider;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Bjoern Schiessle <bjoern@schiessle.org>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\FederatedFileSharing\OCM;
|
||||
|
||||
use OCP\Federation\ICloudFederationFactory;
|
||||
use OCP\Federation\ICloudFederationProvider;
|
||||
use OCP\Federation\ICloudFederationShare;
|
||||
|
||||
class CloudFederationProvider implements ICloudFederationProvider {
|
||||
|
||||
/** @var string */
|
||||
private $shareType;
|
||||
|
||||
/**
|
||||
* CloudFederationProvider constructor.
|
||||
*
|
||||
* @param string $shareType
|
||||
*/
|
||||
public function __construct($shareType) {
|
||||
$this->shareType = $shareType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getShareType() {
|
||||
return $this->shareType;
|
||||
}
|
||||
|
||||
/**
|
||||
* send new share to another server
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function sendShare() {
|
||||
// TODO: Implement sendShare() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* share received from another server
|
||||
*
|
||||
* @param ICloudFederationShare $share
|
||||
* @return string provider specific unique ID of the share
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function shareReceived(ICloudFederationShare $share) {
|
||||
// TODO: Implement shareReceived() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* notification received from another server
|
||||
*
|
||||
* @param string $id unique ID of a already existing share
|
||||
* @param array $notification provider specific notification
|
||||
*
|
||||
* @throws \OCP\Federation\Exceptions\ShareNotFoundException
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function notificationReceived($id, $notification) {
|
||||
// TODO: Implement notificationReceived() method.
|
||||
}
|
||||
}
|
|
@ -107,6 +107,34 @@ $this->create('spreed.pagecontroller.showCall', '/call/{token}')->action(functio
|
|||
}
|
||||
});
|
||||
|
||||
// OCM routes
|
||||
/**
|
||||
* @suppress PhanUndeclaredClassConstant
|
||||
* @suppress PhanUndeclaredClassMethod
|
||||
*/
|
||||
$this->create('cloud_federation_api.requesthandlercontroller.addShare', '/ocm/shares')->post()->action(function($urlParams) {
|
||||
if (class_exists(\OCA\CloudFederationAPI\AppInfo\Application::class, false)) {
|
||||
$app = new \OCA\CloudFederationAPI\AppInfo\Application($urlParams);
|
||||
$app->dispatch('RequestHandlerController', 'addShare');
|
||||
} else {
|
||||
throw new \OC\HintException('Cloud Federation API not enabled');
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @suppress PhanUndeclaredClassConstant
|
||||
* @suppress PhanUndeclaredClassMethod
|
||||
*/
|
||||
$this->create('cloud_federation_api.requesthandlercontroller.receiveNotification', '/ocm/notifications')->post()->action(function($urlParams) {
|
||||
if (class_exists(\OCA\CloudFederationAPI\AppInfo\Application::class, false)) {
|
||||
$app = new \OCA\CloudFederationAPI\AppInfo\Application($urlParams);
|
||||
$app->dispatch('RequestHandlerController', 'receiveNotification');
|
||||
} else {
|
||||
throw new \OC\HintException('Cloud Federation API not enabled');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Sharing routes
|
||||
$this->create('files_sharing.sharecontroller.showShare', '/s/{token}')->action(function($urlParams) {
|
||||
if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
|
||||
|
|
|
@ -132,6 +132,15 @@ return array(
|
|||
'OCP\\Encryption\\IFile' => $baseDir . '/lib/public/Encryption/IFile.php',
|
||||
'OCP\\Encryption\\IManager' => $baseDir . '/lib/public/Encryption/IManager.php',
|
||||
'OCP\\Encryption\\Keys\\IStorage' => $baseDir . '/lib/public/Encryption/Keys/IStorage.php',
|
||||
'OCP\\Federation\\Exceptions\\ProviderAlreadyExistsException' => $baseDir . '/lib/public/Federation/Exceptions/ProviderAlreadyExistsException.php',
|
||||
'OCP\\Federation\\Exceptions\\ProviderCouldNotAddShareException' => $baseDir . '/lib/public/Federation/Exceptions/ProviderCouldNotAddShareException.php',
|
||||
'OCP\\Federation\\Exceptions\\ProviderDoesNotExistsException' => $baseDir . '/lib/public/Federation/Exceptions/ProviderDoesNotExistsException.php',
|
||||
'OCP\\Federation\\Exceptions\\ShareNotFoundException' => $baseDir . '/lib/public/Federation/Exceptions/ShareNotFoundException.php',
|
||||
'OCP\\Federation\\ICloudFederationFactory' => $baseDir . '/lib/public/Federation/ICloudFederationFactory.php',
|
||||
'OCP\\Federation\\ICloudFederationNotification' => $baseDir . '/lib/public/Federation/ICloudFederationNotification.php',
|
||||
'OCP\\Federation\\ICloudFederationProvider' => $baseDir . '/lib/public/Federation/ICloudFederationProvider.php',
|
||||
'OCP\\Federation\\ICloudFederationProviderManager' => $baseDir . '/lib/public/Federation/ICloudFederationProviderManager.php',
|
||||
'OCP\\Federation\\ICloudFederationShare' => $baseDir . '/lib/public/Federation/ICloudFederationShare.php',
|
||||
'OCP\\Federation\\ICloudId' => $baseDir . '/lib/public/Federation/ICloudId.php',
|
||||
'OCP\\Federation\\ICloudIdManager' => $baseDir . '/lib/public/Federation/ICloudIdManager.php',
|
||||
'OCP\\Files' => $baseDir . '/lib/public/Files.php',
|
||||
|
@ -660,6 +669,10 @@ return array(
|
|||
'OC\\Encryption\\Manager' => $baseDir . '/lib/private/Encryption/Manager.php',
|
||||
'OC\\Encryption\\Update' => $baseDir . '/lib/private/Encryption/Update.php',
|
||||
'OC\\Encryption\\Util' => $baseDir . '/lib/private/Encryption/Util.php',
|
||||
'OC\\Federation\\CloudFederationFactory' => $baseDir . '/lib/private/Federation/CloudFederationFactory.php',
|
||||
'OC\\Federation\\CloudFederationNotification' => $baseDir . '/lib/private/Federation/CloudFederationNotification.php',
|
||||
'OC\\Federation\\CloudFederationProviderManager' => $baseDir . '/lib/private/Federation/CloudFederationProviderManager.php',
|
||||
'OC\\Federation\\CloudFederationShare' => $baseDir . '/lib/private/Federation/CloudFederationShare.php',
|
||||
'OC\\Federation\\CloudId' => $baseDir . '/lib/private/Federation/CloudId.php',
|
||||
'OC\\Federation\\CloudIdManager' => $baseDir . '/lib/private/Federation/CloudIdManager.php',
|
||||
'OC\\Files\\AppData\\AppData' => $baseDir . '/lib/private/Files/AppData/AppData.php',
|
||||
|
|
|
@ -162,6 +162,15 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
|
|||
'OCP\\Encryption\\IFile' => __DIR__ . '/../../..' . '/lib/public/Encryption/IFile.php',
|
||||
'OCP\\Encryption\\IManager' => __DIR__ . '/../../..' . '/lib/public/Encryption/IManager.php',
|
||||
'OCP\\Encryption\\Keys\\IStorage' => __DIR__ . '/../../..' . '/lib/public/Encryption/Keys/IStorage.php',
|
||||
'OCP\\Federation\\Exceptions\\ProviderAlreadyExistsException' => __DIR__ . '/../../..' . '/lib/public/Federation/Exceptions/ProviderAlreadyExistsException.php',
|
||||
'OCP\\Federation\\Exceptions\\ProviderCouldNotAddShareException' => __DIR__ . '/../../..' . '/lib/public/Federation/Exceptions/ProviderCouldNotAddShareException.php',
|
||||
'OCP\\Federation\\Exceptions\\ProviderDoesNotExistsException' => __DIR__ . '/../../..' . '/lib/public/Federation/Exceptions/ProviderDoesNotExistsException.php',
|
||||
'OCP\\Federation\\Exceptions\\ShareNotFoundException' => __DIR__ . '/../../..' . '/lib/public/Federation/Exceptions/ShareNotFoundException.php',
|
||||
'OCP\\Federation\\ICloudFederationFactory' => __DIR__ . '/../../..' . '/lib/public/Federation/ICloudFederationFactory.php',
|
||||
'OCP\\Federation\\ICloudFederationNotification' => __DIR__ . '/../../..' . '/lib/public/Federation/ICloudFederationNotification.php',
|
||||
'OCP\\Federation\\ICloudFederationProvider' => __DIR__ . '/../../..' . '/lib/public/Federation/ICloudFederationProvider.php',
|
||||
'OCP\\Federation\\ICloudFederationProviderManager' => __DIR__ . '/../../..' . '/lib/public/Federation/ICloudFederationProviderManager.php',
|
||||
'OCP\\Federation\\ICloudFederationShare' => __DIR__ . '/../../..' . '/lib/public/Federation/ICloudFederationShare.php',
|
||||
'OCP\\Federation\\ICloudId' => __DIR__ . '/../../..' . '/lib/public/Federation/ICloudId.php',
|
||||
'OCP\\Federation\\ICloudIdManager' => __DIR__ . '/../../..' . '/lib/public/Federation/ICloudIdManager.php',
|
||||
'OCP\\Files' => __DIR__ . '/../../..' . '/lib/public/Files.php',
|
||||
|
@ -690,6 +699,10 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
|
|||
'OC\\Encryption\\Manager' => __DIR__ . '/../../..' . '/lib/private/Encryption/Manager.php',
|
||||
'OC\\Encryption\\Update' => __DIR__ . '/../../..' . '/lib/private/Encryption/Update.php',
|
||||
'OC\\Encryption\\Util' => __DIR__ . '/../../..' . '/lib/private/Encryption/Util.php',
|
||||
'OC\\Federation\\CloudFederationFactory' => __DIR__ . '/../../..' . '/lib/private/Federation/CloudFederationFactory.php',
|
||||
'OC\\Federation\\CloudFederationNotification' => __DIR__ . '/../../..' . '/lib/private/Federation/CloudFederationNotification.php',
|
||||
'OC\\Federation\\CloudFederationProviderManager' => __DIR__ . '/../../..' . '/lib/private/Federation/CloudFederationProviderManager.php',
|
||||
'OC\\Federation\\CloudFederationShare' => __DIR__ . '/../../..' . '/lib/private/Federation/CloudFederationShare.php',
|
||||
'OC\\Federation\\CloudId' => __DIR__ . '/../../..' . '/lib/private/Federation/CloudId.php',
|
||||
'OC\\Federation\\CloudIdManager' => __DIR__ . '/../../..' . '/lib/private/Federation/CloudIdManager.php',
|
||||
'OC\\Files\\AppData\\AppData' => __DIR__ . '/../../..' . '/lib/private/Files/AppData/AppData.php',
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Bjoern Schiessle <bjoern@schiessle.org>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OC\Federation;
|
||||
|
||||
use OCP\Federation\ICloudFederationFactory;
|
||||
use OCP\Federation\ICloudFederationNotification;
|
||||
use OCP\Federation\ICloudFederationShare;
|
||||
|
||||
class CloudFederationFactory implements ICloudFederationFactory {
|
||||
|
||||
/**
|
||||
* get a CloudFederationShare Object to prepare a share you want to send
|
||||
*
|
||||
* @param string $shareWith
|
||||
* @param string $name resource name (e.g. document.odt)
|
||||
* @param string $description share description (optional)
|
||||
* @param string $providerId resource UID on the provider side
|
||||
* @param string $owner provider specific UID of the user who owns the resource
|
||||
* @param string $ownerDisplayName display name of the user who shared the item
|
||||
* @param string $sharedBy provider specific UID of the user who shared the resource
|
||||
* @param $sharedByDisplayName display name of the user who shared the resource
|
||||
* @param array $protocol (e,.g. ['name' => 'webdav', 'options' => ['username' => 'john', 'permissions' => 31]])
|
||||
* @param string $shareType ('group' or 'user' share)
|
||||
* @param $resourceType ('file', 'calendar',...)
|
||||
* @return ICloudFederationShare
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $protocol, $shareType, $resourceType) {
|
||||
return new CloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $protocol, $shareType, $resourceType);
|
||||
}
|
||||
|
||||
/**
|
||||
* get a Cloud FederationNotification object to prepare a notification you
|
||||
* want to send
|
||||
*
|
||||
* @return ICloudFederationNotification
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getCloudFederationNotification() {
|
||||
return new CloudFederationNotification();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Bjoern Schiessle <bjoern@schiessle.org>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OC\Federation;
|
||||
|
||||
use OCP\Federation\ICloudFederationNotification;
|
||||
|
||||
class CloudFederationNotification implements ICloudFederationNotification {
|
||||
|
||||
private $message = [];
|
||||
|
||||
/**
|
||||
* add a message to the notification
|
||||
*
|
||||
* @param string $identifier
|
||||
* @param string $message
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function setMessage($identifier, $message) {
|
||||
$this->message[$identifier] = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* get JSON encoded Message, ready to send out
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getMessage() {
|
||||
return json_encode($this->message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Bjoern Schiessle <bjoern@schiessle.org>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace OC\Federation;
|
||||
|
||||
use OCP\Federation\Exceptions\ProviderAlreadyExistsException;
|
||||
use OCP\Federation\Exceptions\ProviderDoesNotExistsException;
|
||||
use OCP\Federation\ICloudFederationNotification;
|
||||
use OCP\Federation\ICloudFederationProvider;
|
||||
use OCP\Federation\ICloudFederationProviderManager;
|
||||
use OCP\Federation\ICloudFederationShare;
|
||||
|
||||
/**
|
||||
* Class Manager
|
||||
*
|
||||
* Manage Cloud Federation Providers
|
||||
*
|
||||
* @package OC\Federation
|
||||
*/
|
||||
class CloudFederationProviderManager implements ICloudFederationProviderManager {
|
||||
|
||||
/** @var array list of available cloud federation providers */
|
||||
private $cloudFederationProvider;
|
||||
|
||||
public function __construct() {
|
||||
$this->cloudFederationProvider= [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Registers an callback function which must return an cloud federation provider
|
||||
*
|
||||
* @param string $shareType which share type does the provider handles
|
||||
* @param string $displayName user facing name of the federated share provider
|
||||
* @param callable $callback
|
||||
*/
|
||||
public function addCloudFederationProvider($shareType, $displayName, callable $callback) {
|
||||
\OC::$server->getRemoteApiFactory();
|
||||
|
||||
$this->cloudFederationProvider[$shareType] = [
|
||||
'shareType' => $shareType,
|
||||
'displayName' => $displayName,
|
||||
'callback' => $callback,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* remove cloud federation provider
|
||||
*
|
||||
* @param string $providerId
|
||||
*/
|
||||
public function removeCloudFederationProvider($providerId) {
|
||||
unset($this->cloudFederationProvider[$providerId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* get a list of all cloudFederationProviders
|
||||
*
|
||||
* @return array [id => ['id' => $id, 'displayName' => $displayName, 'callback' => callback]]
|
||||
*/
|
||||
public function getAllCloudFederationProviders() {
|
||||
return $this->cloudFederationProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* get a specific cloud federation provider
|
||||
*
|
||||
* @param string $shareType
|
||||
* @return ICloudFederationProvider
|
||||
* @throws ProviderDoesNotExistsException
|
||||
*/
|
||||
public function getCloudFederationProvider($shareType) {
|
||||
if (isset($this->cloudFederationProvider[$shareType])) {
|
||||
return call_user_func($this->cloudFederationProvider[$shareType]['callback']);
|
||||
} else {
|
||||
throw new ProviderDoesNotExistsException($shareType);
|
||||
}
|
||||
}
|
||||
|
||||
public function sendShare(ICloudFederationShare $share) {
|
||||
// TODO: Implement sendShare() method.
|
||||
}
|
||||
|
||||
public function sendNotification(ICloudFederationNotification $notification) {
|
||||
// TODO: Implement sendNotification() method.
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,336 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Bjoern Schiessle <bjoern@schiessle.org>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OC\Federation;
|
||||
|
||||
use OCP\Federation\ICloudFederationShare;
|
||||
|
||||
class CloudFederationShare implements ICloudFederationShare {
|
||||
|
||||
private $share = [
|
||||
'shareWith' => '',
|
||||
'shareType' => '',
|
||||
'name' => '',
|
||||
'resourceType' => '',
|
||||
'description' => '',
|
||||
'providerId' => '',
|
||||
'owner' => '',
|
||||
'ownerDisplayName' => '',
|
||||
'sharedBy' => '',
|
||||
'sharedByDisplayName' => '',
|
||||
'protocol' => []
|
||||
];
|
||||
|
||||
/**
|
||||
* get a CloudFederationShare Object to prepare a share you want to send
|
||||
*
|
||||
* @param string $shareWith
|
||||
* @param string $name resource name (e.g. document.odt)
|
||||
* @param string $description share description (optional)
|
||||
* @param string $providerId resource UID on the provider side
|
||||
* @param string $owner provider specific UID of the user who owns the resource
|
||||
* @param string $ownerDisplayName display name of the user who shared the item
|
||||
* @param string $sharedBy provider specific UID of the user who shared the resource
|
||||
* @param string $sharedByDisplayName display name of the user who shared the resource
|
||||
* @param array $protocol (e,.g. ['name' => 'webdav', 'options' => ['username' => 'john', 'permissions' => 31]])
|
||||
* @param string $shareType ('group' or 'user' share)
|
||||
* @param $resourceType ('file', 'calendar',...)
|
||||
*
|
||||
*/
|
||||
public function __construct($shareWith = '',
|
||||
$name = '',
|
||||
$description = '',
|
||||
$providerId = '',
|
||||
$owner = '',
|
||||
$ownerDisplayName = '',
|
||||
$sharedBy = '',
|
||||
$sharedByDisplayName = '',
|
||||
$protocol = [],
|
||||
$shareType = '',
|
||||
$resourceType = ''
|
||||
) {
|
||||
$this->setShareWith($shareWith);
|
||||
$this->setResourceName($name);
|
||||
$this->setDescription($description);
|
||||
$this->setProviderId($providerId);
|
||||
$this->setOwner($owner);
|
||||
$this->setOwnerDisplayName($ownerDisplayName);
|
||||
$this->setSharedBy($sharedBy);
|
||||
$this->setSharedByDisplayName($sharedByDisplayName);
|
||||
$this->setProtocol($protocol);
|
||||
$this->setShareType($shareType);
|
||||
$this->setResourceType($resourceType);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* set uid of the recipient
|
||||
*
|
||||
* @param string $user
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function setShareWith($user) {
|
||||
$this->share['shareWith'] = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* set resource name (e.g. document.odt)
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function setResourceName($name) {
|
||||
$this->share['name'] = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* set resource type (e.g. file, calendar, contact,...)
|
||||
*
|
||||
* @param string $resourceType
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function setResourceType($resourceType) {
|
||||
$this->share['resourceType'] = $resourceType;
|
||||
}
|
||||
|
||||
/**
|
||||
* set resource description (optional)
|
||||
*
|
||||
* @param string $description
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function setDescription($description) {
|
||||
$this->share['description'] = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* set provider ID (e.g. file ID)
|
||||
*
|
||||
* @param string $providerId
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function setProviderId($providerId) {
|
||||
$this->share['providerId'] = $providerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* set owner UID
|
||||
*
|
||||
* @param string $owner
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function setOwner($owner) {
|
||||
$this->share['owner'] = $owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* set owner display name
|
||||
*
|
||||
* @param string $ownerDisplayName
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function setOwnerDisplayName($ownerDisplayName) {
|
||||
$this->share['ownerDisplayName'] = $ownerDisplayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* set UID of the user who sends the share
|
||||
*
|
||||
* @param string $sharedBy
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function setSharedBy($sharedBy) {
|
||||
$this->share['sharedBy'] = $sharedBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* set display name of the user who sends the share
|
||||
*
|
||||
* @param $sharedByDisplayName
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function setSharedByDisplayName($sharedByDisplayName) {
|
||||
$this->share['sharedByDisplayName'] = $sharedByDisplayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* set protocol specification
|
||||
*
|
||||
* @param array $protocol
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function setProtocol(array $protocol) {
|
||||
$this->share['protocol'] = $protocol;
|
||||
}
|
||||
|
||||
/**
|
||||
* share type (group or user)
|
||||
*
|
||||
* @param string $shareType
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function setShareType($shareType) {
|
||||
$this->share['shareType'] = $shareType;
|
||||
}
|
||||
|
||||
/**
|
||||
* get JSON encoded share, ready to send out
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getShare() {
|
||||
return json_encode($this->share);
|
||||
}
|
||||
|
||||
/**
|
||||
* get uid of the recipient
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getShareWith() {
|
||||
return $this->share['shareWith'];
|
||||
}
|
||||
|
||||
/**
|
||||
* get resource name (e.g. file, calendar, contact,...)
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getResourceName() {
|
||||
return $this->share['name'];
|
||||
}
|
||||
|
||||
/**
|
||||
* get resource type (e.g. file, calendar, contact,...)
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getResourceType() {
|
||||
return $this->share['resourceType'];
|
||||
}
|
||||
|
||||
/**
|
||||
* get resource description (optional)
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getDescription() {
|
||||
return $this->share['description'];
|
||||
}
|
||||
|
||||
/**
|
||||
* get provider ID (e.g. file ID)
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getProviderId() {
|
||||
return $this->share['providerId'];
|
||||
}
|
||||
|
||||
/**
|
||||
* get owner UID
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getOwner() {
|
||||
return $this->share['owner'];
|
||||
}
|
||||
|
||||
/**
|
||||
* get owner display name
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getOwnerDisplayName() {
|
||||
return $this->share['ownerDisplayName'];
|
||||
}
|
||||
|
||||
/**
|
||||
* get UID of the user who sends the share
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getSharedBy() {
|
||||
return $this->share['sharedBy'];
|
||||
}
|
||||
|
||||
/**
|
||||
* get display name of the user who sends the share
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getSharedByDisplayName() {
|
||||
return $this->share['sharedByDisplayName'];
|
||||
}
|
||||
|
||||
/**
|
||||
* get share type (group or user)
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getShareType() {
|
||||
return $this->share['shareType'];
|
||||
}
|
||||
|
||||
/**
|
||||
* get protocol specification
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getProtocol() {
|
||||
return $this->share['protocol'];
|
||||
}
|
||||
}
|
|
@ -68,6 +68,8 @@ use OC\Contacts\ContactsMenu\ActionFactory;
|
|||
use OC\Contacts\ContactsMenu\ContactsStore;
|
||||
use OC\Diagnostics\EventLogger;
|
||||
use OC\Diagnostics\QueryLogger;
|
||||
use OC\Federation\CloudFederationFactory;
|
||||
use OC\Federation\CloudFederationProviderManager;
|
||||
use OC\Federation\CloudIdManager;
|
||||
use OC\Files\Config\UserMountCache;
|
||||
use OC\Files\Config\UserMountCacheListener;
|
||||
|
@ -124,9 +126,12 @@ use OCP\Collaboration\AutoComplete\IManager;
|
|||
use OCP\Contacts\ContactsMenu\IContactsStore;
|
||||
use OCP\Defaults;
|
||||
use OCA\Theming\Util;
|
||||
use OCP\Federation\ICloudFederationFactory;
|
||||
use OCP\Federation\ICloudFederationProviderManager;
|
||||
use OCP\Federation\ICloudIdManager;
|
||||
use OCP\Authentication\LoginCredentials\IStore;
|
||||
use OCP\Files\NotFoundException;
|
||||
use OCP\GlobalScale\IConfig;
|
||||
use OCP\ICacheFactory;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IL10N;
|
||||
|
@ -1107,6 +1112,18 @@ class Server extends ServerContainer implements IServerContainer {
|
|||
return new CloudIdManager();
|
||||
});
|
||||
|
||||
$this->registerService(IConfig::class, function (Server $c) {
|
||||
return new GlobalScale\Config($c->getConfig());
|
||||
});
|
||||
|
||||
$this->registerService(ICloudFederationProviderManager::class, function (Server $c) {
|
||||
return new CloudFederationProviderManager();
|
||||
});
|
||||
|
||||
$this->registerService(ICloudFederationFactory::class, function (Server $c) {
|
||||
return new CloudFederationFactory();
|
||||
});
|
||||
|
||||
$this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
|
||||
$this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
|
||||
|
||||
|
@ -1973,6 +1990,20 @@ class Server extends ServerContainer implements IServerContainer {
|
|||
return $this->query(ICloudIdManager::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \OCP\GlobalScale\IConfig
|
||||
*/
|
||||
public function getGlobalScaleConfig() {
|
||||
return $this->query(IConfig::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \OCP\Federation\ICloudFederationProviderManager
|
||||
*/
|
||||
public function getCloudFederationProviderManager() {
|
||||
return $this->query(ICloudFederationProviderManager::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \OCP\Remote\Api\IApiFactory
|
||||
*/
|
||||
|
@ -1980,6 +2011,13 @@ class Server extends ServerContainer implements IServerContainer {
|
|||
return $this->query(IApiFactory::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \OCP\Federation\ICloudFederationFactory
|
||||
*/
|
||||
public function getCloudFederationFactory() {
|
||||
return $this->query(ICloudFederationFactory::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \OCP\Remote\IInstanceFactory
|
||||
*/
|
||||
|
|
|
@ -29,10 +29,10 @@
|
|||
namespace OC\Share20;
|
||||
|
||||
use OC\CapabilitiesManager;
|
||||
use OC\GlobalScale\Config;
|
||||
use OCA\FederatedFileSharing\AddressHandler;
|
||||
use OCA\FederatedFileSharing\FederatedShareProvider;
|
||||
use OCA\FederatedFileSharing\Notifications;
|
||||
use OCA\FederatedFileSharing\OCM\CloudFederationProvider;
|
||||
use OCA\FederatedFileSharing\TokenHandler;
|
||||
use OCA\ShareByMail\Settings\SettingsManager;
|
||||
use OCA\ShareByMail\ShareByMailProvider;
|
||||
|
@ -133,7 +133,7 @@ class ProviderFactory implements IProviderFactory {
|
|||
$this->serverContainer->getConfig(),
|
||||
$this->serverContainer->getUserManager(),
|
||||
$this->serverContainer->getCloudIdManager(),
|
||||
$this->serverContainer->query(Config::class)
|
||||
$this->serverContainer->getGlobalScaleConfig()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Bjoern Schiessle <bjoern@schiessle.org>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCP\Federation\Exceptions;
|
||||
|
||||
use OC\HintException;
|
||||
|
||||
class ProviderAlreadyExistsException extends HintException {
|
||||
|
||||
/**
|
||||
* ProviderAlreadyExistsException constructor.
|
||||
*
|
||||
* @param string $newProviderId cloud federation provider ID of the new provider
|
||||
* @param string $existingProviderName name of cloud federation provider which already use the same ID
|
||||
*/
|
||||
public function __construct($newProviderId, $existingProviderName) {
|
||||
$l = \OC::$server->getL10N('federation');
|
||||
$message = 'Id "' . $newProviderId . '" already used by cloud federation provider "' . $existingProviderName . '"';
|
||||
$hint = $l->t('Id "%s" already used by cloud federation provider "%s"', [$newProviderId, $existingProviderName]);
|
||||
parent::__construct($message, $hint);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Bjoern Schiessle <bjoern@schiessle.org>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCP\Federation\Exceptions;
|
||||
|
||||
use OC\HintException;
|
||||
|
||||
class ProviderCouldNotAddShareException extends HintException {
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Bjoern Schiessle <bjoern@schiessle.org>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCP\Federation\Exceptions;
|
||||
|
||||
use OC\HintException;
|
||||
|
||||
class ProviderDoesNotExistsException extends HintException {
|
||||
|
||||
/**
|
||||
* ProviderDoesNotExistsException constructor.
|
||||
*
|
||||
* @param string $providerId cloud federation provider ID
|
||||
*/
|
||||
public function __construct($providerId) {
|
||||
$l = \OC::$server->getL10N('federation');
|
||||
$message = 'Cloud Federation Provider with ID: "' . $providerId . '" does not exist.';
|
||||
$hint = $l->t('Cloud Federation Provider with ID: "%s" does not exist.', [$providerId]);
|
||||
parent::__construct($message, $hint);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Bjoern Schiessle <bjoern@schiessle.org>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCP\Federation\Exceptions;
|
||||
|
||||
|
||||
use OC\HintException;
|
||||
|
||||
class ShareNotFoundException extends HintException {
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Bjoern Schiessle <bjoern@schiessle.org>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCP\Federation;
|
||||
|
||||
interface ICloudFederationFactory {
|
||||
|
||||
/**
|
||||
* get a CloudFederationShare Object to prepare a share you want to send
|
||||
*
|
||||
* @param string $shareWith
|
||||
* @param string $name resource name (e.g. document.odt)
|
||||
* @param string $description share description (optional)
|
||||
* @param string $providerId resource UID on the provider side
|
||||
* @param string $owner provider specific UID of the user who owns the resource
|
||||
* @param string $ownerDisplayName display name of the user who shared the item
|
||||
* @param string $sharedBy provider specific UID of the user who shared the resource
|
||||
* @param $sharedByDisplayName display name of the user who shared the resource
|
||||
* @param array $protocol (e,.g. ['name' => 'webdav', 'options' => ['username' => 'john', 'permissions' => 31]])
|
||||
* @param string $shareType ('group' or 'user' share)
|
||||
* @param $resourceType ('file', 'calendar',...)
|
||||
* @return ICloudFederationShare
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $protocol, $shareType, $resourceType);
|
||||
|
||||
/**
|
||||
* get a Cloud FederationNotification object to prepare a notification you
|
||||
* want to send
|
||||
*
|
||||
* @return ICloudFederationNotification
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getCloudFederationNotification();
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Bjoern Schiessle <bjoern@schiessle.org>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCP\Federation;
|
||||
|
||||
interface ICloudFederationNotification {
|
||||
|
||||
/**
|
||||
* add a message to the notification
|
||||
*
|
||||
* @param string $identifier
|
||||
* @param string $message
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function setMessage($identifier, $message);
|
||||
|
||||
/**
|
||||
* get JSON encoded Message, ready to send out
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getMessage();
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Bjoern Schiessle <bjoern@schiessle.org>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCP\Federation;
|
||||
|
||||
use OCP\Federation\Exceptions\ShareNotFoundException;
|
||||
|
||||
/**
|
||||
* Interface ICloudFederationProvider
|
||||
*
|
||||
* Enable apps to create their own cloud federation provider
|
||||
*
|
||||
* @since 14.0.0
|
||||
*
|
||||
* @package OCP\Federation
|
||||
*/
|
||||
|
||||
interface ICloudFederationProvider {
|
||||
|
||||
/**
|
||||
* ICloudFederationProvider constructor.
|
||||
*
|
||||
* @param $shareType define the share type, handled by this provider
|
||||
*/
|
||||
public function __construct($shareType);
|
||||
|
||||
/**
|
||||
* get the name of the share type, handled by this provider
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getShareType();
|
||||
|
||||
/**
|
||||
* send new share to another server
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function sendShare();
|
||||
|
||||
/**
|
||||
* share received from another server
|
||||
*
|
||||
* @param ICloudFederationShare $share
|
||||
* @return string provider specific unique ID of the share
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function shareReceived(ICloudFederationShare $share);
|
||||
|
||||
/**
|
||||
* notification received from another server
|
||||
*
|
||||
* @param string $id unique ID of a already existing share
|
||||
* @param array $notification provider specific notification
|
||||
*
|
||||
* @throws ShareNotFoundException
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function notificationReceived($id, $notification);
|
||||
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Bjoern Schiessle <bjoern@schiessle.org>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCP\Federation;
|
||||
|
||||
/**
|
||||
* Class ICloudFederationProviderManager
|
||||
*
|
||||
* Manage cloud federation providers
|
||||
*
|
||||
* @since 14.0.0
|
||||
*
|
||||
* @package OCP\Federation
|
||||
*/
|
||||
interface ICloudFederationProviderManager {
|
||||
|
||||
/**
|
||||
* Registers an callback function which must return an cloud federation provider
|
||||
*
|
||||
* @param string $shareType which share type does the provider handles
|
||||
* @param string $displayName user facing name of the federated share provider
|
||||
* @param callable $callback
|
||||
* @throws Exceptions\ProviderAlreadyExistsException
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function addCloudFederationProvider($shareType, $displayName, callable $callback);
|
||||
|
||||
/**
|
||||
* remove cloud federation provider
|
||||
*
|
||||
* @param string $shareType
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function removeCloudFederationProvider($shareType);
|
||||
|
||||
/**
|
||||
* get a list of all cloudFederationProviders
|
||||
*
|
||||
* @return array [id => ['id' => $id, 'displayName' => $displayName, 'callback' => callback]]
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getAllCloudFederationProviders();
|
||||
|
||||
/**
|
||||
* get a specific cloud federation provider
|
||||
*
|
||||
* @param string $shareType
|
||||
* @return ICloudFederationProvider
|
||||
* @throws Exceptions\ProviderDoesNotExistsException;
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getCloudFederationProvider($shareType);
|
||||
|
||||
/**
|
||||
* send federated share
|
||||
*
|
||||
* @param ICloudFederationShare $share
|
||||
* @return mixed
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function sendShare(ICloudFederationShare $share);
|
||||
|
||||
/**
|
||||
* send notification about existing share
|
||||
*
|
||||
* @param ICloudFederationNotification $notification
|
||||
* @return mixed
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function sendNotification(ICloudFederationNotification $notification);
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,233 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Bjoern Schiessle <bjoern@schiessle.org>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCP\Federation;
|
||||
|
||||
interface ICloudFederationShare {
|
||||
|
||||
/**
|
||||
* set uid of the recipient
|
||||
*
|
||||
* @param string $user
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function setShareWith($user);
|
||||
|
||||
/**
|
||||
* set resource name (e.g. file, calendar, contact,...)
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function setResourceName($name);
|
||||
|
||||
/**
|
||||
* set resource type (e.g. file, calendar, contact,...)
|
||||
*
|
||||
* @param string $resourceType
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function setResourceType($resourceType);
|
||||
|
||||
/**
|
||||
* set resource description (optional)
|
||||
*
|
||||
* @param string $description
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function setDescription($description);
|
||||
|
||||
/**
|
||||
* set provider ID (e.g. file ID)
|
||||
*
|
||||
* @param string $providerId
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function setProviderId($providerId);
|
||||
|
||||
/**
|
||||
* set owner UID
|
||||
*
|
||||
* @param string $owner
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function setOwner($owner);
|
||||
|
||||
/**
|
||||
* set owner display name
|
||||
*
|
||||
* @param string $ownerDisplayName
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function setOwnerDisplayName($ownerDisplayName);
|
||||
|
||||
/**
|
||||
* set UID of the user who sends the share
|
||||
*
|
||||
* @param string $sharedBy
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function setSharedBy($sharedBy);
|
||||
|
||||
/**
|
||||
* set display name of the user who sends the share
|
||||
*
|
||||
* @param $sharedByDisplayName
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function setSharedByDisplayName($sharedByDisplayName);
|
||||
|
||||
/**
|
||||
* set protocol specification
|
||||
*
|
||||
* @param array $protocol
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function setProtocol(array $protocol);
|
||||
|
||||
/**
|
||||
* share type (group or user)
|
||||
*
|
||||
* @param string $shareType
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function setShareType($shareType);
|
||||
|
||||
/**
|
||||
* get JSON encoded share, ready to send out
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getShare();
|
||||
|
||||
/**
|
||||
* get uid of the recipient
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getShareWith();
|
||||
|
||||
/**
|
||||
* get resource name (e.g. file, calendar, contact,...)
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getResourceName();
|
||||
|
||||
/**
|
||||
* get resource type (e.g. file, calendar, contact,...)
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getResourceType();
|
||||
|
||||
/**
|
||||
* get resource description (optional)
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getDescription();
|
||||
|
||||
/**
|
||||
* get provider ID (e.g. file ID)
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getProviderId();
|
||||
|
||||
/**
|
||||
* get owner UID
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getOwner();
|
||||
|
||||
/**
|
||||
* get owner display name
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getOwnerDisplayName();
|
||||
|
||||
/**
|
||||
* get UID of the user who sends the share
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getSharedBy();
|
||||
|
||||
/**
|
||||
* get display name of the user who sends the share
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getSharedByDisplayName();
|
||||
|
||||
/**
|
||||
* get share type (group or user)
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getShareType();
|
||||
|
||||
/**
|
||||
* get protocol specification
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getProtocol();
|
||||
|
||||
}
|
|
@ -45,6 +45,8 @@
|
|||
// This means that they should be used by apps instead of the internal ownCloud classes
|
||||
namespace OCP;
|
||||
use OCP\Log\ILogFactory;
|
||||
use OCP\Federation\ICloudFederationFactory;
|
||||
use OCP\Federation\ICloudFederationProviderManager;
|
||||
use OCP\Security\IContentSecurityPolicyManager;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
|
@ -553,6 +555,23 @@ interface IServerContainer extends IContainer {
|
|||
*/
|
||||
public function getCloudIdManager();
|
||||
|
||||
/**
|
||||
* @return \OCP\GlobalScale\IConfig
|
||||
*/
|
||||
public function getGlobalScaleConfig();
|
||||
|
||||
/**
|
||||
* @return ICloudFederationFactory
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getCloudFederationFactory();
|
||||
|
||||
/**
|
||||
* @return ICloudFederationProviderManager
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getCloudFederationProviderManager();
|
||||
|
||||
/**
|
||||
* @return \OCP\Remote\Api\IApiFactory
|
||||
* @since 13.0.0
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Bjoern Schiessle <bjoern@schiessle.org>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
require_once __DIR__ . '/../lib/base.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$server = \OC::$server;
|
||||
|
||||
$isEnabled = $server->getAppManager()->isEnabledForUser('cloud_federation_api');
|
||||
|
||||
if ($isEnabled) {
|
||||
$capabilities = new OCA\CloudFederationAPI\Capabilities($server->getURLGenerator());
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($capabilities->getCapabilities()['ocm']);
|
||||
} else {
|
||||
header($_SERVER["SERVER_PROTOCOL"]." 501 Not Implemented", true, 501);
|
||||
exit("501 Not Implemented");
|
||||
}
|
||||
|
Loading…
Reference in New Issue