Browse Source
start implementing federated sharing 2.0
start implementing federated sharing 2.0
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>pull/9345/head
No known key found for this signature in database
GPG Key ID: 2378A753E2BF04F6
25 changed files with 1461 additions and 3 deletions
-
1apps/federatedfilesharing/composer/composer/autoload_classmap.php
-
1apps/federatedfilesharing/composer/composer/autoload_static.php
-
8apps/federatedfilesharing/lib/AppInfo/Application.php
-
10apps/federatedfilesharing/lib/FederatedShareProvider.php
-
83apps/federatedfilesharing/lib/ocm/CloudFederationProvider.php
-
28core/routes.php
-
13lib/composer/composer/autoload_classmap.php
-
13lib/composer/composer/autoload_static.php
-
63lib/private/Federation/CloudFederationFactory.php
-
52lib/private/Federation/CloudFederationNotification.php
-
108lib/private/Federation/CloudFederationProviderManager.php
-
336lib/private/Federation/CloudFederationShare.php
-
38lib/private/Server.php
-
4lib/private/Share20/ProviderFactory.php
-
41lib/public/Federation/Exceptions/ProviderAlreadyExistsException.php
-
28lib/public/Federation/Exceptions/ProviderCouldNotAddShareException.php
-
40lib/public/Federation/Exceptions/ProviderDoesNotExistsException.php
-
29lib/public/Federation/Exceptions/ShareNotFoundException.php
-
55lib/public/Federation/ICloudFederationFactory.php
-
44lib/public/Federation/ICloudFederationNotification.php
-
81lib/public/Federation/ICloudFederationProvider.php
-
97lib/public/Federation/ICloudFederationProviderManager.php
-
233lib/public/Federation/ICloudFederationShare.php
-
19lib/public/IServerContainer.php
-
39ocm-provider/index.php
@ -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.
|
|||
} |
|||
} |
|||
@ -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']; |
|||
} |
|||
} |
|||
@ -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(); |
|||
|
|||
} |
|||
@ -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"); |
|||
} |
|||
|
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue