ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilWebDAVRequestHandler.php
Go to the documentation of this file.
1<?php
2
3use function Sabre\HTTP\decodePath;
5
6require_once 'libs/composer/vendor/autoload.php';
7
8// Include all needed classes for a webdav-request
9include_once "Services/WebDAV/classes/auth/class.ilWebDAVAuthentication.php";
10include_once "Services/WebDAV/classes/db/class.ilWebDAVDBManager.php";
11include_once "Services/WebDAV/classes/class.ilWebDAVObjDAVHelper.php";
12include_once "Services/WebDAV/classes/class.ilWebDAVRepositoryHelper.php";
13include_once "Services/WebDAV/classes/browser/class.ilWebDAVSabreBrowserPlugin.php";
14include_once "Services/WebDAV/classes/dav/class.ilObjectDAV.php";
15include_once "Services/WebDAV/classes/dav/class.ilObjContainerDAV.php";
16include_once "Services/WebDAV/classes/dav/class.ilObjFileDAV.php";
17include_once "Services/WebDAV/classes/dav/class.ilObjCategoryDAV.php";
18include_once "Services/WebDAV/classes/dav/class.ilObjCourseDAV.php";
19include_once "Services/WebDAV/classes/dav/class.ilObjGroupDAV.php";
20include_once "Services/WebDAV/classes/dav/class.ilObjFolderDAV.php";
21include_once "Services/WebDAV/classes/dav/class.ilMountPointDAV.php";
22include_once "Services/WebDAV/classes/dav/class.ilClientNodeDAV.php";
23include_once "Services/WebDAV/classes/dav/class.ilObjRepositoryRootDAV.php";
24
34{
35 private static $instance;
36
37 public static function getInstance()
38 {
39 return self::$instance ? self::$instance : self::$instance = new ilWebDAVRequestHandler();
40 }
41
47 public function handleRequest()
48 {
49 $this->runWebDAVServer();
50 }
51
57 protected function runWebDAVServer()
58 {
59 $server = new Sabre\DAV\Server($this->getRootDir());
60 $this->setPlugins($server);
61 $server->exec();
62 }
63
64
68 protected function setPlugins($server)
69 {
70 global $DIC;
71
72 // Set authentication plugin
73 $webdav_auth = new ilWebDAVAuthentication();
74 $cal = new Sabre\DAV\Auth\Backend\BasicCallBack(array($webdav_auth, 'authenticate'));
75 $plugin = new Sabre\DAV\Auth\Plugin($cal);
76 $server->addPlugin($plugin);
77
78 // Set Lock Plugin
79 $db_manager = new ilWebDAVDBManager($DIC->database());
80 $lock_backend = new ilWebDAVLockBackend($db_manager);
81 $lock_plugin = new Sabre\DAV\Locks\Plugin($lock_backend);
82 $server->addPlugin($lock_plugin);
83
84 /* Set Browser Plugin
85 * This plugin is used to redirect GET-Requests from browsers on collections to the mount instruction page */
86 $browser_plugin = new ilWebDAVSabreBrowserPlugin($DIC->ctrl());
87 $server->addPlugin($browser_plugin);
88 }
89
95 protected function getRootDir()
96 {
97 global $DIC;
98
99 $repo_helper = new ilWebDAVRepositoryHelper($DIC->access(), $DIC->repositoryTree());
100 $dav_helper = new ilWebDAVObjDAVHelper($repo_helper);
101 return new ilMountPointDAV($repo_helper, $dav_helper);
102 }
103}
An exception for terminatinating execution or to throw for unit testing.
Extremely simply HTTP Basic auth backend.
This plugin provides Authentication for a WebDAV server.
Definition: Plugin.php:25
Locking plugin.
Definition: Plugin.php:23
Main DAV server class.
Definition: Server.php:23
Class ilMountPointDAV.
Class ilWebDAVAuthentication.
Class ilWebDAVDBManager.
Class ilWebDAVLockBackend.
Class ilWebDAVObjDAVHelper.
Class ilWebDAVRepositoryHelper.
Class ilWebDAVRequestHandler.
setPlugins($server)
Set server plugins.
getRootDir()
Return the first object to mount on WebDAV.
handleRequest()
For the case there might be more to handle as just running the server.
runWebDAVServer()
Creates and runs SabreDAV Server.
Class ilWebDAVSabreBrowserPlugin.
decodePath($path)
Decodes a url-encoded path.
Definition: functions.php:419
$server
Definition: sabredav.php:48
global $DIC
Definition: saml.php:7