summaryrefslogtreecommitdiffstats
path: root/lib/public/Federation
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2018-04-18 16:05:11 +0200
committerBjoern Schiessle <bjoern@schiessle.org>2018-07-02 11:29:27 +0200
commit5cfe20675dfa1f895af47b4a8c93cf479d53b200 (patch)
tree66e0631e2f8791168797a4a7957a420e4ac429cf /lib/public/Federation
parent22bb834c48ad31add1d4bebc17de98d6e7d5d226 (diff)
downloadnextcloud-server-5cfe20675dfa1f895af47b4a8c93cf479d53b200.tar.gz
nextcloud-server-5cfe20675dfa1f895af47b4a8c93cf479d53b200.zip
start implementing federated sharing 2.0
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'lib/public/Federation')
-rw-r--r--lib/public/Federation/Exceptions/ProviderAlreadyExistsException.php41
-rw-r--r--lib/public/Federation/Exceptions/ProviderCouldNotAddShareException.php28
-rw-r--r--lib/public/Federation/Exceptions/ProviderDoesNotExistsException.php40
-rw-r--r--lib/public/Federation/Exceptions/ShareNotFoundException.php29
-rw-r--r--lib/public/Federation/ICloudFederationFactory.php55
-rw-r--r--lib/public/Federation/ICloudFederationNotification.php44
-rw-r--r--lib/public/Federation/ICloudFederationProvider.php81
-rw-r--r--lib/public/Federation/ICloudFederationProviderManager.php97
-rw-r--r--lib/public/Federation/ICloudFederationShare.php233
9 files changed, 648 insertions, 0 deletions
diff --git a/lib/public/Federation/Exceptions/ProviderAlreadyExistsException.php b/lib/public/Federation/Exceptions/ProviderAlreadyExistsException.php
new file mode 100644
index 00000000000..f053a02fbea
--- /dev/null
+++ b/lib/public/Federation/Exceptions/ProviderAlreadyExistsException.php
@@ -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);
+ }
+
+}
diff --git a/lib/public/Federation/Exceptions/ProviderCouldNotAddShareException.php b/lib/public/Federation/Exceptions/ProviderCouldNotAddShareException.php
new file mode 100644
index 00000000000..b608437aa3c
--- /dev/null
+++ b/lib/public/Federation/Exceptions/ProviderCouldNotAddShareException.php
@@ -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 {
+
+}
diff --git a/lib/public/Federation/Exceptions/ProviderDoesNotExistsException.php b/lib/public/Federation/Exceptions/ProviderDoesNotExistsException.php
new file mode 100644
index 00000000000..8f760d6abf4
--- /dev/null
+++ b/lib/public/Federation/Exceptions/ProviderDoesNotExistsException.php
@@ -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);
+ }
+
+}
diff --git a/lib/public/Federation/Exceptions/ShareNotFoundException.php b/lib/public/Federation/Exceptions/ShareNotFoundException.php
new file mode 100644
index 00000000000..6655d5b4430
--- /dev/null
+++ b/lib/public/Federation/Exceptions/ShareNotFoundException.php
@@ -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 {
+
+}
diff --git a/lib/public/Federation/ICloudFederationFactory.php b/lib/public/Federation/ICloudFederationFactory.php
new file mode 100644
index 00000000000..e33608bcab0
--- /dev/null
+++ b/lib/public/Federation/ICloudFederationFactory.php
@@ -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();
+}
diff --git a/lib/public/Federation/ICloudFederationNotification.php b/lib/public/Federation/ICloudFederationNotification.php
new file mode 100644
index 00000000000..5db93ef0a8c
--- /dev/null
+++ b/lib/public/Federation/ICloudFederationNotification.php
@@ -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();
+}
diff --git a/lib/public/Federation/ICloudFederationProvider.php b/lib/public/Federation/ICloudFederationProvider.php
new file mode 100644
index 00000000000..4c11fc20397
--- /dev/null
+++ b/lib/public/Federation/ICloudFederationProvider.php
@@ -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);
+
+}
diff --git a/lib/public/Federation/ICloudFederationProviderManager.php b/lib/public/Federation/ICloudFederationProviderManager.php
new file mode 100644
index 00000000000..c9789949245
--- /dev/null
+++ b/lib/public/Federation/ICloudFederationProviderManager.php
@@ -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);
+
+
+}
diff --git a/lib/public/Federation/ICloudFederationShare.php b/lib/public/Federation/ICloudFederationShare.php
new file mode 100644
index 00000000000..b116da0fb54
--- /dev/null
+++ b/lib/public/Federation/ICloudFederationShare.php
@@ -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();
+
+}