-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f6c6633
commit a5a2f83
Showing
4 changed files
with
218 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,27 @@ | ||
<?php | ||
/** | ||
* @author Viktar Dubiniuk <[email protected]> | ||
* | ||
* @copyright Copyright (c) 2018, ownCloud GmbH | ||
* @license AGPL-3.0 | ||
* | ||
* This code is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* 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, version 3, | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
* | ||
*/ | ||
|
||
return [ | ||
'ocs' => [ | ||
// ocm 0.3 | ||
['root' => '/cloud', 'name' => 'RequestHandler#createShare', 'url' => '/shares', 'verb' => 'POST'], | ||
['root' => '/cloud', 'name' => 'RequestHandler#reShare', 'url' => '/shares/{id}/reshare', 'verb' => 'POST'], | ||
['root' => '/cloud', 'name' => 'RequestHandler#updatePermissions', 'url' => '/shares/{id}/permissions', 'verb' => 'POST'], | ||
|
@@ -10,5 +30,15 @@ | |
['root' => '/cloud', 'name' => 'RequestHandler#declineShare', 'url' => '/shares/{id}/decline', 'verb' => 'POST'], | ||
['root' => '/cloud', 'name' => 'RequestHandler#unshare', 'url' => '/shares/{id}/unshare', 'verb' => 'POST'], | ||
['root' => '/cloud', 'name' => 'RequestHandler#revoke', 'url' => '/shares/{id}/revoke', 'verb' => 'POST'], | ||
|
||
// ocm 1.0-proposal1 | ||
['root' => '/', 'name' => 'OcmController#discovery', 'url' => '/ocm-provider', 'verb' => 'GET'], | ||
], | ||
|
||
'routes' => [ | ||
// ocm 1.0-proposal1 | ||
['name' => 'ocm#index', 'url' => '/', 'verb' => 'GET'], | ||
['name' => 'ocm#createShare', 'url' => '/shares', 'verb' => 'POST'], | ||
['name' => 'ocm#processNotification', 'url' => '/notifications', 'verb' => 'POST'], | ||
] | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
apps/federatedfilesharing/lib/Controller/OcmController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
<?php | ||
/** | ||
* @author Viktar Dubiniuk <[email protected]> | ||
* | ||
* @copyright Copyright (c) 2018, ownCloud GmbH | ||
* @license AGPL-3.0 | ||
* | ||
* This code is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* 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, version 3, | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
* | ||
*/ | ||
|
||
namespace OCA\FederatedFileSharing\Controller; | ||
|
||
use OCP\AppFramework\Controller; | ||
use OCP\IRequest; | ||
use OCP\IURLGenerator; | ||
|
||
/** | ||
* Class OcmController | ||
* | ||
* @package OCA\FederatedFileSharing\Controller | ||
*/ | ||
class OcmController extends Controller { | ||
const API_VERSION = '1.0-proposal1'; | ||
|
||
protected $urlGenerator; | ||
|
||
public function __construct($appName, | ||
IRequest $request, | ||
IURLGenerator $urlGenerator) { | ||
parent::__construct($appName, $request); | ||
|
||
$this->urlGenerator = $urlGenerator; | ||
} | ||
|
||
/** | ||
* @NoCSRFRequired | ||
* @PublicPage | ||
* | ||
* EndPoint discovery | ||
* Responds to /ocm-provider/ requests | ||
* | ||
* @return array | ||
*/ | ||
public function discovery() { | ||
return [ | ||
'enabled' => true, | ||
'apiVersion' => self::API_VERSION, | ||
'endPoint' => $this->urlGenerator->linkToRouteAbsolute( | ||
"{$this->appName}.ocm.index" | ||
), | ||
'shareTypes' => [ | ||
'name' => 'file', | ||
'protocols' => $this->getProtocols() | ||
] | ||
]; | ||
} | ||
|
||
/** | ||
* @NoCSRFRequired | ||
* @PublicPage | ||
* | ||
* | ||
* | ||
* @param string $shareWith identifier of the user or group to share the resource with | ||
* @param string $name name of the shared resource | ||
* @param string $description share description (optional) | ||
* @param string $providerId Identifier of the resource at the provider side | ||
* @param string $owner identifier of the user that owns the resource | ||
* @param string $ownerDisplayName display name of the owner | ||
* @param string $sender Provider specific identifier of the user that wants to share the resource | ||
* @param string $senderDisplayName Display name of the user that wants to share the resource | ||
* @param string $shareType Share type (user or group share) | ||
* @param string $resourceType only 'file' is supported atm | ||
* @param array $protocol | ||
* [ | ||
* 'name' => (string) protocol name. Only 'webdav' is supported atm, | ||
* 'options' => [ | ||
* protocol specific options | ||
* only `webdav` options are supported atm | ||
* e.g. `uri`, `access_token`, `password`, `permissions` etc. | ||
* | ||
* For backward compatibility the webdav protocol will use | ||
* the 'sharedSecret" as username and password | ||
* ] | ||
* | ||
*/ | ||
public function createShare($shareWith, | ||
$name, | ||
$description, | ||
$providerId, | ||
$owner, | ||
$ownerDisplayName, | ||
$sender, | ||
$senderDisplayName, | ||
$shareType, | ||
$resourceType, | ||
$protocol | ||
|
||
) { | ||
// TODO: implement | ||
} | ||
|
||
/** | ||
* @param string $notificationType notification type (SHARE_REMOVED, etc) | ||
* @param string $resourceType only 'file' is supported atm | ||
* @param string $providerId Identifier of the resource at the provider side | ||
* @param array $notification | ||
* [ | ||
* optional additional parameters, depending on the notification and the resource type | ||
* | ||
* ] | ||
*/ | ||
public function processNotification($notificationType, | ||
$resourceType, | ||
$providerId, | ||
$notification | ||
) { | ||
// TODO: implement | ||
} | ||
|
||
protected function getProtocols() { | ||
return [ | ||
'webdav' => '/public.php/webdav/' | ||
]; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
/** | ||
* @author Viktar Dubiniuk <[email protected]> | ||
* | ||
* @copyright Copyright (c) 2018, ownCloud GmbH | ||
* @license AGPL-3.0 | ||
* | ||
* This code is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* 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, version 3, | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
* | ||
*/ | ||
|
||
require_once __DIR__ . '/../lib/base.php'; | ||
|
||
$server = \OC::$server; | ||
|
||
$isFederationEnabled = $server->getAppManager() | ||
->isEnabledForUser('federatedfilesharing'); | ||
if ($isFederationEnabled) { | ||
\OC_App::loadApp('federatedfilesharing'); | ||
$federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application(); | ||
$federatedSharingApp->dispatch('OcmController', 'discovery'); | ||
} else { | ||
$output = new \OC\AppFramework\Http\Output(''); | ||
$output->setHttpResponseCode( | ||
\OCP\AppFramework\Http::STATUS_NOT_IMPLEMENTED | ||
); | ||
$output->setOutput('501 Not Implemented'); | ||
} |