ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilWebDAVRequestHandler.php
Go to the documentation of this file.
1 <?php
2 
3 use function Sabre\HTTP\decodePath;
5 
6 require_once 'libs/composer/vendor/autoload.php';
7 
8 // Include all needed classes for a webdav-request
9 include_once "Services/WebDAV/classes/auth/class.ilWebDAVAuthentication.php";
10 include_once "Services/WebDAV/classes/db/class.ilWebDAVDBManager.php";
11 include_once "Services/WebDAV/classes/class.ilWebDAVObjDAVHelper.php";
12 include_once "Services/WebDAV/classes/class.ilWebDAVRepositoryHelper.php";
13 include_once "Services/WebDAV/classes/browser/class.ilWebDAVSabreBrowserPlugin.php";
14 include_once "Services/WebDAV/classes/dav/class.ilObjectDAV.php";
15 include_once "Services/WebDAV/classes/dav/class.ilObjContainerDAV.php";
16 include_once "Services/WebDAV/classes/dav/class.ilObjFileDAV.php";
17 include_once "Services/WebDAV/classes/dav/class.ilObjCategoryDAV.php";
18 include_once "Services/WebDAV/classes/dav/class.ilObjCourseDAV.php";
19 include_once "Services/WebDAV/classes/dav/class.ilObjGroupDAV.php";
20 include_once "Services/WebDAV/classes/dav/class.ilObjFolderDAV.php";
21 include_once "Services/WebDAV/classes/dav/class.ilMountPointDAV.php";
22 include_once "Services/WebDAV/classes/dav/class.ilClientNodeDAV.php";
23 include_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 }
handleRequest()
For the case there might be more to handle as just running the server.
Class ilWebDAVSabreBrowserPlugin.
Class ilWebDAVAuthentication.
Class ilMountPointDAV.
This plugin provides Authentication for a WebDAV server.
Definition: Plugin.php:25
runWebDAVServer()
Creates and runs SabreDAV Server.
global $DIC
Definition: saml.php:7
Class ilWebDAVRequestHandler.
Class ilWebDAVRepositoryHelper.
decodePath($path)
Decodes a url-encoded path.
Definition: functions.php:419
Extremely simply HTTP Basic auth backend.
$server
Definition: sabredav.php:48
Class ilWebDAVObjDAVHelper.
getRootDir()
Return the first object to mount on WebDAV.
Class ilWebDAVLockBackend.
setPlugins($server)
Set server plugins.
Class ilWebDAVDBManager.
Locking plugin.
Definition: Plugin.php:23