ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
Entrypoint.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\WebDAV;
22
23use Sabre\DAV\Browser\Plugin;
35use ILIAS\WebDAV;
36use Sabre\DAV\Server;
37use Sabre\DAV\TemporaryFileFilterPlugin;
39use Psr\Http\Message\ServerRequestInterface;
42
44{
45 public function __construct(
46 private Factory $factory,
47 private RequestTranslation $request_translation,
48 private SecretKeyRotation $secret_key_rotation,
49 private Config $config
50 ) {
51 }
52
53 public function getName(): string
54 {
55 return WebDAV::class;
56 }
57
58 public function enter(): int
59 {
60 entry_point('ILIAS Legacy Initialisation Adapter');
61
62 global $DIC; // TODO remove Service Locator
63
64 $logger = $DIC->logger()->webdav();
65 $current_user = $DIC->user();
66 $auth_session = $DIC['ilAuthSession'];
67 $filesystem = $DIC->filesystem()->temp();
68 $database = $DIC->database();
69 $request = $DIC->http()->request();
70 $language = $DIC->language();
71 $ui = $DIC->ui();
72 $http = $DIC->http();
73
74 $this->request_translation->setup();
75
76 if(!$this->config->isActive()) {
77 return 0;
78 }
79
80 if ($this->request_translation->showMountPoint()) {
82 $database,
83 $request,
84 $current_user,
85 $language,
86 $ui,
87 $http
88 );
89
90 return 0;
91 }
92
93 $server = new Server(
94 $this->factory->getMountPoint(),
95 );
96
97 $server->setBaseUri($this->request_translation->getBasePath());
98
99 $server->addPlugin(
101 $this->secret_key_rotation,
102 $logger,
103 $current_user,
104 $auth_session,
105 $filesystem,
106 )
107 );
108
109 $server->addPlugin(
110 new GeneralLock(
111 $this->factory,
113 $database
114 )
115 )
116 );
117
118 $server->addPlugin(
119 new TemporaryFileFilterPlugin(sys_get_temp_dir())
120 );
121
122 if ($this->config->enableDebugging()) {
123 $server->addPlugin(
124 new Plugin(true)
125 );
126 }
127
128 $server->addPlugin(
129 new Log(
130 $this->config->enableDebugging()
131 )
132 );
133
134 $server->start();
135
136 $this->request_translation->close();
137
138 return 0;
139 }
140
141 protected function handleMountInstruction(
142 \ilDBInterface $database,
143 ServerRequestInterface $request,
144 \ilObjUser $current_user,
145 \ilLanguage $language,
146 UIServices $ui,
148 ): void {
149 $repo = new RepositoryDB($database);
150 $uri_builder = new UriBuilder(
151 $request,
152 $this->config
153 );
154 $path_value = $this->request_translation->getRequestedPathAsArray()[0] ?? '';
155
156 $settings = new \ilSetting();
157 if (str_starts_with($path_value, 'ref_')) {
158 $instructions = new ObjectInstructions(
159 $repo,
160 $uri_builder,
161 $settings,
162 $current_user->getLanguage(),
163 (int) substr($path_value, 4)
164 );
165 } elseif (strlen($path_value) === 2) {
166 $instructions = new ObjectlessInstructions(
167 $repo,
168 $uri_builder,
169 $settings,
170 $path_value
171 );
172 } else {
173 throw new \InvalidArgumentException("Invalid path for mount-instructions: '$path_value'");
174 }
175
176 $gui = new InstructionsGUI(
177 $instructions,
178 $language,
179 $ui,
180 $http
181 );
182 $gui->renderMountInstructionsContent();
183 }
184
185}
factory()
Provides fluid interface to RBAC services.
Definition: UIServices.php:25
Key rotation can provide an extra layer of mitigation against an attacker discovering a secret key.
handleMountInstruction(\ilDBInterface $database, ServerRequestInterface $request, \ilObjUser $current_user, \ilLanguage $language, UIServices $ui, GlobalHttpState $http)
Definition: Entrypoint.php:141
enter()
Pass program execution to this entry point.
Definition: Entrypoint.php:58
__construct(private Factory $factory, private RequestTranslation $request_translation, private SecretKeyRotation $secret_key_rotation, private Config $config)
Definition: Entrypoint.php:45
language handling
User class.
$http
Definition: deliver.php:30
An entrypoint is where the programm execution starts.
Definition: EntryPoint.php:28
Interface GlobalHttpState.
Interface ilDBInterface.
entry_point(string $name)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: result1.php:21
global $DIC
Definition: shib_login.php:26
$server
Definition: shib_login.php:28