2018-06-19 22:01:14 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @copyright Copyright (c) 2018, Georg Ehrke.
|
|
|
|
*
|
|
|
|
* @author Georg Ehrke <oc.list@georgehrke.com>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2020-04-29 12:57:22 +03:00
|
|
|
* @author Thomas Citharel <nextcloud@tcit.fr>
|
2018-06-19 22:01:14 +03:00
|
|
|
*
|
2019-12-03 21:57:53 +03:00
|
|
|
* @license GNU AGPL version 3 or any later version
|
2018-06-19 22:01:14 +03:00
|
|
|
*
|
2019-12-03 21:57:53 +03:00
|
|
|
* 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.
|
2018-06-19 22:01:14 +03:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2019-12-03 21:57:53 +03:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2018-06-19 22:01:14 +03:00
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
2019-12-03 21:57:53 +03:00
|
|
|
* 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/>.
|
2018-06-19 22:01:14 +03:00
|
|
|
*
|
|
|
|
*/
|
2019-11-22 22:52:10 +03:00
|
|
|
|
2018-06-19 22:01:14 +03:00
|
|
|
namespace OCA\DAV\CalDAV\InvitationResponse;
|
|
|
|
|
2019-11-22 22:52:10 +03:00
|
|
|
use OCA\DAV\AppInfo\PluginManager;
|
|
|
|
use OCA\DAV\Connector\Sabre\AnonymousOptionsPlugin;
|
2018-06-19 22:01:14 +03:00
|
|
|
use OCA\DAV\Connector\Sabre\BlockLegacyClientPlugin;
|
|
|
|
use OCA\DAV\Connector\Sabre\CachingTree;
|
|
|
|
use OCA\DAV\Connector\Sabre\DavAclPlugin;
|
2020-07-13 16:43:42 +03:00
|
|
|
use OCA\DAV\Events\SabrePluginAuthInitEvent;
|
2018-06-19 22:01:14 +03:00
|
|
|
use OCA\DAV\RootCollection;
|
2020-07-13 16:43:42 +03:00
|
|
|
use OCP\EventDispatcher\IEventDispatcher;
|
2018-06-19 22:01:14 +03:00
|
|
|
use Sabre\DAV\Auth\Plugin;
|
|
|
|
use Sabre\VObject\ITip\Message;
|
|
|
|
|
|
|
|
class InvitationResponseServer {
|
|
|
|
|
|
|
|
/** @var \OCA\DAV\Connector\Sabre\Server */
|
|
|
|
public $server;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* InvitationResponseServer constructor.
|
|
|
|
*/
|
|
|
|
public function __construct() {
|
|
|
|
$baseUri = \OC::$WEBROOT . '/remote.php/dav/';
|
|
|
|
$logger = \OC::$server->getLogger();
|
2020-07-13 16:43:42 +03:00
|
|
|
/** @var IEventDispatcher $dispatcher */
|
|
|
|
$dispatcher = \OC::$server->query(IEventDispatcher::class);
|
2018-06-19 22:01:14 +03:00
|
|
|
|
|
|
|
$root = new RootCollection();
|
|
|
|
$this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root));
|
|
|
|
|
|
|
|
// Add maintenance plugin
|
2020-05-06 19:11:54 +03:00
|
|
|
$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig(), \OC::$server->getL10N('dav')));
|
2018-06-19 22:01:14 +03:00
|
|
|
|
|
|
|
// Set URL explicitly due to reverse-proxy situations
|
|
|
|
$this->server->httpRequest->setUrl($baseUri);
|
|
|
|
$this->server->setBaseUri($baseUri);
|
|
|
|
|
|
|
|
$this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig()));
|
|
|
|
$this->server->addPlugin(new AnonymousOptionsPlugin());
|
|
|
|
$this->server->addPlugin(new class() extends Plugin {
|
|
|
|
public function getCurrentPrincipal() {
|
|
|
|
return 'principals/system/public';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// allow setup of additional auth backends
|
2020-07-13 16:43:42 +03:00
|
|
|
$event = new SabrePluginAuthInitEvent($this->server);
|
|
|
|
$dispatcher->dispatchTyped($event);
|
2018-06-19 22:01:14 +03:00
|
|
|
|
|
|
|
$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger));
|
|
|
|
$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
|
|
|
|
$this->server->addPlugin(new \Sabre\DAV\Sync\Plugin());
|
|
|
|
|
|
|
|
// acl
|
|
|
|
$acl = new DavAclPlugin();
|
|
|
|
$acl->principalCollectionSet = [
|
|
|
|
'principals/users', 'principals/groups'
|
|
|
|
];
|
|
|
|
$acl->defaultUsernamePath = 'principals/users';
|
|
|
|
$this->server->addPlugin($acl);
|
|
|
|
|
|
|
|
// calendar plugins
|
|
|
|
$this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin());
|
|
|
|
$this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin());
|
2020-03-08 19:33:27 +03:00
|
|
|
$this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin(\OC::$server->getConfig()));
|
2018-06-19 22:01:14 +03:00
|
|
|
$this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin());
|
|
|
|
$this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin());
|
|
|
|
//$this->server->addPlugin(new \OCA\DAV\DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest()));
|
|
|
|
$this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin(
|
|
|
|
\OC::$server->getConfig(),
|
|
|
|
\OC::$server->getURLGenerator()
|
|
|
|
));
|
|
|
|
|
|
|
|
// wait with registering these until auth is handled and the filesystem is setup
|
2020-03-09 18:32:04 +03:00
|
|
|
$this->server->on('beforeMethod:*', function () use ($root) {
|
2018-06-19 22:01:14 +03:00
|
|
|
// register plugins from apps
|
|
|
|
$pluginManager = new PluginManager(
|
|
|
|
\OC::$server,
|
|
|
|
\OC::$server->getAppManager()
|
|
|
|
);
|
|
|
|
foreach ($pluginManager->getAppPlugins() as $appPlugin) {
|
|
|
|
$this->server->addPlugin($appPlugin);
|
|
|
|
}
|
|
|
|
foreach ($pluginManager->getAppCollections() as $appCollection) {
|
|
|
|
$root->addChild($appCollection);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Message $iTipMessage
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function handleITipMessage(Message $iTipMessage) {
|
|
|
|
/** @var \OCA\DAV\CalDAV\Schedule\Plugin $schedulingPlugin */
|
|
|
|
$schedulingPlugin = $this->server->getPlugin('caldav-schedule');
|
|
|
|
$schedulingPlugin->scheduleLocalDelivery($iTipMessage);
|
|
|
|
}
|
2019-11-22 22:52:10 +03:00
|
|
|
}
|