Passed
Push — master ( 91864a...0893bb )
by Roeland
24:06 queued 12s
created
lib/private/IntegrityCheck/Checker.php 1 patch
Indentation   +533 added lines, -533 removed lines patch added patch discarded remove patch
@@ -58,537 +58,537 @@
 block discarded – undo
58 58
  * @package OC\IntegrityCheck
59 59
  */
60 60
 class Checker {
61
-	public const CACHE_KEY = 'oc.integritycheck.checker';
62
-	/** @var EnvironmentHelper */
63
-	private $environmentHelper;
64
-	/** @var AppLocator */
65
-	private $appLocator;
66
-	/** @var FileAccessHelper */
67
-	private $fileAccessHelper;
68
-	/** @var IConfig|null */
69
-	private $config;
70
-	/** @var ICache */
71
-	private $cache;
72
-	/** @var IAppManager|null */
73
-	private $appManager;
74
-	/** @var IMimeTypeDetector */
75
-	private $mimeTypeDetector;
76
-
77
-	/**
78
-	 * @param EnvironmentHelper $environmentHelper
79
-	 * @param FileAccessHelper $fileAccessHelper
80
-	 * @param AppLocator $appLocator
81
-	 * @param IConfig|null $config
82
-	 * @param ICacheFactory $cacheFactory
83
-	 * @param IAppManager|null $appManager
84
-	 * @param IMimeTypeDetector $mimeTypeDetector
85
-	 */
86
-	public function __construct(EnvironmentHelper $environmentHelper,
87
-								FileAccessHelper $fileAccessHelper,
88
-								AppLocator $appLocator,
89
-								?IConfig $config,
90
-								ICacheFactory $cacheFactory,
91
-								?IAppManager $appManager,
92
-								IMimeTypeDetector $mimeTypeDetector) {
93
-		$this->environmentHelper = $environmentHelper;
94
-		$this->fileAccessHelper = $fileAccessHelper;
95
-		$this->appLocator = $appLocator;
96
-		$this->config = $config;
97
-		$this->cache = $cacheFactory->createDistributed(self::CACHE_KEY);
98
-		$this->appManager = $appManager;
99
-		$this->mimeTypeDetector = $mimeTypeDetector;
100
-	}
101
-
102
-	/**
103
-	 * Whether code signing is enforced or not.
104
-	 *
105
-	 * @return bool
106
-	 */
107
-	public function isCodeCheckEnforced(): bool {
108
-		$notSignedChannels = [ '', 'git'];
109
-		if (\in_array($this->environmentHelper->getChannel(), $notSignedChannels, true)) {
110
-			return false;
111
-		}
112
-
113
-		/**
114
-		 * This config option is undocumented and supposed to be so, it's only
115
-		 * applicable for very specific scenarios and we should not advertise it
116
-		 * too prominent. So please do not add it to config.sample.php.
117
-		 */
118
-		$isIntegrityCheckDisabled = false;
119
-		if ($this->config !== null) {
120
-			$isIntegrityCheckDisabled = $this->config->getSystemValue('integrity.check.disabled', false);
121
-		}
122
-		if ($isIntegrityCheckDisabled === true) {
123
-			return false;
124
-		}
125
-
126
-		return true;
127
-	}
128
-
129
-	/**
130
-	 * Enumerates all files belonging to the folder. Sensible defaults are excluded.
131
-	 *
132
-	 * @param string $folderToIterate
133
-	 * @param string $root
134
-	 * @return \RecursiveIteratorIterator
135
-	 * @throws \Exception
136
-	 */
137
-	private function getFolderIterator(string $folderToIterate, string $root = ''): \RecursiveIteratorIterator {
138
-		$dirItr = new \RecursiveDirectoryIterator(
139
-			$folderToIterate,
140
-			\RecursiveDirectoryIterator::SKIP_DOTS
141
-		);
142
-		if ($root === '') {
143
-			$root = \OC::$SERVERROOT;
144
-		}
145
-		$root = rtrim($root, '/');
146
-
147
-		$excludeGenericFilesIterator = new ExcludeFileByNameFilterIterator($dirItr);
148
-		$excludeFoldersIterator = new ExcludeFoldersByPathFilterIterator($excludeGenericFilesIterator, $root);
149
-
150
-		return new \RecursiveIteratorIterator(
151
-			$excludeFoldersIterator,
152
-			\RecursiveIteratorIterator::SELF_FIRST
153
-		);
154
-	}
155
-
156
-	/**
157
-	 * Returns an array of ['filename' => 'SHA512-hash-of-file'] for all files found
158
-	 * in the iterator.
159
-	 *
160
-	 * @param \RecursiveIteratorIterator $iterator
161
-	 * @param string $path
162
-	 * @return array Array of hashes.
163
-	 */
164
-	private function generateHashes(\RecursiveIteratorIterator $iterator,
165
-									string $path): array {
166
-		$hashes = [];
167
-
168
-		$baseDirectoryLength = \strlen($path);
169
-		foreach ($iterator as $filename => $data) {
170
-			/** @var \DirectoryIterator $data */
171
-			if ($data->isDir()) {
172
-				continue;
173
-			}
174
-
175
-			$relativeFileName = substr($filename, $baseDirectoryLength);
176
-			$relativeFileName = ltrim($relativeFileName, '/');
177
-
178
-			// Exclude signature.json files in the appinfo and root folder
179
-			if ($relativeFileName === 'appinfo/signature.json') {
180
-				continue;
181
-			}
182
-			// Exclude signature.json files in the appinfo and core folder
183
-			if ($relativeFileName === 'core/signature.json') {
184
-				continue;
185
-			}
186
-
187
-			// The .htaccess file in the root folder of ownCloud can contain
188
-			// custom content after the installation due to the fact that dynamic
189
-			// content is written into it at installation time as well. This
190
-			// includes for example the 404 and 403 instructions.
191
-			// Thus we ignore everything below the first occurrence of
192
-			// "#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####" and have the
193
-			// hash generated based on this.
194
-			if ($filename === $this->environmentHelper->getServerRoot() . '/.htaccess') {
195
-				$fileContent = file_get_contents($filename);
196
-				$explodedArray = explode('#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####', $fileContent);
197
-				if (\count($explodedArray) === 2) {
198
-					$hashes[$relativeFileName] = hash('sha512', $explodedArray[0]);
199
-					continue;
200
-				}
201
-			}
202
-			if ($filename === $this->environmentHelper->getServerRoot() . '/core/js/mimetypelist.js') {
203
-				$oldMimetypeList = new GenerateMimetypeFileBuilder();
204
-				$newFile = $oldMimetypeList->generateFile($this->mimeTypeDetector->getAllAliases());
205
-				if ($newFile === file_get_contents($filename)) {
206
-					$hashes[$relativeFileName] = hash('sha512', $oldMimetypeList->generateFile($this->mimeTypeDetector->getOnlyDefaultAliases()));
207
-					continue;
208
-				}
209
-			}
210
-
211
-			$hashes[$relativeFileName] = hash_file('sha512', $filename);
212
-		}
213
-
214
-		return $hashes;
215
-	}
216
-
217
-	/**
218
-	 * Creates the signature data
219
-	 *
220
-	 * @param array $hashes
221
-	 * @param X509 $certificate
222
-	 * @param RSA $privateKey
223
-	 * @return array
224
-	 */
225
-	private function createSignatureData(array $hashes,
226
-										 X509 $certificate,
227
-										 RSA $privateKey): array {
228
-		ksort($hashes);
229
-
230
-		$privateKey->setSignatureMode(RSA::SIGNATURE_PSS);
231
-		$privateKey->setMGFHash('sha512');
232
-		// See https://tools.ietf.org/html/rfc3447#page-38
233
-		$privateKey->setSaltLength(0);
234
-		$signature = $privateKey->sign(json_encode($hashes));
235
-
236
-		return [
237
-			'hashes' => $hashes,
238
-			'signature' => base64_encode($signature),
239
-			'certificate' => $certificate->saveX509($certificate->currentCert),
240
-		];
241
-	}
242
-
243
-	/**
244
-	 * Write the signature of the app in the specified folder
245
-	 *
246
-	 * @param string $path
247
-	 * @param X509 $certificate
248
-	 * @param RSA $privateKey
249
-	 * @throws \Exception
250
-	 */
251
-	public function writeAppSignature($path,
252
-									  X509 $certificate,
253
-									  RSA $privateKey) {
254
-		$appInfoDir = $path . '/appinfo';
255
-		try {
256
-			$this->fileAccessHelper->assertDirectoryExists($appInfoDir);
257
-
258
-			$iterator = $this->getFolderIterator($path);
259
-			$hashes = $this->generateHashes($iterator, $path);
260
-			$signature = $this->createSignatureData($hashes, $certificate, $privateKey);
261
-			$this->fileAccessHelper->file_put_contents(
262
-					$appInfoDir . '/signature.json',
263
-				json_encode($signature, JSON_PRETTY_PRINT)
264
-			);
265
-		} catch (\Exception $e) {
266
-			if (!$this->fileAccessHelper->is_writable($appInfoDir)) {
267
-				throw new \Exception($appInfoDir . ' is not writable');
268
-			}
269
-			throw $e;
270
-		}
271
-	}
272
-
273
-	/**
274
-	 * Write the signature of core
275
-	 *
276
-	 * @param X509 $certificate
277
-	 * @param RSA $rsa
278
-	 * @param string $path
279
-	 * @throws \Exception
280
-	 */
281
-	public function writeCoreSignature(X509 $certificate,
282
-									   RSA $rsa,
283
-									   $path) {
284
-		$coreDir = $path . '/core';
285
-		try {
286
-			$this->fileAccessHelper->assertDirectoryExists($coreDir);
287
-			$iterator = $this->getFolderIterator($path, $path);
288
-			$hashes = $this->generateHashes($iterator, $path);
289
-			$signatureData = $this->createSignatureData($hashes, $certificate, $rsa);
290
-			$this->fileAccessHelper->file_put_contents(
291
-				$coreDir . '/signature.json',
292
-				json_encode($signatureData, JSON_PRETTY_PRINT)
293
-			);
294
-		} catch (\Exception $e) {
295
-			if (!$this->fileAccessHelper->is_writable($coreDir)) {
296
-				throw new \Exception($coreDir . ' is not writable');
297
-			}
298
-			throw $e;
299
-		}
300
-	}
301
-
302
-	/**
303
-	 * Verifies the signature for the specified path.
304
-	 *
305
-	 * @param string $signaturePath
306
-	 * @param string $basePath
307
-	 * @param string $certificateCN
308
-	 * @param bool $forceVerify
309
-	 * @return array
310
-	 * @throws InvalidSignatureException
311
-	 * @throws \Exception
312
-	 */
313
-	private function verify(string $signaturePath, string $basePath, string $certificateCN, bool $forceVerify = false): array {
314
-		if (!$forceVerify && !$this->isCodeCheckEnforced()) {
315
-			return [];
316
-		}
317
-
318
-		$content = $this->fileAccessHelper->file_get_contents($signaturePath);
319
-		$signatureData = null;
320
-
321
-		if (\is_string($content)) {
322
-			$signatureData = json_decode($content, true);
323
-		}
324
-		if (!\is_array($signatureData)) {
325
-			throw new InvalidSignatureException('Signature data not found.');
326
-		}
327
-
328
-		$expectedHashes = $signatureData['hashes'];
329
-		ksort($expectedHashes);
330
-		$signature = base64_decode($signatureData['signature']);
331
-		$certificate = $signatureData['certificate'];
332
-
333
-		// Check if certificate is signed by Nextcloud Root Authority
334
-		$x509 = new \phpseclib\File\X509();
335
-		$rootCertificatePublicKey = $this->fileAccessHelper->file_get_contents($this->environmentHelper->getServerRoot().'/resources/codesigning/root.crt');
336
-		$x509->loadCA($rootCertificatePublicKey);
337
-		$x509->loadX509($certificate);
338
-		if (!$x509->validateSignature()) {
339
-			throw new InvalidSignatureException('Certificate is not valid.');
340
-		}
341
-		// Verify if certificate has proper CN. "core" CN is always trusted.
342
-		if ($x509->getDN(X509::DN_OPENSSL)['CN'] !== $certificateCN && $x509->getDN(X509::DN_OPENSSL)['CN'] !== 'core') {
343
-			throw new InvalidSignatureException(
344
-					sprintf('Certificate is not valid for required scope. (Requested: %s, current: CN=%s)', $certificateCN, $x509->getDN(true)['CN'])
345
-			);
346
-		}
347
-
348
-		// Check if the signature of the files is valid
349
-		$rsa = new \phpseclib\Crypt\RSA();
350
-		$rsa->loadKey($x509->currentCert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey']);
351
-		$rsa->setSignatureMode(RSA::SIGNATURE_PSS);
352
-		$rsa->setMGFHash('sha512');
353
-		// See https://tools.ietf.org/html/rfc3447#page-38
354
-		$rsa->setSaltLength(0);
355
-		if (!$rsa->verify(json_encode($expectedHashes), $signature)) {
356
-			throw new InvalidSignatureException('Signature could not get verified.');
357
-		}
358
-
359
-		// Fixes for the updater as shipped with ownCloud 9.0.x: The updater is
360
-		// replaced after the code integrity check is performed.
361
-		//
362
-		// Due to this reason we exclude the whole updater/ folder from the code
363
-		// integrity check.
364
-		if ($basePath === $this->environmentHelper->getServerRoot()) {
365
-			foreach ($expectedHashes as $fileName => $hash) {
366
-				if (strpos($fileName, 'updater/') === 0) {
367
-					unset($expectedHashes[$fileName]);
368
-				}
369
-			}
370
-		}
371
-
372
-		// Compare the list of files which are not identical
373
-		$currentInstanceHashes = $this->generateHashes($this->getFolderIterator($basePath), $basePath);
374
-		$differencesA = array_diff($expectedHashes, $currentInstanceHashes);
375
-		$differencesB = array_diff($currentInstanceHashes, $expectedHashes);
376
-		$differences = array_unique(array_merge($differencesA, $differencesB));
377
-		$differenceArray = [];
378
-		foreach ($differences as $filename => $hash) {
379
-			// Check if file should not exist in the new signature table
380
-			if (!array_key_exists($filename, $expectedHashes)) {
381
-				$differenceArray['EXTRA_FILE'][$filename]['expected'] = '';
382
-				$differenceArray['EXTRA_FILE'][$filename]['current'] = $hash;
383
-				continue;
384
-			}
385
-
386
-			// Check if file is missing
387
-			if (!array_key_exists($filename, $currentInstanceHashes)) {
388
-				$differenceArray['FILE_MISSING'][$filename]['expected'] = $expectedHashes[$filename];
389
-				$differenceArray['FILE_MISSING'][$filename]['current'] = '';
390
-				continue;
391
-			}
392
-
393
-			// Check if hash does mismatch
394
-			if ($expectedHashes[$filename] !== $currentInstanceHashes[$filename]) {
395
-				$differenceArray['INVALID_HASH'][$filename]['expected'] = $expectedHashes[$filename];
396
-				$differenceArray['INVALID_HASH'][$filename]['current'] = $currentInstanceHashes[$filename];
397
-				continue;
398
-			}
399
-
400
-			// Should never happen.
401
-			throw new \Exception('Invalid behaviour in file hash comparison experienced. Please report this error to the developers.');
402
-		}
403
-
404
-		return $differenceArray;
405
-	}
406
-
407
-	/**
408
-	 * Whether the code integrity check has passed successful or not
409
-	 *
410
-	 * @return bool
411
-	 */
412
-	public function hasPassedCheck(): bool {
413
-		$results = $this->getResults();
414
-		if (empty($results)) {
415
-			return true;
416
-		}
417
-
418
-		return false;
419
-	}
420
-
421
-	/**
422
-	 * @return array
423
-	 */
424
-	public function getResults(): array {
425
-		$cachedResults = $this->cache->get(self::CACHE_KEY);
426
-		if (!\is_null($cachedResults)) {
427
-			return json_decode($cachedResults, true);
428
-		}
429
-
430
-		if ($this->config !== null) {
431
-			return json_decode($this->config->getAppValue('core', self::CACHE_KEY, '{}'), true);
432
-		}
433
-		return [];
434
-	}
435
-
436
-	/**
437
-	 * Stores the results in the app config as well as cache
438
-	 *
439
-	 * @param string $scope
440
-	 * @param array $result
441
-	 */
442
-	private function storeResults(string $scope, array $result) {
443
-		$resultArray = $this->getResults();
444
-		unset($resultArray[$scope]);
445
-		if (!empty($result)) {
446
-			$resultArray[$scope] = $result;
447
-		}
448
-		if ($this->config !== null) {
449
-			$this->config->setAppValue('core', self::CACHE_KEY, json_encode($resultArray));
450
-		}
451
-		$this->cache->set(self::CACHE_KEY, json_encode($resultArray));
452
-	}
453
-
454
-	/**
455
-	 *
456
-	 * Clean previous results for a proper rescanning. Otherwise
457
-	 */
458
-	private function cleanResults() {
459
-		$this->config->deleteAppValue('core', self::CACHE_KEY);
460
-		$this->cache->remove(self::CACHE_KEY);
461
-	}
462
-
463
-	/**
464
-	 * Verify the signature of $appId. Returns an array with the following content:
465
-	 * [
466
-	 * 	'FILE_MISSING' =>
467
-	 * 	[
468
-	 * 		'filename' => [
469
-	 * 			'expected' => 'expectedSHA512',
470
-	 * 			'current' => 'currentSHA512',
471
-	 * 		],
472
-	 * 	],
473
-	 * 	'EXTRA_FILE' =>
474
-	 * 	[
475
-	 * 		'filename' => [
476
-	 * 			'expected' => 'expectedSHA512',
477
-	 * 			'current' => 'currentSHA512',
478
-	 * 		],
479
-	 * 	],
480
-	 * 	'INVALID_HASH' =>
481
-	 * 	[
482
-	 * 		'filename' => [
483
-	 * 			'expected' => 'expectedSHA512',
484
-	 * 			'current' => 'currentSHA512',
485
-	 * 		],
486
-	 * 	],
487
-	 * ]
488
-	 *
489
-	 * Array may be empty in case no problems have been found.
490
-	 *
491
-	 * @param string $appId
492
-	 * @param string $path Optional path. If none is given it will be guessed.
493
-	 * @param bool $forceVerify
494
-	 * @return array
495
-	 */
496
-	public function verifyAppSignature(string $appId, string $path = '', bool $forceVerify = false): array {
497
-		try {
498
-			if ($path === '') {
499
-				$path = $this->appLocator->getAppPath($appId);
500
-			}
501
-			$result = $this->verify(
502
-					$path . '/appinfo/signature.json',
503
-					$path,
504
-					$appId,
505
-					$forceVerify
506
-			);
507
-		} catch (\Exception $e) {
508
-			$result = [
509
-				'EXCEPTION' => [
510
-					'class' => \get_class($e),
511
-					'message' => $e->getMessage(),
512
-				],
513
-			];
514
-		}
515
-		$this->storeResults($appId, $result);
516
-
517
-		return $result;
518
-	}
519
-
520
-	/**
521
-	 * Verify the signature of core. Returns an array with the following content:
522
-	 * [
523
-	 * 	'FILE_MISSING' =>
524
-	 * 	[
525
-	 * 		'filename' => [
526
-	 * 			'expected' => 'expectedSHA512',
527
-	 * 			'current' => 'currentSHA512',
528
-	 * 		],
529
-	 * 	],
530
-	 * 	'EXTRA_FILE' =>
531
-	 * 	[
532
-	 * 		'filename' => [
533
-	 * 			'expected' => 'expectedSHA512',
534
-	 * 			'current' => 'currentSHA512',
535
-	 * 		],
536
-	 * 	],
537
-	 * 	'INVALID_HASH' =>
538
-	 * 	[
539
-	 * 		'filename' => [
540
-	 * 			'expected' => 'expectedSHA512',
541
-	 * 			'current' => 'currentSHA512',
542
-	 * 		],
543
-	 * 	],
544
-	 * ]
545
-	 *
546
-	 * Array may be empty in case no problems have been found.
547
-	 *
548
-	 * @return array
549
-	 */
550
-	public function verifyCoreSignature(): array {
551
-		try {
552
-			$result = $this->verify(
553
-					$this->environmentHelper->getServerRoot() . '/core/signature.json',
554
-					$this->environmentHelper->getServerRoot(),
555
-					'core'
556
-			);
557
-		} catch (\Exception $e) {
558
-			$result = [
559
-				'EXCEPTION' => [
560
-					'class' => \get_class($e),
561
-					'message' => $e->getMessage(),
562
-				],
563
-			];
564
-		}
565
-		$this->storeResults('core', $result);
566
-
567
-		return $result;
568
-	}
569
-
570
-	/**
571
-	 * Verify the core code of the instance as well as all applicable applications
572
-	 * and store the results.
573
-	 */
574
-	public function runInstanceVerification() {
575
-		$this->cleanResults();
576
-		$this->verifyCoreSignature();
577
-		$appIds = $this->appLocator->getAllApps();
578
-		foreach ($appIds as $appId) {
579
-			// If an application is shipped a valid signature is required
580
-			$isShipped = $this->appManager->isShipped($appId);
581
-			$appNeedsToBeChecked = false;
582
-			if ($isShipped) {
583
-				$appNeedsToBeChecked = true;
584
-			} elseif ($this->fileAccessHelper->file_exists($this->appLocator->getAppPath($appId) . '/appinfo/signature.json')) {
585
-				// Otherwise only if the application explicitly ships a signature.json file
586
-				$appNeedsToBeChecked = true;
587
-			}
588
-
589
-			if ($appNeedsToBeChecked) {
590
-				$this->verifyAppSignature($appId);
591
-			}
592
-		}
593
-	}
61
+    public const CACHE_KEY = 'oc.integritycheck.checker';
62
+    /** @var EnvironmentHelper */
63
+    private $environmentHelper;
64
+    /** @var AppLocator */
65
+    private $appLocator;
66
+    /** @var FileAccessHelper */
67
+    private $fileAccessHelper;
68
+    /** @var IConfig|null */
69
+    private $config;
70
+    /** @var ICache */
71
+    private $cache;
72
+    /** @var IAppManager|null */
73
+    private $appManager;
74
+    /** @var IMimeTypeDetector */
75
+    private $mimeTypeDetector;
76
+
77
+    /**
78
+     * @param EnvironmentHelper $environmentHelper
79
+     * @param FileAccessHelper $fileAccessHelper
80
+     * @param AppLocator $appLocator
81
+     * @param IConfig|null $config
82
+     * @param ICacheFactory $cacheFactory
83
+     * @param IAppManager|null $appManager
84
+     * @param IMimeTypeDetector $mimeTypeDetector
85
+     */
86
+    public function __construct(EnvironmentHelper $environmentHelper,
87
+                                FileAccessHelper $fileAccessHelper,
88
+                                AppLocator $appLocator,
89
+                                ?IConfig $config,
90
+                                ICacheFactory $cacheFactory,
91
+                                ?IAppManager $appManager,
92
+                                IMimeTypeDetector $mimeTypeDetector) {
93
+        $this->environmentHelper = $environmentHelper;
94
+        $this->fileAccessHelper = $fileAccessHelper;
95
+        $this->appLocator = $appLocator;
96
+        $this->config = $config;
97
+        $this->cache = $cacheFactory->createDistributed(self::CACHE_KEY);
98
+        $this->appManager = $appManager;
99
+        $this->mimeTypeDetector = $mimeTypeDetector;
100
+    }
101
+
102
+    /**
103
+     * Whether code signing is enforced or not.
104
+     *
105
+     * @return bool
106
+     */
107
+    public function isCodeCheckEnforced(): bool {
108
+        $notSignedChannels = [ '', 'git'];
109
+        if (\in_array($this->environmentHelper->getChannel(), $notSignedChannels, true)) {
110
+            return false;
111
+        }
112
+
113
+        /**
114
+         * This config option is undocumented and supposed to be so, it's only
115
+         * applicable for very specific scenarios and we should not advertise it
116
+         * too prominent. So please do not add it to config.sample.php.
117
+         */
118
+        $isIntegrityCheckDisabled = false;
119
+        if ($this->config !== null) {
120
+            $isIntegrityCheckDisabled = $this->config->getSystemValue('integrity.check.disabled', false);
121
+        }
122
+        if ($isIntegrityCheckDisabled === true) {
123
+            return false;
124
+        }
125
+
126
+        return true;
127
+    }
128
+
129
+    /**
130
+     * Enumerates all files belonging to the folder. Sensible defaults are excluded.
131
+     *
132
+     * @param string $folderToIterate
133
+     * @param string $root
134
+     * @return \RecursiveIteratorIterator
135
+     * @throws \Exception
136
+     */
137
+    private function getFolderIterator(string $folderToIterate, string $root = ''): \RecursiveIteratorIterator {
138
+        $dirItr = new \RecursiveDirectoryIterator(
139
+            $folderToIterate,
140
+            \RecursiveDirectoryIterator::SKIP_DOTS
141
+        );
142
+        if ($root === '') {
143
+            $root = \OC::$SERVERROOT;
144
+        }
145
+        $root = rtrim($root, '/');
146
+
147
+        $excludeGenericFilesIterator = new ExcludeFileByNameFilterIterator($dirItr);
148
+        $excludeFoldersIterator = new ExcludeFoldersByPathFilterIterator($excludeGenericFilesIterator, $root);
149
+
150
+        return new \RecursiveIteratorIterator(
151
+            $excludeFoldersIterator,
152
+            \RecursiveIteratorIterator::SELF_FIRST
153
+        );
154
+    }
155
+
156
+    /**
157
+     * Returns an array of ['filename' => 'SHA512-hash-of-file'] for all files found
158
+     * in the iterator.
159
+     *
160
+     * @param \RecursiveIteratorIterator $iterator
161
+     * @param string $path
162
+     * @return array Array of hashes.
163
+     */
164
+    private function generateHashes(\RecursiveIteratorIterator $iterator,
165
+                                    string $path): array {
166
+        $hashes = [];
167
+
168
+        $baseDirectoryLength = \strlen($path);
169
+        foreach ($iterator as $filename => $data) {
170
+            /** @var \DirectoryIterator $data */
171
+            if ($data->isDir()) {
172
+                continue;
173
+            }
174
+
175
+            $relativeFileName = substr($filename, $baseDirectoryLength);
176
+            $relativeFileName = ltrim($relativeFileName, '/');
177
+
178
+            // Exclude signature.json files in the appinfo and root folder
179
+            if ($relativeFileName === 'appinfo/signature.json') {
180
+                continue;
181
+            }
182
+            // Exclude signature.json files in the appinfo and core folder
183
+            if ($relativeFileName === 'core/signature.json') {
184
+                continue;
185
+            }
186
+
187
+            // The .htaccess file in the root folder of ownCloud can contain
188
+            // custom content after the installation due to the fact that dynamic
189
+            // content is written into it at installation time as well. This
190
+            // includes for example the 404 and 403 instructions.
191
+            // Thus we ignore everything below the first occurrence of
192
+            // "#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####" and have the
193
+            // hash generated based on this.
194
+            if ($filename === $this->environmentHelper->getServerRoot() . '/.htaccess') {
195
+                $fileContent = file_get_contents($filename);
196
+                $explodedArray = explode('#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####', $fileContent);
197
+                if (\count($explodedArray) === 2) {
198
+                    $hashes[$relativeFileName] = hash('sha512', $explodedArray[0]);
199
+                    continue;
200
+                }
201
+            }
202
+            if ($filename === $this->environmentHelper->getServerRoot() . '/core/js/mimetypelist.js') {
203
+                $oldMimetypeList = new GenerateMimetypeFileBuilder();
204
+                $newFile = $oldMimetypeList->generateFile($this->mimeTypeDetector->getAllAliases());
205
+                if ($newFile === file_get_contents($filename)) {
206
+                    $hashes[$relativeFileName] = hash('sha512', $oldMimetypeList->generateFile($this->mimeTypeDetector->getOnlyDefaultAliases()));
207
+                    continue;
208
+                }
209
+            }
210
+
211
+            $hashes[$relativeFileName] = hash_file('sha512', $filename);
212
+        }
213
+
214
+        return $hashes;
215
+    }
216
+
217
+    /**
218
+     * Creates the signature data
219
+     *
220
+     * @param array $hashes
221
+     * @param X509 $certificate
222
+     * @param RSA $privateKey
223
+     * @return array
224
+     */
225
+    private function createSignatureData(array $hashes,
226
+                                            X509 $certificate,
227
+                                            RSA $privateKey): array {
228
+        ksort($hashes);
229
+
230
+        $privateKey->setSignatureMode(RSA::SIGNATURE_PSS);
231
+        $privateKey->setMGFHash('sha512');
232
+        // See https://tools.ietf.org/html/rfc3447#page-38
233
+        $privateKey->setSaltLength(0);
234
+        $signature = $privateKey->sign(json_encode($hashes));
235
+
236
+        return [
237
+            'hashes' => $hashes,
238
+            'signature' => base64_encode($signature),
239
+            'certificate' => $certificate->saveX509($certificate->currentCert),
240
+        ];
241
+    }
242
+
243
+    /**
244
+     * Write the signature of the app in the specified folder
245
+     *
246
+     * @param string $path
247
+     * @param X509 $certificate
248
+     * @param RSA $privateKey
249
+     * @throws \Exception
250
+     */
251
+    public function writeAppSignature($path,
252
+                                        X509 $certificate,
253
+                                        RSA $privateKey) {
254
+        $appInfoDir = $path . '/appinfo';
255
+        try {
256
+            $this->fileAccessHelper->assertDirectoryExists($appInfoDir);
257
+
258
+            $iterator = $this->getFolderIterator($path);
259
+            $hashes = $this->generateHashes($iterator, $path);
260
+            $signature = $this->createSignatureData($hashes, $certificate, $privateKey);
261
+            $this->fileAccessHelper->file_put_contents(
262
+                    $appInfoDir . '/signature.json',
263
+                json_encode($signature, JSON_PRETTY_PRINT)
264
+            );
265
+        } catch (\Exception $e) {
266
+            if (!$this->fileAccessHelper->is_writable($appInfoDir)) {
267
+                throw new \Exception($appInfoDir . ' is not writable');
268
+            }
269
+            throw $e;
270
+        }
271
+    }
272
+
273
+    /**
274
+     * Write the signature of core
275
+     *
276
+     * @param X509 $certificate
277
+     * @param RSA $rsa
278
+     * @param string $path
279
+     * @throws \Exception
280
+     */
281
+    public function writeCoreSignature(X509 $certificate,
282
+                                        RSA $rsa,
283
+                                        $path) {
284
+        $coreDir = $path . '/core';
285
+        try {
286
+            $this->fileAccessHelper->assertDirectoryExists($coreDir);
287
+            $iterator = $this->getFolderIterator($path, $path);
288
+            $hashes = $this->generateHashes($iterator, $path);
289
+            $signatureData = $this->createSignatureData($hashes, $certificate, $rsa);
290
+            $this->fileAccessHelper->file_put_contents(
291
+                $coreDir . '/signature.json',
292
+                json_encode($signatureData, JSON_PRETTY_PRINT)
293
+            );
294
+        } catch (\Exception $e) {
295
+            if (!$this->fileAccessHelper->is_writable($coreDir)) {
296
+                throw new \Exception($coreDir . ' is not writable');
297
+            }
298
+            throw $e;
299
+        }
300
+    }
301
+
302
+    /**
303
+     * Verifies the signature for the specified path.
304
+     *
305
+     * @param string $signaturePath
306
+     * @param string $basePath
307
+     * @param string $certificateCN
308
+     * @param bool $forceVerify
309
+     * @return array
310
+     * @throws InvalidSignatureException
311
+     * @throws \Exception
312
+     */
313
+    private function verify(string $signaturePath, string $basePath, string $certificateCN, bool $forceVerify = false): array {
314
+        if (!$forceVerify && !$this->isCodeCheckEnforced()) {
315
+            return [];
316
+        }
317
+
318
+        $content = $this->fileAccessHelper->file_get_contents($signaturePath);
319
+        $signatureData = null;
320
+
321
+        if (\is_string($content)) {
322
+            $signatureData = json_decode($content, true);
323
+        }
324
+        if (!\is_array($signatureData)) {
325
+            throw new InvalidSignatureException('Signature data not found.');
326
+        }
327
+
328
+        $expectedHashes = $signatureData['hashes'];
329
+        ksort($expectedHashes);
330
+        $signature = base64_decode($signatureData['signature']);
331
+        $certificate = $signatureData['certificate'];
332
+
333
+        // Check if certificate is signed by Nextcloud Root Authority
334
+        $x509 = new \phpseclib\File\X509();
335
+        $rootCertificatePublicKey = $this->fileAccessHelper->file_get_contents($this->environmentHelper->getServerRoot().'/resources/codesigning/root.crt');
336
+        $x509->loadCA($rootCertificatePublicKey);
337
+        $x509->loadX509($certificate);
338
+        if (!$x509->validateSignature()) {
339
+            throw new InvalidSignatureException('Certificate is not valid.');
340
+        }
341
+        // Verify if certificate has proper CN. "core" CN is always trusted.
342
+        if ($x509->getDN(X509::DN_OPENSSL)['CN'] !== $certificateCN && $x509->getDN(X509::DN_OPENSSL)['CN'] !== 'core') {
343
+            throw new InvalidSignatureException(
344
+                    sprintf('Certificate is not valid for required scope. (Requested: %s, current: CN=%s)', $certificateCN, $x509->getDN(true)['CN'])
345
+            );
346
+        }
347
+
348
+        // Check if the signature of the files is valid
349
+        $rsa = new \phpseclib\Crypt\RSA();
350
+        $rsa->loadKey($x509->currentCert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey']);
351
+        $rsa->setSignatureMode(RSA::SIGNATURE_PSS);
352
+        $rsa->setMGFHash('sha512');
353
+        // See https://tools.ietf.org/html/rfc3447#page-38
354
+        $rsa->setSaltLength(0);
355
+        if (!$rsa->verify(json_encode($expectedHashes), $signature)) {
356
+            throw new InvalidSignatureException('Signature could not get verified.');
357
+        }
358
+
359
+        // Fixes for the updater as shipped with ownCloud 9.0.x: The updater is
360
+        // replaced after the code integrity check is performed.
361
+        //
362
+        // Due to this reason we exclude the whole updater/ folder from the code
363
+        // integrity check.
364
+        if ($basePath === $this->environmentHelper->getServerRoot()) {
365
+            foreach ($expectedHashes as $fileName => $hash) {
366
+                if (strpos($fileName, 'updater/') === 0) {
367
+                    unset($expectedHashes[$fileName]);
368
+                }
369
+            }
370
+        }
371
+
372
+        // Compare the list of files which are not identical
373
+        $currentInstanceHashes = $this->generateHashes($this->getFolderIterator($basePath), $basePath);
374
+        $differencesA = array_diff($expectedHashes, $currentInstanceHashes);
375
+        $differencesB = array_diff($currentInstanceHashes, $expectedHashes);
376
+        $differences = array_unique(array_merge($differencesA, $differencesB));
377
+        $differenceArray = [];
378
+        foreach ($differences as $filename => $hash) {
379
+            // Check if file should not exist in the new signature table
380
+            if (!array_key_exists($filename, $expectedHashes)) {
381
+                $differenceArray['EXTRA_FILE'][$filename]['expected'] = '';
382
+                $differenceArray['EXTRA_FILE'][$filename]['current'] = $hash;
383
+                continue;
384
+            }
385
+
386
+            // Check if file is missing
387
+            if (!array_key_exists($filename, $currentInstanceHashes)) {
388
+                $differenceArray['FILE_MISSING'][$filename]['expected'] = $expectedHashes[$filename];
389
+                $differenceArray['FILE_MISSING'][$filename]['current'] = '';
390
+                continue;
391
+            }
392
+
393
+            // Check if hash does mismatch
394
+            if ($expectedHashes[$filename] !== $currentInstanceHashes[$filename]) {
395
+                $differenceArray['INVALID_HASH'][$filename]['expected'] = $expectedHashes[$filename];
396
+                $differenceArray['INVALID_HASH'][$filename]['current'] = $currentInstanceHashes[$filename];
397
+                continue;
398
+            }
399
+
400
+            // Should never happen.
401
+            throw new \Exception('Invalid behaviour in file hash comparison experienced. Please report this error to the developers.');
402
+        }
403
+
404
+        return $differenceArray;
405
+    }
406
+
407
+    /**
408
+     * Whether the code integrity check has passed successful or not
409
+     *
410
+     * @return bool
411
+     */
412
+    public function hasPassedCheck(): bool {
413
+        $results = $this->getResults();
414
+        if (empty($results)) {
415
+            return true;
416
+        }
417
+
418
+        return false;
419
+    }
420
+
421
+    /**
422
+     * @return array
423
+     */
424
+    public function getResults(): array {
425
+        $cachedResults = $this->cache->get(self::CACHE_KEY);
426
+        if (!\is_null($cachedResults)) {
427
+            return json_decode($cachedResults, true);
428
+        }
429
+
430
+        if ($this->config !== null) {
431
+            return json_decode($this->config->getAppValue('core', self::CACHE_KEY, '{}'), true);
432
+        }
433
+        return [];
434
+    }
435
+
436
+    /**
437
+     * Stores the results in the app config as well as cache
438
+     *
439
+     * @param string $scope
440
+     * @param array $result
441
+     */
442
+    private function storeResults(string $scope, array $result) {
443
+        $resultArray = $this->getResults();
444
+        unset($resultArray[$scope]);
445
+        if (!empty($result)) {
446
+            $resultArray[$scope] = $result;
447
+        }
448
+        if ($this->config !== null) {
449
+            $this->config->setAppValue('core', self::CACHE_KEY, json_encode($resultArray));
450
+        }
451
+        $this->cache->set(self::CACHE_KEY, json_encode($resultArray));
452
+    }
453
+
454
+    /**
455
+     *
456
+     * Clean previous results for a proper rescanning. Otherwise
457
+     */
458
+    private function cleanResults() {
459
+        $this->config->deleteAppValue('core', self::CACHE_KEY);
460
+        $this->cache->remove(self::CACHE_KEY);
461
+    }
462
+
463
+    /**
464
+     * Verify the signature of $appId. Returns an array with the following content:
465
+     * [
466
+     * 	'FILE_MISSING' =>
467
+     * 	[
468
+     * 		'filename' => [
469
+     * 			'expected' => 'expectedSHA512',
470
+     * 			'current' => 'currentSHA512',
471
+     * 		],
472
+     * 	],
473
+     * 	'EXTRA_FILE' =>
474
+     * 	[
475
+     * 		'filename' => [
476
+     * 			'expected' => 'expectedSHA512',
477
+     * 			'current' => 'currentSHA512',
478
+     * 		],
479
+     * 	],
480
+     * 	'INVALID_HASH' =>
481
+     * 	[
482
+     * 		'filename' => [
483
+     * 			'expected' => 'expectedSHA512',
484
+     * 			'current' => 'currentSHA512',
485
+     * 		],
486
+     * 	],
487
+     * ]
488
+     *
489
+     * Array may be empty in case no problems have been found.
490
+     *
491
+     * @param string $appId
492
+     * @param string $path Optional path. If none is given it will be guessed.
493
+     * @param bool $forceVerify
494
+     * @return array
495
+     */
496
+    public function verifyAppSignature(string $appId, string $path = '', bool $forceVerify = false): array {
497
+        try {
498
+            if ($path === '') {
499
+                $path = $this->appLocator->getAppPath($appId);
500
+            }
501
+            $result = $this->verify(
502
+                    $path . '/appinfo/signature.json',
503
+                    $path,
504
+                    $appId,
505
+                    $forceVerify
506
+            );
507
+        } catch (\Exception $e) {
508
+            $result = [
509
+                'EXCEPTION' => [
510
+                    'class' => \get_class($e),
511
+                    'message' => $e->getMessage(),
512
+                ],
513
+            ];
514
+        }
515
+        $this->storeResults($appId, $result);
516
+
517
+        return $result;
518
+    }
519
+
520
+    /**
521
+     * Verify the signature of core. Returns an array with the following content:
522
+     * [
523
+     * 	'FILE_MISSING' =>
524
+     * 	[
525
+     * 		'filename' => [
526
+     * 			'expected' => 'expectedSHA512',
527
+     * 			'current' => 'currentSHA512',
528
+     * 		],
529
+     * 	],
530
+     * 	'EXTRA_FILE' =>
531
+     * 	[
532
+     * 		'filename' => [
533
+     * 			'expected' => 'expectedSHA512',
534
+     * 			'current' => 'currentSHA512',
535
+     * 		],
536
+     * 	],
537
+     * 	'INVALID_HASH' =>
538
+     * 	[
539
+     * 		'filename' => [
540
+     * 			'expected' => 'expectedSHA512',
541
+     * 			'current' => 'currentSHA512',
542
+     * 		],
543
+     * 	],
544
+     * ]
545
+     *
546
+     * Array may be empty in case no problems have been found.
547
+     *
548
+     * @return array
549
+     */
550
+    public function verifyCoreSignature(): array {
551
+        try {
552
+            $result = $this->verify(
553
+                    $this->environmentHelper->getServerRoot() . '/core/signature.json',
554
+                    $this->environmentHelper->getServerRoot(),
555
+                    'core'
556
+            );
557
+        } catch (\Exception $e) {
558
+            $result = [
559
+                'EXCEPTION' => [
560
+                    'class' => \get_class($e),
561
+                    'message' => $e->getMessage(),
562
+                ],
563
+            ];
564
+        }
565
+        $this->storeResults('core', $result);
566
+
567
+        return $result;
568
+    }
569
+
570
+    /**
571
+     * Verify the core code of the instance as well as all applicable applications
572
+     * and store the results.
573
+     */
574
+    public function runInstanceVerification() {
575
+        $this->cleanResults();
576
+        $this->verifyCoreSignature();
577
+        $appIds = $this->appLocator->getAllApps();
578
+        foreach ($appIds as $appId) {
579
+            // If an application is shipped a valid signature is required
580
+            $isShipped = $this->appManager->isShipped($appId);
581
+            $appNeedsToBeChecked = false;
582
+            if ($isShipped) {
583
+                $appNeedsToBeChecked = true;
584
+            } elseif ($this->fileAccessHelper->file_exists($this->appLocator->getAppPath($appId) . '/appinfo/signature.json')) {
585
+                // Otherwise only if the application explicitly ships a signature.json file
586
+                $appNeedsToBeChecked = true;
587
+            }
588
+
589
+            if ($appNeedsToBeChecked) {
590
+                $this->verifyAppSignature($appId);
591
+            }
592
+        }
593
+    }
594 594
 }
Please login to merge, or discard this patch.
lib/private/Server.php 1 patch
Indentation   +2031 added lines, -2031 removed lines patch added patch discarded remove patch
@@ -250,2040 +250,2040 @@
 block discarded – undo
250 250
  */
251 251
 class Server extends ServerContainer implements IServerContainer {
252 252
 
253
-	/** @var string */
254
-	private $webRoot;
255
-
256
-	/**
257
-	 * @param string $webRoot
258
-	 * @param \OC\Config $config
259
-	 */
260
-	public function __construct($webRoot, \OC\Config $config) {
261
-		parent::__construct();
262
-		$this->webRoot = $webRoot;
263
-
264
-		// To find out if we are running from CLI or not
265
-		$this->registerParameter('isCLI', \OC::$CLI);
266
-		$this->registerParameter('serverRoot', \OC::$SERVERROOT);
267
-
268
-		$this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
269
-			return $c;
270
-		});
271
-		$this->registerService(\OCP\IServerContainer::class, function (ContainerInterface $c) {
272
-			return $c;
273
-		});
274
-
275
-		$this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
276
-		/** @deprecated 19.0.0 */
277
-		$this->registerDeprecatedAlias('CalendarManager', \OC\Calendar\Manager::class);
278
-
279
-		$this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class);
280
-		/** @deprecated 19.0.0 */
281
-		$this->registerDeprecatedAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class);
282
-
283
-		$this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class);
284
-		/** @deprecated 19.0.0 */
285
-		$this->registerDeprecatedAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class);
286
-
287
-		$this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
288
-		/** @deprecated 19.0.0 */
289
-		$this->registerDeprecatedAlias('ContactsManager', \OCP\Contacts\IManager::class);
290
-
291
-		$this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class);
292
-
293
-		$this->registerAlias(IActionFactory::class, ActionFactory::class);
294
-
295
-		$this->registerService(View::class, function (Server $c) {
296
-			return new View();
297
-		}, false);
298
-
299
-		$this->registerService(IPreview::class, function (ContainerInterface $c) {
300
-			return new PreviewManager(
301
-				$c->get(\OCP\IConfig::class),
302
-				$c->get(IRootFolder::class),
303
-				new \OC\Preview\Storage\Root(
304
-					$c->get(IRootFolder::class),
305
-					$c->get(SystemConfig::class)
306
-				),
307
-				$c->get(SymfonyAdapter::class),
308
-				$c->get(GeneratorHelper::class),
309
-				$c->get(ISession::class)->get('user_id')
310
-			);
311
-		});
312
-		/** @deprecated 19.0.0 */
313
-		$this->registerDeprecatedAlias('PreviewManager', IPreview::class);
314
-
315
-		$this->registerService(\OC\Preview\Watcher::class, function (ContainerInterface $c) {
316
-			return new \OC\Preview\Watcher(
317
-				new \OC\Preview\Storage\Root(
318
-					$c->get(IRootFolder::class),
319
-					$c->get(SystemConfig::class)
320
-				)
321
-			);
322
-		});
323
-
324
-		$this->registerService(\OCP\Encryption\IManager::class, function (Server $c) {
325
-			$view = new View();
326
-			$util = new Encryption\Util(
327
-				$view,
328
-				$c->get(IUserManager::class),
329
-				$c->get(IGroupManager::class),
330
-				$c->get(\OCP\IConfig::class)
331
-			);
332
-			return new Encryption\Manager(
333
-				$c->get(\OCP\IConfig::class),
334
-				$c->get(ILogger::class),
335
-				$c->getL10N('core'),
336
-				new View(),
337
-				$util,
338
-				new ArrayCache()
339
-			);
340
-		});
341
-		/** @deprecated 19.0.0 */
342
-		$this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class);
343
-
344
-		/** @deprecated 21.0.0 */
345
-		$this->registerDeprecatedAlias('EncryptionFileHelper', IFile::class);
346
-		$this->registerService(IFile::class, function (ContainerInterface $c) {
347
-			$util = new Encryption\Util(
348
-				new View(),
349
-				$c->get(IUserManager::class),
350
-				$c->get(IGroupManager::class),
351
-				$c->get(\OCP\IConfig::class)
352
-			);
353
-			return new Encryption\File(
354
-				$util,
355
-				$c->get(IRootFolder::class),
356
-				$c->get(\OCP\Share\IManager::class)
357
-			);
358
-		});
359
-
360
-		/** @deprecated 21.0.0 */
361
-		$this->registerDeprecatedAlias('EncryptionKeyStorage', IStorage::class);
362
-		$this->registerService(IStorage::class, function (ContainerInterface $c) {
363
-			$view = new View();
364
-			$util = new Encryption\Util(
365
-				$view,
366
-				$c->get(IUserManager::class),
367
-				$c->get(IGroupManager::class),
368
-				$c->get(\OCP\IConfig::class)
369
-			);
370
-
371
-			return new Encryption\Keys\Storage(
372
-				$view,
373
-				$util,
374
-				$c->get(ICrypto::class),
375
-				$c->get(\OCP\IConfig::class)
376
-			);
377
-		});
378
-		/** @deprecated 20.0.0 */
379
-		$this->registerDeprecatedAlias('TagMapper', TagMapper::class);
380
-
381
-		$this->registerAlias(\OCP\ITagManager::class, TagManager::class);
382
-		/** @deprecated 19.0.0 */
383
-		$this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class);
384
-
385
-		$this->registerService('SystemTagManagerFactory', function (ContainerInterface $c) {
386
-			/** @var \OCP\IConfig $config */
387
-			$config = $c->get(\OCP\IConfig::class);
388
-			$factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
389
-			return new $factoryClass($this);
390
-		});
391
-		$this->registerService(ISystemTagManager::class, function (ContainerInterface $c) {
392
-			return $c->get('SystemTagManagerFactory')->getManager();
393
-		});
394
-		/** @deprecated 19.0.0 */
395
-		$this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class);
396
-
397
-		$this->registerService(ISystemTagObjectMapper::class, function (ContainerInterface $c) {
398
-			return $c->get('SystemTagManagerFactory')->getObjectMapper();
399
-		});
400
-		$this->registerService('RootFolder', function (ContainerInterface $c) {
401
-			$manager = \OC\Files\Filesystem::getMountManager(null);
402
-			$view = new View();
403
-			$root = new Root(
404
-				$manager,
405
-				$view,
406
-				null,
407
-				$c->get(IUserMountCache::class),
408
-				$this->get(ILogger::class),
409
-				$this->get(IUserManager::class)
410
-			);
411
-
412
-			$previewConnector = new \OC\Preview\WatcherConnector(
413
-				$root,
414
-				$c->get(SystemConfig::class)
415
-			);
416
-			$previewConnector->connectWatcher();
417
-
418
-			return $root;
419
-		});
420
-		$this->registerService(HookConnector::class, function (ContainerInterface $c) {
421
-			return new HookConnector(
422
-				$c->get(IRootFolder::class),
423
-				new View(),
424
-				$c->get(\OC\EventDispatcher\SymfonyAdapter::class),
425
-				$c->get(IEventDispatcher::class)
426
-			);
427
-		});
428
-
429
-		/** @deprecated 19.0.0 */
430
-		$this->registerDeprecatedAlias('SystemTagObjectMapper', ISystemTagObjectMapper::class);
431
-
432
-		$this->registerService(IRootFolder::class, function (ContainerInterface $c) {
433
-			return new LazyRoot(function () use ($c) {
434
-				return $c->get('RootFolder');
435
-			});
436
-		});
437
-		/** @deprecated 19.0.0 */
438
-		$this->registerDeprecatedAlias('LazyRootFolder', IRootFolder::class);
439
-
440
-		/** @deprecated 19.0.0 */
441
-		$this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class);
442
-		$this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
443
-
444
-		$this->registerService(\OCP\IGroupManager::class, function (ContainerInterface $c) {
445
-			$groupManager = new \OC\Group\Manager($this->get(IUserManager::class), $c->get(SymfonyAdapter::class), $this->get(ILogger::class));
446
-			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
447
-				/** @var IEventDispatcher $dispatcher */
448
-				$dispatcher = $this->get(IEventDispatcher::class);
449
-				$dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid));
450
-			});
451
-			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) {
452
-				/** @var IEventDispatcher $dispatcher */
453
-				$dispatcher = $this->get(IEventDispatcher::class);
454
-				$dispatcher->dispatchTyped(new GroupCreatedEvent($group));
455
-			});
456
-			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
457
-				/** @var IEventDispatcher $dispatcher */
458
-				$dispatcher = $this->get(IEventDispatcher::class);
459
-				$dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group));
460
-			});
461
-			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
462
-				/** @var IEventDispatcher $dispatcher */
463
-				$dispatcher = $this->get(IEventDispatcher::class);
464
-				$dispatcher->dispatchTyped(new GroupDeletedEvent($group));
465
-			});
466
-			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
467
-				/** @var IEventDispatcher $dispatcher */
468
-				$dispatcher = $this->get(IEventDispatcher::class);
469
-				$dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user));
470
-			});
471
-			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
472
-				/** @var IEventDispatcher $dispatcher */
473
-				$dispatcher = $this->get(IEventDispatcher::class);
474
-				$dispatcher->dispatchTyped(new UserAddedEvent($group, $user));
475
-			});
476
-			$groupManager->listen('\OC\Group', 'preRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
477
-				/** @var IEventDispatcher $dispatcher */
478
-				$dispatcher = $this->get(IEventDispatcher::class);
479
-				$dispatcher->dispatchTyped(new BeforeUserRemovedEvent($group, $user));
480
-			});
481
-			$groupManager->listen('\OC\Group', 'postRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
482
-				/** @var IEventDispatcher $dispatcher */
483
-				$dispatcher = $this->get(IEventDispatcher::class);
484
-				$dispatcher->dispatchTyped(new UserRemovedEvent($group, $user));
485
-			});
486
-			return $groupManager;
487
-		});
488
-		/** @deprecated 19.0.0 */
489
-		$this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class);
490
-
491
-		$this->registerService(Store::class, function (ContainerInterface $c) {
492
-			$session = $c->get(ISession::class);
493
-			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
494
-				$tokenProvider = $c->get(IProvider::class);
495
-			} else {
496
-				$tokenProvider = null;
497
-			}
498
-			$logger = $c->get(LoggerInterface::class);
499
-			return new Store($session, $logger, $tokenProvider);
500
-		});
501
-		$this->registerAlias(IStore::class, Store::class);
502
-		$this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
503
-
504
-		$this->registerService(\OC\User\Session::class, function (Server $c) {
505
-			$manager = $c->get(IUserManager::class);
506
-			$session = new \OC\Session\Memory('');
507
-			$timeFactory = new TimeFactory();
508
-			// Token providers might require a working database. This code
509
-			// might however be called when ownCloud is not yet setup.
510
-			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
511
-				$defaultTokenProvider = $c->get(IProvider::class);
512
-			} else {
513
-				$defaultTokenProvider = null;
514
-			}
515
-
516
-			$legacyDispatcher = $c->get(SymfonyAdapter::class);
517
-
518
-			$userSession = new \OC\User\Session(
519
-				$manager,
520
-				$session,
521
-				$timeFactory,
522
-				$defaultTokenProvider,
523
-				$c->get(\OCP\IConfig::class),
524
-				$c->get(ISecureRandom::class),
525
-				$c->getLockdownManager(),
526
-				$c->get(ILogger::class),
527
-				$c->get(IEventDispatcher::class)
528
-			);
529
-			/** @deprecated 21.0.0 use BeforeUserCreatedEvent event with the IEventDispatcher instead */
530
-			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
531
-				\OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]);
532
-			});
533
-			/** @deprecated 21.0.0 use UserCreatedEvent event with the IEventDispatcher instead */
534
-			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
535
-				/** @var \OC\User\User $user */
536
-				\OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]);
537
-			});
538
-			/** @deprecated 21.0.0 use BeforeUserDeletedEvent event with the IEventDispatcher instead */
539
-			$userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) {
540
-				/** @var \OC\User\User $user */
541
-				\OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]);
542
-				$legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user));
543
-			});
544
-			/** @deprecated 21.0.0 use UserDeletedEvent event with the IEventDispatcher instead */
545
-			$userSession->listen('\OC\User', 'postDelete', function ($user) {
546
-				/** @var \OC\User\User $user */
547
-				\OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]);
548
-			});
549
-			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
550
-				/** @var \OC\User\User $user */
551
-				\OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
552
-
553
-				/** @var IEventDispatcher $dispatcher */
554
-				$dispatcher = $this->get(IEventDispatcher::class);
555
-				$dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword));
556
-			});
557
-			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
558
-				/** @var \OC\User\User $user */
559
-				\OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
560
-
561
-				/** @var IEventDispatcher $dispatcher */
562
-				$dispatcher = $this->get(IEventDispatcher::class);
563
-				$dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword));
564
-			});
565
-			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
566
-				\OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]);
567
-
568
-				/** @var IEventDispatcher $dispatcher */
569
-				$dispatcher = $this->get(IEventDispatcher::class);
570
-				$dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
571
-			});
572
-			$userSession->listen('\OC\User', 'postLogin', function ($user, $loginName, $password, $isTokenLogin) {
573
-				/** @var \OC\User\User $user */
574
-				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'loginName' => $loginName, 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
575
-
576
-				/** @var IEventDispatcher $dispatcher */
577
-				$dispatcher = $this->get(IEventDispatcher::class);
578
-				$dispatcher->dispatchTyped(new UserLoggedInEvent($user, $password, $isTokenLogin));
579
-			});
580
-			$userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
581
-				/** @var IEventDispatcher $dispatcher */
582
-				$dispatcher = $this->get(IEventDispatcher::class);
583
-				$dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
584
-			});
585
-			$userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
586
-				/** @var \OC\User\User $user */
587
-				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]);
588
-
589
-				/** @var IEventDispatcher $dispatcher */
590
-				$dispatcher = $this->get(IEventDispatcher::class);
591
-				$dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
592
-			});
593
-			$userSession->listen('\OC\User', 'logout', function ($user) {
594
-				\OC_Hook::emit('OC_User', 'logout', []);
595
-
596
-				/** @var IEventDispatcher $dispatcher */
597
-				$dispatcher = $this->get(IEventDispatcher::class);
598
-				$dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
599
-			});
600
-			$userSession->listen('\OC\User', 'postLogout', function ($user) {
601
-				/** @var IEventDispatcher $dispatcher */
602
-				$dispatcher = $this->get(IEventDispatcher::class);
603
-				$dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
604
-			});
605
-			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
606
-				/** @var \OC\User\User $user */
607
-				\OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]);
608
-
609
-				/** @var IEventDispatcher $dispatcher */
610
-				$dispatcher = $this->get(IEventDispatcher::class);
611
-				$dispatcher->dispatchTyped(new UserChangedEvent($user, $feature, $value, $oldValue));
612
-			});
613
-			return $userSession;
614
-		});
615
-		$this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class);
616
-		/** @deprecated 19.0.0 */
617
-		$this->registerDeprecatedAlias('UserSession', \OC\User\Session::class);
618
-
619
-		$this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class);
620
-
621
-		$this->registerAlias(INavigationManager::class, \OC\NavigationManager::class);
622
-		/** @deprecated 19.0.0 */
623
-		$this->registerDeprecatedAlias('NavigationManager', INavigationManager::class);
624
-
625
-		/** @deprecated 19.0.0 */
626
-		$this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class);
627
-		$this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
628
-
629
-		$this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
630
-			return new \OC\SystemConfig($config);
631
-		});
632
-		/** @deprecated 19.0.0 */
633
-		$this->registerDeprecatedAlias('SystemConfig', \OC\SystemConfig::class);
634
-
635
-		/** @deprecated 19.0.0 */
636
-		$this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class);
637
-		$this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
638
-
639
-		$this->registerService(IFactory::class, function (Server $c) {
640
-			return new \OC\L10N\Factory(
641
-				$c->get(\OCP\IConfig::class),
642
-				$c->getRequest(),
643
-				$c->get(IUserSession::class),
644
-				\OC::$SERVERROOT
645
-			);
646
-		});
647
-		/** @deprecated 19.0.0 */
648
-		$this->registerDeprecatedAlias('L10NFactory', IFactory::class);
649
-
650
-		$this->registerAlias(IURLGenerator::class, URLGenerator::class);
651
-		/** @deprecated 19.0.0 */
652
-		$this->registerDeprecatedAlias('URLGenerator', IURLGenerator::class);
653
-
654
-		/** @deprecated 19.0.0 */
655
-		$this->registerDeprecatedAlias('AppFetcher', AppFetcher::class);
656
-		/** @deprecated 19.0.0 */
657
-		$this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class);
658
-
659
-		$this->registerService(ICache::class, function ($c) {
660
-			return new Cache\File();
661
-		});
662
-		/** @deprecated 19.0.0 */
663
-		$this->registerDeprecatedAlias('UserCache', ICache::class);
664
-
665
-		$this->registerService(Factory::class, function (Server $c) {
666
-			$arrayCacheFactory = new \OC\Memcache\Factory('', $c->get(ILogger::class),
667
-				ArrayCache::class,
668
-				ArrayCache::class,
669
-				ArrayCache::class
670
-			);
671
-			/** @var \OCP\IConfig $config */
672
-			$config = $c->get(\OCP\IConfig::class);
673
-
674
-			if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
675
-				$v = \OC_App::getAppVersions();
676
-				$v['core'] = implode(',', \OC_Util::getVersion());
677
-				$version = implode(',', $v);
678
-				$instanceId = \OC_Util::getInstanceId();
679
-				$path = \OC::$SERVERROOT;
680
-				$prefix = md5($instanceId . '-' . $version . '-' . $path);
681
-				return new \OC\Memcache\Factory($prefix, $c->get(ILogger::class),
682
-					$config->getSystemValue('memcache.local', null),
683
-					$config->getSystemValue('memcache.distributed', null),
684
-					$config->getSystemValue('memcache.locking', null)
685
-				);
686
-			}
687
-			return $arrayCacheFactory;
688
-		});
689
-		/** @deprecated 19.0.0 */
690
-		$this->registerDeprecatedAlias('MemCacheFactory', Factory::class);
691
-		$this->registerAlias(ICacheFactory::class, Factory::class);
692
-
693
-		$this->registerService('RedisFactory', function (Server $c) {
694
-			$systemConfig = $c->get(SystemConfig::class);
695
-			return new RedisFactory($systemConfig);
696
-		});
697
-
698
-		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
699
-			$l10n = $this->get(IFactory::class)->get('lib');
700
-			return new \OC\Activity\Manager(
701
-				$c->getRequest(),
702
-				$c->get(IUserSession::class),
703
-				$c->get(\OCP\IConfig::class),
704
-				$c->get(IValidator::class),
705
-				$l10n
706
-			);
707
-		});
708
-		/** @deprecated 19.0.0 */
709
-		$this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class);
710
-
711
-		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
712
-			return new \OC\Activity\EventMerger(
713
-				$c->getL10N('lib')
714
-			);
715
-		});
716
-		$this->registerAlias(IValidator::class, Validator::class);
717
-
718
-		$this->registerService(AvatarManager::class, function (Server $c) {
719
-			return new AvatarManager(
720
-				$c->get(\OC\User\Manager::class),
721
-				$c->getAppDataDir('avatar'),
722
-				$c->getL10N('lib'),
723
-				$c->get(ILogger::class),
724
-				$c->get(\OCP\IConfig::class)
725
-			);
726
-		});
727
-		$this->registerAlias(IAvatarManager::class, AvatarManager::class);
728
-		/** @deprecated 19.0.0 */
729
-		$this->registerDeprecatedAlias('AvatarManager', AvatarManager::class);
730
-
731
-		$this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
732
-		$this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
733
-
734
-		$this->registerService(\OC\Log::class, function (Server $c) {
735
-			$logType = $c->get(AllConfig::class)->getSystemValue('log_type', 'file');
736
-			$factory = new LogFactory($c, $this->get(SystemConfig::class));
737
-			$logger = $factory->get($logType);
738
-			$registry = $c->get(\OCP\Support\CrashReport\IRegistry::class);
739
-
740
-			return new Log($logger, $this->get(SystemConfig::class), null, $registry);
741
-		});
742
-		$this->registerAlias(ILogger::class, \OC\Log::class);
743
-		/** @deprecated 19.0.0 */
744
-		$this->registerDeprecatedAlias('Logger', \OC\Log::class);
745
-		// PSR-3 logger
746
-		$this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class);
747
-
748
-		$this->registerService(ILogFactory::class, function (Server $c) {
749
-			return new LogFactory($c, $this->get(SystemConfig::class));
750
-		});
751
-
752
-		$this->registerAlias(IJobList::class, \OC\BackgroundJob\JobList::class);
753
-		/** @deprecated 19.0.0 */
754
-		$this->registerDeprecatedAlias('JobList', IJobList::class);
755
-
756
-		$this->registerService(Router::class, function (Server $c) {
757
-			$cacheFactory = $c->get(ICacheFactory::class);
758
-			$logger = $c->get(ILogger::class);
759
-			if ($cacheFactory->isLocalCacheAvailable()) {
760
-				$router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger);
761
-			} else {
762
-				$router = new \OC\Route\Router($logger);
763
-			}
764
-			return $router;
765
-		});
766
-		$this->registerAlias(IRouter::class, Router::class);
767
-		/** @deprecated 19.0.0 */
768
-		$this->registerDeprecatedAlias('Router', IRouter::class);
769
-
770
-		$this->registerAlias(ISearch::class, Search::class);
771
-		/** @deprecated 19.0.0 */
772
-		$this->registerDeprecatedAlias('Search', ISearch::class);
773
-
774
-		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
775
-			return new \OC\Security\RateLimiting\Backend\MemoryCache(
776
-				$this->get(ICacheFactory::class),
777
-				new \OC\AppFramework\Utility\TimeFactory()
778
-			);
779
-		});
780
-
781
-		$this->registerAlias(\OCP\Security\ISecureRandom::class, SecureRandom::class);
782
-		/** @deprecated 19.0.0 */
783
-		$this->registerDeprecatedAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
784
-
785
-		$this->registerAlias(ICrypto::class, Crypto::class);
786
-		/** @deprecated 19.0.0 */
787
-		$this->registerDeprecatedAlias('Crypto', ICrypto::class);
788
-
789
-		$this->registerAlias(IHasher::class, Hasher::class);
790
-		/** @deprecated 19.0.0 */
791
-		$this->registerDeprecatedAlias('Hasher', IHasher::class);
792
-
793
-		$this->registerAlias(ICredentialsManager::class, CredentialsManager::class);
794
-		/** @deprecated 19.0.0 */
795
-		$this->registerDeprecatedAlias('CredentialsManager', ICredentialsManager::class);
796
-
797
-		$this->registerAlias(IDBConnection::class, ConnectionAdapter::class);
798
-		$this->registerService(Connection::class, function (Server $c) {
799
-			$systemConfig = $c->get(SystemConfig::class);
800
-			$factory = new \OC\DB\ConnectionFactory($systemConfig);
801
-			$type = $systemConfig->getValue('dbtype', 'sqlite');
802
-			if (!$factory->isValidType($type)) {
803
-				throw new \OC\DatabaseException('Invalid database type');
804
-			}
805
-			$connectionParams = $factory->createConnectionParams();
806
-			$connection = $factory->getConnection($type, $connectionParams);
807
-			$connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
808
-			return $connection;
809
-		});
810
-		/** @deprecated 19.0.0 */
811
-		$this->registerDeprecatedAlias('DatabaseConnection', IDBConnection::class);
812
-
813
-		$this->registerAlias(ICertificateManager::class, CertificateManager::class);
814
-		$this->registerAlias(IClientService::class, ClientService::class);
815
-		$this->registerDeprecatedAlias('HttpClientService', IClientService::class);
816
-		$this->registerService(IEventLogger::class, function (ContainerInterface $c) {
817
-			$eventLogger = new EventLogger();
818
-			if ($c->get(SystemConfig::class)->getValue('debug', false)) {
819
-				// In debug mode, module is being activated by default
820
-				$eventLogger->activate();
821
-			}
822
-			return $eventLogger;
823
-		});
824
-		/** @deprecated 19.0.0 */
825
-		$this->registerDeprecatedAlias('EventLogger', IEventLogger::class);
826
-
827
-		$this->registerService(IQueryLogger::class, function (ContainerInterface $c) {
828
-			$queryLogger = new QueryLogger();
829
-			if ($c->get(SystemConfig::class)->getValue('debug', false)) {
830
-				// In debug mode, module is being activated by default
831
-				$queryLogger->activate();
832
-			}
833
-			return $queryLogger;
834
-		});
835
-		/** @deprecated 19.0.0 */
836
-		$this->registerDeprecatedAlias('QueryLogger', IQueryLogger::class);
837
-
838
-		/** @deprecated 19.0.0 */
839
-		$this->registerDeprecatedAlias('TempManager', TempManager::class);
840
-		$this->registerAlias(ITempManager::class, TempManager::class);
841
-
842
-		$this->registerService(AppManager::class, function (ContainerInterface $c) {
843
-			// TODO: use auto-wiring
844
-			return new \OC\App\AppManager(
845
-				$c->get(IUserSession::class),
846
-				$c->get(\OCP\IConfig::class),
847
-				$c->get(\OC\AppConfig::class),
848
-				$c->get(IGroupManager::class),
849
-				$c->get(ICacheFactory::class),
850
-				$c->get(SymfonyAdapter::class),
851
-				$c->get(ILogger::class)
852
-			);
853
-		});
854
-		/** @deprecated 19.0.0 */
855
-		$this->registerDeprecatedAlias('AppManager', AppManager::class);
856
-		$this->registerAlias(IAppManager::class, AppManager::class);
857
-
858
-		$this->registerAlias(IDateTimeZone::class, DateTimeZone::class);
859
-		/** @deprecated 19.0.0 */
860
-		$this->registerDeprecatedAlias('DateTimeZone', IDateTimeZone::class);
861
-
862
-		$this->registerService(IDateTimeFormatter::class, function (Server $c) {
863
-			$language = $c->get(\OCP\IConfig::class)->getUserValue($c->get(ISession::class)->get('user_id'), 'core', 'lang', null);
864
-
865
-			return new DateTimeFormatter(
866
-				$c->get(IDateTimeZone::class)->getTimeZone(),
867
-				$c->getL10N('lib', $language)
868
-			);
869
-		});
870
-		/** @deprecated 19.0.0 */
871
-		$this->registerDeprecatedAlias('DateTimeFormatter', IDateTimeFormatter::class);
872
-
873
-		$this->registerService(IUserMountCache::class, function (ContainerInterface $c) {
874
-			$mountCache = new UserMountCache(
875
-				$c->get(IDBConnection::class),
876
-				$c->get(IUserManager::class),
877
-				$c->get(ILogger::class)
878
-			);
879
-			$listener = new UserMountCacheListener($mountCache);
880
-			$listener->listen($c->get(IUserManager::class));
881
-			return $mountCache;
882
-		});
883
-		/** @deprecated 19.0.0 */
884
-		$this->registerDeprecatedAlias('UserMountCache', IUserMountCache::class);
885
-
886
-		$this->registerService(IMountProviderCollection::class, function (ContainerInterface $c) {
887
-			$loader = \OC\Files\Filesystem::getLoader();
888
-			$mountCache = $c->get(IUserMountCache::class);
889
-			$manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
890
-
891
-			// builtin providers
892
-
893
-			$config = $c->get(\OCP\IConfig::class);
894
-			$logger = $c->get(ILogger::class);
895
-			$manager->registerProvider(new CacheMountProvider($config));
896
-			$manager->registerHomeProvider(new LocalHomeMountProvider());
897
-			$manager->registerHomeProvider(new ObjectHomeMountProvider($config));
898
-			$manager->registerRootProvider(new ObjectStorePreviewCacheMountProvider($logger, $config));
899
-
900
-			return $manager;
901
-		});
902
-		/** @deprecated 19.0.0 */
903
-		$this->registerDeprecatedAlias('MountConfigManager', IMountProviderCollection::class);
904
-
905
-		/** @deprecated 20.0.0 */
906
-		$this->registerDeprecatedAlias('IniWrapper', IniGetWrapper::class);
907
-		$this->registerService(IBus::class, function (ContainerInterface $c) {
908
-			$busClass = $c->get(\OCP\IConfig::class)->getSystemValue('commandbus');
909
-			if ($busClass) {
910
-				[$app, $class] = explode('::', $busClass, 2);
911
-				if ($c->get(IAppManager::class)->isInstalled($app)) {
912
-					\OC_App::loadApp($app);
913
-					return $c->get($class);
914
-				} else {
915
-					throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
916
-				}
917
-			} else {
918
-				$jobList = $c->get(IJobList::class);
919
-				return new CronBus($jobList);
920
-			}
921
-		});
922
-		$this->registerDeprecatedAlias('AsyncCommandBus', IBus::class);
923
-		/** @deprecated 20.0.0 */
924
-		$this->registerDeprecatedAlias('TrustedDomainHelper', TrustedDomainHelper::class);
925
-		/** @deprecated 19.0.0 */
926
-		$this->registerDeprecatedAlias('Throttler', Throttler::class);
927
-		$this->registerService('IntegrityCodeChecker', function (ContainerInterface $c) {
928
-			// IConfig and IAppManager requires a working database. This code
929
-			// might however be called when ownCloud is not yet setup.
930
-			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
931
-				$config = $c->get(\OCP\IConfig::class);
932
-				$appManager = $c->get(IAppManager::class);
933
-			} else {
934
-				$config = null;
935
-				$appManager = null;
936
-			}
937
-
938
-			return new Checker(
939
-				new EnvironmentHelper(),
940
-				new FileAccessHelper(),
941
-				new AppLocator(),
942
-				$config,
943
-				$c->get(ICacheFactory::class),
944
-				$appManager,
945
-				$c->get(IMimeTypeDetector::class)
946
-			);
947
-		});
948
-		$this->registerService(\OCP\IRequest::class, function (ContainerInterface $c) {
949
-			if (isset($this['urlParams'])) {
950
-				$urlParams = $this['urlParams'];
951
-			} else {
952
-				$urlParams = [];
953
-			}
954
-
955
-			if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
956
-				&& in_array('fakeinput', stream_get_wrappers())
957
-			) {
958
-				$stream = 'fakeinput://data';
959
-			} else {
960
-				$stream = 'php://input';
961
-			}
962
-
963
-			return new Request(
964
-				[
965
-					'get' => $_GET,
966
-					'post' => $_POST,
967
-					'files' => $_FILES,
968
-					'server' => $_SERVER,
969
-					'env' => $_ENV,
970
-					'cookies' => $_COOKIE,
971
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
972
-						? $_SERVER['REQUEST_METHOD']
973
-						: '',
974
-					'urlParams' => $urlParams,
975
-				],
976
-				$this->get(ISecureRandom::class),
977
-				$this->get(\OCP\IConfig::class),
978
-				$this->get(CsrfTokenManager::class),
979
-				$stream
980
-			);
981
-		});
982
-		/** @deprecated 19.0.0 */
983
-		$this->registerDeprecatedAlias('Request', \OCP\IRequest::class);
984
-
985
-		$this->registerService(IMailer::class, function (Server $c) {
986
-			return new Mailer(
987
-				$c->get(\OCP\IConfig::class),
988
-				$c->get(ILogger::class),
989
-				$c->get(Defaults::class),
990
-				$c->get(IURLGenerator::class),
991
-				$c->getL10N('lib'),
992
-				$c->get(IEventDispatcher::class),
993
-				$c->get(IFactory::class)
994
-			);
995
-		});
996
-		/** @deprecated 19.0.0 */
997
-		$this->registerDeprecatedAlias('Mailer', IMailer::class);
998
-
999
-		$this->registerService('LDAPProvider', function (ContainerInterface $c) {
1000
-			$config = $c->get(\OCP\IConfig::class);
1001
-			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
1002
-			if (is_null($factoryClass)) {
1003
-				throw new \Exception('ldapProviderFactory not set');
1004
-			}
1005
-			/** @var \OCP\LDAP\ILDAPProviderFactory $factory */
1006
-			$factory = new $factoryClass($this);
1007
-			return $factory->getLDAPProvider();
1008
-		});
1009
-		$this->registerService(ILockingProvider::class, function (ContainerInterface $c) {
1010
-			$ini = $c->get(IniGetWrapper::class);
1011
-			$config = $c->get(\OCP\IConfig::class);
1012
-			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
1013
-			if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
1014
-				/** @var \OC\Memcache\Factory $memcacheFactory */
1015
-				$memcacheFactory = $c->get(ICacheFactory::class);
1016
-				$memcache = $memcacheFactory->createLocking('lock');
1017
-				if (!($memcache instanceof \OC\Memcache\NullCache)) {
1018
-					return new MemcacheLockingProvider($memcache, $ttl);
1019
-				}
1020
-				return new DBLockingProvider(
1021
-					$c->get(IDBConnection::class),
1022
-					$c->get(ILogger::class),
1023
-					new TimeFactory(),
1024
-					$ttl,
1025
-					!\OC::$CLI
1026
-				);
1027
-			}
1028
-			return new NoopLockingProvider();
1029
-		});
1030
-		/** @deprecated 19.0.0 */
1031
-		$this->registerDeprecatedAlias('LockingProvider', ILockingProvider::class);
1032
-
1033
-		$this->registerAlias(IMountManager::class, \OC\Files\Mount\Manager::class);
1034
-		/** @deprecated 19.0.0 */
1035
-		$this->registerDeprecatedAlias('MountManager', IMountManager::class);
1036
-
1037
-		$this->registerService(IMimeTypeDetector::class, function (ContainerInterface $c) {
1038
-			return new \OC\Files\Type\Detection(
1039
-				$c->get(IURLGenerator::class),
1040
-				$c->get(ILogger::class),
1041
-				\OC::$configDir,
1042
-				\OC::$SERVERROOT . '/resources/config/'
1043
-			);
1044
-		});
1045
-		/** @deprecated 19.0.0 */
1046
-		$this->registerDeprecatedAlias('MimeTypeDetector', IMimeTypeDetector::class);
1047
-
1048
-		$this->registerAlias(IMimeTypeLoader::class, Loader::class);
1049
-		/** @deprecated 19.0.0 */
1050
-		$this->registerDeprecatedAlias('MimeTypeLoader', IMimeTypeLoader::class);
1051
-		$this->registerService(BundleFetcher::class, function () {
1052
-			return new BundleFetcher($this->getL10N('lib'));
1053
-		});
1054
-		$this->registerAlias(\OCP\Notification\IManager::class, Manager::class);
1055
-		/** @deprecated 19.0.0 */
1056
-		$this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class);
1057
-
1058
-		$this->registerService(CapabilitiesManager::class, function (ContainerInterface $c) {
1059
-			$manager = new CapabilitiesManager($c->get(ILogger::class));
1060
-			$manager->registerCapability(function () use ($c) {
1061
-				return new \OC\OCS\CoreCapabilities($c->get(\OCP\IConfig::class));
1062
-			});
1063
-			$manager->registerCapability(function () use ($c) {
1064
-				return $c->get(\OC\Security\Bruteforce\Capabilities::class);
1065
-			});
1066
-			return $manager;
1067
-		});
1068
-		/** @deprecated 19.0.0 */
1069
-		$this->registerDeprecatedAlias('CapabilitiesManager', CapabilitiesManager::class);
1070
-
1071
-		$this->registerService(ICommentsManager::class, function (Server $c) {
1072
-			$config = $c->get(\OCP\IConfig::class);
1073
-			$factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
1074
-			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
1075
-			$factory = new $factoryClass($this);
1076
-			$manager = $factory->getManager();
1077
-
1078
-			$manager->registerDisplayNameResolver('user', function ($id) use ($c) {
1079
-				$manager = $c->get(IUserManager::class);
1080
-				$user = $manager->get($id);
1081
-				if (is_null($user)) {
1082
-					$l = $c->getL10N('core');
1083
-					$displayName = $l->t('Unknown user');
1084
-				} else {
1085
-					$displayName = $user->getDisplayName();
1086
-				}
1087
-				return $displayName;
1088
-			});
1089
-
1090
-			return $manager;
1091
-		});
1092
-		/** @deprecated 19.0.0 */
1093
-		$this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class);
1094
-
1095
-		$this->registerAlias(\OC_Defaults::class, 'ThemingDefaults');
1096
-		$this->registerService('ThemingDefaults', function (Server $c) {
1097
-			/*
253
+    /** @var string */
254
+    private $webRoot;
255
+
256
+    /**
257
+     * @param string $webRoot
258
+     * @param \OC\Config $config
259
+     */
260
+    public function __construct($webRoot, \OC\Config $config) {
261
+        parent::__construct();
262
+        $this->webRoot = $webRoot;
263
+
264
+        // To find out if we are running from CLI or not
265
+        $this->registerParameter('isCLI', \OC::$CLI);
266
+        $this->registerParameter('serverRoot', \OC::$SERVERROOT);
267
+
268
+        $this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
269
+            return $c;
270
+        });
271
+        $this->registerService(\OCP\IServerContainer::class, function (ContainerInterface $c) {
272
+            return $c;
273
+        });
274
+
275
+        $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
276
+        /** @deprecated 19.0.0 */
277
+        $this->registerDeprecatedAlias('CalendarManager', \OC\Calendar\Manager::class);
278
+
279
+        $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class);
280
+        /** @deprecated 19.0.0 */
281
+        $this->registerDeprecatedAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class);
282
+
283
+        $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class);
284
+        /** @deprecated 19.0.0 */
285
+        $this->registerDeprecatedAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class);
286
+
287
+        $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
288
+        /** @deprecated 19.0.0 */
289
+        $this->registerDeprecatedAlias('ContactsManager', \OCP\Contacts\IManager::class);
290
+
291
+        $this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class);
292
+
293
+        $this->registerAlias(IActionFactory::class, ActionFactory::class);
294
+
295
+        $this->registerService(View::class, function (Server $c) {
296
+            return new View();
297
+        }, false);
298
+
299
+        $this->registerService(IPreview::class, function (ContainerInterface $c) {
300
+            return new PreviewManager(
301
+                $c->get(\OCP\IConfig::class),
302
+                $c->get(IRootFolder::class),
303
+                new \OC\Preview\Storage\Root(
304
+                    $c->get(IRootFolder::class),
305
+                    $c->get(SystemConfig::class)
306
+                ),
307
+                $c->get(SymfonyAdapter::class),
308
+                $c->get(GeneratorHelper::class),
309
+                $c->get(ISession::class)->get('user_id')
310
+            );
311
+        });
312
+        /** @deprecated 19.0.0 */
313
+        $this->registerDeprecatedAlias('PreviewManager', IPreview::class);
314
+
315
+        $this->registerService(\OC\Preview\Watcher::class, function (ContainerInterface $c) {
316
+            return new \OC\Preview\Watcher(
317
+                new \OC\Preview\Storage\Root(
318
+                    $c->get(IRootFolder::class),
319
+                    $c->get(SystemConfig::class)
320
+                )
321
+            );
322
+        });
323
+
324
+        $this->registerService(\OCP\Encryption\IManager::class, function (Server $c) {
325
+            $view = new View();
326
+            $util = new Encryption\Util(
327
+                $view,
328
+                $c->get(IUserManager::class),
329
+                $c->get(IGroupManager::class),
330
+                $c->get(\OCP\IConfig::class)
331
+            );
332
+            return new Encryption\Manager(
333
+                $c->get(\OCP\IConfig::class),
334
+                $c->get(ILogger::class),
335
+                $c->getL10N('core'),
336
+                new View(),
337
+                $util,
338
+                new ArrayCache()
339
+            );
340
+        });
341
+        /** @deprecated 19.0.0 */
342
+        $this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class);
343
+
344
+        /** @deprecated 21.0.0 */
345
+        $this->registerDeprecatedAlias('EncryptionFileHelper', IFile::class);
346
+        $this->registerService(IFile::class, function (ContainerInterface $c) {
347
+            $util = new Encryption\Util(
348
+                new View(),
349
+                $c->get(IUserManager::class),
350
+                $c->get(IGroupManager::class),
351
+                $c->get(\OCP\IConfig::class)
352
+            );
353
+            return new Encryption\File(
354
+                $util,
355
+                $c->get(IRootFolder::class),
356
+                $c->get(\OCP\Share\IManager::class)
357
+            );
358
+        });
359
+
360
+        /** @deprecated 21.0.0 */
361
+        $this->registerDeprecatedAlias('EncryptionKeyStorage', IStorage::class);
362
+        $this->registerService(IStorage::class, function (ContainerInterface $c) {
363
+            $view = new View();
364
+            $util = new Encryption\Util(
365
+                $view,
366
+                $c->get(IUserManager::class),
367
+                $c->get(IGroupManager::class),
368
+                $c->get(\OCP\IConfig::class)
369
+            );
370
+
371
+            return new Encryption\Keys\Storage(
372
+                $view,
373
+                $util,
374
+                $c->get(ICrypto::class),
375
+                $c->get(\OCP\IConfig::class)
376
+            );
377
+        });
378
+        /** @deprecated 20.0.0 */
379
+        $this->registerDeprecatedAlias('TagMapper', TagMapper::class);
380
+
381
+        $this->registerAlias(\OCP\ITagManager::class, TagManager::class);
382
+        /** @deprecated 19.0.0 */
383
+        $this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class);
384
+
385
+        $this->registerService('SystemTagManagerFactory', function (ContainerInterface $c) {
386
+            /** @var \OCP\IConfig $config */
387
+            $config = $c->get(\OCP\IConfig::class);
388
+            $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
389
+            return new $factoryClass($this);
390
+        });
391
+        $this->registerService(ISystemTagManager::class, function (ContainerInterface $c) {
392
+            return $c->get('SystemTagManagerFactory')->getManager();
393
+        });
394
+        /** @deprecated 19.0.0 */
395
+        $this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class);
396
+
397
+        $this->registerService(ISystemTagObjectMapper::class, function (ContainerInterface $c) {
398
+            return $c->get('SystemTagManagerFactory')->getObjectMapper();
399
+        });
400
+        $this->registerService('RootFolder', function (ContainerInterface $c) {
401
+            $manager = \OC\Files\Filesystem::getMountManager(null);
402
+            $view = new View();
403
+            $root = new Root(
404
+                $manager,
405
+                $view,
406
+                null,
407
+                $c->get(IUserMountCache::class),
408
+                $this->get(ILogger::class),
409
+                $this->get(IUserManager::class)
410
+            );
411
+
412
+            $previewConnector = new \OC\Preview\WatcherConnector(
413
+                $root,
414
+                $c->get(SystemConfig::class)
415
+            );
416
+            $previewConnector->connectWatcher();
417
+
418
+            return $root;
419
+        });
420
+        $this->registerService(HookConnector::class, function (ContainerInterface $c) {
421
+            return new HookConnector(
422
+                $c->get(IRootFolder::class),
423
+                new View(),
424
+                $c->get(\OC\EventDispatcher\SymfonyAdapter::class),
425
+                $c->get(IEventDispatcher::class)
426
+            );
427
+        });
428
+
429
+        /** @deprecated 19.0.0 */
430
+        $this->registerDeprecatedAlias('SystemTagObjectMapper', ISystemTagObjectMapper::class);
431
+
432
+        $this->registerService(IRootFolder::class, function (ContainerInterface $c) {
433
+            return new LazyRoot(function () use ($c) {
434
+                return $c->get('RootFolder');
435
+            });
436
+        });
437
+        /** @deprecated 19.0.0 */
438
+        $this->registerDeprecatedAlias('LazyRootFolder', IRootFolder::class);
439
+
440
+        /** @deprecated 19.0.0 */
441
+        $this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class);
442
+        $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
443
+
444
+        $this->registerService(\OCP\IGroupManager::class, function (ContainerInterface $c) {
445
+            $groupManager = new \OC\Group\Manager($this->get(IUserManager::class), $c->get(SymfonyAdapter::class), $this->get(ILogger::class));
446
+            $groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
447
+                /** @var IEventDispatcher $dispatcher */
448
+                $dispatcher = $this->get(IEventDispatcher::class);
449
+                $dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid));
450
+            });
451
+            $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) {
452
+                /** @var IEventDispatcher $dispatcher */
453
+                $dispatcher = $this->get(IEventDispatcher::class);
454
+                $dispatcher->dispatchTyped(new GroupCreatedEvent($group));
455
+            });
456
+            $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
457
+                /** @var IEventDispatcher $dispatcher */
458
+                $dispatcher = $this->get(IEventDispatcher::class);
459
+                $dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group));
460
+            });
461
+            $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
462
+                /** @var IEventDispatcher $dispatcher */
463
+                $dispatcher = $this->get(IEventDispatcher::class);
464
+                $dispatcher->dispatchTyped(new GroupDeletedEvent($group));
465
+            });
466
+            $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
467
+                /** @var IEventDispatcher $dispatcher */
468
+                $dispatcher = $this->get(IEventDispatcher::class);
469
+                $dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user));
470
+            });
471
+            $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
472
+                /** @var IEventDispatcher $dispatcher */
473
+                $dispatcher = $this->get(IEventDispatcher::class);
474
+                $dispatcher->dispatchTyped(new UserAddedEvent($group, $user));
475
+            });
476
+            $groupManager->listen('\OC\Group', 'preRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
477
+                /** @var IEventDispatcher $dispatcher */
478
+                $dispatcher = $this->get(IEventDispatcher::class);
479
+                $dispatcher->dispatchTyped(new BeforeUserRemovedEvent($group, $user));
480
+            });
481
+            $groupManager->listen('\OC\Group', 'postRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
482
+                /** @var IEventDispatcher $dispatcher */
483
+                $dispatcher = $this->get(IEventDispatcher::class);
484
+                $dispatcher->dispatchTyped(new UserRemovedEvent($group, $user));
485
+            });
486
+            return $groupManager;
487
+        });
488
+        /** @deprecated 19.0.0 */
489
+        $this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class);
490
+
491
+        $this->registerService(Store::class, function (ContainerInterface $c) {
492
+            $session = $c->get(ISession::class);
493
+            if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
494
+                $tokenProvider = $c->get(IProvider::class);
495
+            } else {
496
+                $tokenProvider = null;
497
+            }
498
+            $logger = $c->get(LoggerInterface::class);
499
+            return new Store($session, $logger, $tokenProvider);
500
+        });
501
+        $this->registerAlias(IStore::class, Store::class);
502
+        $this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
503
+
504
+        $this->registerService(\OC\User\Session::class, function (Server $c) {
505
+            $manager = $c->get(IUserManager::class);
506
+            $session = new \OC\Session\Memory('');
507
+            $timeFactory = new TimeFactory();
508
+            // Token providers might require a working database. This code
509
+            // might however be called when ownCloud is not yet setup.
510
+            if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
511
+                $defaultTokenProvider = $c->get(IProvider::class);
512
+            } else {
513
+                $defaultTokenProvider = null;
514
+            }
515
+
516
+            $legacyDispatcher = $c->get(SymfonyAdapter::class);
517
+
518
+            $userSession = new \OC\User\Session(
519
+                $manager,
520
+                $session,
521
+                $timeFactory,
522
+                $defaultTokenProvider,
523
+                $c->get(\OCP\IConfig::class),
524
+                $c->get(ISecureRandom::class),
525
+                $c->getLockdownManager(),
526
+                $c->get(ILogger::class),
527
+                $c->get(IEventDispatcher::class)
528
+            );
529
+            /** @deprecated 21.0.0 use BeforeUserCreatedEvent event with the IEventDispatcher instead */
530
+            $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
531
+                \OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]);
532
+            });
533
+            /** @deprecated 21.0.0 use UserCreatedEvent event with the IEventDispatcher instead */
534
+            $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
535
+                /** @var \OC\User\User $user */
536
+                \OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]);
537
+            });
538
+            /** @deprecated 21.0.0 use BeforeUserDeletedEvent event with the IEventDispatcher instead */
539
+            $userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) {
540
+                /** @var \OC\User\User $user */
541
+                \OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]);
542
+                $legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user));
543
+            });
544
+            /** @deprecated 21.0.0 use UserDeletedEvent event with the IEventDispatcher instead */
545
+            $userSession->listen('\OC\User', 'postDelete', function ($user) {
546
+                /** @var \OC\User\User $user */
547
+                \OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]);
548
+            });
549
+            $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
550
+                /** @var \OC\User\User $user */
551
+                \OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
552
+
553
+                /** @var IEventDispatcher $dispatcher */
554
+                $dispatcher = $this->get(IEventDispatcher::class);
555
+                $dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword));
556
+            });
557
+            $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
558
+                /** @var \OC\User\User $user */
559
+                \OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
560
+
561
+                /** @var IEventDispatcher $dispatcher */
562
+                $dispatcher = $this->get(IEventDispatcher::class);
563
+                $dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword));
564
+            });
565
+            $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
566
+                \OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]);
567
+
568
+                /** @var IEventDispatcher $dispatcher */
569
+                $dispatcher = $this->get(IEventDispatcher::class);
570
+                $dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
571
+            });
572
+            $userSession->listen('\OC\User', 'postLogin', function ($user, $loginName, $password, $isTokenLogin) {
573
+                /** @var \OC\User\User $user */
574
+                \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'loginName' => $loginName, 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
575
+
576
+                /** @var IEventDispatcher $dispatcher */
577
+                $dispatcher = $this->get(IEventDispatcher::class);
578
+                $dispatcher->dispatchTyped(new UserLoggedInEvent($user, $password, $isTokenLogin));
579
+            });
580
+            $userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
581
+                /** @var IEventDispatcher $dispatcher */
582
+                $dispatcher = $this->get(IEventDispatcher::class);
583
+                $dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
584
+            });
585
+            $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
586
+                /** @var \OC\User\User $user */
587
+                \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]);
588
+
589
+                /** @var IEventDispatcher $dispatcher */
590
+                $dispatcher = $this->get(IEventDispatcher::class);
591
+                $dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
592
+            });
593
+            $userSession->listen('\OC\User', 'logout', function ($user) {
594
+                \OC_Hook::emit('OC_User', 'logout', []);
595
+
596
+                /** @var IEventDispatcher $dispatcher */
597
+                $dispatcher = $this->get(IEventDispatcher::class);
598
+                $dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
599
+            });
600
+            $userSession->listen('\OC\User', 'postLogout', function ($user) {
601
+                /** @var IEventDispatcher $dispatcher */
602
+                $dispatcher = $this->get(IEventDispatcher::class);
603
+                $dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
604
+            });
605
+            $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
606
+                /** @var \OC\User\User $user */
607
+                \OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]);
608
+
609
+                /** @var IEventDispatcher $dispatcher */
610
+                $dispatcher = $this->get(IEventDispatcher::class);
611
+                $dispatcher->dispatchTyped(new UserChangedEvent($user, $feature, $value, $oldValue));
612
+            });
613
+            return $userSession;
614
+        });
615
+        $this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class);
616
+        /** @deprecated 19.0.0 */
617
+        $this->registerDeprecatedAlias('UserSession', \OC\User\Session::class);
618
+
619
+        $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class);
620
+
621
+        $this->registerAlias(INavigationManager::class, \OC\NavigationManager::class);
622
+        /** @deprecated 19.0.0 */
623
+        $this->registerDeprecatedAlias('NavigationManager', INavigationManager::class);
624
+
625
+        /** @deprecated 19.0.0 */
626
+        $this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class);
627
+        $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
628
+
629
+        $this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
630
+            return new \OC\SystemConfig($config);
631
+        });
632
+        /** @deprecated 19.0.0 */
633
+        $this->registerDeprecatedAlias('SystemConfig', \OC\SystemConfig::class);
634
+
635
+        /** @deprecated 19.0.0 */
636
+        $this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class);
637
+        $this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
638
+
639
+        $this->registerService(IFactory::class, function (Server $c) {
640
+            return new \OC\L10N\Factory(
641
+                $c->get(\OCP\IConfig::class),
642
+                $c->getRequest(),
643
+                $c->get(IUserSession::class),
644
+                \OC::$SERVERROOT
645
+            );
646
+        });
647
+        /** @deprecated 19.0.0 */
648
+        $this->registerDeprecatedAlias('L10NFactory', IFactory::class);
649
+
650
+        $this->registerAlias(IURLGenerator::class, URLGenerator::class);
651
+        /** @deprecated 19.0.0 */
652
+        $this->registerDeprecatedAlias('URLGenerator', IURLGenerator::class);
653
+
654
+        /** @deprecated 19.0.0 */
655
+        $this->registerDeprecatedAlias('AppFetcher', AppFetcher::class);
656
+        /** @deprecated 19.0.0 */
657
+        $this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class);
658
+
659
+        $this->registerService(ICache::class, function ($c) {
660
+            return new Cache\File();
661
+        });
662
+        /** @deprecated 19.0.0 */
663
+        $this->registerDeprecatedAlias('UserCache', ICache::class);
664
+
665
+        $this->registerService(Factory::class, function (Server $c) {
666
+            $arrayCacheFactory = new \OC\Memcache\Factory('', $c->get(ILogger::class),
667
+                ArrayCache::class,
668
+                ArrayCache::class,
669
+                ArrayCache::class
670
+            );
671
+            /** @var \OCP\IConfig $config */
672
+            $config = $c->get(\OCP\IConfig::class);
673
+
674
+            if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
675
+                $v = \OC_App::getAppVersions();
676
+                $v['core'] = implode(',', \OC_Util::getVersion());
677
+                $version = implode(',', $v);
678
+                $instanceId = \OC_Util::getInstanceId();
679
+                $path = \OC::$SERVERROOT;
680
+                $prefix = md5($instanceId . '-' . $version . '-' . $path);
681
+                return new \OC\Memcache\Factory($prefix, $c->get(ILogger::class),
682
+                    $config->getSystemValue('memcache.local', null),
683
+                    $config->getSystemValue('memcache.distributed', null),
684
+                    $config->getSystemValue('memcache.locking', null)
685
+                );
686
+            }
687
+            return $arrayCacheFactory;
688
+        });
689
+        /** @deprecated 19.0.0 */
690
+        $this->registerDeprecatedAlias('MemCacheFactory', Factory::class);
691
+        $this->registerAlias(ICacheFactory::class, Factory::class);
692
+
693
+        $this->registerService('RedisFactory', function (Server $c) {
694
+            $systemConfig = $c->get(SystemConfig::class);
695
+            return new RedisFactory($systemConfig);
696
+        });
697
+
698
+        $this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
699
+            $l10n = $this->get(IFactory::class)->get('lib');
700
+            return new \OC\Activity\Manager(
701
+                $c->getRequest(),
702
+                $c->get(IUserSession::class),
703
+                $c->get(\OCP\IConfig::class),
704
+                $c->get(IValidator::class),
705
+                $l10n
706
+            );
707
+        });
708
+        /** @deprecated 19.0.0 */
709
+        $this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class);
710
+
711
+        $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
712
+            return new \OC\Activity\EventMerger(
713
+                $c->getL10N('lib')
714
+            );
715
+        });
716
+        $this->registerAlias(IValidator::class, Validator::class);
717
+
718
+        $this->registerService(AvatarManager::class, function (Server $c) {
719
+            return new AvatarManager(
720
+                $c->get(\OC\User\Manager::class),
721
+                $c->getAppDataDir('avatar'),
722
+                $c->getL10N('lib'),
723
+                $c->get(ILogger::class),
724
+                $c->get(\OCP\IConfig::class)
725
+            );
726
+        });
727
+        $this->registerAlias(IAvatarManager::class, AvatarManager::class);
728
+        /** @deprecated 19.0.0 */
729
+        $this->registerDeprecatedAlias('AvatarManager', AvatarManager::class);
730
+
731
+        $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
732
+        $this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
733
+
734
+        $this->registerService(\OC\Log::class, function (Server $c) {
735
+            $logType = $c->get(AllConfig::class)->getSystemValue('log_type', 'file');
736
+            $factory = new LogFactory($c, $this->get(SystemConfig::class));
737
+            $logger = $factory->get($logType);
738
+            $registry = $c->get(\OCP\Support\CrashReport\IRegistry::class);
739
+
740
+            return new Log($logger, $this->get(SystemConfig::class), null, $registry);
741
+        });
742
+        $this->registerAlias(ILogger::class, \OC\Log::class);
743
+        /** @deprecated 19.0.0 */
744
+        $this->registerDeprecatedAlias('Logger', \OC\Log::class);
745
+        // PSR-3 logger
746
+        $this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class);
747
+
748
+        $this->registerService(ILogFactory::class, function (Server $c) {
749
+            return new LogFactory($c, $this->get(SystemConfig::class));
750
+        });
751
+
752
+        $this->registerAlias(IJobList::class, \OC\BackgroundJob\JobList::class);
753
+        /** @deprecated 19.0.0 */
754
+        $this->registerDeprecatedAlias('JobList', IJobList::class);
755
+
756
+        $this->registerService(Router::class, function (Server $c) {
757
+            $cacheFactory = $c->get(ICacheFactory::class);
758
+            $logger = $c->get(ILogger::class);
759
+            if ($cacheFactory->isLocalCacheAvailable()) {
760
+                $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger);
761
+            } else {
762
+                $router = new \OC\Route\Router($logger);
763
+            }
764
+            return $router;
765
+        });
766
+        $this->registerAlias(IRouter::class, Router::class);
767
+        /** @deprecated 19.0.0 */
768
+        $this->registerDeprecatedAlias('Router', IRouter::class);
769
+
770
+        $this->registerAlias(ISearch::class, Search::class);
771
+        /** @deprecated 19.0.0 */
772
+        $this->registerDeprecatedAlias('Search', ISearch::class);
773
+
774
+        $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
775
+            return new \OC\Security\RateLimiting\Backend\MemoryCache(
776
+                $this->get(ICacheFactory::class),
777
+                new \OC\AppFramework\Utility\TimeFactory()
778
+            );
779
+        });
780
+
781
+        $this->registerAlias(\OCP\Security\ISecureRandom::class, SecureRandom::class);
782
+        /** @deprecated 19.0.0 */
783
+        $this->registerDeprecatedAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
784
+
785
+        $this->registerAlias(ICrypto::class, Crypto::class);
786
+        /** @deprecated 19.0.0 */
787
+        $this->registerDeprecatedAlias('Crypto', ICrypto::class);
788
+
789
+        $this->registerAlias(IHasher::class, Hasher::class);
790
+        /** @deprecated 19.0.0 */
791
+        $this->registerDeprecatedAlias('Hasher', IHasher::class);
792
+
793
+        $this->registerAlias(ICredentialsManager::class, CredentialsManager::class);
794
+        /** @deprecated 19.0.0 */
795
+        $this->registerDeprecatedAlias('CredentialsManager', ICredentialsManager::class);
796
+
797
+        $this->registerAlias(IDBConnection::class, ConnectionAdapter::class);
798
+        $this->registerService(Connection::class, function (Server $c) {
799
+            $systemConfig = $c->get(SystemConfig::class);
800
+            $factory = new \OC\DB\ConnectionFactory($systemConfig);
801
+            $type = $systemConfig->getValue('dbtype', 'sqlite');
802
+            if (!$factory->isValidType($type)) {
803
+                throw new \OC\DatabaseException('Invalid database type');
804
+            }
805
+            $connectionParams = $factory->createConnectionParams();
806
+            $connection = $factory->getConnection($type, $connectionParams);
807
+            $connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
808
+            return $connection;
809
+        });
810
+        /** @deprecated 19.0.0 */
811
+        $this->registerDeprecatedAlias('DatabaseConnection', IDBConnection::class);
812
+
813
+        $this->registerAlias(ICertificateManager::class, CertificateManager::class);
814
+        $this->registerAlias(IClientService::class, ClientService::class);
815
+        $this->registerDeprecatedAlias('HttpClientService', IClientService::class);
816
+        $this->registerService(IEventLogger::class, function (ContainerInterface $c) {
817
+            $eventLogger = new EventLogger();
818
+            if ($c->get(SystemConfig::class)->getValue('debug', false)) {
819
+                // In debug mode, module is being activated by default
820
+                $eventLogger->activate();
821
+            }
822
+            return $eventLogger;
823
+        });
824
+        /** @deprecated 19.0.0 */
825
+        $this->registerDeprecatedAlias('EventLogger', IEventLogger::class);
826
+
827
+        $this->registerService(IQueryLogger::class, function (ContainerInterface $c) {
828
+            $queryLogger = new QueryLogger();
829
+            if ($c->get(SystemConfig::class)->getValue('debug', false)) {
830
+                // In debug mode, module is being activated by default
831
+                $queryLogger->activate();
832
+            }
833
+            return $queryLogger;
834
+        });
835
+        /** @deprecated 19.0.0 */
836
+        $this->registerDeprecatedAlias('QueryLogger', IQueryLogger::class);
837
+
838
+        /** @deprecated 19.0.0 */
839
+        $this->registerDeprecatedAlias('TempManager', TempManager::class);
840
+        $this->registerAlias(ITempManager::class, TempManager::class);
841
+
842
+        $this->registerService(AppManager::class, function (ContainerInterface $c) {
843
+            // TODO: use auto-wiring
844
+            return new \OC\App\AppManager(
845
+                $c->get(IUserSession::class),
846
+                $c->get(\OCP\IConfig::class),
847
+                $c->get(\OC\AppConfig::class),
848
+                $c->get(IGroupManager::class),
849
+                $c->get(ICacheFactory::class),
850
+                $c->get(SymfonyAdapter::class),
851
+                $c->get(ILogger::class)
852
+            );
853
+        });
854
+        /** @deprecated 19.0.0 */
855
+        $this->registerDeprecatedAlias('AppManager', AppManager::class);
856
+        $this->registerAlias(IAppManager::class, AppManager::class);
857
+
858
+        $this->registerAlias(IDateTimeZone::class, DateTimeZone::class);
859
+        /** @deprecated 19.0.0 */
860
+        $this->registerDeprecatedAlias('DateTimeZone', IDateTimeZone::class);
861
+
862
+        $this->registerService(IDateTimeFormatter::class, function (Server $c) {
863
+            $language = $c->get(\OCP\IConfig::class)->getUserValue($c->get(ISession::class)->get('user_id'), 'core', 'lang', null);
864
+
865
+            return new DateTimeFormatter(
866
+                $c->get(IDateTimeZone::class)->getTimeZone(),
867
+                $c->getL10N('lib', $language)
868
+            );
869
+        });
870
+        /** @deprecated 19.0.0 */
871
+        $this->registerDeprecatedAlias('DateTimeFormatter', IDateTimeFormatter::class);
872
+
873
+        $this->registerService(IUserMountCache::class, function (ContainerInterface $c) {
874
+            $mountCache = new UserMountCache(
875
+                $c->get(IDBConnection::class),
876
+                $c->get(IUserManager::class),
877
+                $c->get(ILogger::class)
878
+            );
879
+            $listener = new UserMountCacheListener($mountCache);
880
+            $listener->listen($c->get(IUserManager::class));
881
+            return $mountCache;
882
+        });
883
+        /** @deprecated 19.0.0 */
884
+        $this->registerDeprecatedAlias('UserMountCache', IUserMountCache::class);
885
+
886
+        $this->registerService(IMountProviderCollection::class, function (ContainerInterface $c) {
887
+            $loader = \OC\Files\Filesystem::getLoader();
888
+            $mountCache = $c->get(IUserMountCache::class);
889
+            $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
890
+
891
+            // builtin providers
892
+
893
+            $config = $c->get(\OCP\IConfig::class);
894
+            $logger = $c->get(ILogger::class);
895
+            $manager->registerProvider(new CacheMountProvider($config));
896
+            $manager->registerHomeProvider(new LocalHomeMountProvider());
897
+            $manager->registerHomeProvider(new ObjectHomeMountProvider($config));
898
+            $manager->registerRootProvider(new ObjectStorePreviewCacheMountProvider($logger, $config));
899
+
900
+            return $manager;
901
+        });
902
+        /** @deprecated 19.0.0 */
903
+        $this->registerDeprecatedAlias('MountConfigManager', IMountProviderCollection::class);
904
+
905
+        /** @deprecated 20.0.0 */
906
+        $this->registerDeprecatedAlias('IniWrapper', IniGetWrapper::class);
907
+        $this->registerService(IBus::class, function (ContainerInterface $c) {
908
+            $busClass = $c->get(\OCP\IConfig::class)->getSystemValue('commandbus');
909
+            if ($busClass) {
910
+                [$app, $class] = explode('::', $busClass, 2);
911
+                if ($c->get(IAppManager::class)->isInstalled($app)) {
912
+                    \OC_App::loadApp($app);
913
+                    return $c->get($class);
914
+                } else {
915
+                    throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
916
+                }
917
+            } else {
918
+                $jobList = $c->get(IJobList::class);
919
+                return new CronBus($jobList);
920
+            }
921
+        });
922
+        $this->registerDeprecatedAlias('AsyncCommandBus', IBus::class);
923
+        /** @deprecated 20.0.0 */
924
+        $this->registerDeprecatedAlias('TrustedDomainHelper', TrustedDomainHelper::class);
925
+        /** @deprecated 19.0.0 */
926
+        $this->registerDeprecatedAlias('Throttler', Throttler::class);
927
+        $this->registerService('IntegrityCodeChecker', function (ContainerInterface $c) {
928
+            // IConfig and IAppManager requires a working database. This code
929
+            // might however be called when ownCloud is not yet setup.
930
+            if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
931
+                $config = $c->get(\OCP\IConfig::class);
932
+                $appManager = $c->get(IAppManager::class);
933
+            } else {
934
+                $config = null;
935
+                $appManager = null;
936
+            }
937
+
938
+            return new Checker(
939
+                new EnvironmentHelper(),
940
+                new FileAccessHelper(),
941
+                new AppLocator(),
942
+                $config,
943
+                $c->get(ICacheFactory::class),
944
+                $appManager,
945
+                $c->get(IMimeTypeDetector::class)
946
+            );
947
+        });
948
+        $this->registerService(\OCP\IRequest::class, function (ContainerInterface $c) {
949
+            if (isset($this['urlParams'])) {
950
+                $urlParams = $this['urlParams'];
951
+            } else {
952
+                $urlParams = [];
953
+            }
954
+
955
+            if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
956
+                && in_array('fakeinput', stream_get_wrappers())
957
+            ) {
958
+                $stream = 'fakeinput://data';
959
+            } else {
960
+                $stream = 'php://input';
961
+            }
962
+
963
+            return new Request(
964
+                [
965
+                    'get' => $_GET,
966
+                    'post' => $_POST,
967
+                    'files' => $_FILES,
968
+                    'server' => $_SERVER,
969
+                    'env' => $_ENV,
970
+                    'cookies' => $_COOKIE,
971
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
972
+                        ? $_SERVER['REQUEST_METHOD']
973
+                        : '',
974
+                    'urlParams' => $urlParams,
975
+                ],
976
+                $this->get(ISecureRandom::class),
977
+                $this->get(\OCP\IConfig::class),
978
+                $this->get(CsrfTokenManager::class),
979
+                $stream
980
+            );
981
+        });
982
+        /** @deprecated 19.0.0 */
983
+        $this->registerDeprecatedAlias('Request', \OCP\IRequest::class);
984
+
985
+        $this->registerService(IMailer::class, function (Server $c) {
986
+            return new Mailer(
987
+                $c->get(\OCP\IConfig::class),
988
+                $c->get(ILogger::class),
989
+                $c->get(Defaults::class),
990
+                $c->get(IURLGenerator::class),
991
+                $c->getL10N('lib'),
992
+                $c->get(IEventDispatcher::class),
993
+                $c->get(IFactory::class)
994
+            );
995
+        });
996
+        /** @deprecated 19.0.0 */
997
+        $this->registerDeprecatedAlias('Mailer', IMailer::class);
998
+
999
+        $this->registerService('LDAPProvider', function (ContainerInterface $c) {
1000
+            $config = $c->get(\OCP\IConfig::class);
1001
+            $factoryClass = $config->getSystemValue('ldapProviderFactory', null);
1002
+            if (is_null($factoryClass)) {
1003
+                throw new \Exception('ldapProviderFactory not set');
1004
+            }
1005
+            /** @var \OCP\LDAP\ILDAPProviderFactory $factory */
1006
+            $factory = new $factoryClass($this);
1007
+            return $factory->getLDAPProvider();
1008
+        });
1009
+        $this->registerService(ILockingProvider::class, function (ContainerInterface $c) {
1010
+            $ini = $c->get(IniGetWrapper::class);
1011
+            $config = $c->get(\OCP\IConfig::class);
1012
+            $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
1013
+            if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
1014
+                /** @var \OC\Memcache\Factory $memcacheFactory */
1015
+                $memcacheFactory = $c->get(ICacheFactory::class);
1016
+                $memcache = $memcacheFactory->createLocking('lock');
1017
+                if (!($memcache instanceof \OC\Memcache\NullCache)) {
1018
+                    return new MemcacheLockingProvider($memcache, $ttl);
1019
+                }
1020
+                return new DBLockingProvider(
1021
+                    $c->get(IDBConnection::class),
1022
+                    $c->get(ILogger::class),
1023
+                    new TimeFactory(),
1024
+                    $ttl,
1025
+                    !\OC::$CLI
1026
+                );
1027
+            }
1028
+            return new NoopLockingProvider();
1029
+        });
1030
+        /** @deprecated 19.0.0 */
1031
+        $this->registerDeprecatedAlias('LockingProvider', ILockingProvider::class);
1032
+
1033
+        $this->registerAlias(IMountManager::class, \OC\Files\Mount\Manager::class);
1034
+        /** @deprecated 19.0.0 */
1035
+        $this->registerDeprecatedAlias('MountManager', IMountManager::class);
1036
+
1037
+        $this->registerService(IMimeTypeDetector::class, function (ContainerInterface $c) {
1038
+            return new \OC\Files\Type\Detection(
1039
+                $c->get(IURLGenerator::class),
1040
+                $c->get(ILogger::class),
1041
+                \OC::$configDir,
1042
+                \OC::$SERVERROOT . '/resources/config/'
1043
+            );
1044
+        });
1045
+        /** @deprecated 19.0.0 */
1046
+        $this->registerDeprecatedAlias('MimeTypeDetector', IMimeTypeDetector::class);
1047
+
1048
+        $this->registerAlias(IMimeTypeLoader::class, Loader::class);
1049
+        /** @deprecated 19.0.0 */
1050
+        $this->registerDeprecatedAlias('MimeTypeLoader', IMimeTypeLoader::class);
1051
+        $this->registerService(BundleFetcher::class, function () {
1052
+            return new BundleFetcher($this->getL10N('lib'));
1053
+        });
1054
+        $this->registerAlias(\OCP\Notification\IManager::class, Manager::class);
1055
+        /** @deprecated 19.0.0 */
1056
+        $this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class);
1057
+
1058
+        $this->registerService(CapabilitiesManager::class, function (ContainerInterface $c) {
1059
+            $manager = new CapabilitiesManager($c->get(ILogger::class));
1060
+            $manager->registerCapability(function () use ($c) {
1061
+                return new \OC\OCS\CoreCapabilities($c->get(\OCP\IConfig::class));
1062
+            });
1063
+            $manager->registerCapability(function () use ($c) {
1064
+                return $c->get(\OC\Security\Bruteforce\Capabilities::class);
1065
+            });
1066
+            return $manager;
1067
+        });
1068
+        /** @deprecated 19.0.0 */
1069
+        $this->registerDeprecatedAlias('CapabilitiesManager', CapabilitiesManager::class);
1070
+
1071
+        $this->registerService(ICommentsManager::class, function (Server $c) {
1072
+            $config = $c->get(\OCP\IConfig::class);
1073
+            $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
1074
+            /** @var \OCP\Comments\ICommentsManagerFactory $factory */
1075
+            $factory = new $factoryClass($this);
1076
+            $manager = $factory->getManager();
1077
+
1078
+            $manager->registerDisplayNameResolver('user', function ($id) use ($c) {
1079
+                $manager = $c->get(IUserManager::class);
1080
+                $user = $manager->get($id);
1081
+                if (is_null($user)) {
1082
+                    $l = $c->getL10N('core');
1083
+                    $displayName = $l->t('Unknown user');
1084
+                } else {
1085
+                    $displayName = $user->getDisplayName();
1086
+                }
1087
+                return $displayName;
1088
+            });
1089
+
1090
+            return $manager;
1091
+        });
1092
+        /** @deprecated 19.0.0 */
1093
+        $this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class);
1094
+
1095
+        $this->registerAlias(\OC_Defaults::class, 'ThemingDefaults');
1096
+        $this->registerService('ThemingDefaults', function (Server $c) {
1097
+            /*
1098 1098
 			 * Dark magic for autoloader.
1099 1099
 			 * If we do a class_exists it will try to load the class which will
1100 1100
 			 * make composer cache the result. Resulting in errors when enabling
1101 1101
 			 * the theming app.
1102 1102
 			 */
1103
-			$prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
1104
-			if (isset($prefixes['OCA\\Theming\\'])) {
1105
-				$classExists = true;
1106
-			} else {
1107
-				$classExists = false;
1108
-			}
1109
-
1110
-			if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValue('installed', false) && $c->get(IAppManager::class)->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
1111
-				return new ThemingDefaults(
1112
-					$c->get(\OCP\IConfig::class),
1113
-					$c->getL10N('theming'),
1114
-					$c->get(IURLGenerator::class),
1115
-					$c->get(ICacheFactory::class),
1116
-					new Util($c->get(\OCP\IConfig::class), $this->get(IAppManager::class), $c->getAppDataDir('theming')),
1117
-					new ImageManager(
1118
-						$c->get(\OCP\IConfig::class),
1119
-						$c->getAppDataDir('theming'),
1120
-						$c->get(IURLGenerator::class),
1121
-						$this->get(ICacheFactory::class),
1122
-						$this->get(ILogger::class),
1123
-						$this->get(ITempManager::class)
1124
-					),
1125
-					$c->get(IAppManager::class),
1126
-					$c->get(INavigationManager::class)
1127
-				);
1128
-			}
1129
-			return new \OC_Defaults();
1130
-		});
1131
-		$this->registerService(JSCombiner::class, function (Server $c) {
1132
-			return new JSCombiner(
1133
-				$c->getAppDataDir('js'),
1134
-				$c->get(IURLGenerator::class),
1135
-				$this->get(ICacheFactory::class),
1136
-				$c->get(SystemConfig::class),
1137
-				$c->get(ILogger::class)
1138
-			);
1139
-		});
1140
-		$this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class);
1141
-		/** @deprecated 19.0.0 */
1142
-		$this->registerDeprecatedAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class);
1143
-		$this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class);
1144
-
1145
-		$this->registerService('CryptoWrapper', function (ContainerInterface $c) {
1146
-			// FIXME: Instantiiated here due to cyclic dependency
1147
-			$request = new Request(
1148
-				[
1149
-					'get' => $_GET,
1150
-					'post' => $_POST,
1151
-					'files' => $_FILES,
1152
-					'server' => $_SERVER,
1153
-					'env' => $_ENV,
1154
-					'cookies' => $_COOKIE,
1155
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1156
-						? $_SERVER['REQUEST_METHOD']
1157
-						: null,
1158
-				],
1159
-				$c->get(ISecureRandom::class),
1160
-				$c->get(\OCP\IConfig::class)
1161
-			);
1162
-
1163
-			return new CryptoWrapper(
1164
-				$c->get(\OCP\IConfig::class),
1165
-				$c->get(ICrypto::class),
1166
-				$c->get(ISecureRandom::class),
1167
-				$request
1168
-			);
1169
-		});
1170
-		/** @deprecated 19.0.0 */
1171
-		$this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class);
1172
-		$this->registerService(SessionStorage::class, function (ContainerInterface $c) {
1173
-			return new SessionStorage($c->get(ISession::class));
1174
-		});
1175
-		$this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class);
1176
-		/** @deprecated 19.0.0 */
1177
-		$this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class);
1178
-
1179
-		$this->registerService(\OCP\Share\IManager::class, function (IServerContainer $c) {
1180
-			$config = $c->get(\OCP\IConfig::class);
1181
-			$factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
1182
-			/** @var \OCP\Share\IProviderFactory $factory */
1183
-			$factory = new $factoryClass($this);
1184
-
1185
-			$manager = new \OC\Share20\Manager(
1186
-				$c->get(ILogger::class),
1187
-				$c->get(\OCP\IConfig::class),
1188
-				$c->get(ISecureRandom::class),
1189
-				$c->get(IHasher::class),
1190
-				$c->get(IMountManager::class),
1191
-				$c->get(IGroupManager::class),
1192
-				$c->getL10N('lib'),
1193
-				$c->get(IFactory::class),
1194
-				$factory,
1195
-				$c->get(IUserManager::class),
1196
-				$c->get(IRootFolder::class),
1197
-				$c->get(SymfonyAdapter::class),
1198
-				$c->get(IMailer::class),
1199
-				$c->get(IURLGenerator::class),
1200
-				$c->get('ThemingDefaults'),
1201
-				$c->get(IEventDispatcher::class)
1202
-			);
1203
-
1204
-			return $manager;
1205
-		});
1206
-		/** @deprecated 19.0.0 */
1207
-		$this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class);
1208
-
1209
-		$this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) {
1210
-			$instance = new Collaboration\Collaborators\Search($c);
1211
-
1212
-			// register default plugins
1213
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
1214
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
1215
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
1216
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
1217
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
1218
-
1219
-			return $instance;
1220
-		});
1221
-		/** @deprecated 19.0.0 */
1222
-		$this->registerDeprecatedAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class);
1223
-		$this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class);
1224
-
1225
-		$this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
1226
-
1227
-		$this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class);
1228
-		$this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
1229
-
1230
-		$this->registerDeprecatedAlias('SettingsManager', \OC\Settings\Manager::class);
1231
-		$this->registerAlias(\OCP\Settings\IManager::class, \OC\Settings\Manager::class);
1232
-		$this->registerService(\OC\Files\AppData\Factory::class, function (ContainerInterface $c) {
1233
-			return new \OC\Files\AppData\Factory(
1234
-				$c->get(IRootFolder::class),
1235
-				$c->get(SystemConfig::class)
1236
-			);
1237
-		});
1238
-
1239
-		$this->registerService('LockdownManager', function (ContainerInterface $c) {
1240
-			return new LockdownManager(function () use ($c) {
1241
-				return $c->get(ISession::class);
1242
-			});
1243
-		});
1244
-
1245
-		$this->registerService(\OCP\OCS\IDiscoveryService::class, function (ContainerInterface $c) {
1246
-			return new DiscoveryService(
1247
-				$c->get(ICacheFactory::class),
1248
-				$c->get(IClientService::class)
1249
-			);
1250
-		});
1251
-
1252
-		$this->registerService(ICloudIdManager::class, function (ContainerInterface $c) {
1253
-			return new CloudIdManager($c->get(\OCP\Contacts\IManager::class));
1254
-		});
1255
-
1256
-		$this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class);
1257
-
1258
-		$this->registerService(ICloudFederationProviderManager::class, function (ContainerInterface $c) {
1259
-			return new CloudFederationProviderManager(
1260
-				$c->get(IAppManager::class),
1261
-				$c->get(IClientService::class),
1262
-				$c->get(ICloudIdManager::class),
1263
-				$c->get(ILogger::class)
1264
-			);
1265
-		});
1266
-
1267
-		$this->registerService(ICloudFederationFactory::class, function (Server $c) {
1268
-			return new CloudFederationFactory();
1269
-		});
1270
-
1271
-		$this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1272
-		/** @deprecated 19.0.0 */
1273
-		$this->registerDeprecatedAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
1274
-
1275
-		$this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1276
-		/** @deprecated 19.0.0 */
1277
-		$this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1278
-
1279
-		$this->registerService(Defaults::class, function (Server $c) {
1280
-			return new Defaults(
1281
-				$c->getThemingDefaults()
1282
-			);
1283
-		});
1284
-		/** @deprecated 19.0.0 */
1285
-		$this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class);
1286
-
1287
-		$this->registerService(\OCP\ISession::class, function (ContainerInterface $c) {
1288
-			return $c->get(\OCP\IUserSession::class)->getSession();
1289
-		}, false);
1290
-
1291
-		$this->registerService(IShareHelper::class, function (ContainerInterface $c) {
1292
-			return new ShareHelper(
1293
-				$c->get(\OCP\Share\IManager::class)
1294
-			);
1295
-		});
1296
-
1297
-		$this->registerService(Installer::class, function (ContainerInterface $c) {
1298
-			return new Installer(
1299
-				$c->get(AppFetcher::class),
1300
-				$c->get(IClientService::class),
1301
-				$c->get(ITempManager::class),
1302
-				$c->get(ILogger::class),
1303
-				$c->get(\OCP\IConfig::class),
1304
-				\OC::$CLI
1305
-			);
1306
-		});
1307
-
1308
-		$this->registerService(IApiFactory::class, function (ContainerInterface $c) {
1309
-			return new ApiFactory($c->get(IClientService::class));
1310
-		});
1311
-
1312
-		$this->registerService(IInstanceFactory::class, function (ContainerInterface $c) {
1313
-			$memcacheFactory = $c->get(ICacheFactory::class);
1314
-			return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->get(IClientService::class));
1315
-		});
1316
-
1317
-		$this->registerAlias(IContactsStore::class, ContactsStore::class);
1318
-		$this->registerAlias(IAccountManager::class, AccountManager::class);
1319
-
1320
-		$this->registerAlias(IStorageFactory::class, StorageFactory::class);
1321
-
1322
-		$this->registerAlias(IDashboardManager::class, DashboardManager::class);
1323
-		$this->registerAlias(\OCP\Dashboard\IManager::class, \OC\Dashboard\Manager::class);
1324
-		$this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class);
1325
-
1326
-		$this->registerAlias(ISubAdmin::class, SubAdmin::class);
1327
-
1328
-		$this->registerAlias(IInitialStateService::class, InitialStateService::class);
1329
-
1330
-		$this->registerAlias(\OCP\UserStatus\IManager::class, \OC\UserStatus\Manager::class);
1331
-
1332
-		$this->connectDispatcher();
1333
-	}
1334
-
1335
-	public function boot() {
1336
-		/** @var HookConnector $hookConnector */
1337
-		$hookConnector = $this->get(HookConnector::class);
1338
-		$hookConnector->viewToNode();
1339
-	}
1340
-
1341
-	/**
1342
-	 * @return \OCP\Calendar\IManager
1343
-	 * @deprecated 20.0.0
1344
-	 */
1345
-	public function getCalendarManager() {
1346
-		return $this->get(\OC\Calendar\Manager::class);
1347
-	}
1348
-
1349
-	/**
1350
-	 * @return \OCP\Calendar\Resource\IManager
1351
-	 * @deprecated 20.0.0
1352
-	 */
1353
-	public function getCalendarResourceBackendManager() {
1354
-		return $this->get(\OC\Calendar\Resource\Manager::class);
1355
-	}
1356
-
1357
-	/**
1358
-	 * @return \OCP\Calendar\Room\IManager
1359
-	 * @deprecated 20.0.0
1360
-	 */
1361
-	public function getCalendarRoomBackendManager() {
1362
-		return $this->get(\OC\Calendar\Room\Manager::class);
1363
-	}
1364
-
1365
-	private function connectDispatcher() {
1366
-		$dispatcher = $this->get(SymfonyAdapter::class);
1367
-
1368
-		// Delete avatar on user deletion
1369
-		$dispatcher->addListener('OCP\IUser::preDelete', function (GenericEvent $e) {
1370
-			$logger = $this->get(ILogger::class);
1371
-			$manager = $this->getAvatarManager();
1372
-			/** @var IUser $user */
1373
-			$user = $e->getSubject();
1374
-
1375
-			try {
1376
-				$avatar = $manager->getAvatar($user->getUID());
1377
-				$avatar->remove();
1378
-			} catch (NotFoundException $e) {
1379
-				// no avatar to remove
1380
-			} catch (\Exception $e) {
1381
-				// Ignore exceptions
1382
-				$logger->info('Could not cleanup avatar of ' . $user->getUID());
1383
-			}
1384
-		});
1385
-
1386
-		$dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) {
1387
-			$manager = $this->getAvatarManager();
1388
-			/** @var IUser $user */
1389
-			$user = $e->getSubject();
1390
-			$feature = $e->getArgument('feature');
1391
-			$oldValue = $e->getArgument('oldValue');
1392
-			$value = $e->getArgument('value');
1393
-
1394
-			// We only change the avatar on display name changes
1395
-			if ($feature !== 'displayName') {
1396
-				return;
1397
-			}
1398
-
1399
-			try {
1400
-				$avatar = $manager->getAvatar($user->getUID());
1401
-				$avatar->userChanged($feature, $oldValue, $value);
1402
-			} catch (NotFoundException $e) {
1403
-				// no avatar to remove
1404
-			}
1405
-		});
1406
-
1407
-		/** @var IEventDispatcher $eventDispatched */
1408
-		$eventDispatched = $this->get(IEventDispatcher::class);
1409
-		$eventDispatched->addServiceListener(LoginFailed::class, LoginFailedListener::class);
1410
-		$eventDispatched->addServiceListener(PostLoginEvent::class, UserLoggedInListener::class);
1411
-	}
1412
-
1413
-	/**
1414
-	 * @return \OCP\Contacts\IManager
1415
-	 * @deprecated 20.0.0
1416
-	 */
1417
-	public function getContactsManager() {
1418
-		return $this->get(\OCP\Contacts\IManager::class);
1419
-	}
1420
-
1421
-	/**
1422
-	 * @return \OC\Encryption\Manager
1423
-	 * @deprecated 20.0.0
1424
-	 */
1425
-	public function getEncryptionManager() {
1426
-		return $this->get(\OCP\Encryption\IManager::class);
1427
-	}
1428
-
1429
-	/**
1430
-	 * @return \OC\Encryption\File
1431
-	 * @deprecated 20.0.0
1432
-	 */
1433
-	public function getEncryptionFilesHelper() {
1434
-		return $this->get(IFile::class);
1435
-	}
1436
-
1437
-	/**
1438
-	 * @return \OCP\Encryption\Keys\IStorage
1439
-	 * @deprecated 20.0.0
1440
-	 */
1441
-	public function getEncryptionKeyStorage() {
1442
-		return $this->get(IStorage::class);
1443
-	}
1444
-
1445
-	/**
1446
-	 * The current request object holding all information about the request
1447
-	 * currently being processed is returned from this method.
1448
-	 * In case the current execution was not initiated by a web request null is returned
1449
-	 *
1450
-	 * @return \OCP\IRequest
1451
-	 * @deprecated 20.0.0
1452
-	 */
1453
-	public function getRequest() {
1454
-		return $this->get(IRequest::class);
1455
-	}
1456
-
1457
-	/**
1458
-	 * Returns the preview manager which can create preview images for a given file
1459
-	 *
1460
-	 * @return IPreview
1461
-	 * @deprecated 20.0.0
1462
-	 */
1463
-	public function getPreviewManager() {
1464
-		return $this->get(IPreview::class);
1465
-	}
1466
-
1467
-	/**
1468
-	 * Returns the tag manager which can get and set tags for different object types
1469
-	 *
1470
-	 * @see \OCP\ITagManager::load()
1471
-	 * @return ITagManager
1472
-	 * @deprecated 20.0.0
1473
-	 */
1474
-	public function getTagManager() {
1475
-		return $this->get(ITagManager::class);
1476
-	}
1477
-
1478
-	/**
1479
-	 * Returns the system-tag manager
1480
-	 *
1481
-	 * @return ISystemTagManager
1482
-	 *
1483
-	 * @since 9.0.0
1484
-	 * @deprecated 20.0.0
1485
-	 */
1486
-	public function getSystemTagManager() {
1487
-		return $this->get(ISystemTagManager::class);
1488
-	}
1489
-
1490
-	/**
1491
-	 * Returns the system-tag object mapper
1492
-	 *
1493
-	 * @return ISystemTagObjectMapper
1494
-	 *
1495
-	 * @since 9.0.0
1496
-	 * @deprecated 20.0.0
1497
-	 */
1498
-	public function getSystemTagObjectMapper() {
1499
-		return $this->get(ISystemTagObjectMapper::class);
1500
-	}
1501
-
1502
-	/**
1503
-	 * Returns the avatar manager, used for avatar functionality
1504
-	 *
1505
-	 * @return IAvatarManager
1506
-	 * @deprecated 20.0.0
1507
-	 */
1508
-	public function getAvatarManager() {
1509
-		return $this->get(IAvatarManager::class);
1510
-	}
1511
-
1512
-	/**
1513
-	 * Returns the root folder of ownCloud's data directory
1514
-	 *
1515
-	 * @return IRootFolder
1516
-	 * @deprecated 20.0.0
1517
-	 */
1518
-	public function getRootFolder() {
1519
-		return $this->get(IRootFolder::class);
1520
-	}
1521
-
1522
-	/**
1523
-	 * Returns the root folder of ownCloud's data directory
1524
-	 * This is the lazy variant so this gets only initialized once it
1525
-	 * is actually used.
1526
-	 *
1527
-	 * @return IRootFolder
1528
-	 * @deprecated 20.0.0
1529
-	 */
1530
-	public function getLazyRootFolder() {
1531
-		return $this->get(IRootFolder::class);
1532
-	}
1533
-
1534
-	/**
1535
-	 * Returns a view to ownCloud's files folder
1536
-	 *
1537
-	 * @param string $userId user ID
1538
-	 * @return \OCP\Files\Folder|null
1539
-	 * @deprecated 20.0.0
1540
-	 */
1541
-	public function getUserFolder($userId = null) {
1542
-		if ($userId === null) {
1543
-			$user = $this->get(IUserSession::class)->getUser();
1544
-			if (!$user) {
1545
-				return null;
1546
-			}
1547
-			$userId = $user->getUID();
1548
-		}
1549
-		$root = $this->get(IRootFolder::class);
1550
-		return $root->getUserFolder($userId);
1551
-	}
1552
-
1553
-	/**
1554
-	 * @return \OC\User\Manager
1555
-	 * @deprecated 20.0.0
1556
-	 */
1557
-	public function getUserManager() {
1558
-		return $this->get(IUserManager::class);
1559
-	}
1560
-
1561
-	/**
1562
-	 * @return \OC\Group\Manager
1563
-	 * @deprecated 20.0.0
1564
-	 */
1565
-	public function getGroupManager() {
1566
-		return $this->get(IGroupManager::class);
1567
-	}
1568
-
1569
-	/**
1570
-	 * @return \OC\User\Session
1571
-	 * @deprecated 20.0.0
1572
-	 */
1573
-	public function getUserSession() {
1574
-		return $this->get(IUserSession::class);
1575
-	}
1576
-
1577
-	/**
1578
-	 * @return \OCP\ISession
1579
-	 * @deprecated 20.0.0
1580
-	 */
1581
-	public function getSession() {
1582
-		return $this->get(IUserSession::class)->getSession();
1583
-	}
1584
-
1585
-	/**
1586
-	 * @param \OCP\ISession $session
1587
-	 */
1588
-	public function setSession(\OCP\ISession $session) {
1589
-		$this->get(SessionStorage::class)->setSession($session);
1590
-		$this->get(IUserSession::class)->setSession($session);
1591
-		$this->get(Store::class)->setSession($session);
1592
-	}
1593
-
1594
-	/**
1595
-	 * @return \OC\Authentication\TwoFactorAuth\Manager
1596
-	 * @deprecated 20.0.0
1597
-	 */
1598
-	public function getTwoFactorAuthManager() {
1599
-		return $this->get(\OC\Authentication\TwoFactorAuth\Manager::class);
1600
-	}
1601
-
1602
-	/**
1603
-	 * @return \OC\NavigationManager
1604
-	 * @deprecated 20.0.0
1605
-	 */
1606
-	public function getNavigationManager() {
1607
-		return $this->get(INavigationManager::class);
1608
-	}
1609
-
1610
-	/**
1611
-	 * @return \OCP\IConfig
1612
-	 * @deprecated 20.0.0
1613
-	 */
1614
-	public function getConfig() {
1615
-		return $this->get(AllConfig::class);
1616
-	}
1617
-
1618
-	/**
1619
-	 * @return \OC\SystemConfig
1620
-	 * @deprecated 20.0.0
1621
-	 */
1622
-	public function getSystemConfig() {
1623
-		return $this->get(SystemConfig::class);
1624
-	}
1625
-
1626
-	/**
1627
-	 * Returns the app config manager
1628
-	 *
1629
-	 * @return IAppConfig
1630
-	 * @deprecated 20.0.0
1631
-	 */
1632
-	public function getAppConfig() {
1633
-		return $this->get(IAppConfig::class);
1634
-	}
1635
-
1636
-	/**
1637
-	 * @return IFactory
1638
-	 * @deprecated 20.0.0
1639
-	 */
1640
-	public function getL10NFactory() {
1641
-		return $this->get(IFactory::class);
1642
-	}
1643
-
1644
-	/**
1645
-	 * get an L10N instance
1646
-	 *
1647
-	 * @param string $app appid
1648
-	 * @param string $lang
1649
-	 * @return IL10N
1650
-	 * @deprecated 20.0.0
1651
-	 */
1652
-	public function getL10N($app, $lang = null) {
1653
-		return $this->get(IFactory::class)->get($app, $lang);
1654
-	}
1655
-
1656
-	/**
1657
-	 * @return IURLGenerator
1658
-	 * @deprecated 20.0.0
1659
-	 */
1660
-	public function getURLGenerator() {
1661
-		return $this->get(IURLGenerator::class);
1662
-	}
1663
-
1664
-	/**
1665
-	 * @return AppFetcher
1666
-	 * @deprecated 20.0.0
1667
-	 */
1668
-	public function getAppFetcher() {
1669
-		return $this->get(AppFetcher::class);
1670
-	}
1671
-
1672
-	/**
1673
-	 * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1674
-	 * getMemCacheFactory() instead.
1675
-	 *
1676
-	 * @return ICache
1677
-	 * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1678
-	 */
1679
-	public function getCache() {
1680
-		return $this->get(ICache::class);
1681
-	}
1682
-
1683
-	/**
1684
-	 * Returns an \OCP\CacheFactory instance
1685
-	 *
1686
-	 * @return \OCP\ICacheFactory
1687
-	 * @deprecated 20.0.0
1688
-	 */
1689
-	public function getMemCacheFactory() {
1690
-		return $this->get(ICacheFactory::class);
1691
-	}
1692
-
1693
-	/**
1694
-	 * Returns an \OC\RedisFactory instance
1695
-	 *
1696
-	 * @return \OC\RedisFactory
1697
-	 * @deprecated 20.0.0
1698
-	 */
1699
-	public function getGetRedisFactory() {
1700
-		return $this->get('RedisFactory');
1701
-	}
1702
-
1703
-
1704
-	/**
1705
-	 * Returns the current session
1706
-	 *
1707
-	 * @return \OCP\IDBConnection
1708
-	 * @deprecated 20.0.0
1709
-	 */
1710
-	public function getDatabaseConnection() {
1711
-		return $this->get(IDBConnection::class);
1712
-	}
1713
-
1714
-	/**
1715
-	 * Returns the activity manager
1716
-	 *
1717
-	 * @return \OCP\Activity\IManager
1718
-	 * @deprecated 20.0.0
1719
-	 */
1720
-	public function getActivityManager() {
1721
-		return $this->get(\OCP\Activity\IManager::class);
1722
-	}
1723
-
1724
-	/**
1725
-	 * Returns an job list for controlling background jobs
1726
-	 *
1727
-	 * @return IJobList
1728
-	 * @deprecated 20.0.0
1729
-	 */
1730
-	public function getJobList() {
1731
-		return $this->get(IJobList::class);
1732
-	}
1733
-
1734
-	/**
1735
-	 * Returns a logger instance
1736
-	 *
1737
-	 * @return ILogger
1738
-	 * @deprecated 20.0.0
1739
-	 */
1740
-	public function getLogger() {
1741
-		return $this->get(ILogger::class);
1742
-	}
1743
-
1744
-	/**
1745
-	 * @return ILogFactory
1746
-	 * @throws \OCP\AppFramework\QueryException
1747
-	 * @deprecated 20.0.0
1748
-	 */
1749
-	public function getLogFactory() {
1750
-		return $this->get(ILogFactory::class);
1751
-	}
1752
-
1753
-	/**
1754
-	 * Returns a router for generating and matching urls
1755
-	 *
1756
-	 * @return IRouter
1757
-	 * @deprecated 20.0.0
1758
-	 */
1759
-	public function getRouter() {
1760
-		return $this->get(IRouter::class);
1761
-	}
1762
-
1763
-	/**
1764
-	 * Returns a search instance
1765
-	 *
1766
-	 * @return ISearch
1767
-	 * @deprecated 20.0.0
1768
-	 */
1769
-	public function getSearch() {
1770
-		return $this->get(ISearch::class);
1771
-	}
1772
-
1773
-	/**
1774
-	 * Returns a SecureRandom instance
1775
-	 *
1776
-	 * @return \OCP\Security\ISecureRandom
1777
-	 * @deprecated 20.0.0
1778
-	 */
1779
-	public function getSecureRandom() {
1780
-		return $this->get(ISecureRandom::class);
1781
-	}
1782
-
1783
-	/**
1784
-	 * Returns a Crypto instance
1785
-	 *
1786
-	 * @return ICrypto
1787
-	 * @deprecated 20.0.0
1788
-	 */
1789
-	public function getCrypto() {
1790
-		return $this->get(ICrypto::class);
1791
-	}
1792
-
1793
-	/**
1794
-	 * Returns a Hasher instance
1795
-	 *
1796
-	 * @return IHasher
1797
-	 * @deprecated 20.0.0
1798
-	 */
1799
-	public function getHasher() {
1800
-		return $this->get(IHasher::class);
1801
-	}
1802
-
1803
-	/**
1804
-	 * Returns a CredentialsManager instance
1805
-	 *
1806
-	 * @return ICredentialsManager
1807
-	 * @deprecated 20.0.0
1808
-	 */
1809
-	public function getCredentialsManager() {
1810
-		return $this->get(ICredentialsManager::class);
1811
-	}
1812
-
1813
-	/**
1814
-	 * Get the certificate manager
1815
-	 *
1816
-	 * @return \OCP\ICertificateManager
1817
-	 */
1818
-	public function getCertificateManager() {
1819
-		return $this->get(ICertificateManager::class);
1820
-	}
1821
-
1822
-	/**
1823
-	 * Returns an instance of the HTTP client service
1824
-	 *
1825
-	 * @return IClientService
1826
-	 * @deprecated 20.0.0
1827
-	 */
1828
-	public function getHTTPClientService() {
1829
-		return $this->get(IClientService::class);
1830
-	}
1831
-
1832
-	/**
1833
-	 * Create a new event source
1834
-	 *
1835
-	 * @return \OCP\IEventSource
1836
-	 * @deprecated 20.0.0
1837
-	 */
1838
-	public function createEventSource() {
1839
-		return new \OC_EventSource();
1840
-	}
1841
-
1842
-	/**
1843
-	 * Get the active event logger
1844
-	 *
1845
-	 * The returned logger only logs data when debug mode is enabled
1846
-	 *
1847
-	 * @return IEventLogger
1848
-	 * @deprecated 20.0.0
1849
-	 */
1850
-	public function getEventLogger() {
1851
-		return $this->get(IEventLogger::class);
1852
-	}
1853
-
1854
-	/**
1855
-	 * Get the active query logger
1856
-	 *
1857
-	 * The returned logger only logs data when debug mode is enabled
1858
-	 *
1859
-	 * @return IQueryLogger
1860
-	 * @deprecated 20.0.0
1861
-	 */
1862
-	public function getQueryLogger() {
1863
-		return $this->get(IQueryLogger::class);
1864
-	}
1865
-
1866
-	/**
1867
-	 * Get the manager for temporary files and folders
1868
-	 *
1869
-	 * @return \OCP\ITempManager
1870
-	 * @deprecated 20.0.0
1871
-	 */
1872
-	public function getTempManager() {
1873
-		return $this->get(ITempManager::class);
1874
-	}
1875
-
1876
-	/**
1877
-	 * Get the app manager
1878
-	 *
1879
-	 * @return \OCP\App\IAppManager
1880
-	 * @deprecated 20.0.0
1881
-	 */
1882
-	public function getAppManager() {
1883
-		return $this->get(IAppManager::class);
1884
-	}
1885
-
1886
-	/**
1887
-	 * Creates a new mailer
1888
-	 *
1889
-	 * @return IMailer
1890
-	 * @deprecated 20.0.0
1891
-	 */
1892
-	public function getMailer() {
1893
-		return $this->get(IMailer::class);
1894
-	}
1895
-
1896
-	/**
1897
-	 * Get the webroot
1898
-	 *
1899
-	 * @return string
1900
-	 * @deprecated 20.0.0
1901
-	 */
1902
-	public function getWebRoot() {
1903
-		return $this->webRoot;
1904
-	}
1905
-
1906
-	/**
1907
-	 * @return \OC\OCSClient
1908
-	 * @deprecated 20.0.0
1909
-	 */
1910
-	public function getOcsClient() {
1911
-		return $this->get('OcsClient');
1912
-	}
1913
-
1914
-	/**
1915
-	 * @return IDateTimeZone
1916
-	 * @deprecated 20.0.0
1917
-	 */
1918
-	public function getDateTimeZone() {
1919
-		return $this->get(IDateTimeZone::class);
1920
-	}
1921
-
1922
-	/**
1923
-	 * @return IDateTimeFormatter
1924
-	 * @deprecated 20.0.0
1925
-	 */
1926
-	public function getDateTimeFormatter() {
1927
-		return $this->get(IDateTimeFormatter::class);
1928
-	}
1929
-
1930
-	/**
1931
-	 * @return IMountProviderCollection
1932
-	 * @deprecated 20.0.0
1933
-	 */
1934
-	public function getMountProviderCollection() {
1935
-		return $this->get(IMountProviderCollection::class);
1936
-	}
1937
-
1938
-	/**
1939
-	 * Get the IniWrapper
1940
-	 *
1941
-	 * @return IniGetWrapper
1942
-	 * @deprecated 20.0.0
1943
-	 */
1944
-	public function getIniWrapper() {
1945
-		return $this->get(IniGetWrapper::class);
1946
-	}
1947
-
1948
-	/**
1949
-	 * @return \OCP\Command\IBus
1950
-	 * @deprecated 20.0.0
1951
-	 */
1952
-	public function getCommandBus() {
1953
-		return $this->get(IBus::class);
1954
-	}
1955
-
1956
-	/**
1957
-	 * Get the trusted domain helper
1958
-	 *
1959
-	 * @return TrustedDomainHelper
1960
-	 * @deprecated 20.0.0
1961
-	 */
1962
-	public function getTrustedDomainHelper() {
1963
-		return $this->get(TrustedDomainHelper::class);
1964
-	}
1965
-
1966
-	/**
1967
-	 * Get the locking provider
1968
-	 *
1969
-	 * @return ILockingProvider
1970
-	 * @since 8.1.0
1971
-	 * @deprecated 20.0.0
1972
-	 */
1973
-	public function getLockingProvider() {
1974
-		return $this->get(ILockingProvider::class);
1975
-	}
1976
-
1977
-	/**
1978
-	 * @return IMountManager
1979
-	 * @deprecated 20.0.0
1980
-	 **/
1981
-	public function getMountManager() {
1982
-		return $this->get(IMountManager::class);
1983
-	}
1984
-
1985
-	/**
1986
-	 * @return IUserMountCache
1987
-	 * @deprecated 20.0.0
1988
-	 */
1989
-	public function getUserMountCache() {
1990
-		return $this->get(IUserMountCache::class);
1991
-	}
1992
-
1993
-	/**
1994
-	 * Get the MimeTypeDetector
1995
-	 *
1996
-	 * @return IMimeTypeDetector
1997
-	 * @deprecated 20.0.0
1998
-	 */
1999
-	public function getMimeTypeDetector() {
2000
-		return $this->get(IMimeTypeDetector::class);
2001
-	}
2002
-
2003
-	/**
2004
-	 * Get the MimeTypeLoader
2005
-	 *
2006
-	 * @return IMimeTypeLoader
2007
-	 * @deprecated 20.0.0
2008
-	 */
2009
-	public function getMimeTypeLoader() {
2010
-		return $this->get(IMimeTypeLoader::class);
2011
-	}
2012
-
2013
-	/**
2014
-	 * Get the manager of all the capabilities
2015
-	 *
2016
-	 * @return CapabilitiesManager
2017
-	 * @deprecated 20.0.0
2018
-	 */
2019
-	public function getCapabilitiesManager() {
2020
-		return $this->get(CapabilitiesManager::class);
2021
-	}
2022
-
2023
-	/**
2024
-	 * Get the EventDispatcher
2025
-	 *
2026
-	 * @return EventDispatcherInterface
2027
-	 * @since 8.2.0
2028
-	 * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher
2029
-	 */
2030
-	public function getEventDispatcher() {
2031
-		return $this->get(\OC\EventDispatcher\SymfonyAdapter::class);
2032
-	}
2033
-
2034
-	/**
2035
-	 * Get the Notification Manager
2036
-	 *
2037
-	 * @return \OCP\Notification\IManager
2038
-	 * @since 8.2.0
2039
-	 * @deprecated 20.0.0
2040
-	 */
2041
-	public function getNotificationManager() {
2042
-		return $this->get(\OCP\Notification\IManager::class);
2043
-	}
2044
-
2045
-	/**
2046
-	 * @return ICommentsManager
2047
-	 * @deprecated 20.0.0
2048
-	 */
2049
-	public function getCommentsManager() {
2050
-		return $this->get(ICommentsManager::class);
2051
-	}
2052
-
2053
-	/**
2054
-	 * @return \OCA\Theming\ThemingDefaults
2055
-	 * @deprecated 20.0.0
2056
-	 */
2057
-	public function getThemingDefaults() {
2058
-		return $this->get('ThemingDefaults');
2059
-	}
2060
-
2061
-	/**
2062
-	 * @return \OC\IntegrityCheck\Checker
2063
-	 * @deprecated 20.0.0
2064
-	 */
2065
-	public function getIntegrityCodeChecker() {
2066
-		return $this->get('IntegrityCodeChecker');
2067
-	}
2068
-
2069
-	/**
2070
-	 * @return \OC\Session\CryptoWrapper
2071
-	 * @deprecated 20.0.0
2072
-	 */
2073
-	public function getSessionCryptoWrapper() {
2074
-		return $this->get('CryptoWrapper');
2075
-	}
2076
-
2077
-	/**
2078
-	 * @return CsrfTokenManager
2079
-	 * @deprecated 20.0.0
2080
-	 */
2081
-	public function getCsrfTokenManager() {
2082
-		return $this->get(CsrfTokenManager::class);
2083
-	}
2084
-
2085
-	/**
2086
-	 * @return Throttler
2087
-	 * @deprecated 20.0.0
2088
-	 */
2089
-	public function getBruteForceThrottler() {
2090
-		return $this->get(Throttler::class);
2091
-	}
2092
-
2093
-	/**
2094
-	 * @return IContentSecurityPolicyManager
2095
-	 * @deprecated 20.0.0
2096
-	 */
2097
-	public function getContentSecurityPolicyManager() {
2098
-		return $this->get(ContentSecurityPolicyManager::class);
2099
-	}
2100
-
2101
-	/**
2102
-	 * @return ContentSecurityPolicyNonceManager
2103
-	 * @deprecated 20.0.0
2104
-	 */
2105
-	public function getContentSecurityPolicyNonceManager() {
2106
-		return $this->get(ContentSecurityPolicyNonceManager::class);
2107
-	}
2108
-
2109
-	/**
2110
-	 * Not a public API as of 8.2, wait for 9.0
2111
-	 *
2112
-	 * @return \OCA\Files_External\Service\BackendService
2113
-	 * @deprecated 20.0.0
2114
-	 */
2115
-	public function getStoragesBackendService() {
2116
-		return $this->get(BackendService::class);
2117
-	}
2118
-
2119
-	/**
2120
-	 * Not a public API as of 8.2, wait for 9.0
2121
-	 *
2122
-	 * @return \OCA\Files_External\Service\GlobalStoragesService
2123
-	 * @deprecated 20.0.0
2124
-	 */
2125
-	public function getGlobalStoragesService() {
2126
-		return $this->get(GlobalStoragesService::class);
2127
-	}
2128
-
2129
-	/**
2130
-	 * Not a public API as of 8.2, wait for 9.0
2131
-	 *
2132
-	 * @return \OCA\Files_External\Service\UserGlobalStoragesService
2133
-	 * @deprecated 20.0.0
2134
-	 */
2135
-	public function getUserGlobalStoragesService() {
2136
-		return $this->get(UserGlobalStoragesService::class);
2137
-	}
2138
-
2139
-	/**
2140
-	 * Not a public API as of 8.2, wait for 9.0
2141
-	 *
2142
-	 * @return \OCA\Files_External\Service\UserStoragesService
2143
-	 * @deprecated 20.0.0
2144
-	 */
2145
-	public function getUserStoragesService() {
2146
-		return $this->get(UserStoragesService::class);
2147
-	}
2148
-
2149
-	/**
2150
-	 * @return \OCP\Share\IManager
2151
-	 * @deprecated 20.0.0
2152
-	 */
2153
-	public function getShareManager() {
2154
-		return $this->get(\OCP\Share\IManager::class);
2155
-	}
2156
-
2157
-	/**
2158
-	 * @return \OCP\Collaboration\Collaborators\ISearch
2159
-	 * @deprecated 20.0.0
2160
-	 */
2161
-	public function getCollaboratorSearch() {
2162
-		return $this->get(\OCP\Collaboration\Collaborators\ISearch::class);
2163
-	}
2164
-
2165
-	/**
2166
-	 * @return \OCP\Collaboration\AutoComplete\IManager
2167
-	 * @deprecated 20.0.0
2168
-	 */
2169
-	public function getAutoCompleteManager() {
2170
-		return $this->get(IManager::class);
2171
-	}
2172
-
2173
-	/**
2174
-	 * Returns the LDAP Provider
2175
-	 *
2176
-	 * @return \OCP\LDAP\ILDAPProvider
2177
-	 * @deprecated 20.0.0
2178
-	 */
2179
-	public function getLDAPProvider() {
2180
-		return $this->get('LDAPProvider');
2181
-	}
2182
-
2183
-	/**
2184
-	 * @return \OCP\Settings\IManager
2185
-	 * @deprecated 20.0.0
2186
-	 */
2187
-	public function getSettingsManager() {
2188
-		return $this->get(\OC\Settings\Manager::class);
2189
-	}
2190
-
2191
-	/**
2192
-	 * @return \OCP\Files\IAppData
2193
-	 * @deprecated 20.0.0
2194
-	 */
2195
-	public function getAppDataDir($app) {
2196
-		/** @var \OC\Files\AppData\Factory $factory */
2197
-		$factory = $this->get(\OC\Files\AppData\Factory::class);
2198
-		return $factory->get($app);
2199
-	}
2200
-
2201
-	/**
2202
-	 * @return \OCP\Lockdown\ILockdownManager
2203
-	 * @deprecated 20.0.0
2204
-	 */
2205
-	public function getLockdownManager() {
2206
-		return $this->get('LockdownManager');
2207
-	}
2208
-
2209
-	/**
2210
-	 * @return \OCP\Federation\ICloudIdManager
2211
-	 * @deprecated 20.0.0
2212
-	 */
2213
-	public function getCloudIdManager() {
2214
-		return $this->get(ICloudIdManager::class);
2215
-	}
2216
-
2217
-	/**
2218
-	 * @return \OCP\GlobalScale\IConfig
2219
-	 * @deprecated 20.0.0
2220
-	 */
2221
-	public function getGlobalScaleConfig() {
2222
-		return $this->get(IConfig::class);
2223
-	}
2224
-
2225
-	/**
2226
-	 * @return \OCP\Federation\ICloudFederationProviderManager
2227
-	 * @deprecated 20.0.0
2228
-	 */
2229
-	public function getCloudFederationProviderManager() {
2230
-		return $this->get(ICloudFederationProviderManager::class);
2231
-	}
2232
-
2233
-	/**
2234
-	 * @return \OCP\Remote\Api\IApiFactory
2235
-	 * @deprecated 20.0.0
2236
-	 */
2237
-	public function getRemoteApiFactory() {
2238
-		return $this->get(IApiFactory::class);
2239
-	}
2240
-
2241
-	/**
2242
-	 * @return \OCP\Federation\ICloudFederationFactory
2243
-	 * @deprecated 20.0.0
2244
-	 */
2245
-	public function getCloudFederationFactory() {
2246
-		return $this->get(ICloudFederationFactory::class);
2247
-	}
2248
-
2249
-	/**
2250
-	 * @return \OCP\Remote\IInstanceFactory
2251
-	 * @deprecated 20.0.0
2252
-	 */
2253
-	public function getRemoteInstanceFactory() {
2254
-		return $this->get(IInstanceFactory::class);
2255
-	}
2256
-
2257
-	/**
2258
-	 * @return IStorageFactory
2259
-	 * @deprecated 20.0.0
2260
-	 */
2261
-	public function getStorageFactory() {
2262
-		return $this->get(IStorageFactory::class);
2263
-	}
2264
-
2265
-	/**
2266
-	 * Get the Preview GeneratorHelper
2267
-	 *
2268
-	 * @return GeneratorHelper
2269
-	 * @since 17.0.0
2270
-	 * @deprecated 20.0.0
2271
-	 */
2272
-	public function getGeneratorHelper() {
2273
-		return $this->get(\OC\Preview\GeneratorHelper::class);
2274
-	}
2275
-
2276
-	private function registerDeprecatedAlias(string $alias, string $target) {
2277
-		$this->registerService($alias, function (ContainerInterface $container) use ($target, $alias) {
2278
-			try {
2279
-				/** @var ILogger $logger */
2280
-				$logger = $container->get(ILogger::class);
2281
-				$logger->debug('The requested alias "' . $alias . '" is deprecated. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']);
2282
-			} catch (ContainerExceptionInterface $e) {
2283
-				// Could not get logger. Continue
2284
-			}
2285
-
2286
-			return $container->get($target);
2287
-		}, false);
2288
-	}
1103
+            $prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
1104
+            if (isset($prefixes['OCA\\Theming\\'])) {
1105
+                $classExists = true;
1106
+            } else {
1107
+                $classExists = false;
1108
+            }
1109
+
1110
+            if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValue('installed', false) && $c->get(IAppManager::class)->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
1111
+                return new ThemingDefaults(
1112
+                    $c->get(\OCP\IConfig::class),
1113
+                    $c->getL10N('theming'),
1114
+                    $c->get(IURLGenerator::class),
1115
+                    $c->get(ICacheFactory::class),
1116
+                    new Util($c->get(\OCP\IConfig::class), $this->get(IAppManager::class), $c->getAppDataDir('theming')),
1117
+                    new ImageManager(
1118
+                        $c->get(\OCP\IConfig::class),
1119
+                        $c->getAppDataDir('theming'),
1120
+                        $c->get(IURLGenerator::class),
1121
+                        $this->get(ICacheFactory::class),
1122
+                        $this->get(ILogger::class),
1123
+                        $this->get(ITempManager::class)
1124
+                    ),
1125
+                    $c->get(IAppManager::class),
1126
+                    $c->get(INavigationManager::class)
1127
+                );
1128
+            }
1129
+            return new \OC_Defaults();
1130
+        });
1131
+        $this->registerService(JSCombiner::class, function (Server $c) {
1132
+            return new JSCombiner(
1133
+                $c->getAppDataDir('js'),
1134
+                $c->get(IURLGenerator::class),
1135
+                $this->get(ICacheFactory::class),
1136
+                $c->get(SystemConfig::class),
1137
+                $c->get(ILogger::class)
1138
+            );
1139
+        });
1140
+        $this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class);
1141
+        /** @deprecated 19.0.0 */
1142
+        $this->registerDeprecatedAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class);
1143
+        $this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class);
1144
+
1145
+        $this->registerService('CryptoWrapper', function (ContainerInterface $c) {
1146
+            // FIXME: Instantiiated here due to cyclic dependency
1147
+            $request = new Request(
1148
+                [
1149
+                    'get' => $_GET,
1150
+                    'post' => $_POST,
1151
+                    'files' => $_FILES,
1152
+                    'server' => $_SERVER,
1153
+                    'env' => $_ENV,
1154
+                    'cookies' => $_COOKIE,
1155
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1156
+                        ? $_SERVER['REQUEST_METHOD']
1157
+                        : null,
1158
+                ],
1159
+                $c->get(ISecureRandom::class),
1160
+                $c->get(\OCP\IConfig::class)
1161
+            );
1162
+
1163
+            return new CryptoWrapper(
1164
+                $c->get(\OCP\IConfig::class),
1165
+                $c->get(ICrypto::class),
1166
+                $c->get(ISecureRandom::class),
1167
+                $request
1168
+            );
1169
+        });
1170
+        /** @deprecated 19.0.0 */
1171
+        $this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class);
1172
+        $this->registerService(SessionStorage::class, function (ContainerInterface $c) {
1173
+            return new SessionStorage($c->get(ISession::class));
1174
+        });
1175
+        $this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class);
1176
+        /** @deprecated 19.0.0 */
1177
+        $this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class);
1178
+
1179
+        $this->registerService(\OCP\Share\IManager::class, function (IServerContainer $c) {
1180
+            $config = $c->get(\OCP\IConfig::class);
1181
+            $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
1182
+            /** @var \OCP\Share\IProviderFactory $factory */
1183
+            $factory = new $factoryClass($this);
1184
+
1185
+            $manager = new \OC\Share20\Manager(
1186
+                $c->get(ILogger::class),
1187
+                $c->get(\OCP\IConfig::class),
1188
+                $c->get(ISecureRandom::class),
1189
+                $c->get(IHasher::class),
1190
+                $c->get(IMountManager::class),
1191
+                $c->get(IGroupManager::class),
1192
+                $c->getL10N('lib'),
1193
+                $c->get(IFactory::class),
1194
+                $factory,
1195
+                $c->get(IUserManager::class),
1196
+                $c->get(IRootFolder::class),
1197
+                $c->get(SymfonyAdapter::class),
1198
+                $c->get(IMailer::class),
1199
+                $c->get(IURLGenerator::class),
1200
+                $c->get('ThemingDefaults'),
1201
+                $c->get(IEventDispatcher::class)
1202
+            );
1203
+
1204
+            return $manager;
1205
+        });
1206
+        /** @deprecated 19.0.0 */
1207
+        $this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class);
1208
+
1209
+        $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) {
1210
+            $instance = new Collaboration\Collaborators\Search($c);
1211
+
1212
+            // register default plugins
1213
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
1214
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
1215
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
1216
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
1217
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
1218
+
1219
+            return $instance;
1220
+        });
1221
+        /** @deprecated 19.0.0 */
1222
+        $this->registerDeprecatedAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class);
1223
+        $this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class);
1224
+
1225
+        $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
1226
+
1227
+        $this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class);
1228
+        $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
1229
+
1230
+        $this->registerDeprecatedAlias('SettingsManager', \OC\Settings\Manager::class);
1231
+        $this->registerAlias(\OCP\Settings\IManager::class, \OC\Settings\Manager::class);
1232
+        $this->registerService(\OC\Files\AppData\Factory::class, function (ContainerInterface $c) {
1233
+            return new \OC\Files\AppData\Factory(
1234
+                $c->get(IRootFolder::class),
1235
+                $c->get(SystemConfig::class)
1236
+            );
1237
+        });
1238
+
1239
+        $this->registerService('LockdownManager', function (ContainerInterface $c) {
1240
+            return new LockdownManager(function () use ($c) {
1241
+                return $c->get(ISession::class);
1242
+            });
1243
+        });
1244
+
1245
+        $this->registerService(\OCP\OCS\IDiscoveryService::class, function (ContainerInterface $c) {
1246
+            return new DiscoveryService(
1247
+                $c->get(ICacheFactory::class),
1248
+                $c->get(IClientService::class)
1249
+            );
1250
+        });
1251
+
1252
+        $this->registerService(ICloudIdManager::class, function (ContainerInterface $c) {
1253
+            return new CloudIdManager($c->get(\OCP\Contacts\IManager::class));
1254
+        });
1255
+
1256
+        $this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class);
1257
+
1258
+        $this->registerService(ICloudFederationProviderManager::class, function (ContainerInterface $c) {
1259
+            return new CloudFederationProviderManager(
1260
+                $c->get(IAppManager::class),
1261
+                $c->get(IClientService::class),
1262
+                $c->get(ICloudIdManager::class),
1263
+                $c->get(ILogger::class)
1264
+            );
1265
+        });
1266
+
1267
+        $this->registerService(ICloudFederationFactory::class, function (Server $c) {
1268
+            return new CloudFederationFactory();
1269
+        });
1270
+
1271
+        $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1272
+        /** @deprecated 19.0.0 */
1273
+        $this->registerDeprecatedAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
1274
+
1275
+        $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1276
+        /** @deprecated 19.0.0 */
1277
+        $this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1278
+
1279
+        $this->registerService(Defaults::class, function (Server $c) {
1280
+            return new Defaults(
1281
+                $c->getThemingDefaults()
1282
+            );
1283
+        });
1284
+        /** @deprecated 19.0.0 */
1285
+        $this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class);
1286
+
1287
+        $this->registerService(\OCP\ISession::class, function (ContainerInterface $c) {
1288
+            return $c->get(\OCP\IUserSession::class)->getSession();
1289
+        }, false);
1290
+
1291
+        $this->registerService(IShareHelper::class, function (ContainerInterface $c) {
1292
+            return new ShareHelper(
1293
+                $c->get(\OCP\Share\IManager::class)
1294
+            );
1295
+        });
1296
+
1297
+        $this->registerService(Installer::class, function (ContainerInterface $c) {
1298
+            return new Installer(
1299
+                $c->get(AppFetcher::class),
1300
+                $c->get(IClientService::class),
1301
+                $c->get(ITempManager::class),
1302
+                $c->get(ILogger::class),
1303
+                $c->get(\OCP\IConfig::class),
1304
+                \OC::$CLI
1305
+            );
1306
+        });
1307
+
1308
+        $this->registerService(IApiFactory::class, function (ContainerInterface $c) {
1309
+            return new ApiFactory($c->get(IClientService::class));
1310
+        });
1311
+
1312
+        $this->registerService(IInstanceFactory::class, function (ContainerInterface $c) {
1313
+            $memcacheFactory = $c->get(ICacheFactory::class);
1314
+            return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->get(IClientService::class));
1315
+        });
1316
+
1317
+        $this->registerAlias(IContactsStore::class, ContactsStore::class);
1318
+        $this->registerAlias(IAccountManager::class, AccountManager::class);
1319
+
1320
+        $this->registerAlias(IStorageFactory::class, StorageFactory::class);
1321
+
1322
+        $this->registerAlias(IDashboardManager::class, DashboardManager::class);
1323
+        $this->registerAlias(\OCP\Dashboard\IManager::class, \OC\Dashboard\Manager::class);
1324
+        $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class);
1325
+
1326
+        $this->registerAlias(ISubAdmin::class, SubAdmin::class);
1327
+
1328
+        $this->registerAlias(IInitialStateService::class, InitialStateService::class);
1329
+
1330
+        $this->registerAlias(\OCP\UserStatus\IManager::class, \OC\UserStatus\Manager::class);
1331
+
1332
+        $this->connectDispatcher();
1333
+    }
1334
+
1335
+    public function boot() {
1336
+        /** @var HookConnector $hookConnector */
1337
+        $hookConnector = $this->get(HookConnector::class);
1338
+        $hookConnector->viewToNode();
1339
+    }
1340
+
1341
+    /**
1342
+     * @return \OCP\Calendar\IManager
1343
+     * @deprecated 20.0.0
1344
+     */
1345
+    public function getCalendarManager() {
1346
+        return $this->get(\OC\Calendar\Manager::class);
1347
+    }
1348
+
1349
+    /**
1350
+     * @return \OCP\Calendar\Resource\IManager
1351
+     * @deprecated 20.0.0
1352
+     */
1353
+    public function getCalendarResourceBackendManager() {
1354
+        return $this->get(\OC\Calendar\Resource\Manager::class);
1355
+    }
1356
+
1357
+    /**
1358
+     * @return \OCP\Calendar\Room\IManager
1359
+     * @deprecated 20.0.0
1360
+     */
1361
+    public function getCalendarRoomBackendManager() {
1362
+        return $this->get(\OC\Calendar\Room\Manager::class);
1363
+    }
1364
+
1365
+    private function connectDispatcher() {
1366
+        $dispatcher = $this->get(SymfonyAdapter::class);
1367
+
1368
+        // Delete avatar on user deletion
1369
+        $dispatcher->addListener('OCP\IUser::preDelete', function (GenericEvent $e) {
1370
+            $logger = $this->get(ILogger::class);
1371
+            $manager = $this->getAvatarManager();
1372
+            /** @var IUser $user */
1373
+            $user = $e->getSubject();
1374
+
1375
+            try {
1376
+                $avatar = $manager->getAvatar($user->getUID());
1377
+                $avatar->remove();
1378
+            } catch (NotFoundException $e) {
1379
+                // no avatar to remove
1380
+            } catch (\Exception $e) {
1381
+                // Ignore exceptions
1382
+                $logger->info('Could not cleanup avatar of ' . $user->getUID());
1383
+            }
1384
+        });
1385
+
1386
+        $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) {
1387
+            $manager = $this->getAvatarManager();
1388
+            /** @var IUser $user */
1389
+            $user = $e->getSubject();
1390
+            $feature = $e->getArgument('feature');
1391
+            $oldValue = $e->getArgument('oldValue');
1392
+            $value = $e->getArgument('value');
1393
+
1394
+            // We only change the avatar on display name changes
1395
+            if ($feature !== 'displayName') {
1396
+                return;
1397
+            }
1398
+
1399
+            try {
1400
+                $avatar = $manager->getAvatar($user->getUID());
1401
+                $avatar->userChanged($feature, $oldValue, $value);
1402
+            } catch (NotFoundException $e) {
1403
+                // no avatar to remove
1404
+            }
1405
+        });
1406
+
1407
+        /** @var IEventDispatcher $eventDispatched */
1408
+        $eventDispatched = $this->get(IEventDispatcher::class);
1409
+        $eventDispatched->addServiceListener(LoginFailed::class, LoginFailedListener::class);
1410
+        $eventDispatched->addServiceListener(PostLoginEvent::class, UserLoggedInListener::class);
1411
+    }
1412
+
1413
+    /**
1414
+     * @return \OCP\Contacts\IManager
1415
+     * @deprecated 20.0.0
1416
+     */
1417
+    public function getContactsManager() {
1418
+        return $this->get(\OCP\Contacts\IManager::class);
1419
+    }
1420
+
1421
+    /**
1422
+     * @return \OC\Encryption\Manager
1423
+     * @deprecated 20.0.0
1424
+     */
1425
+    public function getEncryptionManager() {
1426
+        return $this->get(\OCP\Encryption\IManager::class);
1427
+    }
1428
+
1429
+    /**
1430
+     * @return \OC\Encryption\File
1431
+     * @deprecated 20.0.0
1432
+     */
1433
+    public function getEncryptionFilesHelper() {
1434
+        return $this->get(IFile::class);
1435
+    }
1436
+
1437
+    /**
1438
+     * @return \OCP\Encryption\Keys\IStorage
1439
+     * @deprecated 20.0.0
1440
+     */
1441
+    public function getEncryptionKeyStorage() {
1442
+        return $this->get(IStorage::class);
1443
+    }
1444
+
1445
+    /**
1446
+     * The current request object holding all information about the request
1447
+     * currently being processed is returned from this method.
1448
+     * In case the current execution was not initiated by a web request null is returned
1449
+     *
1450
+     * @return \OCP\IRequest
1451
+     * @deprecated 20.0.0
1452
+     */
1453
+    public function getRequest() {
1454
+        return $this->get(IRequest::class);
1455
+    }
1456
+
1457
+    /**
1458
+     * Returns the preview manager which can create preview images for a given file
1459
+     *
1460
+     * @return IPreview
1461
+     * @deprecated 20.0.0
1462
+     */
1463
+    public function getPreviewManager() {
1464
+        return $this->get(IPreview::class);
1465
+    }
1466
+
1467
+    /**
1468
+     * Returns the tag manager which can get and set tags for different object types
1469
+     *
1470
+     * @see \OCP\ITagManager::load()
1471
+     * @return ITagManager
1472
+     * @deprecated 20.0.0
1473
+     */
1474
+    public function getTagManager() {
1475
+        return $this->get(ITagManager::class);
1476
+    }
1477
+
1478
+    /**
1479
+     * Returns the system-tag manager
1480
+     *
1481
+     * @return ISystemTagManager
1482
+     *
1483
+     * @since 9.0.0
1484
+     * @deprecated 20.0.0
1485
+     */
1486
+    public function getSystemTagManager() {
1487
+        return $this->get(ISystemTagManager::class);
1488
+    }
1489
+
1490
+    /**
1491
+     * Returns the system-tag object mapper
1492
+     *
1493
+     * @return ISystemTagObjectMapper
1494
+     *
1495
+     * @since 9.0.0
1496
+     * @deprecated 20.0.0
1497
+     */
1498
+    public function getSystemTagObjectMapper() {
1499
+        return $this->get(ISystemTagObjectMapper::class);
1500
+    }
1501
+
1502
+    /**
1503
+     * Returns the avatar manager, used for avatar functionality
1504
+     *
1505
+     * @return IAvatarManager
1506
+     * @deprecated 20.0.0
1507
+     */
1508
+    public function getAvatarManager() {
1509
+        return $this->get(IAvatarManager::class);
1510
+    }
1511
+
1512
+    /**
1513
+     * Returns the root folder of ownCloud's data directory
1514
+     *
1515
+     * @return IRootFolder
1516
+     * @deprecated 20.0.0
1517
+     */
1518
+    public function getRootFolder() {
1519
+        return $this->get(IRootFolder::class);
1520
+    }
1521
+
1522
+    /**
1523
+     * Returns the root folder of ownCloud's data directory
1524
+     * This is the lazy variant so this gets only initialized once it
1525
+     * is actually used.
1526
+     *
1527
+     * @return IRootFolder
1528
+     * @deprecated 20.0.0
1529
+     */
1530
+    public function getLazyRootFolder() {
1531
+        return $this->get(IRootFolder::class);
1532
+    }
1533
+
1534
+    /**
1535
+     * Returns a view to ownCloud's files folder
1536
+     *
1537
+     * @param string $userId user ID
1538
+     * @return \OCP\Files\Folder|null
1539
+     * @deprecated 20.0.0
1540
+     */
1541
+    public function getUserFolder($userId = null) {
1542
+        if ($userId === null) {
1543
+            $user = $this->get(IUserSession::class)->getUser();
1544
+            if (!$user) {
1545
+                return null;
1546
+            }
1547
+            $userId = $user->getUID();
1548
+        }
1549
+        $root = $this->get(IRootFolder::class);
1550
+        return $root->getUserFolder($userId);
1551
+    }
1552
+
1553
+    /**
1554
+     * @return \OC\User\Manager
1555
+     * @deprecated 20.0.0
1556
+     */
1557
+    public function getUserManager() {
1558
+        return $this->get(IUserManager::class);
1559
+    }
1560
+
1561
+    /**
1562
+     * @return \OC\Group\Manager
1563
+     * @deprecated 20.0.0
1564
+     */
1565
+    public function getGroupManager() {
1566
+        return $this->get(IGroupManager::class);
1567
+    }
1568
+
1569
+    /**
1570
+     * @return \OC\User\Session
1571
+     * @deprecated 20.0.0
1572
+     */
1573
+    public function getUserSession() {
1574
+        return $this->get(IUserSession::class);
1575
+    }
1576
+
1577
+    /**
1578
+     * @return \OCP\ISession
1579
+     * @deprecated 20.0.0
1580
+     */
1581
+    public function getSession() {
1582
+        return $this->get(IUserSession::class)->getSession();
1583
+    }
1584
+
1585
+    /**
1586
+     * @param \OCP\ISession $session
1587
+     */
1588
+    public function setSession(\OCP\ISession $session) {
1589
+        $this->get(SessionStorage::class)->setSession($session);
1590
+        $this->get(IUserSession::class)->setSession($session);
1591
+        $this->get(Store::class)->setSession($session);
1592
+    }
1593
+
1594
+    /**
1595
+     * @return \OC\Authentication\TwoFactorAuth\Manager
1596
+     * @deprecated 20.0.0
1597
+     */
1598
+    public function getTwoFactorAuthManager() {
1599
+        return $this->get(\OC\Authentication\TwoFactorAuth\Manager::class);
1600
+    }
1601
+
1602
+    /**
1603
+     * @return \OC\NavigationManager
1604
+     * @deprecated 20.0.0
1605
+     */
1606
+    public function getNavigationManager() {
1607
+        return $this->get(INavigationManager::class);
1608
+    }
1609
+
1610
+    /**
1611
+     * @return \OCP\IConfig
1612
+     * @deprecated 20.0.0
1613
+     */
1614
+    public function getConfig() {
1615
+        return $this->get(AllConfig::class);
1616
+    }
1617
+
1618
+    /**
1619
+     * @return \OC\SystemConfig
1620
+     * @deprecated 20.0.0
1621
+     */
1622
+    public function getSystemConfig() {
1623
+        return $this->get(SystemConfig::class);
1624
+    }
1625
+
1626
+    /**
1627
+     * Returns the app config manager
1628
+     *
1629
+     * @return IAppConfig
1630
+     * @deprecated 20.0.0
1631
+     */
1632
+    public function getAppConfig() {
1633
+        return $this->get(IAppConfig::class);
1634
+    }
1635
+
1636
+    /**
1637
+     * @return IFactory
1638
+     * @deprecated 20.0.0
1639
+     */
1640
+    public function getL10NFactory() {
1641
+        return $this->get(IFactory::class);
1642
+    }
1643
+
1644
+    /**
1645
+     * get an L10N instance
1646
+     *
1647
+     * @param string $app appid
1648
+     * @param string $lang
1649
+     * @return IL10N
1650
+     * @deprecated 20.0.0
1651
+     */
1652
+    public function getL10N($app, $lang = null) {
1653
+        return $this->get(IFactory::class)->get($app, $lang);
1654
+    }
1655
+
1656
+    /**
1657
+     * @return IURLGenerator
1658
+     * @deprecated 20.0.0
1659
+     */
1660
+    public function getURLGenerator() {
1661
+        return $this->get(IURLGenerator::class);
1662
+    }
1663
+
1664
+    /**
1665
+     * @return AppFetcher
1666
+     * @deprecated 20.0.0
1667
+     */
1668
+    public function getAppFetcher() {
1669
+        return $this->get(AppFetcher::class);
1670
+    }
1671
+
1672
+    /**
1673
+     * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1674
+     * getMemCacheFactory() instead.
1675
+     *
1676
+     * @return ICache
1677
+     * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1678
+     */
1679
+    public function getCache() {
1680
+        return $this->get(ICache::class);
1681
+    }
1682
+
1683
+    /**
1684
+     * Returns an \OCP\CacheFactory instance
1685
+     *
1686
+     * @return \OCP\ICacheFactory
1687
+     * @deprecated 20.0.0
1688
+     */
1689
+    public function getMemCacheFactory() {
1690
+        return $this->get(ICacheFactory::class);
1691
+    }
1692
+
1693
+    /**
1694
+     * Returns an \OC\RedisFactory instance
1695
+     *
1696
+     * @return \OC\RedisFactory
1697
+     * @deprecated 20.0.0
1698
+     */
1699
+    public function getGetRedisFactory() {
1700
+        return $this->get('RedisFactory');
1701
+    }
1702
+
1703
+
1704
+    /**
1705
+     * Returns the current session
1706
+     *
1707
+     * @return \OCP\IDBConnection
1708
+     * @deprecated 20.0.0
1709
+     */
1710
+    public function getDatabaseConnection() {
1711
+        return $this->get(IDBConnection::class);
1712
+    }
1713
+
1714
+    /**
1715
+     * Returns the activity manager
1716
+     *
1717
+     * @return \OCP\Activity\IManager
1718
+     * @deprecated 20.0.0
1719
+     */
1720
+    public function getActivityManager() {
1721
+        return $this->get(\OCP\Activity\IManager::class);
1722
+    }
1723
+
1724
+    /**
1725
+     * Returns an job list for controlling background jobs
1726
+     *
1727
+     * @return IJobList
1728
+     * @deprecated 20.0.0
1729
+     */
1730
+    public function getJobList() {
1731
+        return $this->get(IJobList::class);
1732
+    }
1733
+
1734
+    /**
1735
+     * Returns a logger instance
1736
+     *
1737
+     * @return ILogger
1738
+     * @deprecated 20.0.0
1739
+     */
1740
+    public function getLogger() {
1741
+        return $this->get(ILogger::class);
1742
+    }
1743
+
1744
+    /**
1745
+     * @return ILogFactory
1746
+     * @throws \OCP\AppFramework\QueryException
1747
+     * @deprecated 20.0.0
1748
+     */
1749
+    public function getLogFactory() {
1750
+        return $this->get(ILogFactory::class);
1751
+    }
1752
+
1753
+    /**
1754
+     * Returns a router for generating and matching urls
1755
+     *
1756
+     * @return IRouter
1757
+     * @deprecated 20.0.0
1758
+     */
1759
+    public function getRouter() {
1760
+        return $this->get(IRouter::class);
1761
+    }
1762
+
1763
+    /**
1764
+     * Returns a search instance
1765
+     *
1766
+     * @return ISearch
1767
+     * @deprecated 20.0.0
1768
+     */
1769
+    public function getSearch() {
1770
+        return $this->get(ISearch::class);
1771
+    }
1772
+
1773
+    /**
1774
+     * Returns a SecureRandom instance
1775
+     *
1776
+     * @return \OCP\Security\ISecureRandom
1777
+     * @deprecated 20.0.0
1778
+     */
1779
+    public function getSecureRandom() {
1780
+        return $this->get(ISecureRandom::class);
1781
+    }
1782
+
1783
+    /**
1784
+     * Returns a Crypto instance
1785
+     *
1786
+     * @return ICrypto
1787
+     * @deprecated 20.0.0
1788
+     */
1789
+    public function getCrypto() {
1790
+        return $this->get(ICrypto::class);
1791
+    }
1792
+
1793
+    /**
1794
+     * Returns a Hasher instance
1795
+     *
1796
+     * @return IHasher
1797
+     * @deprecated 20.0.0
1798
+     */
1799
+    public function getHasher() {
1800
+        return $this->get(IHasher::class);
1801
+    }
1802
+
1803
+    /**
1804
+     * Returns a CredentialsManager instance
1805
+     *
1806
+     * @return ICredentialsManager
1807
+     * @deprecated 20.0.0
1808
+     */
1809
+    public function getCredentialsManager() {
1810
+        return $this->get(ICredentialsManager::class);
1811
+    }
1812
+
1813
+    /**
1814
+     * Get the certificate manager
1815
+     *
1816
+     * @return \OCP\ICertificateManager
1817
+     */
1818
+    public function getCertificateManager() {
1819
+        return $this->get(ICertificateManager::class);
1820
+    }
1821
+
1822
+    /**
1823
+     * Returns an instance of the HTTP client service
1824
+     *
1825
+     * @return IClientService
1826
+     * @deprecated 20.0.0
1827
+     */
1828
+    public function getHTTPClientService() {
1829
+        return $this->get(IClientService::class);
1830
+    }
1831
+
1832
+    /**
1833
+     * Create a new event source
1834
+     *
1835
+     * @return \OCP\IEventSource
1836
+     * @deprecated 20.0.0
1837
+     */
1838
+    public function createEventSource() {
1839
+        return new \OC_EventSource();
1840
+    }
1841
+
1842
+    /**
1843
+     * Get the active event logger
1844
+     *
1845
+     * The returned logger only logs data when debug mode is enabled
1846
+     *
1847
+     * @return IEventLogger
1848
+     * @deprecated 20.0.0
1849
+     */
1850
+    public function getEventLogger() {
1851
+        return $this->get(IEventLogger::class);
1852
+    }
1853
+
1854
+    /**
1855
+     * Get the active query logger
1856
+     *
1857
+     * The returned logger only logs data when debug mode is enabled
1858
+     *
1859
+     * @return IQueryLogger
1860
+     * @deprecated 20.0.0
1861
+     */
1862
+    public function getQueryLogger() {
1863
+        return $this->get(IQueryLogger::class);
1864
+    }
1865
+
1866
+    /**
1867
+     * Get the manager for temporary files and folders
1868
+     *
1869
+     * @return \OCP\ITempManager
1870
+     * @deprecated 20.0.0
1871
+     */
1872
+    public function getTempManager() {
1873
+        return $this->get(ITempManager::class);
1874
+    }
1875
+
1876
+    /**
1877
+     * Get the app manager
1878
+     *
1879
+     * @return \OCP\App\IAppManager
1880
+     * @deprecated 20.0.0
1881
+     */
1882
+    public function getAppManager() {
1883
+        return $this->get(IAppManager::class);
1884
+    }
1885
+
1886
+    /**
1887
+     * Creates a new mailer
1888
+     *
1889
+     * @return IMailer
1890
+     * @deprecated 20.0.0
1891
+     */
1892
+    public function getMailer() {
1893
+        return $this->get(IMailer::class);
1894
+    }
1895
+
1896
+    /**
1897
+     * Get the webroot
1898
+     *
1899
+     * @return string
1900
+     * @deprecated 20.0.0
1901
+     */
1902
+    public function getWebRoot() {
1903
+        return $this->webRoot;
1904
+    }
1905
+
1906
+    /**
1907
+     * @return \OC\OCSClient
1908
+     * @deprecated 20.0.0
1909
+     */
1910
+    public function getOcsClient() {
1911
+        return $this->get('OcsClient');
1912
+    }
1913
+
1914
+    /**
1915
+     * @return IDateTimeZone
1916
+     * @deprecated 20.0.0
1917
+     */
1918
+    public function getDateTimeZone() {
1919
+        return $this->get(IDateTimeZone::class);
1920
+    }
1921
+
1922
+    /**
1923
+     * @return IDateTimeFormatter
1924
+     * @deprecated 20.0.0
1925
+     */
1926
+    public function getDateTimeFormatter() {
1927
+        return $this->get(IDateTimeFormatter::class);
1928
+    }
1929
+
1930
+    /**
1931
+     * @return IMountProviderCollection
1932
+     * @deprecated 20.0.0
1933
+     */
1934
+    public function getMountProviderCollection() {
1935
+        return $this->get(IMountProviderCollection::class);
1936
+    }
1937
+
1938
+    /**
1939
+     * Get the IniWrapper
1940
+     *
1941
+     * @return IniGetWrapper
1942
+     * @deprecated 20.0.0
1943
+     */
1944
+    public function getIniWrapper() {
1945
+        return $this->get(IniGetWrapper::class);
1946
+    }
1947
+
1948
+    /**
1949
+     * @return \OCP\Command\IBus
1950
+     * @deprecated 20.0.0
1951
+     */
1952
+    public function getCommandBus() {
1953
+        return $this->get(IBus::class);
1954
+    }
1955
+
1956
+    /**
1957
+     * Get the trusted domain helper
1958
+     *
1959
+     * @return TrustedDomainHelper
1960
+     * @deprecated 20.0.0
1961
+     */
1962
+    public function getTrustedDomainHelper() {
1963
+        return $this->get(TrustedDomainHelper::class);
1964
+    }
1965
+
1966
+    /**
1967
+     * Get the locking provider
1968
+     *
1969
+     * @return ILockingProvider
1970
+     * @since 8.1.0
1971
+     * @deprecated 20.0.0
1972
+     */
1973
+    public function getLockingProvider() {
1974
+        return $this->get(ILockingProvider::class);
1975
+    }
1976
+
1977
+    /**
1978
+     * @return IMountManager
1979
+     * @deprecated 20.0.0
1980
+     **/
1981
+    public function getMountManager() {
1982
+        return $this->get(IMountManager::class);
1983
+    }
1984
+
1985
+    /**
1986
+     * @return IUserMountCache
1987
+     * @deprecated 20.0.0
1988
+     */
1989
+    public function getUserMountCache() {
1990
+        return $this->get(IUserMountCache::class);
1991
+    }
1992
+
1993
+    /**
1994
+     * Get the MimeTypeDetector
1995
+     *
1996
+     * @return IMimeTypeDetector
1997
+     * @deprecated 20.0.0
1998
+     */
1999
+    public function getMimeTypeDetector() {
2000
+        return $this->get(IMimeTypeDetector::class);
2001
+    }
2002
+
2003
+    /**
2004
+     * Get the MimeTypeLoader
2005
+     *
2006
+     * @return IMimeTypeLoader
2007
+     * @deprecated 20.0.0
2008
+     */
2009
+    public function getMimeTypeLoader() {
2010
+        return $this->get(IMimeTypeLoader::class);
2011
+    }
2012
+
2013
+    /**
2014
+     * Get the manager of all the capabilities
2015
+     *
2016
+     * @return CapabilitiesManager
2017
+     * @deprecated 20.0.0
2018
+     */
2019
+    public function getCapabilitiesManager() {
2020
+        return $this->get(CapabilitiesManager::class);
2021
+    }
2022
+
2023
+    /**
2024
+     * Get the EventDispatcher
2025
+     *
2026
+     * @return EventDispatcherInterface
2027
+     * @since 8.2.0
2028
+     * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher
2029
+     */
2030
+    public function getEventDispatcher() {
2031
+        return $this->get(\OC\EventDispatcher\SymfonyAdapter::class);
2032
+    }
2033
+
2034
+    /**
2035
+     * Get the Notification Manager
2036
+     *
2037
+     * @return \OCP\Notification\IManager
2038
+     * @since 8.2.0
2039
+     * @deprecated 20.0.0
2040
+     */
2041
+    public function getNotificationManager() {
2042
+        return $this->get(\OCP\Notification\IManager::class);
2043
+    }
2044
+
2045
+    /**
2046
+     * @return ICommentsManager
2047
+     * @deprecated 20.0.0
2048
+     */
2049
+    public function getCommentsManager() {
2050
+        return $this->get(ICommentsManager::class);
2051
+    }
2052
+
2053
+    /**
2054
+     * @return \OCA\Theming\ThemingDefaults
2055
+     * @deprecated 20.0.0
2056
+     */
2057
+    public function getThemingDefaults() {
2058
+        return $this->get('ThemingDefaults');
2059
+    }
2060
+
2061
+    /**
2062
+     * @return \OC\IntegrityCheck\Checker
2063
+     * @deprecated 20.0.0
2064
+     */
2065
+    public function getIntegrityCodeChecker() {
2066
+        return $this->get('IntegrityCodeChecker');
2067
+    }
2068
+
2069
+    /**
2070
+     * @return \OC\Session\CryptoWrapper
2071
+     * @deprecated 20.0.0
2072
+     */
2073
+    public function getSessionCryptoWrapper() {
2074
+        return $this->get('CryptoWrapper');
2075
+    }
2076
+
2077
+    /**
2078
+     * @return CsrfTokenManager
2079
+     * @deprecated 20.0.0
2080
+     */
2081
+    public function getCsrfTokenManager() {
2082
+        return $this->get(CsrfTokenManager::class);
2083
+    }
2084
+
2085
+    /**
2086
+     * @return Throttler
2087
+     * @deprecated 20.0.0
2088
+     */
2089
+    public function getBruteForceThrottler() {
2090
+        return $this->get(Throttler::class);
2091
+    }
2092
+
2093
+    /**
2094
+     * @return IContentSecurityPolicyManager
2095
+     * @deprecated 20.0.0
2096
+     */
2097
+    public function getContentSecurityPolicyManager() {
2098
+        return $this->get(ContentSecurityPolicyManager::class);
2099
+    }
2100
+
2101
+    /**
2102
+     * @return ContentSecurityPolicyNonceManager
2103
+     * @deprecated 20.0.0
2104
+     */
2105
+    public function getContentSecurityPolicyNonceManager() {
2106
+        return $this->get(ContentSecurityPolicyNonceManager::class);
2107
+    }
2108
+
2109
+    /**
2110
+     * Not a public API as of 8.2, wait for 9.0
2111
+     *
2112
+     * @return \OCA\Files_External\Service\BackendService
2113
+     * @deprecated 20.0.0
2114
+     */
2115
+    public function getStoragesBackendService() {
2116
+        return $this->get(BackendService::class);
2117
+    }
2118
+
2119
+    /**
2120
+     * Not a public API as of 8.2, wait for 9.0
2121
+     *
2122
+     * @return \OCA\Files_External\Service\GlobalStoragesService
2123
+     * @deprecated 20.0.0
2124
+     */
2125
+    public function getGlobalStoragesService() {
2126
+        return $this->get(GlobalStoragesService::class);
2127
+    }
2128
+
2129
+    /**
2130
+     * Not a public API as of 8.2, wait for 9.0
2131
+     *
2132
+     * @return \OCA\Files_External\Service\UserGlobalStoragesService
2133
+     * @deprecated 20.0.0
2134
+     */
2135
+    public function getUserGlobalStoragesService() {
2136
+        return $this->get(UserGlobalStoragesService::class);
2137
+    }
2138
+
2139
+    /**
2140
+     * Not a public API as of 8.2, wait for 9.0
2141
+     *
2142
+     * @return \OCA\Files_External\Service\UserStoragesService
2143
+     * @deprecated 20.0.0
2144
+     */
2145
+    public function getUserStoragesService() {
2146
+        return $this->get(UserStoragesService::class);
2147
+    }
2148
+
2149
+    /**
2150
+     * @return \OCP\Share\IManager
2151
+     * @deprecated 20.0.0
2152
+     */
2153
+    public function getShareManager() {
2154
+        return $this->get(\OCP\Share\IManager::class);
2155
+    }
2156
+
2157
+    /**
2158
+     * @return \OCP\Collaboration\Collaborators\ISearch
2159
+     * @deprecated 20.0.0
2160
+     */
2161
+    public function getCollaboratorSearch() {
2162
+        return $this->get(\OCP\Collaboration\Collaborators\ISearch::class);
2163
+    }
2164
+
2165
+    /**
2166
+     * @return \OCP\Collaboration\AutoComplete\IManager
2167
+     * @deprecated 20.0.0
2168
+     */
2169
+    public function getAutoCompleteManager() {
2170
+        return $this->get(IManager::class);
2171
+    }
2172
+
2173
+    /**
2174
+     * Returns the LDAP Provider
2175
+     *
2176
+     * @return \OCP\LDAP\ILDAPProvider
2177
+     * @deprecated 20.0.0
2178
+     */
2179
+    public function getLDAPProvider() {
2180
+        return $this->get('LDAPProvider');
2181
+    }
2182
+
2183
+    /**
2184
+     * @return \OCP\Settings\IManager
2185
+     * @deprecated 20.0.0
2186
+     */
2187
+    public function getSettingsManager() {
2188
+        return $this->get(\OC\Settings\Manager::class);
2189
+    }
2190
+
2191
+    /**
2192
+     * @return \OCP\Files\IAppData
2193
+     * @deprecated 20.0.0
2194
+     */
2195
+    public function getAppDataDir($app) {
2196
+        /** @var \OC\Files\AppData\Factory $factory */
2197
+        $factory = $this->get(\OC\Files\AppData\Factory::class);
2198
+        return $factory->get($app);
2199
+    }
2200
+
2201
+    /**
2202
+     * @return \OCP\Lockdown\ILockdownManager
2203
+     * @deprecated 20.0.0
2204
+     */
2205
+    public function getLockdownManager() {
2206
+        return $this->get('LockdownManager');
2207
+    }
2208
+
2209
+    /**
2210
+     * @return \OCP\Federation\ICloudIdManager
2211
+     * @deprecated 20.0.0
2212
+     */
2213
+    public function getCloudIdManager() {
2214
+        return $this->get(ICloudIdManager::class);
2215
+    }
2216
+
2217
+    /**
2218
+     * @return \OCP\GlobalScale\IConfig
2219
+     * @deprecated 20.0.0
2220
+     */
2221
+    public function getGlobalScaleConfig() {
2222
+        return $this->get(IConfig::class);
2223
+    }
2224
+
2225
+    /**
2226
+     * @return \OCP\Federation\ICloudFederationProviderManager
2227
+     * @deprecated 20.0.0
2228
+     */
2229
+    public function getCloudFederationProviderManager() {
2230
+        return $this->get(ICloudFederationProviderManager::class);
2231
+    }
2232
+
2233
+    /**
2234
+     * @return \OCP\Remote\Api\IApiFactory
2235
+     * @deprecated 20.0.0
2236
+     */
2237
+    public function getRemoteApiFactory() {
2238
+        return $this->get(IApiFactory::class);
2239
+    }
2240
+
2241
+    /**
2242
+     * @return \OCP\Federation\ICloudFederationFactory
2243
+     * @deprecated 20.0.0
2244
+     */
2245
+    public function getCloudFederationFactory() {
2246
+        return $this->get(ICloudFederationFactory::class);
2247
+    }
2248
+
2249
+    /**
2250
+     * @return \OCP\Remote\IInstanceFactory
2251
+     * @deprecated 20.0.0
2252
+     */
2253
+    public function getRemoteInstanceFactory() {
2254
+        return $this->get(IInstanceFactory::class);
2255
+    }
2256
+
2257
+    /**
2258
+     * @return IStorageFactory
2259
+     * @deprecated 20.0.0
2260
+     */
2261
+    public function getStorageFactory() {
2262
+        return $this->get(IStorageFactory::class);
2263
+    }
2264
+
2265
+    /**
2266
+     * Get the Preview GeneratorHelper
2267
+     *
2268
+     * @return GeneratorHelper
2269
+     * @since 17.0.0
2270
+     * @deprecated 20.0.0
2271
+     */
2272
+    public function getGeneratorHelper() {
2273
+        return $this->get(\OC\Preview\GeneratorHelper::class);
2274
+    }
2275
+
2276
+    private function registerDeprecatedAlias(string $alias, string $target) {
2277
+        $this->registerService($alias, function (ContainerInterface $container) use ($target, $alias) {
2278
+            try {
2279
+                /** @var ILogger $logger */
2280
+                $logger = $container->get(ILogger::class);
2281
+                $logger->debug('The requested alias "' . $alias . '" is deprecated. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']);
2282
+            } catch (ContainerExceptionInterface $e) {
2283
+                // Could not get logger. Continue
2284
+            }
2285
+
2286
+            return $container->get($target);
2287
+        }, false);
2288
+    }
2289 2289
 }
Please login to merge, or discard this patch.
core/Command/Integrity/CheckCore.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -37,40 +37,40 @@
 block discarded – undo
37 37
  * @package OC\Core\Command\Integrity
38 38
  */
39 39
 class CheckCore extends Base {
40
-	/**
41
-	 * @var Checker
42
-	 */
43
-	private $checker;
40
+    /**
41
+     * @var Checker
42
+     */
43
+    private $checker;
44 44
 
45
-	public function __construct(Checker $checker) {
46
-		parent::__construct();
47
-		$this->checker = $checker;
48
-	}
45
+    public function __construct(Checker $checker) {
46
+        parent::__construct();
47
+        $this->checker = $checker;
48
+    }
49 49
 
50
-	/**
51
-	 * {@inheritdoc }
52
-	 */
53
-	protected function configure() {
54
-		parent::configure();
55
-		$this
56
-			->setName('integrity:check-core')
57
-			->setDescription('Check integrity of core code using a signature.');
58
-	}
50
+    /**
51
+     * {@inheritdoc }
52
+     */
53
+    protected function configure() {
54
+        parent::configure();
55
+        $this
56
+            ->setName('integrity:check-core')
57
+            ->setDescription('Check integrity of core code using a signature.');
58
+    }
59 59
 
60
-	/**
61
-	 * {@inheritdoc }
62
-	 */
63
-	protected function execute(InputInterface $input, OutputInterface $output): int {
64
-		if (!$this->checker->isCodeCheckEnforced()) {
65
-			$output->writeln('<comment>integrity:check-core can not be used on git checkouts</comment>');
66
-			return 2;
67
-		}
60
+    /**
61
+     * {@inheritdoc }
62
+     */
63
+    protected function execute(InputInterface $input, OutputInterface $output): int {
64
+        if (!$this->checker->isCodeCheckEnforced()) {
65
+            $output->writeln('<comment>integrity:check-core can not be used on git checkouts</comment>');
66
+            return 2;
67
+        }
68 68
 
69
-		$result = $this->checker->verifyCoreSignature();
70
-		$this->writeArrayInOutputFormat($input, $output, $result);
71
-		if (count($result) > 0) {
72
-			return 1;
73
-		}
74
-		return 0;
75
-	}
69
+        $result = $this->checker->verifyCoreSignature();
70
+        $this->writeArrayInOutputFormat($input, $output, $result);
71
+        if (count($result) > 0) {
72
+            return 1;
73
+        }
74
+        return 0;
75
+    }
76 76
 }
Please login to merge, or discard this patch.
core/Command/Integrity/CheckApp.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -42,39 +42,39 @@
 block discarded – undo
42 42
  */
43 43
 class CheckApp extends Base {
44 44
 
45
-	/**
46
-	 * @var Checker
47
-	 */
48
-	private $checker;
45
+    /**
46
+     * @var Checker
47
+     */
48
+    private $checker;
49 49
 
50
-	public function __construct(Checker $checker) {
51
-		parent::__construct();
52
-		$this->checker = $checker;
53
-	}
50
+    public function __construct(Checker $checker) {
51
+        parent::__construct();
52
+        $this->checker = $checker;
53
+    }
54 54
 
55
-	/**
56
-	 * {@inheritdoc }
57
-	 */
58
-	protected function configure() {
59
-		parent::configure();
60
-		$this
61
-			->setName('integrity:check-app')
62
-			->setDescription('Check integrity of an app using a signature.')
63
-			->addArgument('appid', InputArgument::REQUIRED, 'Application to check')
64
-			->addOption('path', null, InputOption::VALUE_OPTIONAL, 'Path to application. If none is given it will be guessed.');
65
-	}
55
+    /**
56
+     * {@inheritdoc }
57
+     */
58
+    protected function configure() {
59
+        parent::configure();
60
+        $this
61
+            ->setName('integrity:check-app')
62
+            ->setDescription('Check integrity of an app using a signature.')
63
+            ->addArgument('appid', InputArgument::REQUIRED, 'Application to check')
64
+            ->addOption('path', null, InputOption::VALUE_OPTIONAL, 'Path to application. If none is given it will be guessed.');
65
+    }
66 66
 
67
-	/**
68
-	 * {@inheritdoc }
69
-	 */
70
-	protected function execute(InputInterface $input, OutputInterface $output): int {
71
-		$appid = $input->getArgument('appid');
72
-		$path = (string)$input->getOption('path');
73
-		$result = $this->checker->verifyAppSignature($appid, $path, true);
74
-		$this->writeArrayInOutputFormat($input, $output, $result);
75
-		if (count($result) > 0) {
76
-			return 1;
77
-		}
78
-		return 0;
79
-	}
67
+    /**
68
+     * {@inheritdoc }
69
+     */
70
+    protected function execute(InputInterface $input, OutputInterface $output): int {
71
+        $appid = $input->getArgument('appid');
72
+        $path = (string)$input->getOption('path');
73
+        $result = $this->checker->verifyAppSignature($appid, $path, true);
74
+        $this->writeArrayInOutputFormat($input, $output, $result);
75
+        if (count($result) > 0) {
76
+            return 1;
77
+        }
78
+        return 0;
79
+    }
80 80
 }
Please login to merge, or discard this patch.
core/Command/Upgrade.php 1 patch
Indentation   +230 added lines, -230 removed lines patch added patch discarded remove patch
@@ -46,250 +46,250 @@
 block discarded – undo
46 46
 use Symfony\Component\EventDispatcher\GenericEvent;
47 47
 
48 48
 class Upgrade extends Command {
49
-	public const ERROR_SUCCESS = 0;
50
-	public const ERROR_NOT_INSTALLED = 1;
51
-	public const ERROR_MAINTENANCE_MODE = 2;
52
-	public const ERROR_UP_TO_DATE = 0;
53
-	public const ERROR_INVALID_ARGUMENTS = 4;
54
-	public const ERROR_FAILURE = 5;
49
+    public const ERROR_SUCCESS = 0;
50
+    public const ERROR_NOT_INSTALLED = 1;
51
+    public const ERROR_MAINTENANCE_MODE = 2;
52
+    public const ERROR_UP_TO_DATE = 0;
53
+    public const ERROR_INVALID_ARGUMENTS = 4;
54
+    public const ERROR_FAILURE = 5;
55 55
 
56
-	/** @var IConfig */
57
-	private $config;
56
+    /** @var IConfig */
57
+    private $config;
58 58
 
59
-	/** @var ILogger */
60
-	private $logger;
59
+    /** @var ILogger */
60
+    private $logger;
61 61
 
62
-	/**
63
-	 * @param IConfig $config
64
-	 * @param ILogger $logger
65
-	 * @param Installer $installer
66
-	 */
67
-	public function __construct(IConfig $config, ILogger $logger, Installer $installer) {
68
-		parent::__construct();
69
-		$this->config = $config;
70
-		$this->logger = $logger;
71
-		$this->installer = $installer;
72
-	}
62
+    /**
63
+     * @param IConfig $config
64
+     * @param ILogger $logger
65
+     * @param Installer $installer
66
+     */
67
+    public function __construct(IConfig $config, ILogger $logger, Installer $installer) {
68
+        parent::__construct();
69
+        $this->config = $config;
70
+        $this->logger = $logger;
71
+        $this->installer = $installer;
72
+    }
73 73
 
74
-	protected function configure() {
75
-		$this
76
-			->setName('upgrade')
77
-			->setDescription('run upgrade routines after installation of a new release. The release has to be installed before.');
78
-	}
74
+    protected function configure() {
75
+        $this
76
+            ->setName('upgrade')
77
+            ->setDescription('run upgrade routines after installation of a new release. The release has to be installed before.');
78
+    }
79 79
 
80
-	/**
81
-	 * Execute the upgrade command
82
-	 *
83
-	 * @param InputInterface $input input interface
84
-	 * @param OutputInterface $output output interface
85
-	 */
86
-	protected function execute(InputInterface $input, OutputInterface $output): int {
87
-		if (Util::needUpgrade()) {
88
-			if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
89
-				// Prepend each line with a little timestamp
90
-				$timestampFormatter = new TimestampFormatter($this->config, $output->getFormatter());
91
-				$output->setFormatter($timestampFormatter);
92
-			}
80
+    /**
81
+     * Execute the upgrade command
82
+     *
83
+     * @param InputInterface $input input interface
84
+     * @param OutputInterface $output output interface
85
+     */
86
+    protected function execute(InputInterface $input, OutputInterface $output): int {
87
+        if (Util::needUpgrade()) {
88
+            if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
89
+                // Prepend each line with a little timestamp
90
+                $timestampFormatter = new TimestampFormatter($this->config, $output->getFormatter());
91
+                $output->setFormatter($timestampFormatter);
92
+            }
93 93
 
94
-			$self = $this;
95
-			$updater = new Updater(
96
-					$this->config,
97
-					\OC::$server->getIntegrityCodeChecker(),
98
-					$this->logger,
99
-					$this->installer
100
-			);
94
+            $self = $this;
95
+            $updater = new Updater(
96
+                    $this->config,
97
+                    \OC::$server->getIntegrityCodeChecker(),
98
+                    $this->logger,
99
+                    $this->installer
100
+            );
101 101
 
102
-			$dispatcher = \OC::$server->getEventDispatcher();
103
-			$progress = new ProgressBar($output);
104
-			$progress->setFormat(" %message%\n %current%/%max% [%bar%] %percent:3s%%");
105
-			$listener = function ($event) use ($progress, $output) {
106
-				if ($event instanceof GenericEvent) {
107
-					$message = $event->getSubject();
108
-					if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
109
-						$output->writeln(' Checking table ' . $message);
110
-					} else {
111
-						if (strlen($message) > 60) {
112
-							$message = substr($message, 0, 57) . '...';
113
-						}
114
-						$progress->setMessage($message);
115
-						if ($event[0] === 1) {
116
-							$output->writeln('');
117
-							$progress->start($event[1]);
118
-						}
119
-						$progress->setProgress($event[0]);
120
-						if ($event[0] === $event[1]) {
121
-							$progress->setMessage('Done');
122
-							$progress->finish();
123
-							$output->writeln('');
124
-						}
125
-					}
126
-				}
127
-			};
128
-			$repairListener = function ($event) use ($progress, $output) {
129
-				if (!$event instanceof GenericEvent) {
130
-					return;
131
-				}
132
-				switch ($event->getSubject()) {
133
-					case '\OC\Repair::startProgress':
134
-						$progress->setMessage('Starting ...');
135
-						$output->writeln($event->getArgument(1));
136
-						$output->writeln('');
137
-						$progress->start($event->getArgument(0));
138
-						break;
139
-					case '\OC\Repair::advance':
140
-						$desc = $event->getArgument(1);
141
-						if (!empty($desc)) {
142
-							$progress->setMessage($desc);
143
-						}
144
-						$progress->advance($event->getArgument(0));
102
+            $dispatcher = \OC::$server->getEventDispatcher();
103
+            $progress = new ProgressBar($output);
104
+            $progress->setFormat(" %message%\n %current%/%max% [%bar%] %percent:3s%%");
105
+            $listener = function ($event) use ($progress, $output) {
106
+                if ($event instanceof GenericEvent) {
107
+                    $message = $event->getSubject();
108
+                    if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
109
+                        $output->writeln(' Checking table ' . $message);
110
+                    } else {
111
+                        if (strlen($message) > 60) {
112
+                            $message = substr($message, 0, 57) . '...';
113
+                        }
114
+                        $progress->setMessage($message);
115
+                        if ($event[0] === 1) {
116
+                            $output->writeln('');
117
+                            $progress->start($event[1]);
118
+                        }
119
+                        $progress->setProgress($event[0]);
120
+                        if ($event[0] === $event[1]) {
121
+                            $progress->setMessage('Done');
122
+                            $progress->finish();
123
+                            $output->writeln('');
124
+                        }
125
+                    }
126
+                }
127
+            };
128
+            $repairListener = function ($event) use ($progress, $output) {
129
+                if (!$event instanceof GenericEvent) {
130
+                    return;
131
+                }
132
+                switch ($event->getSubject()) {
133
+                    case '\OC\Repair::startProgress':
134
+                        $progress->setMessage('Starting ...');
135
+                        $output->writeln($event->getArgument(1));
136
+                        $output->writeln('');
137
+                        $progress->start($event->getArgument(0));
138
+                        break;
139
+                    case '\OC\Repair::advance':
140
+                        $desc = $event->getArgument(1);
141
+                        if (!empty($desc)) {
142
+                            $progress->setMessage($desc);
143
+                        }
144
+                        $progress->advance($event->getArgument(0));
145 145
 
146
-						break;
147
-					case '\OC\Repair::finishProgress':
148
-						$progress->setMessage('Done');
149
-						$progress->finish();
150
-						$output->writeln('');
151
-						break;
152
-					case '\OC\Repair::step':
153
-						if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
154
-							$output->writeln('<info>Repair step: ' . $event->getArgument(0) . '</info>');
155
-						}
156
-						break;
157
-					case '\OC\Repair::info':
158
-						if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
159
-							$output->writeln('<info>Repair info: ' . $event->getArgument(0) . '</info>');
160
-						}
161
-						break;
162
-					case '\OC\Repair::warning':
163
-						$output->writeln('<error>Repair warning: ' . $event->getArgument(0) . '</error>');
164
-						break;
165
-					case '\OC\Repair::error':
166
-						$output->writeln('<error>Repair error: ' . $event->getArgument(0) . '</error>');
167
-						break;
168
-				}
169
-			};
146
+                        break;
147
+                    case '\OC\Repair::finishProgress':
148
+                        $progress->setMessage('Done');
149
+                        $progress->finish();
150
+                        $output->writeln('');
151
+                        break;
152
+                    case '\OC\Repair::step':
153
+                        if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
154
+                            $output->writeln('<info>Repair step: ' . $event->getArgument(0) . '</info>');
155
+                        }
156
+                        break;
157
+                    case '\OC\Repair::info':
158
+                        if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
159
+                            $output->writeln('<info>Repair info: ' . $event->getArgument(0) . '</info>');
160
+                        }
161
+                        break;
162
+                    case '\OC\Repair::warning':
163
+                        $output->writeln('<error>Repair warning: ' . $event->getArgument(0) . '</error>');
164
+                        break;
165
+                    case '\OC\Repair::error':
166
+                        $output->writeln('<error>Repair error: ' . $event->getArgument(0) . '</error>');
167
+                        break;
168
+                }
169
+            };
170 170
 
171
-			$dispatcher->addListener('\OC\DB\Migrator::executeSql', $listener);
172
-			$dispatcher->addListener('\OC\DB\Migrator::checkTable', $listener);
173
-			$dispatcher->addListener('\OC\Repair::startProgress', $repairListener);
174
-			$dispatcher->addListener('\OC\Repair::advance', $repairListener);
175
-			$dispatcher->addListener('\OC\Repair::finishProgress', $repairListener);
176
-			$dispatcher->addListener('\OC\Repair::step', $repairListener);
177
-			$dispatcher->addListener('\OC\Repair::info', $repairListener);
178
-			$dispatcher->addListener('\OC\Repair::warning', $repairListener);
179
-			$dispatcher->addListener('\OC\Repair::error', $repairListener);
171
+            $dispatcher->addListener('\OC\DB\Migrator::executeSql', $listener);
172
+            $dispatcher->addListener('\OC\DB\Migrator::checkTable', $listener);
173
+            $dispatcher->addListener('\OC\Repair::startProgress', $repairListener);
174
+            $dispatcher->addListener('\OC\Repair::advance', $repairListener);
175
+            $dispatcher->addListener('\OC\Repair::finishProgress', $repairListener);
176
+            $dispatcher->addListener('\OC\Repair::step', $repairListener);
177
+            $dispatcher->addListener('\OC\Repair::info', $repairListener);
178
+            $dispatcher->addListener('\OC\Repair::warning', $repairListener);
179
+            $dispatcher->addListener('\OC\Repair::error', $repairListener);
180 180
 
181 181
 
182
-			$updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($output) {
183
-				$output->writeln('<info>Turned on maintenance mode</info>');
184
-			});
185
-			$updater->listen('\OC\Updater', 'maintenanceDisabled', function () use ($output) {
186
-				$output->writeln('<info>Turned off maintenance mode</info>');
187
-			});
188
-			$updater->listen('\OC\Updater', 'maintenanceActive', function () use ($output) {
189
-				$output->writeln('<info>Maintenance mode is kept active</info>');
190
-			});
191
-			$updater->listen('\OC\Updater', 'updateEnd',
192
-				function ($success) use ($output, $self) {
193
-					if ($success) {
194
-						$message = "<info>Update successful</info>";
195
-					} else {
196
-						$message = "<error>Update failed</error>";
197
-					}
198
-					$output->writeln($message);
199
-				});
200
-			$updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use ($output) {
201
-				$output->writeln('<info>Updating database schema</info>');
202
-			});
203
-			$updater->listen('\OC\Updater', 'dbUpgrade', function () use ($output) {
204
-				$output->writeln('<info>Updated database</info>');
205
-			});
206
-			$updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use ($output) {
207
-				$output->writeln('<info>Checking whether the database schema can be updated (this can take a long time depending on the database size)</info>');
208
-			});
209
-			$updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use ($output) {
210
-				$output->writeln('<info>Checked database schema update</info>');
211
-			});
212
-			$updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use ($output) {
213
-				$output->writeln('<comment>Disabled incompatible app: ' . $app . '</comment>');
214
-			});
215
-			$updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use ($output) {
216
-				$output->writeln('<info>Checking for update of app ' . $app . ' in appstore</info>');
217
-			});
218
-			$updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($output) {
219
-				$output->writeln('<info>Update app ' . $app . ' from appstore</info>');
220
-			});
221
-			$updater->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use ($output) {
222
-				$output->writeln('<info>Checked for update of app "' . $app . '" in appstore </info>');
223
-			});
224
-			$updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($output) {
225
-				$output->writeln('<info>Checking updates of apps</info>');
226
-			});
227
-			$updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($output) {
228
-				$output->writeln("<info>Checking whether the database schema for <$app> can be updated (this can take a long time depending on the database size)</info>");
229
-			});
230
-			$updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($output) {
231
-				$output->writeln('<info>Checked database schema update for apps</info>');
232
-			});
233
-			$updater->listen('\OC\Updater', 'appUpgradeStarted', function ($app, $version) use ($output) {
234
-				$output->writeln("<info>Updating <$app> ...</info>");
235
-			});
236
-			$updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($output) {
237
-				$output->writeln("<info>Updated <$app> to $version</info>");
238
-			});
239
-			$updater->listen('\OC\Updater', 'failure', function ($message) use ($output, $self) {
240
-				$output->writeln("<error>$message</error>");
241
-			});
242
-			$updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use ($output) {
243
-				$output->writeln("<info>Setting log level to debug</info>");
244
-			});
245
-			$updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use ($output) {
246
-				$output->writeln("<info>Resetting log level</info>");
247
-			});
248
-			$updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use ($output) {
249
-				$output->writeln("<info>Starting code integrity check...</info>");
250
-			});
251
-			$updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use ($output) {
252
-				$output->writeln("<info>Finished code integrity check</info>");
253
-			});
182
+            $updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($output) {
183
+                $output->writeln('<info>Turned on maintenance mode</info>');
184
+            });
185
+            $updater->listen('\OC\Updater', 'maintenanceDisabled', function () use ($output) {
186
+                $output->writeln('<info>Turned off maintenance mode</info>');
187
+            });
188
+            $updater->listen('\OC\Updater', 'maintenanceActive', function () use ($output) {
189
+                $output->writeln('<info>Maintenance mode is kept active</info>');
190
+            });
191
+            $updater->listen('\OC\Updater', 'updateEnd',
192
+                function ($success) use ($output, $self) {
193
+                    if ($success) {
194
+                        $message = "<info>Update successful</info>";
195
+                    } else {
196
+                        $message = "<error>Update failed</error>";
197
+                    }
198
+                    $output->writeln($message);
199
+                });
200
+            $updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use ($output) {
201
+                $output->writeln('<info>Updating database schema</info>');
202
+            });
203
+            $updater->listen('\OC\Updater', 'dbUpgrade', function () use ($output) {
204
+                $output->writeln('<info>Updated database</info>');
205
+            });
206
+            $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use ($output) {
207
+                $output->writeln('<info>Checking whether the database schema can be updated (this can take a long time depending on the database size)</info>');
208
+            });
209
+            $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use ($output) {
210
+                $output->writeln('<info>Checked database schema update</info>');
211
+            });
212
+            $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use ($output) {
213
+                $output->writeln('<comment>Disabled incompatible app: ' . $app . '</comment>');
214
+            });
215
+            $updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use ($output) {
216
+                $output->writeln('<info>Checking for update of app ' . $app . ' in appstore</info>');
217
+            });
218
+            $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($output) {
219
+                $output->writeln('<info>Update app ' . $app . ' from appstore</info>');
220
+            });
221
+            $updater->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use ($output) {
222
+                $output->writeln('<info>Checked for update of app "' . $app . '" in appstore </info>');
223
+            });
224
+            $updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($output) {
225
+                $output->writeln('<info>Checking updates of apps</info>');
226
+            });
227
+            $updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($output) {
228
+                $output->writeln("<info>Checking whether the database schema for <$app> can be updated (this can take a long time depending on the database size)</info>");
229
+            });
230
+            $updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($output) {
231
+                $output->writeln('<info>Checked database schema update for apps</info>');
232
+            });
233
+            $updater->listen('\OC\Updater', 'appUpgradeStarted', function ($app, $version) use ($output) {
234
+                $output->writeln("<info>Updating <$app> ...</info>");
235
+            });
236
+            $updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($output) {
237
+                $output->writeln("<info>Updated <$app> to $version</info>");
238
+            });
239
+            $updater->listen('\OC\Updater', 'failure', function ($message) use ($output, $self) {
240
+                $output->writeln("<error>$message</error>");
241
+            });
242
+            $updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use ($output) {
243
+                $output->writeln("<info>Setting log level to debug</info>");
244
+            });
245
+            $updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use ($output) {
246
+                $output->writeln("<info>Resetting log level</info>");
247
+            });
248
+            $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use ($output) {
249
+                $output->writeln("<info>Starting code integrity check...</info>");
250
+            });
251
+            $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use ($output) {
252
+                $output->writeln("<info>Finished code integrity check</info>");
253
+            });
254 254
 
255
-			$success = $updater->upgrade();
255
+            $success = $updater->upgrade();
256 256
 
257
-			$this->postUpgradeCheck($input, $output);
257
+            $this->postUpgradeCheck($input, $output);
258 258
 
259
-			if (!$success) {
260
-				return self::ERROR_FAILURE;
261
-			}
259
+            if (!$success) {
260
+                return self::ERROR_FAILURE;
261
+            }
262 262
 
263
-			return self::ERROR_SUCCESS;
264
-		} elseif ($this->config->getSystemValueBool('maintenance')) {
265
-			//Possible scenario: Nextcloud core is updated but an app failed
266
-			$output->writeln('<comment>Nextcloud is in maintenance mode</comment>');
267
-			$output->write('<comment>Maybe an upgrade is already in process. Please check the '
268
-				. 'logfile (data/nextcloud.log). If you want to re-run the '
269
-				. 'upgrade procedure, remove the "maintenance mode" from '
270
-				. 'config.php and call this script again.</comment>'
271
-				, true);
272
-			return self::ERROR_MAINTENANCE_MODE;
273
-		} else {
274
-			$output->writeln('<info>Nextcloud is already latest version</info>');
275
-			return self::ERROR_UP_TO_DATE;
276
-		}
277
-	}
263
+            return self::ERROR_SUCCESS;
264
+        } elseif ($this->config->getSystemValueBool('maintenance')) {
265
+            //Possible scenario: Nextcloud core is updated but an app failed
266
+            $output->writeln('<comment>Nextcloud is in maintenance mode</comment>');
267
+            $output->write('<comment>Maybe an upgrade is already in process. Please check the '
268
+                . 'logfile (data/nextcloud.log). If you want to re-run the '
269
+                . 'upgrade procedure, remove the "maintenance mode" from '
270
+                . 'config.php and call this script again.</comment>'
271
+                , true);
272
+            return self::ERROR_MAINTENANCE_MODE;
273
+        } else {
274
+            $output->writeln('<info>Nextcloud is already latest version</info>');
275
+            return self::ERROR_UP_TO_DATE;
276
+        }
277
+    }
278 278
 
279
-	/**
280
-	 * Perform a post upgrade check (specific to the command line tool)
281
-	 *
282
-	 * @param InputInterface $input input interface
283
-	 * @param OutputInterface $output output interface
284
-	 */
285
-	protected function postUpgradeCheck(InputInterface $input, OutputInterface $output) {
286
-		$trustedDomains = $this->config->getSystemValue('trusted_domains', []);
287
-		if (empty($trustedDomains)) {
288
-			$output->write(
289
-				'<warning>The setting "trusted_domains" could not be ' .
290
-				'set automatically by the upgrade script, ' .
291
-				'please set it manually</warning>'
292
-			);
293
-		}
294
-	}
279
+    /**
280
+     * Perform a post upgrade check (specific to the command line tool)
281
+     *
282
+     * @param InputInterface $input input interface
283
+     * @param OutputInterface $output output interface
284
+     */
285
+    protected function postUpgradeCheck(InputInterface $input, OutputInterface $output) {
286
+        $trustedDomains = $this->config->getSystemValue('trusted_domains', []);
287
+        if (empty($trustedDomains)) {
288
+            $output->write(
289
+                '<warning>The setting "trusted_domains" could not be ' .
290
+                'set automatically by the upgrade script, ' .
291
+                'please set it manually</warning>'
292
+            );
293
+        }
294
+    }
295 295
 }
Please login to merge, or discard this patch.