From 882ac47c31f14c494d5a6f11e868dde2abe10589 Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Wed, 14 Aug 2024 12:16:32 +0200 Subject: [PATCH] feat(CloudfederationApi): update addShare to support OCM v1.1.0 This patchset also updates ICloudFederationFactory and ICloudFedarationShare to accomdate the new format of a share. This should be backwards compatible. Signed-off-by: Micke Nordin --- .../Controller/RequestHandlerController.php | 210 +++++++++++++---- .../Federation/CloudFederationFactory.php | 38 ++- .../Federation/CloudFederationShare.php | 219 +++++++++++++----- lib/private/OCM/Model/OCMProvider.php | 3 +- .../Federation/ICloudFederationFactory.php | 21 ++ .../Federation/ICloudFederationShare.php | 39 ++++ lib/public/OCM/IOCMProvider.php | 2 +- 7 files changed, 428 insertions(+), 104 deletions(-) diff --git a/apps/cloud_federation_api/lib/Controller/RequestHandlerController.php b/apps/cloud_federation_api/lib/Controller/RequestHandlerController.php index 239dc82a184f4..e00dca4228ed3 100644 --- a/apps/cloud_federation_api/lib/Controller/RequestHandlerController.php +++ b/apps/cloud_federation_api/lib/Controller/RequestHandlerController.php @@ -1,20 +1,21 @@ } $protocol e,.g. ['name' => 'webdav', 'options' => ['username' => 'john', 'permissions' => 31]] * @param string $shareType 'group' or 'user' share * @param string $resourceType 'file', 'calendar',... @@ -82,19 +84,20 @@ public function __construct( #[PublicPage] #[NoCSRFRequired] #[BruteForceProtection(action: 'receiveFederatedShare')] - public function addShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $protocol, $shareType, $resourceType) { + public function addShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sender, $senderDisplayName, $protocol, $shareType, $resourceType, $expiration): JSONResponse + { + $new_protocol = $this->normalizeProtocol($protocol); + $protocol_valid = $this->validateProtocol($new_protocol); // check if all required parameters are set - if ($shareWith === null || + if ( + $shareWith === null || $name === null || $providerId === null || $owner === null || + $sender === null || $resourceType === null || $shareType === null || - !is_array($protocol) || - !isset($protocol['name']) || - !isset($protocol['options']) || - !is_array($protocol['options']) || - !isset($protocol['options']['sharedSecret']) + !$protocol_valid ) { return new JSONResponse( [ @@ -113,11 +116,10 @@ public function addShare($shareWith, $name, $description, $providerId, $owner, $ ); } - $cloudId = $this->cloudIdManager->resolveCloudId($shareWith); - $shareWith = $cloudId->getUser(); - if ($shareType === 'user') { $shareWith = $this->mapUid($shareWith); + $cloudId = $this->cloudIdManager->resolveCloudId($shareWith); + $shareWith = $cloudId->getUser(); if (!$this->userManager->userExists($shareWith)) { $response = new JSONResponse( @@ -148,20 +150,15 @@ public function addShare($shareWith, $name, $description, $providerId, $owner, $ // if no explicit display name is given, we use the uid as display name $ownerDisplayName = $ownerDisplayName === null ? $owner : $ownerDisplayName; - $sharedByDisplayName = $sharedByDisplayName === null ? $sharedBy : $sharedByDisplayName; - - // sharedBy* parameter is optional, if nothing is set we assume that it is the same user as the owner - if ($sharedBy === null) { - $sharedBy = $owner; - $sharedByDisplayName = $ownerDisplayName; - } + $senderDisplayName = $senderDisplayName === null ? $sender : $senderDisplayName; try { $provider = $this->cloudFederationProviderManager->getCloudFederationProvider($resourceType); - $share = $this->factory->getCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, '', $shareType, $resourceType); - $share->setProtocol($protocol); + + $sharedSecret = $this->extractSharedSecret($new_protocol); + $share = $this->factory->createCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sender, $senderDisplayName, $sharedSecret, $shareType, $resourceType, $expiration, $new_protocol); $provider->shareReceived($share); - } catch (ProviderDoesNotExistsException|ProviderCouldNotAddShareException $e) { + } catch (ProviderDoesNotExistsException | ProviderCouldNotAddShareException $e) { return new JSONResponse( ['message' => $e->getMessage()], Http::STATUS_NOT_IMPLEMENTED @@ -185,7 +182,8 @@ public function addShare($shareWith, $name, $description, $providerId, $owner, $ return new JSONResponse( ['recipientDisplayName' => $recipientDisplayName], - Http::STATUS_CREATED); + Http::STATUS_CREATED + ); } /** @@ -212,37 +210,35 @@ public function addShare($shareWith, $name, $description, $providerId, $owner, $ #[PublicPage] #[NoCSRFRequired] #[BruteForceProtection(action: 'inviteAccepted')] - public function inviteAccepted(string $recipientProvider, string $token, string $userId, string $email, string $name): JSONResponse { + public function inviteAccepted(string $recipientProvider, string $token, string $userId, string $email, string $name): JSONResponse + { $this->logger->debug('Invite accepted for ' . $userId . ' with token ' . $token . ' and email ' . $email . ' and name ' . $name); $found_for_this_user = false; foreach ($this->ocConfig->getAppKeys($this->appName) as $key) { - if(str_starts_with($key, $token) ){ - $found_for_this_user = $this->getAppValue($this->appName, $token . '_remote_id') === $userId; + if (str_starts_with($key, $token)) { + $found_for_this_user = $this->ocConfig->getAppValue($this->appName, $token . '_remote_id') === $userId; } } - - if (!$found_for_this_user) { $response = ['message' => 'Invalid or non existing token', 'error' => true]; $status = Http::STATUS_BAD_REQUEST; - return new JSONResponse($response,$status); + return new JSONResponse($response, $status); } - if(!$this->trustedServers->isTrustedServer($recipientProvider)) { + if (!$this->trustedServers->isTrustedServer($recipientProvider)) { $response = ['message' => 'Remote server not trusted', 'error' => true]; $status = Http::STATUS_FORBIDDEN; - return new JSONResponse($response,$status); + return new JSONResponse($response, $status); } // Note: Not implementing 404 Invitation token does not exist, instead using 400 - if ($this->ocConfig->getAppValue($this->appName, $token . '_accepted') === true ) { + if ($this->ocConfig->getAppValue($this->appName, $token . '_accepted') === true) { $response = ['message' => 'Invite already accepted', 'error' => true]; $status = Http::STATUS_CONFLICT; - return new JSONResponse($response,$status); + return new JSONResponse($response, $status); } - $localId = $this->ocConfig->getAppValue($this->appName, $token . '_local_id'); $response = ['usedID' => $localId, 'email' => $email, 'name' => $name]; $status = Http::STATUS_OK; @@ -252,7 +248,7 @@ public function inviteAccepted(string $recipientProvider, string $token, string // $this->ocConfig->setAppValue($this->appName, $token . '_local_id', $localId); // $this->ocConfig->setAppValue($this->appName, $token . '_remote_id', $remoteId); - return new JSONResponse($response,$status); + return new JSONResponse($response, $status); } /** @@ -272,9 +268,11 @@ public function inviteAccepted(string $recipientProvider, string $token, string #[NoCSRFRequired] #[PublicPage] #[BruteForceProtection(action: 'receiveFederatedShareNotification')] - public function receiveNotification($notificationType, $resourceType, $providerId, ?array $notification) { + public function receiveNotification($notificationType, $resourceType, $providerId, ?array $notification): JSONResponse + { // check if all required parameters are set - if ($notificationType === null || + if ( + $notificationType === null || $resourceType === null || $providerId === null || !is_array($notification) @@ -339,7 +337,8 @@ public function receiveNotification($notificationType, $resourceType, $providerI * @param string $uid * @return string mixed */ - private function mapUid($uid) { + private function mapUid($uid): string + { // FIXME this should be a method in the user management instead $this->logger->debug('shareWith before, ' . $uid, ['app' => $this->appName]); \OCP\Util::emitHook( @@ -351,4 +350,129 @@ private function mapUid($uid) { return $uid; } + + /** + * Normalize protocol to the new format + * this way we can speak OCM 1.1.0 even with + * older implementations + * + * @param array $protocol + * @return array + */ + private function normalizeProtocol($protocol): array + { + if (array_key_exists('name', $protocol)) { + return ['singleProtocolLegacy' => $protocol]; + } + + return $protocol; + } + + /** + * Validate the protocol + * For 1.0.0 this was: + * !is_array($protocol) || + * !isset($protocol['name']) || + * !isset($protocol['options']) || + * !is_array($protocol['options']) || + * !isset($protocol['options']['sharedSecret']) + * + * Now we chek all the things: + * https://cs3org.github.io/OCM-API/docs.html?branch=v1.1.0&repo=OCM-API&user=cs3org#/paths/~1shares/post + * @param array $protocol + * @return bool + */ + private function validateProtocol($protocol): bool + { + if (!is_array($protocol)) { + return false; + } + + if (array_key_exists('singleProtocolLegacy', $protocol)) { + $name = $protocol['singleProtocolLegacy']['name']; + if (!isset($name) || $name !== 'webdav') { + return false; + } + $options = $protocol['singleProtocolLegacy']['options']; + if (!isset($options) || !is_array($options) || !isset($options['sharedSecret'])) { + return false; + } + return true; + } + if (array_key_exists('singleProtocolNew', $protocol)) { + $name = $protocol['singleProtocolNew']['name']; + if (!isset($name) || $name !== 'webdav') { + return false; + } + $options = $protocol['singleProtocolNew']['options']; + if (!isset($options) || !is_array($options) || !isset($options['sharedSecret'])) { + return false; + } + $webdav = $protocol['singleProtocolNew']['webdav']; + if ( + !isset($webdav) || + !is_array($webdav) || + !isset($webdav['sharedSecret']) || + !isset($webdav['permissions']) || + !isset($webdav['uri']) + ) { + return false; + } + return true; + } + if (array_key_exists('multipleProtocols', $protocol)) { + $name = $protocol['multipleProtocols']['name']; + if (!isset($name) || $name !== 'multi') { + return false; + } + $webdav = $protocol['multipleProtocols']['webdav']; + $webapp = $protocol['multipleProtocols']['webapp']; + $datatx = $protocol['multipleProtocols']['datatx']; + if ( + !isset($webdav) || + !isset($webapp) || + !isset($datatx) + ) { + return false; + } + if (isset($webdav)) { + if (!array_key_exists('uri', $webdav) || !array_key_exists('permissions', $webdav)) { + return false; + } + } + if (isset($webapp)) { + if (!array_key_exists('uriTemplate', $webapp) || !array_key_exists('viewMode', $webapp)) { + return false; + } + } + if (isset($datatx)) { + if (!array_key_exists('srcUri', $datatx) || !array_key_exists('size', $datatx)) { + return false; + } + } + return true; + } + return false; + } + + /** + * Extracts the shared secret from the protocol array. + * @param array $protocol + * @return string + */ + private function extractSharedSecret(array $protocol): string + { + $sharedSecret = ''; + if (array_key_exists('singleProtocolLegacy', $protocol)) { + $sharedSecret = $protocol['singleProtocolLegacy']['options']['sharedSecret']; + } elseif (array_key_exists('singleProtocolNew', $protocol)) { + $sharedSecret = $protocol['singleProtocolNew']['options']['sharedSecret']; + } elseif (array_key_exists('multipleProtocols', $protocol)) { + $options = $protocol['multipleProtocols']['options']; + if (isset($options)) { + $sharedSecret = $options['sharedSecret']; + } + } + return $sharedSecret; + } } diff --git a/lib/private/Federation/CloudFederationFactory.php b/lib/private/Federation/CloudFederationFactory.php index f5f25d14ea143..bf1d5ef325897 100644 --- a/lib/private/Federation/CloudFederationFactory.php +++ b/lib/private/Federation/CloudFederationFactory.php @@ -25,11 +25,47 @@ class CloudFederationFactory implements ICloudFederationFactory { * @param string $shareType ('group' or 'user' share) * @param $resourceType ('file', 'calendar',...) * @return ICloudFederationShare + * @deprecated 30.0.0 use createCloudFederationShare instead * * @since 14.0.0 */ 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); + $permissions = '{http://open-cloud-mesh.org/ns}share-permissions'; + $protocol = array( + 'singleProtocolLegacy' => [ + 'name' => 'webdav', + 'options' => [ + 'sharedSecret' => $sharedSecret, + 'permissions' => $permissions, + ], + ] + ); + $expiration = NULL; + return $this->createCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $shareType, $resourceType, $sharedSecret, $expiration, $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 $senderDisplayName 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 string $resourceType ('file', 'calendar',...) + * @param int|NULL $expiration (optional) + * @param array $protocol + * @return ICloudFederationShare + * + * @since 30.0.0 + */ + public function createCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $sharedSecret, $shareType, $resourceType, $expiration, $protocol) { + return new CloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $shareType, $resourceType, $sharedSecret, $expiration, $protocol); + } /** diff --git a/lib/private/Federation/CloudFederationShare.php b/lib/private/Federation/CloudFederationShare.php index aa86905f234c8..f70edef65aa43 100644 --- a/lib/private/Federation/CloudFederationShare.php +++ b/lib/private/Federation/CloudFederationShare.php @@ -1,14 +1,17 @@ '', 'shareType' => '', @@ -18,54 +21,56 @@ class CloudFederationShare implements ICloudFederationShare { 'providerId' => '', 'owner' => '', 'ownerDisplayName' => '', - 'sharedBy' => '', - 'sharedByDisplayName' => '', - 'protocol' => [] + 'sender' => '', + 'senderDisplayName' => '', + 'expiration' => NULL, + '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 string $shareType ('group' or 'user' share) - * @param string $resourceType ('file', 'calendar',...) - * @param string $sharedSecret + * @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 $sender provider specific UID of the user who shared the resource + * @param string $senderDisplayName display name of the user who shared the resource + * @param string $shareType ('group' or 'user' share) + * @param string $resourceType ('file', 'calendar',...) + * @param string $sharedSecret + * @param int|NULL $expiration + * @param array $protocol */ - public function __construct($shareWith = '', + public function __construct( + $shareWith = '', $name = '', $description = '', $providerId = '', $owner = '', $ownerDisplayName = '', - $sharedBy = '', - $sharedByDisplayName = '', + $sender = '', + $senderDisplayName = '', $shareType = '', $resourceType = '', - $sharedSecret = '' + $sharedSecret = '', + $expiration = NULL, + $protocol = [], ) { $this->setShareWith($shareWith); $this->setResourceName($name); $this->setDescription($description); + $this->setExpiration($expiration); $this->setProviderId($providerId); $this->setOwner($owner); $this->setOwnerDisplayName($ownerDisplayName); - $this->setSharedBy($sharedBy); - $this->setSharedByDisplayName($sharedByDisplayName); - $this->setProtocol([ - 'name' => 'webdav', - 'options' => [ - 'sharedSecret' => $sharedSecret, - 'permissions' => '{http://open-cloud-mesh.org/ns}share-permissions' - ] - ]); + $this->setSender($sender); + $this->setSenderDisplayName($senderDisplayName); $this->setShareType($shareType); + $this->setProtocol($protocol); + $this->setShareSecret($sharedSecret); $this->setResourceType($resourceType); } @@ -76,7 +81,8 @@ public function __construct($shareWith = '', * * @since 14.0.0 */ - public function setShareWith($user) { + public function setShareWith($user) + { $this->share['shareWith'] = $user; } @@ -87,7 +93,8 @@ public function setShareWith($user) { * * @since 14.0.0 */ - public function setResourceName($name) { + public function setResourceName($name) + { $this->share['name'] = $name; } @@ -98,7 +105,8 @@ public function setResourceName($name) { * * @since 14.0.0 */ - public function setResourceType($resourceType) { + public function setResourceType($resourceType) + { $this->share['resourceType'] = $resourceType; } @@ -109,10 +117,22 @@ public function setResourceType($resourceType) { * * @since 14.0.0 */ - public function setDescription($description) { + public function setDescription($description) + { $this->share['description'] = $description; } + /** + * set resource expiration (optional) + * + * @param int $expiration + * + * @since 30.0.0 + */ + public function setExpiration($expiration) + { + $this->share['expiration'] = $expiration; + } /** * set provider ID (e.g. file ID) * @@ -120,7 +140,8 @@ public function setDescription($description) { * * @since 14.0.0 */ - public function setProviderId($providerId) { + public function setProviderId($providerId) + { $this->share['providerId'] = $providerId; } @@ -131,7 +152,8 @@ public function setProviderId($providerId) { * * @since 14.0.0 */ - public function setOwner($owner) { + public function setOwner($owner) + { $this->share['owner'] = $owner; } @@ -142,7 +164,8 @@ public function setOwner($owner) { * * @since 14.0.0 */ - public function setOwnerDisplayName($ownerDisplayName) { + public function setOwnerDisplayName($ownerDisplayName) + { $this->share['ownerDisplayName'] = $ownerDisplayName; } @@ -150,22 +173,49 @@ public function setOwnerDisplayName($ownerDisplayName) { * set UID of the user who sends the share * * @param string $sharedBy + * @deprecated 30.0.0 use setSender instead * * @since 14.0.0 */ - public function setSharedBy($sharedBy) { - $this->share['sharedBy'] = $sharedBy; + public function setSharedBy($sharedBy) + { + $this->setSender($sharedBy); + } + /** + * set UID of the user who sends the share + * + * @param string $sender + * + * @since 30.0.0 + */ + public function setSender($sender) + { + $this->share['sender'] = $sender; } /** * set display name of the user who sends the share * * @param $sharedByDisplayName + * @deprecated 30.0.0 use setSenderDisplayName instead * * @since 14.0.0 */ - public function setSharedByDisplayName($sharedByDisplayName) { - $this->share['sharedByDisplayName'] = $sharedByDisplayName; + public function setSharedByDisplayName($sharedByDisplayName) + { + $this->setSender($sharedByDisplayName); + } + + /** + * set display name of the user who sends the share + * + * @param $senderDisplayName + * + * @since 30.0.0 + */ + public function setSenderDisplayName($senderDisplayName) + { + $this->share['senderDisplayName'] = $senderDisplayName; } /** @@ -175,25 +225,41 @@ public function setSharedByDisplayName($sharedByDisplayName) { * * @since 14.0.0 */ - public function setProtocol(array $protocol) { + public function setProtocol(array $protocol) + { $this->share['protocol'] = $protocol; } /** - * share type (group or user) + * share type (group, user or federation) * * @param string $shareType * * @since 14.0.0 */ - public function setShareType($shareType) { + public function setShareType($shareType) + { if ($shareType === 'group' || $shareType === IShare::TYPE_REMOTE_GROUP) { $this->share['shareType'] = 'group'; + } elseif ($shareType == 'federation') { + $this->share['shareType'] = 'federation'; } else { $this->share['shareType'] = 'user'; } } + /** + * set the shared secret + * + * @param string $sharedSecret + * + * @since 30.0.0 + */ + public function setShareSecret($sharedSecret) + { + $this->share['sharedSecret'] = $sharedSecret; + } + /** * get the whole share, ready to send out * @@ -201,7 +267,8 @@ public function setShareType($shareType) { * * @since 14.0.0 */ - public function getShare() { + public function getShare() + { return $this->share; } @@ -212,7 +279,8 @@ public function getShare() { * * @since 14.0.0 */ - public function getShareWith() { + public function getShareWith() + { return $this->share['shareWith']; } @@ -223,7 +291,8 @@ public function getShareWith() { * * @since 14.0.0 */ - public function getResourceName() { + public function getResourceName() + { return $this->share['name']; } @@ -234,7 +303,8 @@ public function getResourceName() { * * @since 14.0.0 */ - public function getResourceType() { + public function getResourceType() + { return $this->share['resourceType']; } @@ -245,7 +315,8 @@ public function getResourceType() { * * @since 14.0.0 */ - public function getDescription() { + public function getDescription() + { return $this->share['description']; } @@ -256,7 +327,8 @@ public function getDescription() { * * @since 14.0.0 */ - public function getProviderId() { + public function getProviderId() + { return $this->share['providerId']; } @@ -267,7 +339,8 @@ public function getProviderId() { * * @since 14.0.0 */ - public function getOwner() { + public function getOwner() + { return $this->share['owner']; } @@ -278,7 +351,8 @@ public function getOwner() { * * @since 14.0.0 */ - public function getOwnerDisplayName() { + public function getOwnerDisplayName() + { return $this->share['ownerDisplayName']; } @@ -286,11 +360,38 @@ public function getOwnerDisplayName() { * get UID of the user who sends the share * * @return string + * @deprecated 30.0.0 use getSender() instead + * + * @since 14.0.0 + */ + public function getSharedBy() + { + return $this->getSender(); + } + + /** + * get UID of the user who sends the share + * + * @return string + * + * @since 30.0.0 + */ + public function getSender() + { + return $this->share['sender']; + } + + /** + * get display name of the user who sends the share + * + * @return string + * @deprecated 30.0.0 use getSenderDisplayName() instead * * @since 14.0.0 */ - public function getSharedBy() { - return $this->share['sharedBy']; + public function getSharedByDisplayName() + { + return $this->getSenderDisplayName(); } /** @@ -300,8 +401,9 @@ public function getSharedBy() { * * @since 14.0.0 */ - public function getSharedByDisplayName() { - return $this->share['sharedByDisplayName']; + public function getSenderDisplayName() + { + return $this->share['senderDisplayName']; } /** @@ -311,7 +413,8 @@ public function getSharedByDisplayName() { * * @since 14.0.0 */ - public function getShareType() { + public function getShareType() + { return $this->share['shareType']; } @@ -322,7 +425,8 @@ public function getShareType() { * * @since 14.0.0 */ - public function getShareSecret() { + public function getShareSecret() + { return $this->share['protocol']['options']['sharedSecret']; } @@ -333,7 +437,8 @@ public function getShareSecret() { * * @since 14.0.0 */ - public function getProtocol() { + public function getProtocol() + { return $this->share['protocol']; } } diff --git a/lib/private/OCM/Model/OCMProvider.php b/lib/private/OCM/Model/OCMProvider.php index adf2e239da908..b87973a3c162f 100644 --- a/lib/private/OCM/Model/OCMProvider.php +++ b/lib/private/OCM/Model/OCMProvider.php @@ -34,8 +34,7 @@ class OCMProvider implements IOCMProvider { public function __construct( protected IEventDispatcher $dispatcher, - IConfig $config, - LoggerInterface $logger + IConfig $config ) { $this->config = $config; $this->provider = 'Nextcloud ' . $config->getSystemValue('version'); diff --git a/lib/public/Federation/ICloudFederationFactory.php b/lib/public/Federation/ICloudFederationFactory.php index a25e4ee30f72e..55c24f827605f 100644 --- a/lib/public/Federation/ICloudFederationFactory.php +++ b/lib/public/Federation/ICloudFederationFactory.php @@ -27,11 +27,32 @@ interface ICloudFederationFactory { * @param string $shareType ('group' or 'user' share) * @param $resourceType ('file', 'calendar',...) * @return ICloudFederationShare + * @deprecated 30.0.0 use ICloudFederationShareManager::createCloudFederationShare() instead * * @since 14.0.0 */ public function getCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $sharedSecret, $shareType, $resourceType); + /** + * 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 $senderDisplayName 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 string $resourceType ('file', 'calendar',...) + * @param int $expiration (optional) + * @param array $protocol (optional) + * @return ICloudFederationShare + * + * @since 30.0.0 + */ + public function createCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $sharedSecret, $shareType, $resourceType, $expiration, $protocol); /** * get a Cloud FederationNotification object to prepare a notification you * want to send diff --git a/lib/public/Federation/ICloudFederationShare.php b/lib/public/Federation/ICloudFederationShare.php index 197ebf1af9a72..2cc519ce62417 100644 --- a/lib/public/Federation/ICloudFederationShare.php +++ b/lib/public/Federation/ICloudFederationShare.php @@ -21,6 +21,15 @@ interface ICloudFederationShare { */ public function setShareWith($user); + /** + * set sharedSecret + * + * @param string $sharedSecret + * + * @since 30.0.0 + */ + public function setShareSecret($sharedSecret); + /** * set resource name (e.g. file, calendar, contact,...) * @@ -28,6 +37,7 @@ public function setShareWith($user); * * @since 14.0.0 */ + public function setResourceName($name); /** @@ -79,20 +89,49 @@ public function setOwnerDisplayName($ownerDisplayName); * set UID of the user who sends the share * * @param string $sharedBy + * @deprecated 30.0.0 use setSender() instead * * @since 14.0.0 */ public function setSharedBy($sharedBy); + /** + * set UID of the user who sends the share + * + * @param string $sender + * + * @since 30.0.0 + */ + public function setSender($sender); + /** * set display name of the user who sends the share * * @param $sharedByDisplayName + * @deprecated 30.0.0 use setSenderDisplayName() instead * * @since 14.0.0 */ public function setSharedByDisplayName($sharedByDisplayName); + /** + * set display name of the user who sends the share + * + * @param string $senderDisplayName + * + * @since 30.0.0 + */ + public function setSenderDisplayName($senderDisplayName); + + /** + * set expiration time in seconds of UTC time since Unix epoch + * + * @param int + * + * @since 30.0.0 + */ + public function setExpiration(int $expiration); + /** * set protocol specification * diff --git a/lib/public/OCM/IOCMProvider.php b/lib/public/OCM/IOCMProvider.php index e7c74e9f2461d..2250da41c4fc0 100644 --- a/lib/public/OCM/IOCMProvider.php +++ b/lib/public/OCM/IOCMProvider.php @@ -98,7 +98,7 @@ public function getEndPoint(): string; * @return string * @since 30.0.0 */ - public function getProvider()): string; + public function getProvider(): string; /** * create a new resource to later add it with {@see addResourceType()} * @return IOCMResource