Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
5cfe206
start implementing federated sharing 2.0
schiessle Apr 18, 2018
21e64ec
implement receiving of federated shares
schiessle Apr 30, 2018
4c8f3d6
add cloud federation api app
schiessle Apr 30, 2018
6208f25
check if cloud federation api is ready
schiessle May 2, 2018
a3948e8
use new API to send a federated share if possible
schiessle May 4, 2018
db428ea
send accept share notification (WIP)
schiessle May 9, 2018
af178ef
check API Version
schiessle May 14, 2018
daba042
update capabilities
schiessle May 28, 2018
bbce8c3
adjust to latest api version
schiessle May 28, 2018
8889e14
implement accept share notification
schiessle May 29, 2018
c572e84
detect correctly if a share was send successful
schiessle May 29, 2018
b7b8430
fix capabilities
schiessle May 29, 2018
41a1528
implement decline share
schiessle May 30, 2018
fab4e56
send reshare over OCM API
schiessle Jun 4, 2018
a176a1f
implement unshare notification
schiessle Jun 4, 2018
d77eedd
- Don't remove share before all notifications are created, otherwise …
schiessle Jun 5, 2018
2bb1956
implement RESHARE_UNDO notification
schiessle Jun 5, 2018
ed41572
send RESHARE_CHANGE_PERMISSION message
schiessle Jun 5, 2018
61485e3
fix check for reshare permissions
schiessle Jun 5, 2018
957b27f
replace \OCP\Federation\Exception\ShareNotFoundException with the gen…
schiessle Jun 7, 2018
84fc188
some minor fixes and clode cleanup
schiessle Jun 7, 2018
34c4527
add ocm-provider to the list of expected files
schiessle Jun 11, 2018
5d0d33a
remove unused method
schiessle Jun 11, 2018
9d145bb
update tests
schiessle Jun 11, 2018
2e19213
fix notification tests
schiessle Jun 12, 2018
9365fd2
fix external manager tests
schiessle Jun 12, 2018
21b8a87
implement config check
schiessle Jun 12, 2018
2781412
make sure that remote url gets stored with a trailing '/'
schiessle Jun 12, 2018
22d9246
send the display name back after a federated share was received
schiessle Jun 13, 2018
5c8b262
let the actual federated share provider check if incoming/outgoing sh…
schiessle Jun 13, 2018
e251b34
cleanup variable naming, it is actually a resource type
schiessle Jun 13, 2018
8d4da30
add support for different share types
schiessle Jun 13, 2018
cfb3e80
remove the makefile
schiessle Jun 14, 2018
086e7a0
remove debug output
schiessle Jun 18, 2018
cdf8abb
look for correct OCM permissions
schiessle Jun 25, 2018
511a34b
always enable cloud federation api
schiessle Jun 29, 2018
411bae5
fix return type from send share
schiessle Jun 29, 2018
ce567b6
remove unused code
schiessle Jul 2, 2018
7ff74ae
cache results from ocm end-point discovery
schiessle Jul 2, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
some minor fixes and clode cleanup
Signed-off-by: Bjoern Schiessle <[email protected]>
  • Loading branch information
schiessle committed Jul 2, 2018
commit 84fc188dfc73ab16510bc80a6c091d1a017d4368
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ public function __construct($appName,
* @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 $sharedSecret use to authenticate accross servers
* @param array $protocol (e,.g. ['name' => 'webdav', 'options' => ['username' => 'john', 'permissions' => 31]])
* @param string $shareType ('group' or 'user' share)
* @param $resourceType ('file', 'calendar',...)
Expand Down
4 changes: 2 additions & 2 deletions apps/federatedfilesharing/lib/FederatedShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -506,13 +506,13 @@ public function getChildren(IShare $parent) {
* Delete a share (owner unShares the file)
*
* @param IShare $share
* @throws ShareNotFound
* @throws \OC\HintException
*/
public function delete(IShare $share) {

list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedWith());

$isOwner = false;

// if the local user is the owner we can send the unShare request directly...
if ($this->userManager->userExists($share->getShareOwner())) {
$this->notifications->sendRemoteUnShare($remote, $share->getId(), $share->getToken());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ public function shareReceived(ICloudFederationShare $share) {

list($ownerUid, $remote) = $this->addressHandler->splitUserRemote($share->getOwner());

$remote = $remote;
$token = $share->getShareSecret();
$name = $share->getResourceName();
$owner = $share->getOwnerDisplayName();
Expand Down Expand Up @@ -247,7 +246,7 @@ public function shareReceived(ICloudFederationShare $share) {
} catch (\Exception $e) {
$this->logger->logException($e, [
'message' => 'Server can not add remote share.',
'level' => Util::ERROR,
'level' => ILogger::ERROR,
'app' => 'files_sharing'
]);
throw new ProviderCouldNotAddShareException('internal server error, was not able to add share from ' . $remote, '', HTTP::STATUS_INTERNAL_SERVER_ERROR);
Expand Down Expand Up @@ -304,7 +303,7 @@ public function notificationReceived($notificationType, $providerId, array $noti
* @throws BadRequestException
* @throws \OC\HintException
*/
private function shareAccepted($id, $notification) {
private function shareAccepted($id, array $notification) {

if (!$this->isS2SEnabled()) {
throw new ActionNotSupportedException('Server does not support federated cloud sharing');
Expand Down Expand Up @@ -376,7 +375,7 @@ protected function executeAcceptShare(IShare $share) {
* @throws \OC\HintException
*
*/
protected function shareDeclined($id, $notification) {
protected function shareDeclined($id, array $notification) {

if (!$this->isS2SEnabled()) {
throw new ActionNotSupportedException('Server does not support federated cloud sharing');
Expand Down Expand Up @@ -446,12 +445,12 @@ protected function executeDeclineShare(IShare $share) {
* received the notification that the owner unshared a file from you
*
* @param string $id
* @param string $notification
* @param array $notification
* @return array
* @throws AuthenticationFailedException
* @throws BadRequestException
*/
private function undoReshare($id, $notification) {
private function undoReshare($id, array $notification) {
if (!isset($notification['sharedSecret'])) {
throw new BadRequestException(['sharedSecret']);
}
Expand Down Expand Up @@ -550,15 +549,15 @@ private function cleanupRemote($remote) {
/**
* recipient of a share request to re-share the file with another user
*
* @param $id
* @param $notification
* @param string $id
* @param array $notification
* @return array
* @throws AuthenticationFailedException
* @throws BadRequestException
* @throws ProviderCouldNotAddShareException
* @throws ShareNotFound
*/
protected function reshareRequested($id, $notification) {
protected function reshareRequested($id, array $notification) {

if (!isset($notification['sharedSecret'])) {
throw new BadRequestException(['sharedSecret']);
Expand Down Expand Up @@ -602,7 +601,6 @@ protected function reshareRequested($id, $notification) {
throw new ProviderCouldNotAddShareException('resharing not allowed for share: ' . $id);
}

throw new BadRequestException([]);
}

/**
Expand All @@ -615,7 +613,7 @@ protected function reshareRequested($id, $notification) {
* @throws AuthenticationFailedException
* @throws BadRequestException
*/
protected function updateResharePermissions($id, $notification) {
protected function updateResharePermissions($id, array $notification) {

if (!isset($notification['sharedSecret'])) {
throw new BadRequestException(['sharedSecret']);
Expand All @@ -640,12 +638,11 @@ protected function updateResharePermissions($id, $notification) {
/**
* translate OCM Permissions to Nextcloud permissions
*
* @param $ocmPermissions
* @param array $ocmPermissions
* @return int
* @throws BadRequestException
*/
protected function ocmPermissions2ncPermissions($ocmPermissions) {
error_log("ocm permissions: " . json_encode($ocmPermissions));
protected function ocmPermissions2ncPermissions(array $ocmPermissions) {
$ncPermissions = 0;
foreach($ocmPermissions as $permission) {
switch (strtolower($permission)) {
Expand Down Expand Up @@ -701,7 +698,7 @@ private function getFile($user, $fileSource) {
$args = Filesystem::is_dir($file) ? array('dir' => $file) : array('dir' => dirname($file), 'scrollto' => $file);
$link = Util::linkToAbsolute('files', 'index.php', $args);

return array($file, $link);
return [$file, $link];

}

Expand Down
7 changes: 7 additions & 0 deletions lib/private/Federation/CloudFederationNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@

use OCP\Federation\ICloudFederationNotification;

/**
* Class CloudFederationNotification
*
* @package OC\Federation
*
* @since 14.0.0
*/
class CloudFederationNotification implements ICloudFederationNotification {

private $message = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function sendNotification($url, ICloudFederationNotification $notificatio
* @return bool
*/
public function isReady() {
return $this->appManager->isEnabledForUser('cloud_federation_api', false);
return $this->appManager->isEnabledForUser('cloud_federation_api');
}
/**
* check if server supports the new OCM api and ask for the correct end-point
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,20 @@

use OC\HintException;

/**
* Class ActionNotSupportedException
*
* @package OCP\Federation\Exceptions
*
* @since 14.0.0
*/
class ActionNotSupportedException extends HintException {

/**
* ActionNotSupportedException constructor.
*
* @since 14.0.0
*
*/
public function __construct($action) {
$l = \OC::$server->getL10N('federation');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,20 @@

use OC\HintException;

/**
* Class AuthenticationFailedException
*
* @package OCP\Federation\Exceptions
*
* @since 14.0.0
*/
class AuthenticationFailedException extends HintException {

/**
* BadRequestException constructor.
*
* @param array $missingParameters
* @since 14.0.0
*
*/
public function __construct() {
$l = \OC::$server->getL10N('federation');
Expand Down
11 changes: 11 additions & 0 deletions lib/public/Federation/Exceptions/BadRequestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,22 @@

use OC\HintException;

/**
* Class BadRequestException
*
* @package OCP\Federation\Exceptions
*
* @since 14.0.0
*/
class BadRequestException extends HintException {

private $parameterList;

/**
* BadRequestException constructor.
*
* @since 14.0.0
*
* @param array $missingParameters
*/
public function __construct(array $missingParameters) {
Expand All @@ -44,6 +53,8 @@ public function __construct(array $missingParameters) {
/**
* get array with the return message as defined in the OCM API
*
* @since 14.0.0
*
* @return array
*/
public function getReturnMessage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,20 @@

use OC\HintException;

/**
* Class ProviderAlreadyExistsException
*
* @package OCP\Federation\Exceptions
*
* @since 14.0.0
*/
class ProviderAlreadyExistsException extends HintException {

/**
* ProviderAlreadyExistsException constructor.
*
* @since 14.0.0
*
* @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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,25 @@
use OC\HintException;
use OCP\AppFramework\Http;

/**
* Class ProviderCouldNotAddShareException
*
* @package OCP\Federation\Exceptions
*
* @since 14.0.0
*/
class ProviderCouldNotAddShareException extends HintException {

/**
* ProviderCouldNotAddShareException constructor.
*
* @since 14.0.0
*
* @param string $message
* @param string $hint
* @param int $code
* @param \Exception|null $previous
*/
public function __construct($message, $hint = '', $code = Http::STATUS_BAD_REQUEST, \Exception $previous = null) {
parent::__construct($message, $hint, $code, $previous);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,20 @@

use OC\HintException;

/**
* Class ProviderDoesNotExistsException
*
* @package OCP\Federation\Exceptions
*
* @since 14.0.0
*/
class ProviderDoesNotExistsException extends HintException {

/**
* ProviderDoesNotExistsException constructor.
*
* @since 14.0.0
*
* @param string $providerId cloud federation provider ID
*/
public function __construct($providerId) {
Expand Down
7 changes: 7 additions & 0 deletions lib/public/Federation/ICloudFederationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@

namespace OCP\Federation;

/**
* Interface ICloudFederationFactory
*
* @package OCP\Federation
*
* @since 14.0.0
*/
interface ICloudFederationFactory {

/**
Expand Down
10 changes: 8 additions & 2 deletions lib/public/Federation/ICloudFederationNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@

namespace OCP\Federation;

/**
* Interface ICloudFederationNotification
*
* @package OCP\Federation
*
* @since 14.0.0
*/
interface ICloudFederationNotification {

/**
Expand All @@ -31,15 +38,14 @@ interface ICloudFederationNotification {
* @param $providerId id of the share
* @param array $notification , payload of the notification
*
* @return
* @since 14.0.0
*/
public function setMessage($notificationType, $resourceType, $providerId, array $notification);

/**
* get message, ready to send out
*
* @return string
* @return array
*
* @since 14.0.0
*/
Expand Down
7 changes: 7 additions & 0 deletions lib/public/Federation/ICloudFederationShare.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@

namespace OCP\Federation;

/**
* Interface ICloudFederationShare
*
* @package OCP\Federation
*
* @since 14.0.0
*/
interface ICloudFederationShare {

/**
Expand Down
1 change: 1 addition & 0 deletions lib/public/IServerContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ public function getCloudIdManager();

/**
* @return \OCP\GlobalScale\IConfig
* @since 14.0.0
*/
public function getGlobalScaleConfig();

Expand Down