diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2018-05-28 17:13:19 +0200 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2018-07-02 11:29:28 +0200 |
commit | bbce8c3ea1c73726f233961fe7bdb16b8a08bb67 (patch) | |
tree | e3f345e7e2e6f5d21947013331af1f83593fb20a /lib/private/Federation | |
parent | daba042d269bfd701c78e014c0ad7794975d2133 (diff) | |
download | nextcloud-server-bbce8c3ea1c73726f233961fe7bdb16b8a08bb67.tar.gz nextcloud-server-bbce8c3ea1c73726f233961fe7bdb16b8a08bb67.zip |
adjust to latest api version
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'lib/private/Federation')
4 files changed, 41 insertions, 22 deletions
diff --git a/lib/private/Federation/CloudFederationFactory.php b/lib/private/Federation/CloudFederationFactory.php index 4f42eb50bca..11566dd44a9 100644 --- a/lib/private/Federation/CloudFederationFactory.php +++ b/lib/private/Federation/CloudFederationFactory.php @@ -37,16 +37,16 @@ class CloudFederationFactory implements ICloudFederationFactory { * @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 $sharedByDisplayName display name of the user who shared the resource + * @param string $sharedSecret used to authenticate requests across servers * @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); + public function getCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $sharedSecret, $shareType, $resourceType) { + return new CloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $shareType, $resourceType, $sharedSecret); } /** diff --git a/lib/private/Federation/CloudFederationNotification.php b/lib/private/Federation/CloudFederationNotification.php index 356c47968f5..fec69174a2f 100644 --- a/lib/private/Federation/CloudFederationNotification.php +++ b/lib/private/Federation/CloudFederationNotification.php @@ -32,16 +32,19 @@ class CloudFederationNotification implements ICloudFederationNotification { * * @param string $notificationType (e.g. SHARE_ACCEPTED) * @param string $resourceType (e.g. file, calendar, contact,...) - * @param array $message + * @param string $providerId id of the share + * @param array $notification payload of the notification * * @since 14.0.0 */ - public function setMessage($notificationType, $resourceType, array $message) { + public function setMessage($notificationType, $resourceType, $providerId, array $notification) { $this->message = [ 'notificationType' => $notificationType, 'resourceType' => $resourceType, - 'message' => $message, + 'providerId' => $providerId, + 'notification' => $notification, ]; + } /** diff --git a/lib/private/Federation/CloudFederationProviderManager.php b/lib/private/Federation/CloudFederationProviderManager.php index b0f5c58f51d..77866795c30 100644 --- a/lib/private/Federation/CloudFederationProviderManager.php +++ b/lib/private/Federation/CloudFederationProviderManager.php @@ -57,7 +57,7 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager /** @var ILogger */ private $logger; - private $supportedAPIVersion = '2.0-draft'; + private $supportedAPIVersion = '1.0-proposal1'; /** * CloudFederationProviderManager constructor. @@ -131,7 +131,8 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager } public function sendShare(ICloudFederationShare $share) { - $ocmEndPoint = $this->getOCMEndPoint($share->getShareWith()); + $cloudID = $this->cloudIdManager->resolveCloudId($share->getShareWith()); + $ocmEndPoint = $this->getOCMEndPoint($cloudID->getRemote()); if (empty($ocmEndPoint)) { return false; @@ -203,14 +204,13 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager /** * check if server supports the new OCM api and ask for the correct end-point * - * @param string $recipient full federated cloud ID of the recipient of a share + * @param string $url full base URL of the cloud server * @return string */ - protected function getOCMEndPoint($recipient) { - $cloudId = $this->cloudIdManager->resolveCloudId($recipient); + protected function getOCMEndPoint($url) { $client = $this->httpClientService->newClient(); try { - $response = $client->get($cloudId->getRemote() . '/ocm-provider/', ['timeout' => 10, 'connect_timeout' => 10]); + $response = $client->get($url . '/ocm-provider/', ['timeout' => 10, 'connect_timeout' => 10]); } catch (\Exception $e) { return ''; } @@ -218,10 +218,10 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager $result = $response->getBody(); $result = json_decode($result, true); - $supportedVersion = isset($result['api-version']) && $result['api-version'] === $this->supportedAPIVersion; + $supportedVersion = isset($result['apiVersion']) && $result['apiVersion'] === $this->supportedAPIVersion; - if (isset($result['end-point']) && $supportedVersion) { - return $result['end-point']; + if (isset($result['endPoint']) && $supportedVersion) { + return $result['endPoint']; } return ''; diff --git a/lib/private/Federation/CloudFederationShare.php b/lib/private/Federation/CloudFederationShare.php index 5bc172ab6b6..d26073be822 100644 --- a/lib/private/Federation/CloudFederationShare.php +++ b/lib/private/Federation/CloudFederationShare.php @@ -50,10 +50,9 @@ class CloudFederationShare implements ICloudFederationShare { * @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',...) - * + * @param string $resourceType ('file', 'calendar',...) + * @param string $sharedSecret */ public function __construct($shareWith = '', $name = '', @@ -63,9 +62,9 @@ class CloudFederationShare implements ICloudFederationShare { $ownerDisplayName = '', $sharedBy = '', $sharedByDisplayName = '', - $protocol = [], $shareType = '', - $resourceType = '' + $resourceType = '', + $sharedSecret = '' ) { $this->setShareWith($shareWith); $this->setResourceName($name); @@ -75,7 +74,13 @@ class CloudFederationShare implements ICloudFederationShare { $this->setOwnerDisplayName($ownerDisplayName); $this->setSharedBy($sharedBy); $this->setSharedByDisplayName($sharedByDisplayName); - $this->setProtocol($protocol); + $this->setProtocol([ + 'name' => 'webdav', + 'options' => [ + 'sharedSecret' => $sharedSecret, + 'permissions' => '{http://open-collaboration-services.org/ns}share-permissions' + ] + ]); $this->setShareType($shareType); $this->setResourceType($resourceType); @@ -324,6 +329,17 @@ class CloudFederationShare implements ICloudFederationShare { } /** + * get share Secret + * + * @return string + * + * @since 14.0.0 + */ + public function getShareSecret() { + return $this->share['protocol']['options']['sharedSecret']; + } + + /** * get protocol specification * * @return array |