Passed
Push — master ( bfb764...c00e59 )
by Christoph
15:35 queued 13s
created
lib/public/Security/IRemoteHostValidator.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -32,20 +32,20 @@
 block discarded – undo
32 32
  */
33 33
 interface IRemoteHostValidator {
34 34
 
35
-	/**
36
-	 * Validate if a host may be connected to
37
-	 *
38
-	 * By default, Nextcloud does not connect to any local servers. That is neither
39
-	 * localhost nor any host in the local network.
40
-	 *
41
-	 * Admins can overwrite this behavior with the global `allow_local_remote_servers`
42
-	 * settings flag. If the flag is set to `true`, local hosts will be considered
43
-	 * valid.
44
-	 *
45
-	 * @param string $host hostname of the remote server, IPv4 or IPv6 address
46
-	 *
47
-	 * @return bool
48
-	 * @since 26.0.0
49
-	 */
50
-	public function isValid(string $host): bool;
35
+    /**
36
+     * Validate if a host may be connected to
37
+     *
38
+     * By default, Nextcloud does not connect to any local servers. That is neither
39
+     * localhost nor any host in the local network.
40
+     *
41
+     * Admins can overwrite this behavior with the global `allow_local_remote_servers`
42
+     * settings flag. If the flag is set to `true`, local hosts will be considered
43
+     * valid.
44
+     *
45
+     * @param string $host hostname of the remote server, IPv4 or IPv6 address
46
+     *
47
+     * @return bool
48
+     * @since 26.0.0
49
+     */
50
+    public function isValid(string $host): bool;
51 51
 }
Please login to merge, or discard this patch.
lib/private/Server.php 2 patches
Indentation   +2086 added lines, -2086 removed lines patch added patch discarded remove patch
@@ -278,2095 +278,2095 @@
 block discarded – undo
278 278
  */
279 279
 class Server extends ServerContainer implements IServerContainer {
280 280
 
281
-	/** @var string */
282
-	private $webRoot;
283
-
284
-	/**
285
-	 * @param string $webRoot
286
-	 * @param \OC\Config $config
287
-	 */
288
-	public function __construct($webRoot, \OC\Config $config) {
289
-		parent::__construct();
290
-		$this->webRoot = $webRoot;
291
-
292
-		// To find out if we are running from CLI or not
293
-		$this->registerParameter('isCLI', \OC::$CLI);
294
-		$this->registerParameter('serverRoot', \OC::$SERVERROOT);
295
-
296
-		$this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
297
-			return $c;
298
-		});
299
-		$this->registerService(\OCP\IServerContainer::class, function (ContainerInterface $c) {
300
-			return $c;
301
-		});
302
-
303
-		$this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
304
-		/** @deprecated 19.0.0 */
305
-		$this->registerDeprecatedAlias('CalendarManager', \OC\Calendar\Manager::class);
306
-
307
-		$this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class);
308
-		/** @deprecated 19.0.0 */
309
-		$this->registerDeprecatedAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class);
310
-
311
-		$this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class);
312
-		/** @deprecated 19.0.0 */
313
-		$this->registerDeprecatedAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class);
314
-
315
-		$this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
316
-		/** @deprecated 19.0.0 */
317
-		$this->registerDeprecatedAlias('ContactsManager', \OCP\Contacts\IManager::class);
318
-
319
-		$this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class);
320
-		$this->registerAlias(ITemplateManager::class, TemplateManager::class);
321
-
322
-		$this->registerAlias(IActionFactory::class, ActionFactory::class);
323
-
324
-		$this->registerService(View::class, function (Server $c) {
325
-			return new View();
326
-		}, false);
327
-
328
-		$this->registerService(IPreview::class, function (ContainerInterface $c) {
329
-			return new PreviewManager(
330
-				$c->get(\OCP\IConfig::class),
331
-				$c->get(IRootFolder::class),
332
-				new \OC\Preview\Storage\Root(
333
-					$c->get(IRootFolder::class),
334
-					$c->get(SystemConfig::class)
335
-				),
336
-				$c->get(IEventDispatcher::class),
337
-				$c->get(SymfonyAdapter::class),
338
-				$c->get(GeneratorHelper::class),
339
-				$c->get(ISession::class)->get('user_id'),
340
-				$c->get(Coordinator::class),
341
-				$c->get(IServerContainer::class),
342
-				$c->get(IBinaryFinder::class)
343
-			);
344
-		});
345
-		/** @deprecated 19.0.0 */
346
-		$this->registerDeprecatedAlias('PreviewManager', IPreview::class);
347
-
348
-		$this->registerService(\OC\Preview\Watcher::class, function (ContainerInterface $c) {
349
-			return new \OC\Preview\Watcher(
350
-				new \OC\Preview\Storage\Root(
351
-					$c->get(IRootFolder::class),
352
-					$c->get(SystemConfig::class)
353
-				)
354
-			);
355
-		});
356
-
357
-		$this->registerService(IProfiler::class, function (Server $c) {
358
-			return new Profiler($c->get(SystemConfig::class));
359
-		});
360
-
361
-		$this->registerService(\OCP\Encryption\IManager::class, function (Server $c): Encryption\Manager {
362
-			$view = new View();
363
-			$util = new Encryption\Util(
364
-				$view,
365
-				$c->get(IUserManager::class),
366
-				$c->get(IGroupManager::class),
367
-				$c->get(\OCP\IConfig::class)
368
-			);
369
-			return new Encryption\Manager(
370
-				$c->get(\OCP\IConfig::class),
371
-				$c->get(LoggerInterface::class),
372
-				$c->getL10N('core'),
373
-				new View(),
374
-				$util,
375
-				new ArrayCache()
376
-			);
377
-		});
378
-		/** @deprecated 19.0.0 */
379
-		$this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class);
380
-
381
-		/** @deprecated 21.0.0 */
382
-		$this->registerDeprecatedAlias('EncryptionFileHelper', IFile::class);
383
-		$this->registerService(IFile::class, function (ContainerInterface $c) {
384
-			$util = new Encryption\Util(
385
-				new View(),
386
-				$c->get(IUserManager::class),
387
-				$c->get(IGroupManager::class),
388
-				$c->get(\OCP\IConfig::class)
389
-			);
390
-			return new Encryption\File(
391
-				$util,
392
-				$c->get(IRootFolder::class),
393
-				$c->get(\OCP\Share\IManager::class)
394
-			);
395
-		});
396
-
397
-		/** @deprecated 21.0.0 */
398
-		$this->registerDeprecatedAlias('EncryptionKeyStorage', IStorage::class);
399
-		$this->registerService(IStorage::class, function (ContainerInterface $c) {
400
-			$view = new View();
401
-			$util = new Encryption\Util(
402
-				$view,
403
-				$c->get(IUserManager::class),
404
-				$c->get(IGroupManager::class),
405
-				$c->get(\OCP\IConfig::class)
406
-			);
407
-
408
-			return new Encryption\Keys\Storage(
409
-				$view,
410
-				$util,
411
-				$c->get(ICrypto::class),
412
-				$c->get(\OCP\IConfig::class)
413
-			);
414
-		});
415
-		/** @deprecated 20.0.0 */
416
-		$this->registerDeprecatedAlias('TagMapper', TagMapper::class);
417
-
418
-		$this->registerAlias(\OCP\ITagManager::class, TagManager::class);
419
-		/** @deprecated 19.0.0 */
420
-		$this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class);
421
-
422
-		$this->registerService('SystemTagManagerFactory', function (ContainerInterface $c) {
423
-			/** @var \OCP\IConfig $config */
424
-			$config = $c->get(\OCP\IConfig::class);
425
-			$factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
426
-			return new $factoryClass($this);
427
-		});
428
-		$this->registerService(ISystemTagManager::class, function (ContainerInterface $c) {
429
-			return $c->get('SystemTagManagerFactory')->getManager();
430
-		});
431
-		/** @deprecated 19.0.0 */
432
-		$this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class);
433
-
434
-		$this->registerService(ISystemTagObjectMapper::class, function (ContainerInterface $c) {
435
-			return $c->get('SystemTagManagerFactory')->getObjectMapper();
436
-		});
437
-		$this->registerService('RootFolder', function (ContainerInterface $c) {
438
-			$manager = \OC\Files\Filesystem::getMountManager(null);
439
-			$view = new View();
440
-			$root = new Root(
441
-				$manager,
442
-				$view,
443
-				null,
444
-				$c->get(IUserMountCache::class),
445
-				$this->get(LoggerInterface::class),
446
-				$this->get(IUserManager::class),
447
-				$this->get(IEventDispatcher::class),
448
-			);
449
-
450
-			$previewConnector = new \OC\Preview\WatcherConnector(
451
-				$root,
452
-				$c->get(SystemConfig::class)
453
-			);
454
-			$previewConnector->connectWatcher();
455
-
456
-			return $root;
457
-		});
458
-		$this->registerService(HookConnector::class, function (ContainerInterface $c) {
459
-			return new HookConnector(
460
-				$c->get(IRootFolder::class),
461
-				new View(),
462
-				$c->get(\OC\EventDispatcher\SymfonyAdapter::class),
463
-				$c->get(IEventDispatcher::class)
464
-			);
465
-		});
466
-
467
-		/** @deprecated 19.0.0 */
468
-		$this->registerDeprecatedAlias('SystemTagObjectMapper', ISystemTagObjectMapper::class);
469
-
470
-		$this->registerService(IRootFolder::class, function (ContainerInterface $c) {
471
-			return new LazyRoot(function () use ($c) {
472
-				return $c->get('RootFolder');
473
-			});
474
-		});
475
-		/** @deprecated 19.0.0 */
476
-		$this->registerDeprecatedAlias('LazyRootFolder', IRootFolder::class);
477
-
478
-		/** @deprecated 19.0.0 */
479
-		$this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class);
480
-		$this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
481
-
482
-		$this->registerService(DisplayNameCache::class, function (ContainerInterface $c) {
483
-			return $c->get(\OC\User\Manager::class)->getDisplayNameCache();
484
-		});
485
-
486
-		$this->registerService(\OCP\IGroupManager::class, function (ContainerInterface $c) {
487
-			$groupManager = new \OC\Group\Manager(
488
-				$this->get(IUserManager::class),
489
-				$c->get(SymfonyAdapter::class),
490
-				$this->get(LoggerInterface::class)
491
-			);
492
-			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
493
-				/** @var IEventDispatcher $dispatcher */
494
-				$dispatcher = $this->get(IEventDispatcher::class);
495
-				$dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid));
496
-			});
497
-			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) {
498
-				/** @var IEventDispatcher $dispatcher */
499
-				$dispatcher = $this->get(IEventDispatcher::class);
500
-				$dispatcher->dispatchTyped(new GroupCreatedEvent($group));
501
-			});
502
-			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
503
-				/** @var IEventDispatcher $dispatcher */
504
-				$dispatcher = $this->get(IEventDispatcher::class);
505
-				$dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group));
506
-			});
507
-			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
508
-				/** @var IEventDispatcher $dispatcher */
509
-				$dispatcher = $this->get(IEventDispatcher::class);
510
-				$dispatcher->dispatchTyped(new GroupDeletedEvent($group));
511
-			});
512
-			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
513
-				/** @var IEventDispatcher $dispatcher */
514
-				$dispatcher = $this->get(IEventDispatcher::class);
515
-				$dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user));
516
-			});
517
-			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
518
-				/** @var IEventDispatcher $dispatcher */
519
-				$dispatcher = $this->get(IEventDispatcher::class);
520
-				$dispatcher->dispatchTyped(new UserAddedEvent($group, $user));
521
-			});
522
-			$groupManager->listen('\OC\Group', 'preRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
523
-				/** @var IEventDispatcher $dispatcher */
524
-				$dispatcher = $this->get(IEventDispatcher::class);
525
-				$dispatcher->dispatchTyped(new BeforeUserRemovedEvent($group, $user));
526
-			});
527
-			$groupManager->listen('\OC\Group', 'postRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
528
-				/** @var IEventDispatcher $dispatcher */
529
-				$dispatcher = $this->get(IEventDispatcher::class);
530
-				$dispatcher->dispatchTyped(new UserRemovedEvent($group, $user));
531
-			});
532
-			return $groupManager;
533
-		});
534
-		/** @deprecated 19.0.0 */
535
-		$this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class);
536
-
537
-		$this->registerService(Store::class, function (ContainerInterface $c) {
538
-			$session = $c->get(ISession::class);
539
-			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
540
-				$tokenProvider = $c->get(IProvider::class);
541
-			} else {
542
-				$tokenProvider = null;
543
-			}
544
-			$logger = $c->get(LoggerInterface::class);
545
-			return new Store($session, $logger, $tokenProvider);
546
-		});
547
-		$this->registerAlias(IStore::class, Store::class);
548
-		$this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
549
-
550
-		$this->registerService(\OC\User\Session::class, function (Server $c) {
551
-			$manager = $c->get(IUserManager::class);
552
-			$session = new \OC\Session\Memory('');
553
-			$timeFactory = new TimeFactory();
554
-			// Token providers might require a working database. This code
555
-			// might however be called when Nextcloud is not yet setup.
556
-			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
557
-				$provider = $c->get(IProvider::class);
558
-			} else {
559
-				$provider = null;
560
-			}
561
-
562
-			$legacyDispatcher = $c->get(SymfonyAdapter::class);
563
-
564
-			$userSession = new \OC\User\Session(
565
-				$manager,
566
-				$session,
567
-				$timeFactory,
568
-				$provider,
569
-				$c->get(\OCP\IConfig::class),
570
-				$c->get(ISecureRandom::class),
571
-				$c->getLockdownManager(),
572
-				$c->get(LoggerInterface::class),
573
-				$c->get(IEventDispatcher::class)
574
-			);
575
-			/** @deprecated 21.0.0 use BeforeUserCreatedEvent event with the IEventDispatcher instead */
576
-			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
577
-				\OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]);
578
-			});
579
-			/** @deprecated 21.0.0 use UserCreatedEvent event with the IEventDispatcher instead */
580
-			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
581
-				/** @var \OC\User\User $user */
582
-				\OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]);
583
-			});
584
-			/** @deprecated 21.0.0 use BeforeUserDeletedEvent event with the IEventDispatcher instead */
585
-			$userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) {
586
-				/** @var \OC\User\User $user */
587
-				\OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]);
588
-				$legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user));
589
-			});
590
-			/** @deprecated 21.0.0 use UserDeletedEvent event with the IEventDispatcher instead */
591
-			$userSession->listen('\OC\User', 'postDelete', function ($user) {
592
-				/** @var \OC\User\User $user */
593
-				\OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]);
594
-			});
595
-			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
596
-				/** @var \OC\User\User $user */
597
-				\OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
598
-
599
-				/** @var IEventDispatcher $dispatcher */
600
-				$dispatcher = $this->get(IEventDispatcher::class);
601
-				$dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword));
602
-			});
603
-			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
604
-				/** @var \OC\User\User $user */
605
-				\OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
606
-
607
-				/** @var IEventDispatcher $dispatcher */
608
-				$dispatcher = $this->get(IEventDispatcher::class);
609
-				$dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword));
610
-			});
611
-			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
612
-				\OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]);
613
-
614
-				/** @var IEventDispatcher $dispatcher */
615
-				$dispatcher = $this->get(IEventDispatcher::class);
616
-				$dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
617
-			});
618
-			$userSession->listen('\OC\User', 'postLogin', function ($user, $loginName, $password, $isTokenLogin) {
619
-				/** @var \OC\User\User $user */
620
-				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'loginName' => $loginName, 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
621
-
622
-				/** @var IEventDispatcher $dispatcher */
623
-				$dispatcher = $this->get(IEventDispatcher::class);
624
-				$dispatcher->dispatchTyped(new UserLoggedInEvent($user, $loginName, $password, $isTokenLogin));
625
-			});
626
-			$userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
627
-				/** @var IEventDispatcher $dispatcher */
628
-				$dispatcher = $this->get(IEventDispatcher::class);
629
-				$dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
630
-			});
631
-			$userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
632
-				/** @var \OC\User\User $user */
633
-				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]);
634
-
635
-				/** @var IEventDispatcher $dispatcher */
636
-				$dispatcher = $this->get(IEventDispatcher::class);
637
-				$dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
638
-			});
639
-			$userSession->listen('\OC\User', 'logout', function ($user) {
640
-				\OC_Hook::emit('OC_User', 'logout', []);
641
-
642
-				/** @var IEventDispatcher $dispatcher */
643
-				$dispatcher = $this->get(IEventDispatcher::class);
644
-				$dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
645
-			});
646
-			$userSession->listen('\OC\User', 'postLogout', function ($user) {
647
-				/** @var IEventDispatcher $dispatcher */
648
-				$dispatcher = $this->get(IEventDispatcher::class);
649
-				$dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
650
-			});
651
-			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
652
-				/** @var \OC\User\User $user */
653
-				\OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]);
654
-
655
-				/** @var IEventDispatcher $dispatcher */
656
-				$dispatcher = $this->get(IEventDispatcher::class);
657
-				$dispatcher->dispatchTyped(new UserChangedEvent($user, $feature, $value, $oldValue));
658
-			});
659
-			return $userSession;
660
-		});
661
-		$this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class);
662
-		/** @deprecated 19.0.0 */
663
-		$this->registerDeprecatedAlias('UserSession', \OC\User\Session::class);
664
-
665
-		$this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class);
666
-
667
-		$this->registerAlias(INavigationManager::class, \OC\NavigationManager::class);
668
-		/** @deprecated 19.0.0 */
669
-		$this->registerDeprecatedAlias('NavigationManager', INavigationManager::class);
670
-
671
-		/** @deprecated 19.0.0 */
672
-		$this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class);
673
-		$this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
674
-
675
-		$this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
676
-			return new \OC\SystemConfig($config);
677
-		});
678
-		/** @deprecated 19.0.0 */
679
-		$this->registerDeprecatedAlias('SystemConfig', \OC\SystemConfig::class);
680
-
681
-		/** @deprecated 19.0.0 */
682
-		$this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class);
683
-		$this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
684
-
685
-		$this->registerService(IFactory::class, function (Server $c) {
686
-			return new \OC\L10N\Factory(
687
-				$c->get(\OCP\IConfig::class),
688
-				$c->getRequest(),
689
-				$c->get(IUserSession::class),
690
-				\OC::$SERVERROOT
691
-			);
692
-		});
693
-		/** @deprecated 19.0.0 */
694
-		$this->registerDeprecatedAlias('L10NFactory', IFactory::class);
695
-
696
-		$this->registerAlias(IURLGenerator::class, URLGenerator::class);
697
-		/** @deprecated 19.0.0 */
698
-		$this->registerDeprecatedAlias('URLGenerator', IURLGenerator::class);
699
-
700
-		/** @deprecated 19.0.0 */
701
-		$this->registerDeprecatedAlias('AppFetcher', AppFetcher::class);
702
-		/** @deprecated 19.0.0 */
703
-		$this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class);
704
-
705
-		$this->registerService(ICache::class, function ($c) {
706
-			return new Cache\File();
707
-		});
708
-		/** @deprecated 19.0.0 */
709
-		$this->registerDeprecatedAlias('UserCache', ICache::class);
710
-
711
-		$this->registerService(Factory::class, function (Server $c) {
712
-			$profiler = $c->get(IProfiler::class);
713
-			$arrayCacheFactory = new \OC\Memcache\Factory('', $c->get(LoggerInterface::class),
714
-				$profiler,
715
-				ArrayCache::class,
716
-				ArrayCache::class,
717
-				ArrayCache::class
718
-			);
719
-			/** @var \OCP\IConfig $config */
720
-			$config = $c->get(\OCP\IConfig::class);
721
-
722
-			if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
723
-				if (!$config->getSystemValueBool('log_query')) {
724
-					$v = \OC_App::getAppVersions();
725
-				} else {
726
-					// If the log_query is enabled, we can not get the app versions
727
-					// as that does a query, which will be logged and the logging
728
-					// depends on redis and here we are back again in the same function.
729
-					$v = [
730
-						'log_query' => 'enabled',
731
-					];
732
-				}
733
-				$v['core'] = implode(',', \OC_Util::getVersion());
734
-				$version = implode(',', $v);
735
-				$instanceId = \OC_Util::getInstanceId();
736
-				$path = \OC::$SERVERROOT;
737
-				$prefix = md5($instanceId . '-' . $version . '-' . $path);
738
-				return new \OC\Memcache\Factory($prefix,
739
-					$c->get(LoggerInterface::class),
740
-					$profiler,
741
-					$config->getSystemValue('memcache.local', null),
742
-					$config->getSystemValue('memcache.distributed', null),
743
-					$config->getSystemValue('memcache.locking', null),
744
-					$config->getSystemValueString('redis_log_file')
745
-				);
746
-			}
747
-			return $arrayCacheFactory;
748
-		});
749
-		/** @deprecated 19.0.0 */
750
-		$this->registerDeprecatedAlias('MemCacheFactory', Factory::class);
751
-		$this->registerAlias(ICacheFactory::class, Factory::class);
752
-
753
-		$this->registerService('RedisFactory', function (Server $c) {
754
-			$systemConfig = $c->get(SystemConfig::class);
755
-			return new RedisFactory($systemConfig, $c->getEventLogger());
756
-		});
757
-
758
-		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
759
-			$l10n = $this->get(IFactory::class)->get('lib');
760
-			return new \OC\Activity\Manager(
761
-				$c->getRequest(),
762
-				$c->get(IUserSession::class),
763
-				$c->get(\OCP\IConfig::class),
764
-				$c->get(IValidator::class),
765
-				$l10n
766
-			);
767
-		});
768
-		/** @deprecated 19.0.0 */
769
-		$this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class);
770
-
771
-		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
772
-			return new \OC\Activity\EventMerger(
773
-				$c->getL10N('lib')
774
-			);
775
-		});
776
-		$this->registerAlias(IValidator::class, Validator::class);
777
-
778
-		$this->registerService(AvatarManager::class, function (Server $c) {
779
-			return new AvatarManager(
780
-				$c->get(IUserSession::class),
781
-				$c->get(\OC\User\Manager::class),
782
-				$c->getAppDataDir('avatar'),
783
-				$c->getL10N('lib'),
784
-				$c->get(LoggerInterface::class),
785
-				$c->get(\OCP\IConfig::class),
786
-				$c->get(IAccountManager::class),
787
-				$c->get(KnownUserService::class)
788
-			);
789
-		});
790
-
791
-		$this->registerAlias(IAvatarManager::class, AvatarManager::class);
792
-		/** @deprecated 19.0.0 */
793
-		$this->registerDeprecatedAlias('AvatarManager', AvatarManager::class);
794
-
795
-		$this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
796
-		$this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
797
-		$this->registerAlias(\OCP\Support\Subscription\IAssertion::class, \OC\Support\Subscription\Assertion::class);
798
-
799
-		$this->registerService(\OC\Log::class, function (Server $c) {
800
-			$logType = $c->get(AllConfig::class)->getSystemValue('log_type', 'file');
801
-			$factory = new LogFactory($c, $this->get(SystemConfig::class));
802
-			$logger = $factory->get($logType);
803
-			$registry = $c->get(\OCP\Support\CrashReport\IRegistry::class);
804
-
805
-			return new Log($logger, $this->get(SystemConfig::class), null, $registry);
806
-		});
807
-		$this->registerAlias(ILogger::class, \OC\Log::class);
808
-		/** @deprecated 19.0.0 */
809
-		$this->registerDeprecatedAlias('Logger', \OC\Log::class);
810
-		// PSR-3 logger
811
-		$this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class);
812
-
813
-		$this->registerService(ILogFactory::class, function (Server $c) {
814
-			return new LogFactory($c, $this->get(SystemConfig::class));
815
-		});
816
-
817
-		$this->registerAlias(IJobList::class, \OC\BackgroundJob\JobList::class);
818
-		/** @deprecated 19.0.0 */
819
-		$this->registerDeprecatedAlias('JobList', IJobList::class);
820
-
821
-		$this->registerService(Router::class, function (Server $c) {
822
-			$cacheFactory = $c->get(ICacheFactory::class);
823
-			$logger = $c->get(LoggerInterface::class);
824
-			if ($cacheFactory->isLocalCacheAvailable()) {
825
-				$router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger);
826
-			} else {
827
-				$router = new \OC\Route\Router($logger);
828
-			}
829
-			return $router;
830
-		});
831
-		$this->registerAlias(IRouter::class, Router::class);
832
-		/** @deprecated 19.0.0 */
833
-		$this->registerDeprecatedAlias('Router', IRouter::class);
834
-
835
-		$this->registerAlias(ISearch::class, Search::class);
836
-		/** @deprecated 19.0.0 */
837
-		$this->registerDeprecatedAlias('Search', ISearch::class);
838
-
839
-		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
840
-			$cacheFactory = $c->get(ICacheFactory::class);
841
-			if ($cacheFactory->isAvailable()) {
842
-				$backend = new \OC\Security\RateLimiting\Backend\MemoryCacheBackend(
843
-					$this->get(ICacheFactory::class),
844
-					new \OC\AppFramework\Utility\TimeFactory()
845
-				);
846
-			} else {
847
-				$backend = new \OC\Security\RateLimiting\Backend\DatabaseBackend(
848
-					$c->get(IDBConnection::class),
849
-					new \OC\AppFramework\Utility\TimeFactory()
850
-				);
851
-			}
852
-
853
-			return $backend;
854
-		});
855
-
856
-		$this->registerAlias(\OCP\Security\ISecureRandom::class, SecureRandom::class);
857
-		/** @deprecated 19.0.0 */
858
-		$this->registerDeprecatedAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
859
-		$this->registerAlias(\OCP\Security\IRemoteHostValidator::class, \OC\Security\RemoteHostValidator::class);
860
-		$this->registerAlias(IVerificationToken::class, VerificationToken::class);
861
-
862
-		$this->registerAlias(ICrypto::class, Crypto::class);
863
-		/** @deprecated 19.0.0 */
864
-		$this->registerDeprecatedAlias('Crypto', ICrypto::class);
865
-
866
-		$this->registerAlias(IHasher::class, Hasher::class);
867
-		/** @deprecated 19.0.0 */
868
-		$this->registerDeprecatedAlias('Hasher', IHasher::class);
869
-
870
-		$this->registerAlias(ICredentialsManager::class, CredentialsManager::class);
871
-		/** @deprecated 19.0.0 */
872
-		$this->registerDeprecatedAlias('CredentialsManager', ICredentialsManager::class);
873
-
874
-		$this->registerAlias(IDBConnection::class, ConnectionAdapter::class);
875
-		$this->registerService(Connection::class, function (Server $c) {
876
-			$systemConfig = $c->get(SystemConfig::class);
877
-			$factory = new \OC\DB\ConnectionFactory($systemConfig);
878
-			$type = $systemConfig->getValue('dbtype', 'sqlite');
879
-			if (!$factory->isValidType($type)) {
880
-				throw new \OC\DatabaseException('Invalid database type');
881
-			}
882
-			$connectionParams = $factory->createConnectionParams();
883
-			$connection = $factory->getConnection($type, $connectionParams);
884
-			return $connection;
885
-		});
886
-		/** @deprecated 19.0.0 */
887
-		$this->registerDeprecatedAlias('DatabaseConnection', IDBConnection::class);
888
-
889
-		$this->registerAlias(ICertificateManager::class, CertificateManager::class);
890
-		$this->registerAlias(IClientService::class, ClientService::class);
891
-		$this->registerService(NegativeDnsCache::class, function (ContainerInterface $c) {
892
-			return new NegativeDnsCache(
893
-				$c->get(ICacheFactory::class),
894
-			);
895
-		});
896
-		$this->registerDeprecatedAlias('HttpClientService', IClientService::class);
897
-		$this->registerService(IEventLogger::class, function (ContainerInterface $c) {
898
-			return new EventLogger($c->get(SystemConfig::class), $c->get(LoggerInterface::class), $c->get(Log::class));
899
-		});
900
-		/** @deprecated 19.0.0 */
901
-		$this->registerDeprecatedAlias('EventLogger', IEventLogger::class);
902
-
903
-		$this->registerService(IQueryLogger::class, function (ContainerInterface $c) {
904
-			$queryLogger = new QueryLogger();
905
-			if ($c->get(SystemConfig::class)->getValue('debug', false)) {
906
-				// In debug mode, module is being activated by default
907
-				$queryLogger->activate();
908
-			}
909
-			return $queryLogger;
910
-		});
911
-		/** @deprecated 19.0.0 */
912
-		$this->registerDeprecatedAlias('QueryLogger', IQueryLogger::class);
913
-
914
-		/** @deprecated 19.0.0 */
915
-		$this->registerDeprecatedAlias('TempManager', TempManager::class);
916
-		$this->registerAlias(ITempManager::class, TempManager::class);
917
-
918
-		$this->registerService(AppManager::class, function (ContainerInterface $c) {
919
-			// TODO: use auto-wiring
920
-			return new \OC\App\AppManager(
921
-				$c->get(IUserSession::class),
922
-				$c->get(\OCP\IConfig::class),
923
-				$c->get(\OC\AppConfig::class),
924
-				$c->get(IGroupManager::class),
925
-				$c->get(ICacheFactory::class),
926
-				$c->get(SymfonyAdapter::class),
927
-				$c->get(LoggerInterface::class)
928
-			);
929
-		});
930
-		/** @deprecated 19.0.0 */
931
-		$this->registerDeprecatedAlias('AppManager', AppManager::class);
932
-		$this->registerAlias(IAppManager::class, AppManager::class);
933
-
934
-		$this->registerAlias(IDateTimeZone::class, DateTimeZone::class);
935
-		/** @deprecated 19.0.0 */
936
-		$this->registerDeprecatedAlias('DateTimeZone', IDateTimeZone::class);
937
-
938
-		$this->registerService(IDateTimeFormatter::class, function (Server $c) {
939
-			$language = $c->get(\OCP\IConfig::class)->getUserValue($c->get(ISession::class)->get('user_id'), 'core', 'lang', null);
940
-
941
-			return new DateTimeFormatter(
942
-				$c->get(IDateTimeZone::class)->getTimeZone(),
943
-				$c->getL10N('lib', $language)
944
-			);
945
-		});
946
-		/** @deprecated 19.0.0 */
947
-		$this->registerDeprecatedAlias('DateTimeFormatter', IDateTimeFormatter::class);
948
-
949
-		$this->registerService(IUserMountCache::class, function (ContainerInterface $c) {
950
-			$mountCache = new UserMountCache(
951
-				$c->get(IDBConnection::class),
952
-				$c->get(IUserManager::class),
953
-				$c->get(LoggerInterface::class)
954
-			);
955
-			$listener = new UserMountCacheListener($mountCache);
956
-			$listener->listen($c->get(IUserManager::class));
957
-			return $mountCache;
958
-		});
959
-		/** @deprecated 19.0.0 */
960
-		$this->registerDeprecatedAlias('UserMountCache', IUserMountCache::class);
961
-
962
-		$this->registerService(IMountProviderCollection::class, function (ContainerInterface $c) {
963
-			$loader = \OC\Files\Filesystem::getLoader();
964
-			$mountCache = $c->get(IUserMountCache::class);
965
-			$manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
966
-
967
-			// builtin providers
968
-
969
-			$config = $c->get(\OCP\IConfig::class);
970
-			$logger = $c->get(LoggerInterface::class);
971
-			$manager->registerProvider(new CacheMountProvider($config));
972
-			$manager->registerHomeProvider(new LocalHomeMountProvider());
973
-			$manager->registerHomeProvider(new ObjectHomeMountProvider($config));
974
-			$manager->registerRootProvider(new RootMountProvider($config, $c->get(LoggerInterface::class)));
975
-			$manager->registerRootProvider(new ObjectStorePreviewCacheMountProvider($logger, $config));
976
-
977
-			return $manager;
978
-		});
979
-		/** @deprecated 19.0.0 */
980
-		$this->registerDeprecatedAlias('MountConfigManager', IMountProviderCollection::class);
981
-
982
-		/** @deprecated 20.0.0 */
983
-		$this->registerDeprecatedAlias('IniWrapper', IniGetWrapper::class);
984
-		$this->registerService(IBus::class, function (ContainerInterface $c) {
985
-			$busClass = $c->get(\OCP\IConfig::class)->getSystemValue('commandbus');
986
-			if ($busClass) {
987
-				[$app, $class] = explode('::', $busClass, 2);
988
-				if ($c->get(IAppManager::class)->isInstalled($app)) {
989
-					\OC_App::loadApp($app);
990
-					return $c->get($class);
991
-				} else {
992
-					throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
993
-				}
994
-			} else {
995
-				$jobList = $c->get(IJobList::class);
996
-				return new CronBus($jobList);
997
-			}
998
-		});
999
-		$this->registerDeprecatedAlias('AsyncCommandBus', IBus::class);
1000
-		/** @deprecated 20.0.0 */
1001
-		$this->registerDeprecatedAlias('TrustedDomainHelper', TrustedDomainHelper::class);
1002
-		$this->registerAlias(ITrustedDomainHelper::class, TrustedDomainHelper::class);
1003
-		/** @deprecated 19.0.0 */
1004
-		$this->registerDeprecatedAlias('Throttler', Throttler::class);
1005
-		$this->registerAlias(IThrottler::class, Throttler::class);
1006
-		$this->registerService('IntegrityCodeChecker', function (ContainerInterface $c) {
1007
-			// IConfig and IAppManager requires a working database. This code
1008
-			// might however be called when ownCloud is not yet setup.
1009
-			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
1010
-				$config = $c->get(\OCP\IConfig::class);
1011
-				$appManager = $c->get(IAppManager::class);
1012
-			} else {
1013
-				$config = null;
1014
-				$appManager = null;
1015
-			}
1016
-
1017
-			return new Checker(
1018
-				new EnvironmentHelper(),
1019
-				new FileAccessHelper(),
1020
-				new AppLocator(),
1021
-				$config,
1022
-				$c->get(ICacheFactory::class),
1023
-				$appManager,
1024
-				$c->get(IMimeTypeDetector::class)
1025
-			);
1026
-		});
1027
-		$this->registerService(\OCP\IRequest::class, function (ContainerInterface $c) {
1028
-			if (isset($this['urlParams'])) {
1029
-				$urlParams = $this['urlParams'];
1030
-			} else {
1031
-				$urlParams = [];
1032
-			}
1033
-
1034
-			if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
1035
-				&& in_array('fakeinput', stream_get_wrappers())
1036
-			) {
1037
-				$stream = 'fakeinput://data';
1038
-			} else {
1039
-				$stream = 'php://input';
1040
-			}
1041
-
1042
-			return new Request(
1043
-				[
1044
-					'get' => $_GET,
1045
-					'post' => $_POST,
1046
-					'files' => $_FILES,
1047
-					'server' => $_SERVER,
1048
-					'env' => $_ENV,
1049
-					'cookies' => $_COOKIE,
1050
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1051
-						? $_SERVER['REQUEST_METHOD']
1052
-						: '',
1053
-					'urlParams' => $urlParams,
1054
-				],
1055
-				$this->get(IRequestId::class),
1056
-				$this->get(\OCP\IConfig::class),
1057
-				$this->get(CsrfTokenManager::class),
1058
-				$stream
1059
-			);
1060
-		});
1061
-		/** @deprecated 19.0.0 */
1062
-		$this->registerDeprecatedAlias('Request', \OCP\IRequest::class);
1063
-
1064
-		$this->registerService(IRequestId::class, function (ContainerInterface $c): IRequestId {
1065
-			return new RequestId(
1066
-				$_SERVER['UNIQUE_ID'] ?? '',
1067
-				$this->get(ISecureRandom::class)
1068
-			);
1069
-		});
1070
-
1071
-		$this->registerService(IMailer::class, function (Server $c) {
1072
-			return new Mailer(
1073
-				$c->get(\OCP\IConfig::class),
1074
-				$c->get(LoggerInterface::class),
1075
-				$c->get(Defaults::class),
1076
-				$c->get(IURLGenerator::class),
1077
-				$c->getL10N('lib'),
1078
-				$c->get(IEventDispatcher::class),
1079
-				$c->get(IFactory::class)
1080
-			);
1081
-		});
1082
-		/** @deprecated 19.0.0 */
1083
-		$this->registerDeprecatedAlias('Mailer', IMailer::class);
1084
-
1085
-		/** @deprecated 21.0.0 */
1086
-		$this->registerDeprecatedAlias('LDAPProvider', ILDAPProvider::class);
1087
-
1088
-		$this->registerService(ILDAPProviderFactory::class, function (ContainerInterface $c) {
1089
-			$config = $c->get(\OCP\IConfig::class);
1090
-			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
1091
-			if (is_null($factoryClass) || !class_exists($factoryClass)) {
1092
-				return new NullLDAPProviderFactory($this);
1093
-			}
1094
-			/** @var \OCP\LDAP\ILDAPProviderFactory $factory */
1095
-			return new $factoryClass($this);
1096
-		});
1097
-		$this->registerService(ILDAPProvider::class, function (ContainerInterface $c) {
1098
-			$factory = $c->get(ILDAPProviderFactory::class);
1099
-			return $factory->getLDAPProvider();
1100
-		});
1101
-		$this->registerService(ILockingProvider::class, function (ContainerInterface $c) {
1102
-			$ini = $c->get(IniGetWrapper::class);
1103
-			$config = $c->get(\OCP\IConfig::class);
1104
-			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
1105
-			if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
1106
-				/** @var \OC\Memcache\Factory $memcacheFactory */
1107
-				$memcacheFactory = $c->get(ICacheFactory::class);
1108
-				$memcache = $memcacheFactory->createLocking('lock');
1109
-				if (!($memcache instanceof \OC\Memcache\NullCache)) {
1110
-					return new MemcacheLockingProvider($memcache, $ttl);
1111
-				}
1112
-				return new DBLockingProvider(
1113
-					$c->get(IDBConnection::class),
1114
-					new TimeFactory(),
1115
-					$ttl,
1116
-					!\OC::$CLI
1117
-				);
1118
-			}
1119
-			return new NoopLockingProvider();
1120
-		});
1121
-		/** @deprecated 19.0.0 */
1122
-		$this->registerDeprecatedAlias('LockingProvider', ILockingProvider::class);
1123
-
1124
-		$this->registerService(ILockManager::class, function (Server $c): LockManager {
1125
-			return new LockManager();
1126
-		});
1127
-
1128
-		$this->registerAlias(ILockdownManager::class, 'LockdownManager');
1129
-		$this->registerService(SetupManager::class, function ($c) {
1130
-			// create the setupmanager through the mount manager to resolve the cyclic dependency
1131
-			return $c->get(\OC\Files\Mount\Manager::class)->getSetupManager();
1132
-		});
1133
-		$this->registerAlias(IMountManager::class, \OC\Files\Mount\Manager::class);
1134
-		/** @deprecated 19.0.0 */
1135
-		$this->registerDeprecatedAlias('MountManager', IMountManager::class);
1136
-
1137
-		$this->registerService(IMimeTypeDetector::class, function (ContainerInterface $c) {
1138
-			return new \OC\Files\Type\Detection(
1139
-				$c->get(IURLGenerator::class),
1140
-				$c->get(LoggerInterface::class),
1141
-				\OC::$configDir,
1142
-				\OC::$SERVERROOT . '/resources/config/'
1143
-			);
1144
-		});
1145
-		/** @deprecated 19.0.0 */
1146
-		$this->registerDeprecatedAlias('MimeTypeDetector', IMimeTypeDetector::class);
1147
-
1148
-		$this->registerAlias(IMimeTypeLoader::class, Loader::class);
1149
-		/** @deprecated 19.0.0 */
1150
-		$this->registerDeprecatedAlias('MimeTypeLoader', IMimeTypeLoader::class);
1151
-		$this->registerService(BundleFetcher::class, function () {
1152
-			return new BundleFetcher($this->getL10N('lib'));
1153
-		});
1154
-		$this->registerAlias(\OCP\Notification\IManager::class, Manager::class);
1155
-		/** @deprecated 19.0.0 */
1156
-		$this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class);
1157
-
1158
-		$this->registerService(CapabilitiesManager::class, function (ContainerInterface $c) {
1159
-			$manager = new CapabilitiesManager($c->get(LoggerInterface::class));
1160
-			$manager->registerCapability(function () use ($c) {
1161
-				return new \OC\OCS\CoreCapabilities($c->get(\OCP\IConfig::class));
1162
-			});
1163
-			$manager->registerCapability(function () use ($c) {
1164
-				return $c->get(\OC\Security\Bruteforce\Capabilities::class);
1165
-			});
1166
-			$manager->registerCapability(function () use ($c) {
1167
-				return $c->get(MetadataCapabilities::class);
1168
-			});
1169
-			return $manager;
1170
-		});
1171
-		/** @deprecated 19.0.0 */
1172
-		$this->registerDeprecatedAlias('CapabilitiesManager', CapabilitiesManager::class);
1173
-
1174
-		$this->registerService(ICommentsManager::class, function (Server $c) {
1175
-			$config = $c->get(\OCP\IConfig::class);
1176
-			$factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
1177
-			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
1178
-			$factory = new $factoryClass($this);
1179
-			$manager = $factory->getManager();
1180
-
1181
-			$manager->registerDisplayNameResolver('user', function ($id) use ($c) {
1182
-				$manager = $c->get(IUserManager::class);
1183
-				$userDisplayName = $manager->getDisplayName($id);
1184
-				if ($userDisplayName === null) {
1185
-					$l = $c->get(IFactory::class)->get('core');
1186
-					return $l->t('Unknown user');
1187
-				}
1188
-				return $userDisplayName;
1189
-			});
1190
-
1191
-			return $manager;
1192
-		});
1193
-		/** @deprecated 19.0.0 */
1194
-		$this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class);
1195
-
1196
-		$this->registerAlias(\OC_Defaults::class, 'ThemingDefaults');
1197
-		$this->registerService('ThemingDefaults', function (Server $c) {
1198
-			/*
281
+    /** @var string */
282
+    private $webRoot;
283
+
284
+    /**
285
+     * @param string $webRoot
286
+     * @param \OC\Config $config
287
+     */
288
+    public function __construct($webRoot, \OC\Config $config) {
289
+        parent::__construct();
290
+        $this->webRoot = $webRoot;
291
+
292
+        // To find out if we are running from CLI or not
293
+        $this->registerParameter('isCLI', \OC::$CLI);
294
+        $this->registerParameter('serverRoot', \OC::$SERVERROOT);
295
+
296
+        $this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
297
+            return $c;
298
+        });
299
+        $this->registerService(\OCP\IServerContainer::class, function (ContainerInterface $c) {
300
+            return $c;
301
+        });
302
+
303
+        $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
304
+        /** @deprecated 19.0.0 */
305
+        $this->registerDeprecatedAlias('CalendarManager', \OC\Calendar\Manager::class);
306
+
307
+        $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class);
308
+        /** @deprecated 19.0.0 */
309
+        $this->registerDeprecatedAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class);
310
+
311
+        $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class);
312
+        /** @deprecated 19.0.0 */
313
+        $this->registerDeprecatedAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class);
314
+
315
+        $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
316
+        /** @deprecated 19.0.0 */
317
+        $this->registerDeprecatedAlias('ContactsManager', \OCP\Contacts\IManager::class);
318
+
319
+        $this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class);
320
+        $this->registerAlias(ITemplateManager::class, TemplateManager::class);
321
+
322
+        $this->registerAlias(IActionFactory::class, ActionFactory::class);
323
+
324
+        $this->registerService(View::class, function (Server $c) {
325
+            return new View();
326
+        }, false);
327
+
328
+        $this->registerService(IPreview::class, function (ContainerInterface $c) {
329
+            return new PreviewManager(
330
+                $c->get(\OCP\IConfig::class),
331
+                $c->get(IRootFolder::class),
332
+                new \OC\Preview\Storage\Root(
333
+                    $c->get(IRootFolder::class),
334
+                    $c->get(SystemConfig::class)
335
+                ),
336
+                $c->get(IEventDispatcher::class),
337
+                $c->get(SymfonyAdapter::class),
338
+                $c->get(GeneratorHelper::class),
339
+                $c->get(ISession::class)->get('user_id'),
340
+                $c->get(Coordinator::class),
341
+                $c->get(IServerContainer::class),
342
+                $c->get(IBinaryFinder::class)
343
+            );
344
+        });
345
+        /** @deprecated 19.0.0 */
346
+        $this->registerDeprecatedAlias('PreviewManager', IPreview::class);
347
+
348
+        $this->registerService(\OC\Preview\Watcher::class, function (ContainerInterface $c) {
349
+            return new \OC\Preview\Watcher(
350
+                new \OC\Preview\Storage\Root(
351
+                    $c->get(IRootFolder::class),
352
+                    $c->get(SystemConfig::class)
353
+                )
354
+            );
355
+        });
356
+
357
+        $this->registerService(IProfiler::class, function (Server $c) {
358
+            return new Profiler($c->get(SystemConfig::class));
359
+        });
360
+
361
+        $this->registerService(\OCP\Encryption\IManager::class, function (Server $c): Encryption\Manager {
362
+            $view = new View();
363
+            $util = new Encryption\Util(
364
+                $view,
365
+                $c->get(IUserManager::class),
366
+                $c->get(IGroupManager::class),
367
+                $c->get(\OCP\IConfig::class)
368
+            );
369
+            return new Encryption\Manager(
370
+                $c->get(\OCP\IConfig::class),
371
+                $c->get(LoggerInterface::class),
372
+                $c->getL10N('core'),
373
+                new View(),
374
+                $util,
375
+                new ArrayCache()
376
+            );
377
+        });
378
+        /** @deprecated 19.0.0 */
379
+        $this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class);
380
+
381
+        /** @deprecated 21.0.0 */
382
+        $this->registerDeprecatedAlias('EncryptionFileHelper', IFile::class);
383
+        $this->registerService(IFile::class, function (ContainerInterface $c) {
384
+            $util = new Encryption\Util(
385
+                new View(),
386
+                $c->get(IUserManager::class),
387
+                $c->get(IGroupManager::class),
388
+                $c->get(\OCP\IConfig::class)
389
+            );
390
+            return new Encryption\File(
391
+                $util,
392
+                $c->get(IRootFolder::class),
393
+                $c->get(\OCP\Share\IManager::class)
394
+            );
395
+        });
396
+
397
+        /** @deprecated 21.0.0 */
398
+        $this->registerDeprecatedAlias('EncryptionKeyStorage', IStorage::class);
399
+        $this->registerService(IStorage::class, function (ContainerInterface $c) {
400
+            $view = new View();
401
+            $util = new Encryption\Util(
402
+                $view,
403
+                $c->get(IUserManager::class),
404
+                $c->get(IGroupManager::class),
405
+                $c->get(\OCP\IConfig::class)
406
+            );
407
+
408
+            return new Encryption\Keys\Storage(
409
+                $view,
410
+                $util,
411
+                $c->get(ICrypto::class),
412
+                $c->get(\OCP\IConfig::class)
413
+            );
414
+        });
415
+        /** @deprecated 20.0.0 */
416
+        $this->registerDeprecatedAlias('TagMapper', TagMapper::class);
417
+
418
+        $this->registerAlias(\OCP\ITagManager::class, TagManager::class);
419
+        /** @deprecated 19.0.0 */
420
+        $this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class);
421
+
422
+        $this->registerService('SystemTagManagerFactory', function (ContainerInterface $c) {
423
+            /** @var \OCP\IConfig $config */
424
+            $config = $c->get(\OCP\IConfig::class);
425
+            $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
426
+            return new $factoryClass($this);
427
+        });
428
+        $this->registerService(ISystemTagManager::class, function (ContainerInterface $c) {
429
+            return $c->get('SystemTagManagerFactory')->getManager();
430
+        });
431
+        /** @deprecated 19.0.0 */
432
+        $this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class);
433
+
434
+        $this->registerService(ISystemTagObjectMapper::class, function (ContainerInterface $c) {
435
+            return $c->get('SystemTagManagerFactory')->getObjectMapper();
436
+        });
437
+        $this->registerService('RootFolder', function (ContainerInterface $c) {
438
+            $manager = \OC\Files\Filesystem::getMountManager(null);
439
+            $view = new View();
440
+            $root = new Root(
441
+                $manager,
442
+                $view,
443
+                null,
444
+                $c->get(IUserMountCache::class),
445
+                $this->get(LoggerInterface::class),
446
+                $this->get(IUserManager::class),
447
+                $this->get(IEventDispatcher::class),
448
+            );
449
+
450
+            $previewConnector = new \OC\Preview\WatcherConnector(
451
+                $root,
452
+                $c->get(SystemConfig::class)
453
+            );
454
+            $previewConnector->connectWatcher();
455
+
456
+            return $root;
457
+        });
458
+        $this->registerService(HookConnector::class, function (ContainerInterface $c) {
459
+            return new HookConnector(
460
+                $c->get(IRootFolder::class),
461
+                new View(),
462
+                $c->get(\OC\EventDispatcher\SymfonyAdapter::class),
463
+                $c->get(IEventDispatcher::class)
464
+            );
465
+        });
466
+
467
+        /** @deprecated 19.0.0 */
468
+        $this->registerDeprecatedAlias('SystemTagObjectMapper', ISystemTagObjectMapper::class);
469
+
470
+        $this->registerService(IRootFolder::class, function (ContainerInterface $c) {
471
+            return new LazyRoot(function () use ($c) {
472
+                return $c->get('RootFolder');
473
+            });
474
+        });
475
+        /** @deprecated 19.0.0 */
476
+        $this->registerDeprecatedAlias('LazyRootFolder', IRootFolder::class);
477
+
478
+        /** @deprecated 19.0.0 */
479
+        $this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class);
480
+        $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
481
+
482
+        $this->registerService(DisplayNameCache::class, function (ContainerInterface $c) {
483
+            return $c->get(\OC\User\Manager::class)->getDisplayNameCache();
484
+        });
485
+
486
+        $this->registerService(\OCP\IGroupManager::class, function (ContainerInterface $c) {
487
+            $groupManager = new \OC\Group\Manager(
488
+                $this->get(IUserManager::class),
489
+                $c->get(SymfonyAdapter::class),
490
+                $this->get(LoggerInterface::class)
491
+            );
492
+            $groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
493
+                /** @var IEventDispatcher $dispatcher */
494
+                $dispatcher = $this->get(IEventDispatcher::class);
495
+                $dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid));
496
+            });
497
+            $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) {
498
+                /** @var IEventDispatcher $dispatcher */
499
+                $dispatcher = $this->get(IEventDispatcher::class);
500
+                $dispatcher->dispatchTyped(new GroupCreatedEvent($group));
501
+            });
502
+            $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
503
+                /** @var IEventDispatcher $dispatcher */
504
+                $dispatcher = $this->get(IEventDispatcher::class);
505
+                $dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group));
506
+            });
507
+            $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
508
+                /** @var IEventDispatcher $dispatcher */
509
+                $dispatcher = $this->get(IEventDispatcher::class);
510
+                $dispatcher->dispatchTyped(new GroupDeletedEvent($group));
511
+            });
512
+            $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
513
+                /** @var IEventDispatcher $dispatcher */
514
+                $dispatcher = $this->get(IEventDispatcher::class);
515
+                $dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user));
516
+            });
517
+            $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
518
+                /** @var IEventDispatcher $dispatcher */
519
+                $dispatcher = $this->get(IEventDispatcher::class);
520
+                $dispatcher->dispatchTyped(new UserAddedEvent($group, $user));
521
+            });
522
+            $groupManager->listen('\OC\Group', 'preRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
523
+                /** @var IEventDispatcher $dispatcher */
524
+                $dispatcher = $this->get(IEventDispatcher::class);
525
+                $dispatcher->dispatchTyped(new BeforeUserRemovedEvent($group, $user));
526
+            });
527
+            $groupManager->listen('\OC\Group', 'postRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
528
+                /** @var IEventDispatcher $dispatcher */
529
+                $dispatcher = $this->get(IEventDispatcher::class);
530
+                $dispatcher->dispatchTyped(new UserRemovedEvent($group, $user));
531
+            });
532
+            return $groupManager;
533
+        });
534
+        /** @deprecated 19.0.0 */
535
+        $this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class);
536
+
537
+        $this->registerService(Store::class, function (ContainerInterface $c) {
538
+            $session = $c->get(ISession::class);
539
+            if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
540
+                $tokenProvider = $c->get(IProvider::class);
541
+            } else {
542
+                $tokenProvider = null;
543
+            }
544
+            $logger = $c->get(LoggerInterface::class);
545
+            return new Store($session, $logger, $tokenProvider);
546
+        });
547
+        $this->registerAlias(IStore::class, Store::class);
548
+        $this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
549
+
550
+        $this->registerService(\OC\User\Session::class, function (Server $c) {
551
+            $manager = $c->get(IUserManager::class);
552
+            $session = new \OC\Session\Memory('');
553
+            $timeFactory = new TimeFactory();
554
+            // Token providers might require a working database. This code
555
+            // might however be called when Nextcloud is not yet setup.
556
+            if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
557
+                $provider = $c->get(IProvider::class);
558
+            } else {
559
+                $provider = null;
560
+            }
561
+
562
+            $legacyDispatcher = $c->get(SymfonyAdapter::class);
563
+
564
+            $userSession = new \OC\User\Session(
565
+                $manager,
566
+                $session,
567
+                $timeFactory,
568
+                $provider,
569
+                $c->get(\OCP\IConfig::class),
570
+                $c->get(ISecureRandom::class),
571
+                $c->getLockdownManager(),
572
+                $c->get(LoggerInterface::class),
573
+                $c->get(IEventDispatcher::class)
574
+            );
575
+            /** @deprecated 21.0.0 use BeforeUserCreatedEvent event with the IEventDispatcher instead */
576
+            $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
577
+                \OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]);
578
+            });
579
+            /** @deprecated 21.0.0 use UserCreatedEvent event with the IEventDispatcher instead */
580
+            $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
581
+                /** @var \OC\User\User $user */
582
+                \OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]);
583
+            });
584
+            /** @deprecated 21.0.0 use BeforeUserDeletedEvent event with the IEventDispatcher instead */
585
+            $userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) {
586
+                /** @var \OC\User\User $user */
587
+                \OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]);
588
+                $legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user));
589
+            });
590
+            /** @deprecated 21.0.0 use UserDeletedEvent event with the IEventDispatcher instead */
591
+            $userSession->listen('\OC\User', 'postDelete', function ($user) {
592
+                /** @var \OC\User\User $user */
593
+                \OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]);
594
+            });
595
+            $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
596
+                /** @var \OC\User\User $user */
597
+                \OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
598
+
599
+                /** @var IEventDispatcher $dispatcher */
600
+                $dispatcher = $this->get(IEventDispatcher::class);
601
+                $dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword));
602
+            });
603
+            $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
604
+                /** @var \OC\User\User $user */
605
+                \OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
606
+
607
+                /** @var IEventDispatcher $dispatcher */
608
+                $dispatcher = $this->get(IEventDispatcher::class);
609
+                $dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword));
610
+            });
611
+            $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
612
+                \OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]);
613
+
614
+                /** @var IEventDispatcher $dispatcher */
615
+                $dispatcher = $this->get(IEventDispatcher::class);
616
+                $dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
617
+            });
618
+            $userSession->listen('\OC\User', 'postLogin', function ($user, $loginName, $password, $isTokenLogin) {
619
+                /** @var \OC\User\User $user */
620
+                \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'loginName' => $loginName, 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
621
+
622
+                /** @var IEventDispatcher $dispatcher */
623
+                $dispatcher = $this->get(IEventDispatcher::class);
624
+                $dispatcher->dispatchTyped(new UserLoggedInEvent($user, $loginName, $password, $isTokenLogin));
625
+            });
626
+            $userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
627
+                /** @var IEventDispatcher $dispatcher */
628
+                $dispatcher = $this->get(IEventDispatcher::class);
629
+                $dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
630
+            });
631
+            $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
632
+                /** @var \OC\User\User $user */
633
+                \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]);
634
+
635
+                /** @var IEventDispatcher $dispatcher */
636
+                $dispatcher = $this->get(IEventDispatcher::class);
637
+                $dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
638
+            });
639
+            $userSession->listen('\OC\User', 'logout', function ($user) {
640
+                \OC_Hook::emit('OC_User', 'logout', []);
641
+
642
+                /** @var IEventDispatcher $dispatcher */
643
+                $dispatcher = $this->get(IEventDispatcher::class);
644
+                $dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
645
+            });
646
+            $userSession->listen('\OC\User', 'postLogout', function ($user) {
647
+                /** @var IEventDispatcher $dispatcher */
648
+                $dispatcher = $this->get(IEventDispatcher::class);
649
+                $dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
650
+            });
651
+            $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
652
+                /** @var \OC\User\User $user */
653
+                \OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]);
654
+
655
+                /** @var IEventDispatcher $dispatcher */
656
+                $dispatcher = $this->get(IEventDispatcher::class);
657
+                $dispatcher->dispatchTyped(new UserChangedEvent($user, $feature, $value, $oldValue));
658
+            });
659
+            return $userSession;
660
+        });
661
+        $this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class);
662
+        /** @deprecated 19.0.0 */
663
+        $this->registerDeprecatedAlias('UserSession', \OC\User\Session::class);
664
+
665
+        $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class);
666
+
667
+        $this->registerAlias(INavigationManager::class, \OC\NavigationManager::class);
668
+        /** @deprecated 19.0.0 */
669
+        $this->registerDeprecatedAlias('NavigationManager', INavigationManager::class);
670
+
671
+        /** @deprecated 19.0.0 */
672
+        $this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class);
673
+        $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
674
+
675
+        $this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
676
+            return new \OC\SystemConfig($config);
677
+        });
678
+        /** @deprecated 19.0.0 */
679
+        $this->registerDeprecatedAlias('SystemConfig', \OC\SystemConfig::class);
680
+
681
+        /** @deprecated 19.0.0 */
682
+        $this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class);
683
+        $this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
684
+
685
+        $this->registerService(IFactory::class, function (Server $c) {
686
+            return new \OC\L10N\Factory(
687
+                $c->get(\OCP\IConfig::class),
688
+                $c->getRequest(),
689
+                $c->get(IUserSession::class),
690
+                \OC::$SERVERROOT
691
+            );
692
+        });
693
+        /** @deprecated 19.0.0 */
694
+        $this->registerDeprecatedAlias('L10NFactory', IFactory::class);
695
+
696
+        $this->registerAlias(IURLGenerator::class, URLGenerator::class);
697
+        /** @deprecated 19.0.0 */
698
+        $this->registerDeprecatedAlias('URLGenerator', IURLGenerator::class);
699
+
700
+        /** @deprecated 19.0.0 */
701
+        $this->registerDeprecatedAlias('AppFetcher', AppFetcher::class);
702
+        /** @deprecated 19.0.0 */
703
+        $this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class);
704
+
705
+        $this->registerService(ICache::class, function ($c) {
706
+            return new Cache\File();
707
+        });
708
+        /** @deprecated 19.0.0 */
709
+        $this->registerDeprecatedAlias('UserCache', ICache::class);
710
+
711
+        $this->registerService(Factory::class, function (Server $c) {
712
+            $profiler = $c->get(IProfiler::class);
713
+            $arrayCacheFactory = new \OC\Memcache\Factory('', $c->get(LoggerInterface::class),
714
+                $profiler,
715
+                ArrayCache::class,
716
+                ArrayCache::class,
717
+                ArrayCache::class
718
+            );
719
+            /** @var \OCP\IConfig $config */
720
+            $config = $c->get(\OCP\IConfig::class);
721
+
722
+            if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
723
+                if (!$config->getSystemValueBool('log_query')) {
724
+                    $v = \OC_App::getAppVersions();
725
+                } else {
726
+                    // If the log_query is enabled, we can not get the app versions
727
+                    // as that does a query, which will be logged and the logging
728
+                    // depends on redis and here we are back again in the same function.
729
+                    $v = [
730
+                        'log_query' => 'enabled',
731
+                    ];
732
+                }
733
+                $v['core'] = implode(',', \OC_Util::getVersion());
734
+                $version = implode(',', $v);
735
+                $instanceId = \OC_Util::getInstanceId();
736
+                $path = \OC::$SERVERROOT;
737
+                $prefix = md5($instanceId . '-' . $version . '-' . $path);
738
+                return new \OC\Memcache\Factory($prefix,
739
+                    $c->get(LoggerInterface::class),
740
+                    $profiler,
741
+                    $config->getSystemValue('memcache.local', null),
742
+                    $config->getSystemValue('memcache.distributed', null),
743
+                    $config->getSystemValue('memcache.locking', null),
744
+                    $config->getSystemValueString('redis_log_file')
745
+                );
746
+            }
747
+            return $arrayCacheFactory;
748
+        });
749
+        /** @deprecated 19.0.0 */
750
+        $this->registerDeprecatedAlias('MemCacheFactory', Factory::class);
751
+        $this->registerAlias(ICacheFactory::class, Factory::class);
752
+
753
+        $this->registerService('RedisFactory', function (Server $c) {
754
+            $systemConfig = $c->get(SystemConfig::class);
755
+            return new RedisFactory($systemConfig, $c->getEventLogger());
756
+        });
757
+
758
+        $this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
759
+            $l10n = $this->get(IFactory::class)->get('lib');
760
+            return new \OC\Activity\Manager(
761
+                $c->getRequest(),
762
+                $c->get(IUserSession::class),
763
+                $c->get(\OCP\IConfig::class),
764
+                $c->get(IValidator::class),
765
+                $l10n
766
+            );
767
+        });
768
+        /** @deprecated 19.0.0 */
769
+        $this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class);
770
+
771
+        $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
772
+            return new \OC\Activity\EventMerger(
773
+                $c->getL10N('lib')
774
+            );
775
+        });
776
+        $this->registerAlias(IValidator::class, Validator::class);
777
+
778
+        $this->registerService(AvatarManager::class, function (Server $c) {
779
+            return new AvatarManager(
780
+                $c->get(IUserSession::class),
781
+                $c->get(\OC\User\Manager::class),
782
+                $c->getAppDataDir('avatar'),
783
+                $c->getL10N('lib'),
784
+                $c->get(LoggerInterface::class),
785
+                $c->get(\OCP\IConfig::class),
786
+                $c->get(IAccountManager::class),
787
+                $c->get(KnownUserService::class)
788
+            );
789
+        });
790
+
791
+        $this->registerAlias(IAvatarManager::class, AvatarManager::class);
792
+        /** @deprecated 19.0.0 */
793
+        $this->registerDeprecatedAlias('AvatarManager', AvatarManager::class);
794
+
795
+        $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
796
+        $this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
797
+        $this->registerAlias(\OCP\Support\Subscription\IAssertion::class, \OC\Support\Subscription\Assertion::class);
798
+
799
+        $this->registerService(\OC\Log::class, function (Server $c) {
800
+            $logType = $c->get(AllConfig::class)->getSystemValue('log_type', 'file');
801
+            $factory = new LogFactory($c, $this->get(SystemConfig::class));
802
+            $logger = $factory->get($logType);
803
+            $registry = $c->get(\OCP\Support\CrashReport\IRegistry::class);
804
+
805
+            return new Log($logger, $this->get(SystemConfig::class), null, $registry);
806
+        });
807
+        $this->registerAlias(ILogger::class, \OC\Log::class);
808
+        /** @deprecated 19.0.0 */
809
+        $this->registerDeprecatedAlias('Logger', \OC\Log::class);
810
+        // PSR-3 logger
811
+        $this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class);
812
+
813
+        $this->registerService(ILogFactory::class, function (Server $c) {
814
+            return new LogFactory($c, $this->get(SystemConfig::class));
815
+        });
816
+
817
+        $this->registerAlias(IJobList::class, \OC\BackgroundJob\JobList::class);
818
+        /** @deprecated 19.0.0 */
819
+        $this->registerDeprecatedAlias('JobList', IJobList::class);
820
+
821
+        $this->registerService(Router::class, function (Server $c) {
822
+            $cacheFactory = $c->get(ICacheFactory::class);
823
+            $logger = $c->get(LoggerInterface::class);
824
+            if ($cacheFactory->isLocalCacheAvailable()) {
825
+                $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger);
826
+            } else {
827
+                $router = new \OC\Route\Router($logger);
828
+            }
829
+            return $router;
830
+        });
831
+        $this->registerAlias(IRouter::class, Router::class);
832
+        /** @deprecated 19.0.0 */
833
+        $this->registerDeprecatedAlias('Router', IRouter::class);
834
+
835
+        $this->registerAlias(ISearch::class, Search::class);
836
+        /** @deprecated 19.0.0 */
837
+        $this->registerDeprecatedAlias('Search', ISearch::class);
838
+
839
+        $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
840
+            $cacheFactory = $c->get(ICacheFactory::class);
841
+            if ($cacheFactory->isAvailable()) {
842
+                $backend = new \OC\Security\RateLimiting\Backend\MemoryCacheBackend(
843
+                    $this->get(ICacheFactory::class),
844
+                    new \OC\AppFramework\Utility\TimeFactory()
845
+                );
846
+            } else {
847
+                $backend = new \OC\Security\RateLimiting\Backend\DatabaseBackend(
848
+                    $c->get(IDBConnection::class),
849
+                    new \OC\AppFramework\Utility\TimeFactory()
850
+                );
851
+            }
852
+
853
+            return $backend;
854
+        });
855
+
856
+        $this->registerAlias(\OCP\Security\ISecureRandom::class, SecureRandom::class);
857
+        /** @deprecated 19.0.0 */
858
+        $this->registerDeprecatedAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
859
+        $this->registerAlias(\OCP\Security\IRemoteHostValidator::class, \OC\Security\RemoteHostValidator::class);
860
+        $this->registerAlias(IVerificationToken::class, VerificationToken::class);
861
+
862
+        $this->registerAlias(ICrypto::class, Crypto::class);
863
+        /** @deprecated 19.0.0 */
864
+        $this->registerDeprecatedAlias('Crypto', ICrypto::class);
865
+
866
+        $this->registerAlias(IHasher::class, Hasher::class);
867
+        /** @deprecated 19.0.0 */
868
+        $this->registerDeprecatedAlias('Hasher', IHasher::class);
869
+
870
+        $this->registerAlias(ICredentialsManager::class, CredentialsManager::class);
871
+        /** @deprecated 19.0.0 */
872
+        $this->registerDeprecatedAlias('CredentialsManager', ICredentialsManager::class);
873
+
874
+        $this->registerAlias(IDBConnection::class, ConnectionAdapter::class);
875
+        $this->registerService(Connection::class, function (Server $c) {
876
+            $systemConfig = $c->get(SystemConfig::class);
877
+            $factory = new \OC\DB\ConnectionFactory($systemConfig);
878
+            $type = $systemConfig->getValue('dbtype', 'sqlite');
879
+            if (!$factory->isValidType($type)) {
880
+                throw new \OC\DatabaseException('Invalid database type');
881
+            }
882
+            $connectionParams = $factory->createConnectionParams();
883
+            $connection = $factory->getConnection($type, $connectionParams);
884
+            return $connection;
885
+        });
886
+        /** @deprecated 19.0.0 */
887
+        $this->registerDeprecatedAlias('DatabaseConnection', IDBConnection::class);
888
+
889
+        $this->registerAlias(ICertificateManager::class, CertificateManager::class);
890
+        $this->registerAlias(IClientService::class, ClientService::class);
891
+        $this->registerService(NegativeDnsCache::class, function (ContainerInterface $c) {
892
+            return new NegativeDnsCache(
893
+                $c->get(ICacheFactory::class),
894
+            );
895
+        });
896
+        $this->registerDeprecatedAlias('HttpClientService', IClientService::class);
897
+        $this->registerService(IEventLogger::class, function (ContainerInterface $c) {
898
+            return new EventLogger($c->get(SystemConfig::class), $c->get(LoggerInterface::class), $c->get(Log::class));
899
+        });
900
+        /** @deprecated 19.0.0 */
901
+        $this->registerDeprecatedAlias('EventLogger', IEventLogger::class);
902
+
903
+        $this->registerService(IQueryLogger::class, function (ContainerInterface $c) {
904
+            $queryLogger = new QueryLogger();
905
+            if ($c->get(SystemConfig::class)->getValue('debug', false)) {
906
+                // In debug mode, module is being activated by default
907
+                $queryLogger->activate();
908
+            }
909
+            return $queryLogger;
910
+        });
911
+        /** @deprecated 19.0.0 */
912
+        $this->registerDeprecatedAlias('QueryLogger', IQueryLogger::class);
913
+
914
+        /** @deprecated 19.0.0 */
915
+        $this->registerDeprecatedAlias('TempManager', TempManager::class);
916
+        $this->registerAlias(ITempManager::class, TempManager::class);
917
+
918
+        $this->registerService(AppManager::class, function (ContainerInterface $c) {
919
+            // TODO: use auto-wiring
920
+            return new \OC\App\AppManager(
921
+                $c->get(IUserSession::class),
922
+                $c->get(\OCP\IConfig::class),
923
+                $c->get(\OC\AppConfig::class),
924
+                $c->get(IGroupManager::class),
925
+                $c->get(ICacheFactory::class),
926
+                $c->get(SymfonyAdapter::class),
927
+                $c->get(LoggerInterface::class)
928
+            );
929
+        });
930
+        /** @deprecated 19.0.0 */
931
+        $this->registerDeprecatedAlias('AppManager', AppManager::class);
932
+        $this->registerAlias(IAppManager::class, AppManager::class);
933
+
934
+        $this->registerAlias(IDateTimeZone::class, DateTimeZone::class);
935
+        /** @deprecated 19.0.0 */
936
+        $this->registerDeprecatedAlias('DateTimeZone', IDateTimeZone::class);
937
+
938
+        $this->registerService(IDateTimeFormatter::class, function (Server $c) {
939
+            $language = $c->get(\OCP\IConfig::class)->getUserValue($c->get(ISession::class)->get('user_id'), 'core', 'lang', null);
940
+
941
+            return new DateTimeFormatter(
942
+                $c->get(IDateTimeZone::class)->getTimeZone(),
943
+                $c->getL10N('lib', $language)
944
+            );
945
+        });
946
+        /** @deprecated 19.0.0 */
947
+        $this->registerDeprecatedAlias('DateTimeFormatter', IDateTimeFormatter::class);
948
+
949
+        $this->registerService(IUserMountCache::class, function (ContainerInterface $c) {
950
+            $mountCache = new UserMountCache(
951
+                $c->get(IDBConnection::class),
952
+                $c->get(IUserManager::class),
953
+                $c->get(LoggerInterface::class)
954
+            );
955
+            $listener = new UserMountCacheListener($mountCache);
956
+            $listener->listen($c->get(IUserManager::class));
957
+            return $mountCache;
958
+        });
959
+        /** @deprecated 19.0.0 */
960
+        $this->registerDeprecatedAlias('UserMountCache', IUserMountCache::class);
961
+
962
+        $this->registerService(IMountProviderCollection::class, function (ContainerInterface $c) {
963
+            $loader = \OC\Files\Filesystem::getLoader();
964
+            $mountCache = $c->get(IUserMountCache::class);
965
+            $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
966
+
967
+            // builtin providers
968
+
969
+            $config = $c->get(\OCP\IConfig::class);
970
+            $logger = $c->get(LoggerInterface::class);
971
+            $manager->registerProvider(new CacheMountProvider($config));
972
+            $manager->registerHomeProvider(new LocalHomeMountProvider());
973
+            $manager->registerHomeProvider(new ObjectHomeMountProvider($config));
974
+            $manager->registerRootProvider(new RootMountProvider($config, $c->get(LoggerInterface::class)));
975
+            $manager->registerRootProvider(new ObjectStorePreviewCacheMountProvider($logger, $config));
976
+
977
+            return $manager;
978
+        });
979
+        /** @deprecated 19.0.0 */
980
+        $this->registerDeprecatedAlias('MountConfigManager', IMountProviderCollection::class);
981
+
982
+        /** @deprecated 20.0.0 */
983
+        $this->registerDeprecatedAlias('IniWrapper', IniGetWrapper::class);
984
+        $this->registerService(IBus::class, function (ContainerInterface $c) {
985
+            $busClass = $c->get(\OCP\IConfig::class)->getSystemValue('commandbus');
986
+            if ($busClass) {
987
+                [$app, $class] = explode('::', $busClass, 2);
988
+                if ($c->get(IAppManager::class)->isInstalled($app)) {
989
+                    \OC_App::loadApp($app);
990
+                    return $c->get($class);
991
+                } else {
992
+                    throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
993
+                }
994
+            } else {
995
+                $jobList = $c->get(IJobList::class);
996
+                return new CronBus($jobList);
997
+            }
998
+        });
999
+        $this->registerDeprecatedAlias('AsyncCommandBus', IBus::class);
1000
+        /** @deprecated 20.0.0 */
1001
+        $this->registerDeprecatedAlias('TrustedDomainHelper', TrustedDomainHelper::class);
1002
+        $this->registerAlias(ITrustedDomainHelper::class, TrustedDomainHelper::class);
1003
+        /** @deprecated 19.0.0 */
1004
+        $this->registerDeprecatedAlias('Throttler', Throttler::class);
1005
+        $this->registerAlias(IThrottler::class, Throttler::class);
1006
+        $this->registerService('IntegrityCodeChecker', function (ContainerInterface $c) {
1007
+            // IConfig and IAppManager requires a working database. This code
1008
+            // might however be called when ownCloud is not yet setup.
1009
+            if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
1010
+                $config = $c->get(\OCP\IConfig::class);
1011
+                $appManager = $c->get(IAppManager::class);
1012
+            } else {
1013
+                $config = null;
1014
+                $appManager = null;
1015
+            }
1016
+
1017
+            return new Checker(
1018
+                new EnvironmentHelper(),
1019
+                new FileAccessHelper(),
1020
+                new AppLocator(),
1021
+                $config,
1022
+                $c->get(ICacheFactory::class),
1023
+                $appManager,
1024
+                $c->get(IMimeTypeDetector::class)
1025
+            );
1026
+        });
1027
+        $this->registerService(\OCP\IRequest::class, function (ContainerInterface $c) {
1028
+            if (isset($this['urlParams'])) {
1029
+                $urlParams = $this['urlParams'];
1030
+            } else {
1031
+                $urlParams = [];
1032
+            }
1033
+
1034
+            if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
1035
+                && in_array('fakeinput', stream_get_wrappers())
1036
+            ) {
1037
+                $stream = 'fakeinput://data';
1038
+            } else {
1039
+                $stream = 'php://input';
1040
+            }
1041
+
1042
+            return new Request(
1043
+                [
1044
+                    'get' => $_GET,
1045
+                    'post' => $_POST,
1046
+                    'files' => $_FILES,
1047
+                    'server' => $_SERVER,
1048
+                    'env' => $_ENV,
1049
+                    'cookies' => $_COOKIE,
1050
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1051
+                        ? $_SERVER['REQUEST_METHOD']
1052
+                        : '',
1053
+                    'urlParams' => $urlParams,
1054
+                ],
1055
+                $this->get(IRequestId::class),
1056
+                $this->get(\OCP\IConfig::class),
1057
+                $this->get(CsrfTokenManager::class),
1058
+                $stream
1059
+            );
1060
+        });
1061
+        /** @deprecated 19.0.0 */
1062
+        $this->registerDeprecatedAlias('Request', \OCP\IRequest::class);
1063
+
1064
+        $this->registerService(IRequestId::class, function (ContainerInterface $c): IRequestId {
1065
+            return new RequestId(
1066
+                $_SERVER['UNIQUE_ID'] ?? '',
1067
+                $this->get(ISecureRandom::class)
1068
+            );
1069
+        });
1070
+
1071
+        $this->registerService(IMailer::class, function (Server $c) {
1072
+            return new Mailer(
1073
+                $c->get(\OCP\IConfig::class),
1074
+                $c->get(LoggerInterface::class),
1075
+                $c->get(Defaults::class),
1076
+                $c->get(IURLGenerator::class),
1077
+                $c->getL10N('lib'),
1078
+                $c->get(IEventDispatcher::class),
1079
+                $c->get(IFactory::class)
1080
+            );
1081
+        });
1082
+        /** @deprecated 19.0.0 */
1083
+        $this->registerDeprecatedAlias('Mailer', IMailer::class);
1084
+
1085
+        /** @deprecated 21.0.0 */
1086
+        $this->registerDeprecatedAlias('LDAPProvider', ILDAPProvider::class);
1087
+
1088
+        $this->registerService(ILDAPProviderFactory::class, function (ContainerInterface $c) {
1089
+            $config = $c->get(\OCP\IConfig::class);
1090
+            $factoryClass = $config->getSystemValue('ldapProviderFactory', null);
1091
+            if (is_null($factoryClass) || !class_exists($factoryClass)) {
1092
+                return new NullLDAPProviderFactory($this);
1093
+            }
1094
+            /** @var \OCP\LDAP\ILDAPProviderFactory $factory */
1095
+            return new $factoryClass($this);
1096
+        });
1097
+        $this->registerService(ILDAPProvider::class, function (ContainerInterface $c) {
1098
+            $factory = $c->get(ILDAPProviderFactory::class);
1099
+            return $factory->getLDAPProvider();
1100
+        });
1101
+        $this->registerService(ILockingProvider::class, function (ContainerInterface $c) {
1102
+            $ini = $c->get(IniGetWrapper::class);
1103
+            $config = $c->get(\OCP\IConfig::class);
1104
+            $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
1105
+            if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
1106
+                /** @var \OC\Memcache\Factory $memcacheFactory */
1107
+                $memcacheFactory = $c->get(ICacheFactory::class);
1108
+                $memcache = $memcacheFactory->createLocking('lock');
1109
+                if (!($memcache instanceof \OC\Memcache\NullCache)) {
1110
+                    return new MemcacheLockingProvider($memcache, $ttl);
1111
+                }
1112
+                return new DBLockingProvider(
1113
+                    $c->get(IDBConnection::class),
1114
+                    new TimeFactory(),
1115
+                    $ttl,
1116
+                    !\OC::$CLI
1117
+                );
1118
+            }
1119
+            return new NoopLockingProvider();
1120
+        });
1121
+        /** @deprecated 19.0.0 */
1122
+        $this->registerDeprecatedAlias('LockingProvider', ILockingProvider::class);
1123
+
1124
+        $this->registerService(ILockManager::class, function (Server $c): LockManager {
1125
+            return new LockManager();
1126
+        });
1127
+
1128
+        $this->registerAlias(ILockdownManager::class, 'LockdownManager');
1129
+        $this->registerService(SetupManager::class, function ($c) {
1130
+            // create the setupmanager through the mount manager to resolve the cyclic dependency
1131
+            return $c->get(\OC\Files\Mount\Manager::class)->getSetupManager();
1132
+        });
1133
+        $this->registerAlias(IMountManager::class, \OC\Files\Mount\Manager::class);
1134
+        /** @deprecated 19.0.0 */
1135
+        $this->registerDeprecatedAlias('MountManager', IMountManager::class);
1136
+
1137
+        $this->registerService(IMimeTypeDetector::class, function (ContainerInterface $c) {
1138
+            return new \OC\Files\Type\Detection(
1139
+                $c->get(IURLGenerator::class),
1140
+                $c->get(LoggerInterface::class),
1141
+                \OC::$configDir,
1142
+                \OC::$SERVERROOT . '/resources/config/'
1143
+            );
1144
+        });
1145
+        /** @deprecated 19.0.0 */
1146
+        $this->registerDeprecatedAlias('MimeTypeDetector', IMimeTypeDetector::class);
1147
+
1148
+        $this->registerAlias(IMimeTypeLoader::class, Loader::class);
1149
+        /** @deprecated 19.0.0 */
1150
+        $this->registerDeprecatedAlias('MimeTypeLoader', IMimeTypeLoader::class);
1151
+        $this->registerService(BundleFetcher::class, function () {
1152
+            return new BundleFetcher($this->getL10N('lib'));
1153
+        });
1154
+        $this->registerAlias(\OCP\Notification\IManager::class, Manager::class);
1155
+        /** @deprecated 19.0.0 */
1156
+        $this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class);
1157
+
1158
+        $this->registerService(CapabilitiesManager::class, function (ContainerInterface $c) {
1159
+            $manager = new CapabilitiesManager($c->get(LoggerInterface::class));
1160
+            $manager->registerCapability(function () use ($c) {
1161
+                return new \OC\OCS\CoreCapabilities($c->get(\OCP\IConfig::class));
1162
+            });
1163
+            $manager->registerCapability(function () use ($c) {
1164
+                return $c->get(\OC\Security\Bruteforce\Capabilities::class);
1165
+            });
1166
+            $manager->registerCapability(function () use ($c) {
1167
+                return $c->get(MetadataCapabilities::class);
1168
+            });
1169
+            return $manager;
1170
+        });
1171
+        /** @deprecated 19.0.0 */
1172
+        $this->registerDeprecatedAlias('CapabilitiesManager', CapabilitiesManager::class);
1173
+
1174
+        $this->registerService(ICommentsManager::class, function (Server $c) {
1175
+            $config = $c->get(\OCP\IConfig::class);
1176
+            $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
1177
+            /** @var \OCP\Comments\ICommentsManagerFactory $factory */
1178
+            $factory = new $factoryClass($this);
1179
+            $manager = $factory->getManager();
1180
+
1181
+            $manager->registerDisplayNameResolver('user', function ($id) use ($c) {
1182
+                $manager = $c->get(IUserManager::class);
1183
+                $userDisplayName = $manager->getDisplayName($id);
1184
+                if ($userDisplayName === null) {
1185
+                    $l = $c->get(IFactory::class)->get('core');
1186
+                    return $l->t('Unknown user');
1187
+                }
1188
+                return $userDisplayName;
1189
+            });
1190
+
1191
+            return $manager;
1192
+        });
1193
+        /** @deprecated 19.0.0 */
1194
+        $this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class);
1195
+
1196
+        $this->registerAlias(\OC_Defaults::class, 'ThemingDefaults');
1197
+        $this->registerService('ThemingDefaults', function (Server $c) {
1198
+            /*
1199 1199
 			 * Dark magic for autoloader.
1200 1200
 			 * If we do a class_exists it will try to load the class which will
1201 1201
 			 * make composer cache the result. Resulting in errors when enabling
1202 1202
 			 * the theming app.
1203 1203
 			 */
1204
-			$prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
1205
-			if (isset($prefixes['OCA\\Theming\\'])) {
1206
-				$classExists = true;
1207
-			} else {
1208
-				$classExists = false;
1209
-			}
1210
-
1211
-			if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValue('installed', false) && $c->get(IAppManager::class)->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
1212
-				return new ThemingDefaults(
1213
-					$c->get(\OCP\IConfig::class),
1214
-					$c->getL10N('theming'),
1215
-					$c->get(IUserSession::class),
1216
-					$c->get(IURLGenerator::class),
1217
-					$c->get(ICacheFactory::class),
1218
-					new Util($c->get(\OCP\IConfig::class), $this->get(IAppManager::class), $c->getAppDataDir('theming')),
1219
-					new ImageManager(
1220
-						$c->get(\OCP\IConfig::class),
1221
-						$c->getAppDataDir('theming'),
1222
-						$c->get(IURLGenerator::class),
1223
-						$this->get(ICacheFactory::class),
1224
-						$this->get(ILogger::class),
1225
-						$this->get(ITempManager::class)
1226
-					),
1227
-					$c->get(IAppManager::class),
1228
-					$c->get(INavigationManager::class)
1229
-				);
1230
-			}
1231
-			return new \OC_Defaults();
1232
-		});
1233
-		$this->registerService(JSCombiner::class, function (Server $c) {
1234
-			return new JSCombiner(
1235
-				$c->getAppDataDir('js'),
1236
-				$c->get(IURLGenerator::class),
1237
-				$this->get(ICacheFactory::class),
1238
-				$c->get(SystemConfig::class),
1239
-				$c->get(LoggerInterface::class)
1240
-			);
1241
-		});
1242
-		$this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class);
1243
-		/** @deprecated 19.0.0 */
1244
-		$this->registerDeprecatedAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class);
1245
-		$this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class);
1246
-
1247
-		$this->registerService('CryptoWrapper', function (ContainerInterface $c) {
1248
-			// FIXME: Instantiated here due to cyclic dependency
1249
-			$request = new Request(
1250
-				[
1251
-					'get' => $_GET,
1252
-					'post' => $_POST,
1253
-					'files' => $_FILES,
1254
-					'server' => $_SERVER,
1255
-					'env' => $_ENV,
1256
-					'cookies' => $_COOKIE,
1257
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1258
-						? $_SERVER['REQUEST_METHOD']
1259
-						: null,
1260
-				],
1261
-				$c->get(IRequestId::class),
1262
-				$c->get(\OCP\IConfig::class)
1263
-			);
1264
-
1265
-			return new CryptoWrapper(
1266
-				$c->get(\OCP\IConfig::class),
1267
-				$c->get(ICrypto::class),
1268
-				$c->get(ISecureRandom::class),
1269
-				$request
1270
-			);
1271
-		});
1272
-		/** @deprecated 19.0.0 */
1273
-		$this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class);
1274
-		$this->registerService(SessionStorage::class, function (ContainerInterface $c) {
1275
-			return new SessionStorage($c->get(ISession::class));
1276
-		});
1277
-		$this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class);
1278
-		/** @deprecated 19.0.0 */
1279
-		$this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class);
1280
-
1281
-		$this->registerService(\OCP\Share\IManager::class, function (IServerContainer $c) {
1282
-			$config = $c->get(\OCP\IConfig::class);
1283
-			$factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
1284
-			/** @var \OCP\Share\IProviderFactory $factory */
1285
-			$factory = new $factoryClass($this);
1286
-
1287
-			$manager = new \OC\Share20\Manager(
1288
-				$c->get(LoggerInterface::class),
1289
-				$c->get(\OCP\IConfig::class),
1290
-				$c->get(ISecureRandom::class),
1291
-				$c->get(IHasher::class),
1292
-				$c->get(IMountManager::class),
1293
-				$c->get(IGroupManager::class),
1294
-				$c->getL10N('lib'),
1295
-				$c->get(IFactory::class),
1296
-				$factory,
1297
-				$c->get(IUserManager::class),
1298
-				$c->get(IRootFolder::class),
1299
-				$c->get(SymfonyAdapter::class),
1300
-				$c->get(IMailer::class),
1301
-				$c->get(IURLGenerator::class),
1302
-				$c->get('ThemingDefaults'),
1303
-				$c->get(IEventDispatcher::class),
1304
-				$c->get(IUserSession::class),
1305
-				$c->get(KnownUserService::class)
1306
-			);
1307
-
1308
-			return $manager;
1309
-		});
1310
-		/** @deprecated 19.0.0 */
1311
-		$this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class);
1312
-
1313
-		$this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) {
1314
-			$instance = new Collaboration\Collaborators\Search($c);
1315
-
1316
-			// register default plugins
1317
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
1318
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
1319
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
1320
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
1321
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
1322
-
1323
-			return $instance;
1324
-		});
1325
-		/** @deprecated 19.0.0 */
1326
-		$this->registerDeprecatedAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class);
1327
-		$this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class);
1328
-
1329
-		$this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
1330
-
1331
-		$this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class);
1332
-		$this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
1333
-
1334
-		$this->registerAlias(IReferenceManager::class, ReferenceManager::class);
1335
-
1336
-		$this->registerDeprecatedAlias('SettingsManager', \OC\Settings\Manager::class);
1337
-		$this->registerAlias(\OCP\Settings\IManager::class, \OC\Settings\Manager::class);
1338
-		$this->registerService(\OC\Files\AppData\Factory::class, function (ContainerInterface $c) {
1339
-			return new \OC\Files\AppData\Factory(
1340
-				$c->get(IRootFolder::class),
1341
-				$c->get(SystemConfig::class)
1342
-			);
1343
-		});
1344
-
1345
-		$this->registerService('LockdownManager', function (ContainerInterface $c) {
1346
-			return new LockdownManager(function () use ($c) {
1347
-				return $c->get(ISession::class);
1348
-			});
1349
-		});
1350
-
1351
-		$this->registerService(\OCP\OCS\IDiscoveryService::class, function (ContainerInterface $c) {
1352
-			return new DiscoveryService(
1353
-				$c->get(ICacheFactory::class),
1354
-				$c->get(IClientService::class)
1355
-			);
1356
-		});
1357
-
1358
-		$this->registerService(ICloudIdManager::class, function (ContainerInterface $c) {
1359
-			return new CloudIdManager(
1360
-				$c->get(\OCP\Contacts\IManager::class),
1361
-				$c->get(IURLGenerator::class),
1362
-				$c->get(IUserManager::class),
1363
-				$c->get(ICacheFactory::class),
1364
-				$c->get(IEventDispatcher::class),
1365
-			);
1366
-		});
1367
-
1368
-		$this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class);
1369
-
1370
-		$this->registerService(ICloudFederationProviderManager::class, function (ContainerInterface $c) {
1371
-			return new CloudFederationProviderManager(
1372
-				$c->get(IAppManager::class),
1373
-				$c->get(IClientService::class),
1374
-				$c->get(ICloudIdManager::class),
1375
-				$c->get(LoggerInterface::class)
1376
-			);
1377
-		});
1378
-
1379
-		$this->registerService(ICloudFederationFactory::class, function (Server $c) {
1380
-			return new CloudFederationFactory();
1381
-		});
1382
-
1383
-		$this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1384
-		/** @deprecated 19.0.0 */
1385
-		$this->registerDeprecatedAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
1386
-
1387
-		$this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1388
-		/** @deprecated 19.0.0 */
1389
-		$this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1390
-
1391
-		$this->registerService(Defaults::class, function (Server $c) {
1392
-			return new Defaults(
1393
-				$c->getThemingDefaults()
1394
-			);
1395
-		});
1396
-		/** @deprecated 19.0.0 */
1397
-		$this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class);
1398
-
1399
-		$this->registerService(\OCP\ISession::class, function (ContainerInterface $c) {
1400
-			return $c->get(\OCP\IUserSession::class)->getSession();
1401
-		}, false);
1402
-
1403
-		$this->registerService(IShareHelper::class, function (ContainerInterface $c) {
1404
-			return new ShareHelper(
1405
-				$c->get(\OCP\Share\IManager::class)
1406
-			);
1407
-		});
1408
-
1409
-		$this->registerService(Installer::class, function (ContainerInterface $c) {
1410
-			return new Installer(
1411
-				$c->get(AppFetcher::class),
1412
-				$c->get(IClientService::class),
1413
-				$c->get(ITempManager::class),
1414
-				$c->get(LoggerInterface::class),
1415
-				$c->get(\OCP\IConfig::class),
1416
-				\OC::$CLI
1417
-			);
1418
-		});
1419
-
1420
-		$this->registerService(IApiFactory::class, function (ContainerInterface $c) {
1421
-			return new ApiFactory($c->get(IClientService::class));
1422
-		});
1423
-
1424
-		$this->registerService(IInstanceFactory::class, function (ContainerInterface $c) {
1425
-			$memcacheFactory = $c->get(ICacheFactory::class);
1426
-			return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->get(IClientService::class));
1427
-		});
1428
-
1429
-		$this->registerAlias(IContactsStore::class, ContactsStore::class);
1430
-		$this->registerAlias(IAccountManager::class, AccountManager::class);
1431
-
1432
-		$this->registerAlias(IStorageFactory::class, StorageFactory::class);
1433
-
1434
-		$this->registerAlias(IDashboardManager::class, DashboardManager::class);
1435
-		$this->registerAlias(\OCP\Dashboard\IManager::class, \OC\Dashboard\Manager::class);
1436
-		$this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class);
1437
-
1438
-		$this->registerAlias(ISubAdmin::class, SubAdmin::class);
1439
-
1440
-		$this->registerAlias(IInitialStateService::class, InitialStateService::class);
1441
-
1442
-		$this->registerAlias(\OCP\IEmojiHelper::class, \OC\EmojiHelper::class);
1443
-
1444
-		$this->registerAlias(\OCP\UserStatus\IManager::class, \OC\UserStatus\Manager::class);
1445
-
1446
-		$this->registerAlias(IBroker::class, Broker::class);
1447
-
1448
-		$this->registerAlias(IMetadataManager::class, MetadataManager::class);
1449
-
1450
-		$this->registerAlias(\OCP\Files\AppData\IAppDataFactory::class, \OC\Files\AppData\Factory::class);
1451
-
1452
-		$this->registerAlias(IBinaryFinder::class, BinaryFinder::class);
1453
-
1454
-		$this->connectDispatcher();
1455
-	}
1456
-
1457
-	public function boot() {
1458
-		/** @var HookConnector $hookConnector */
1459
-		$hookConnector = $this->get(HookConnector::class);
1460
-		$hookConnector->viewToNode();
1461
-	}
1462
-
1463
-	/**
1464
-	 * @return \OCP\Calendar\IManager
1465
-	 * @deprecated 20.0.0
1466
-	 */
1467
-	public function getCalendarManager() {
1468
-		return $this->get(\OC\Calendar\Manager::class);
1469
-	}
1470
-
1471
-	/**
1472
-	 * @return \OCP\Calendar\Resource\IManager
1473
-	 * @deprecated 20.0.0
1474
-	 */
1475
-	public function getCalendarResourceBackendManager() {
1476
-		return $this->get(\OC\Calendar\Resource\Manager::class);
1477
-	}
1478
-
1479
-	/**
1480
-	 * @return \OCP\Calendar\Room\IManager
1481
-	 * @deprecated 20.0.0
1482
-	 */
1483
-	public function getCalendarRoomBackendManager() {
1484
-		return $this->get(\OC\Calendar\Room\Manager::class);
1485
-	}
1486
-
1487
-	private function connectDispatcher(): void {
1488
-		/** @var IEventDispatcher $eventDispatcher */
1489
-		$eventDispatcher = $this->get(IEventDispatcher::class);
1490
-		$eventDispatcher->addServiceListener(LoginFailed::class, LoginFailedListener::class);
1491
-		$eventDispatcher->addServiceListener(PostLoginEvent::class, UserLoggedInListener::class);
1492
-		$eventDispatcher->addServiceListener(UserChangedEvent::class, UserChangedListener::class);
1493
-		$eventDispatcher->addServiceListener(BeforeUserDeletedEvent::class, BeforeUserDeletedListener::class);
1494
-	}
1495
-
1496
-	/**
1497
-	 * @return \OCP\Contacts\IManager
1498
-	 * @deprecated 20.0.0
1499
-	 */
1500
-	public function getContactsManager() {
1501
-		return $this->get(\OCP\Contacts\IManager::class);
1502
-	}
1503
-
1504
-	/**
1505
-	 * @return \OC\Encryption\Manager
1506
-	 * @deprecated 20.0.0
1507
-	 */
1508
-	public function getEncryptionManager() {
1509
-		return $this->get(\OCP\Encryption\IManager::class);
1510
-	}
1511
-
1512
-	/**
1513
-	 * @return \OC\Encryption\File
1514
-	 * @deprecated 20.0.0
1515
-	 */
1516
-	public function getEncryptionFilesHelper() {
1517
-		return $this->get(IFile::class);
1518
-	}
1519
-
1520
-	/**
1521
-	 * @return \OCP\Encryption\Keys\IStorage
1522
-	 * @deprecated 20.0.0
1523
-	 */
1524
-	public function getEncryptionKeyStorage() {
1525
-		return $this->get(IStorage::class);
1526
-	}
1527
-
1528
-	/**
1529
-	 * The current request object holding all information about the request
1530
-	 * currently being processed is returned from this method.
1531
-	 * In case the current execution was not initiated by a web request null is returned
1532
-	 *
1533
-	 * @return \OCP\IRequest
1534
-	 * @deprecated 20.0.0
1535
-	 */
1536
-	public function getRequest() {
1537
-		return $this->get(IRequest::class);
1538
-	}
1539
-
1540
-	/**
1541
-	 * Returns the preview manager which can create preview images for a given file
1542
-	 *
1543
-	 * @return IPreview
1544
-	 * @deprecated 20.0.0
1545
-	 */
1546
-	public function getPreviewManager() {
1547
-		return $this->get(IPreview::class);
1548
-	}
1549
-
1550
-	/**
1551
-	 * Returns the tag manager which can get and set tags for different object types
1552
-	 *
1553
-	 * @see \OCP\ITagManager::load()
1554
-	 * @return ITagManager
1555
-	 * @deprecated 20.0.0
1556
-	 */
1557
-	public function getTagManager() {
1558
-		return $this->get(ITagManager::class);
1559
-	}
1560
-
1561
-	/**
1562
-	 * Returns the system-tag manager
1563
-	 *
1564
-	 * @return ISystemTagManager
1565
-	 *
1566
-	 * @since 9.0.0
1567
-	 * @deprecated 20.0.0
1568
-	 */
1569
-	public function getSystemTagManager() {
1570
-		return $this->get(ISystemTagManager::class);
1571
-	}
1572
-
1573
-	/**
1574
-	 * Returns the system-tag object mapper
1575
-	 *
1576
-	 * @return ISystemTagObjectMapper
1577
-	 *
1578
-	 * @since 9.0.0
1579
-	 * @deprecated 20.0.0
1580
-	 */
1581
-	public function getSystemTagObjectMapper() {
1582
-		return $this->get(ISystemTagObjectMapper::class);
1583
-	}
1584
-
1585
-	/**
1586
-	 * Returns the avatar manager, used for avatar functionality
1587
-	 *
1588
-	 * @return IAvatarManager
1589
-	 * @deprecated 20.0.0
1590
-	 */
1591
-	public function getAvatarManager() {
1592
-		return $this->get(IAvatarManager::class);
1593
-	}
1594
-
1595
-	/**
1596
-	 * Returns the root folder of ownCloud's data directory
1597
-	 *
1598
-	 * @return IRootFolder
1599
-	 * @deprecated 20.0.0
1600
-	 */
1601
-	public function getRootFolder() {
1602
-		return $this->get(IRootFolder::class);
1603
-	}
1604
-
1605
-	/**
1606
-	 * Returns the root folder of ownCloud's data directory
1607
-	 * This is the lazy variant so this gets only initialized once it
1608
-	 * is actually used.
1609
-	 *
1610
-	 * @return IRootFolder
1611
-	 * @deprecated 20.0.0
1612
-	 */
1613
-	public function getLazyRootFolder() {
1614
-		return $this->get(IRootFolder::class);
1615
-	}
1616
-
1617
-	/**
1618
-	 * Returns a view to ownCloud's files folder
1619
-	 *
1620
-	 * @param string $userId user ID
1621
-	 * @return \OCP\Files\Folder|null
1622
-	 * @deprecated 20.0.0
1623
-	 */
1624
-	public function getUserFolder($userId = null) {
1625
-		if ($userId === null) {
1626
-			$user = $this->get(IUserSession::class)->getUser();
1627
-			if (!$user) {
1628
-				return null;
1629
-			}
1630
-			$userId = $user->getUID();
1631
-		}
1632
-		$root = $this->get(IRootFolder::class);
1633
-		return $root->getUserFolder($userId);
1634
-	}
1635
-
1636
-	/**
1637
-	 * @return \OC\User\Manager
1638
-	 * @deprecated 20.0.0
1639
-	 */
1640
-	public function getUserManager() {
1641
-		return $this->get(IUserManager::class);
1642
-	}
1643
-
1644
-	/**
1645
-	 * @return \OC\Group\Manager
1646
-	 * @deprecated 20.0.0
1647
-	 */
1648
-	public function getGroupManager() {
1649
-		return $this->get(IGroupManager::class);
1650
-	}
1651
-
1652
-	/**
1653
-	 * @return \OC\User\Session
1654
-	 * @deprecated 20.0.0
1655
-	 */
1656
-	public function getUserSession() {
1657
-		return $this->get(IUserSession::class);
1658
-	}
1659
-
1660
-	/**
1661
-	 * @return \OCP\ISession
1662
-	 * @deprecated 20.0.0
1663
-	 */
1664
-	public function getSession() {
1665
-		return $this->get(Session::class)->getSession();
1666
-	}
1667
-
1668
-	/**
1669
-	 * @param \OCP\ISession $session
1670
-	 */
1671
-	public function setSession(\OCP\ISession $session) {
1672
-		$this->get(SessionStorage::class)->setSession($session);
1673
-		$this->get(Session::class)->setSession($session);
1674
-		$this->get(Store::class)->setSession($session);
1675
-	}
1676
-
1677
-	/**
1678
-	 * @return \OC\Authentication\TwoFactorAuth\Manager
1679
-	 * @deprecated 20.0.0
1680
-	 */
1681
-	public function getTwoFactorAuthManager() {
1682
-		return $this->get(\OC\Authentication\TwoFactorAuth\Manager::class);
1683
-	}
1684
-
1685
-	/**
1686
-	 * @return \OC\NavigationManager
1687
-	 * @deprecated 20.0.0
1688
-	 */
1689
-	public function getNavigationManager() {
1690
-		return $this->get(INavigationManager::class);
1691
-	}
1692
-
1693
-	/**
1694
-	 * @return \OCP\IConfig
1695
-	 * @deprecated 20.0.0
1696
-	 */
1697
-	public function getConfig() {
1698
-		return $this->get(AllConfig::class);
1699
-	}
1700
-
1701
-	/**
1702
-	 * @return \OC\SystemConfig
1703
-	 * @deprecated 20.0.0
1704
-	 */
1705
-	public function getSystemConfig() {
1706
-		return $this->get(SystemConfig::class);
1707
-	}
1708
-
1709
-	/**
1710
-	 * Returns the app config manager
1711
-	 *
1712
-	 * @return IAppConfig
1713
-	 * @deprecated 20.0.0
1714
-	 */
1715
-	public function getAppConfig() {
1716
-		return $this->get(IAppConfig::class);
1717
-	}
1718
-
1719
-	/**
1720
-	 * @return IFactory
1721
-	 * @deprecated 20.0.0
1722
-	 */
1723
-	public function getL10NFactory() {
1724
-		return $this->get(IFactory::class);
1725
-	}
1726
-
1727
-	/**
1728
-	 * get an L10N instance
1729
-	 *
1730
-	 * @param string $app appid
1731
-	 * @param string $lang
1732
-	 * @return IL10N
1733
-	 * @deprecated 20.0.0
1734
-	 */
1735
-	public function getL10N($app, $lang = null) {
1736
-		return $this->get(IFactory::class)->get($app, $lang);
1737
-	}
1738
-
1739
-	/**
1740
-	 * @return IURLGenerator
1741
-	 * @deprecated 20.0.0
1742
-	 */
1743
-	public function getURLGenerator() {
1744
-		return $this->get(IURLGenerator::class);
1745
-	}
1746
-
1747
-	/**
1748
-	 * @return AppFetcher
1749
-	 * @deprecated 20.0.0
1750
-	 */
1751
-	public function getAppFetcher() {
1752
-		return $this->get(AppFetcher::class);
1753
-	}
1754
-
1755
-	/**
1756
-	 * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1757
-	 * getMemCacheFactory() instead.
1758
-	 *
1759
-	 * @return ICache
1760
-	 * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1761
-	 */
1762
-	public function getCache() {
1763
-		return $this->get(ICache::class);
1764
-	}
1765
-
1766
-	/**
1767
-	 * Returns an \OCP\CacheFactory instance
1768
-	 *
1769
-	 * @return \OCP\ICacheFactory
1770
-	 * @deprecated 20.0.0
1771
-	 */
1772
-	public function getMemCacheFactory() {
1773
-		return $this->get(ICacheFactory::class);
1774
-	}
1775
-
1776
-	/**
1777
-	 * Returns an \OC\RedisFactory instance
1778
-	 *
1779
-	 * @return \OC\RedisFactory
1780
-	 * @deprecated 20.0.0
1781
-	 */
1782
-	public function getGetRedisFactory() {
1783
-		return $this->get('RedisFactory');
1784
-	}
1785
-
1786
-
1787
-	/**
1788
-	 * Returns the current session
1789
-	 *
1790
-	 * @return \OCP\IDBConnection
1791
-	 * @deprecated 20.0.0
1792
-	 */
1793
-	public function getDatabaseConnection() {
1794
-		return $this->get(IDBConnection::class);
1795
-	}
1796
-
1797
-	/**
1798
-	 * Returns the activity manager
1799
-	 *
1800
-	 * @return \OCP\Activity\IManager
1801
-	 * @deprecated 20.0.0
1802
-	 */
1803
-	public function getActivityManager() {
1804
-		return $this->get(\OCP\Activity\IManager::class);
1805
-	}
1806
-
1807
-	/**
1808
-	 * Returns an job list for controlling background jobs
1809
-	 *
1810
-	 * @return IJobList
1811
-	 * @deprecated 20.0.0
1812
-	 */
1813
-	public function getJobList() {
1814
-		return $this->get(IJobList::class);
1815
-	}
1816
-
1817
-	/**
1818
-	 * Returns a logger instance
1819
-	 *
1820
-	 * @return ILogger
1821
-	 * @deprecated 20.0.0
1822
-	 */
1823
-	public function getLogger() {
1824
-		return $this->get(ILogger::class);
1825
-	}
1826
-
1827
-	/**
1828
-	 * @return ILogFactory
1829
-	 * @throws \OCP\AppFramework\QueryException
1830
-	 * @deprecated 20.0.0
1831
-	 */
1832
-	public function getLogFactory() {
1833
-		return $this->get(ILogFactory::class);
1834
-	}
1835
-
1836
-	/**
1837
-	 * Returns a router for generating and matching urls
1838
-	 *
1839
-	 * @return IRouter
1840
-	 * @deprecated 20.0.0
1841
-	 */
1842
-	public function getRouter() {
1843
-		return $this->get(IRouter::class);
1844
-	}
1845
-
1846
-	/**
1847
-	 * Returns a search instance
1848
-	 *
1849
-	 * @return ISearch
1850
-	 * @deprecated 20.0.0
1851
-	 */
1852
-	public function getSearch() {
1853
-		return $this->get(ISearch::class);
1854
-	}
1855
-
1856
-	/**
1857
-	 * Returns a SecureRandom instance
1858
-	 *
1859
-	 * @return \OCP\Security\ISecureRandom
1860
-	 * @deprecated 20.0.0
1861
-	 */
1862
-	public function getSecureRandom() {
1863
-		return $this->get(ISecureRandom::class);
1864
-	}
1865
-
1866
-	/**
1867
-	 * Returns a Crypto instance
1868
-	 *
1869
-	 * @return ICrypto
1870
-	 * @deprecated 20.0.0
1871
-	 */
1872
-	public function getCrypto() {
1873
-		return $this->get(ICrypto::class);
1874
-	}
1875
-
1876
-	/**
1877
-	 * Returns a Hasher instance
1878
-	 *
1879
-	 * @return IHasher
1880
-	 * @deprecated 20.0.0
1881
-	 */
1882
-	public function getHasher() {
1883
-		return $this->get(IHasher::class);
1884
-	}
1885
-
1886
-	/**
1887
-	 * Returns a CredentialsManager instance
1888
-	 *
1889
-	 * @return ICredentialsManager
1890
-	 * @deprecated 20.0.0
1891
-	 */
1892
-	public function getCredentialsManager() {
1893
-		return $this->get(ICredentialsManager::class);
1894
-	}
1895
-
1896
-	/**
1897
-	 * Get the certificate manager
1898
-	 *
1899
-	 * @return \OCP\ICertificateManager
1900
-	 */
1901
-	public function getCertificateManager() {
1902
-		return $this->get(ICertificateManager::class);
1903
-	}
1904
-
1905
-	/**
1906
-	 * Returns an instance of the HTTP client service
1907
-	 *
1908
-	 * @return IClientService
1909
-	 * @deprecated 20.0.0
1910
-	 */
1911
-	public function getHTTPClientService() {
1912
-		return $this->get(IClientService::class);
1913
-	}
1914
-
1915
-	/**
1916
-	 * Create a new event source
1917
-	 *
1918
-	 * @return \OCP\IEventSource
1919
-	 * @deprecated 20.0.0
1920
-	 */
1921
-	public function createEventSource() {
1922
-		return new \OC_EventSource();
1923
-	}
1924
-
1925
-	/**
1926
-	 * Get the active event logger
1927
-	 *
1928
-	 * The returned logger only logs data when debug mode is enabled
1929
-	 *
1930
-	 * @return IEventLogger
1931
-	 * @deprecated 20.0.0
1932
-	 */
1933
-	public function getEventLogger() {
1934
-		return $this->get(IEventLogger::class);
1935
-	}
1936
-
1937
-	/**
1938
-	 * Get the active query logger
1939
-	 *
1940
-	 * The returned logger only logs data when debug mode is enabled
1941
-	 *
1942
-	 * @return IQueryLogger
1943
-	 * @deprecated 20.0.0
1944
-	 */
1945
-	public function getQueryLogger() {
1946
-		return $this->get(IQueryLogger::class);
1947
-	}
1948
-
1949
-	/**
1950
-	 * Get the manager for temporary files and folders
1951
-	 *
1952
-	 * @return \OCP\ITempManager
1953
-	 * @deprecated 20.0.0
1954
-	 */
1955
-	public function getTempManager() {
1956
-		return $this->get(ITempManager::class);
1957
-	}
1958
-
1959
-	/**
1960
-	 * Get the app manager
1961
-	 *
1962
-	 * @return \OCP\App\IAppManager
1963
-	 * @deprecated 20.0.0
1964
-	 */
1965
-	public function getAppManager() {
1966
-		return $this->get(IAppManager::class);
1967
-	}
1968
-
1969
-	/**
1970
-	 * Creates a new mailer
1971
-	 *
1972
-	 * @return IMailer
1973
-	 * @deprecated 20.0.0
1974
-	 */
1975
-	public function getMailer() {
1976
-		return $this->get(IMailer::class);
1977
-	}
1978
-
1979
-	/**
1980
-	 * Get the webroot
1981
-	 *
1982
-	 * @return string
1983
-	 * @deprecated 20.0.0
1984
-	 */
1985
-	public function getWebRoot() {
1986
-		return $this->webRoot;
1987
-	}
1988
-
1989
-	/**
1990
-	 * @return \OC\OCSClient
1991
-	 * @deprecated 20.0.0
1992
-	 */
1993
-	public function getOcsClient() {
1994
-		return $this->get('OcsClient');
1995
-	}
1996
-
1997
-	/**
1998
-	 * @return IDateTimeZone
1999
-	 * @deprecated 20.0.0
2000
-	 */
2001
-	public function getDateTimeZone() {
2002
-		return $this->get(IDateTimeZone::class);
2003
-	}
2004
-
2005
-	/**
2006
-	 * @return IDateTimeFormatter
2007
-	 * @deprecated 20.0.0
2008
-	 */
2009
-	public function getDateTimeFormatter() {
2010
-		return $this->get(IDateTimeFormatter::class);
2011
-	}
2012
-
2013
-	/**
2014
-	 * @return IMountProviderCollection
2015
-	 * @deprecated 20.0.0
2016
-	 */
2017
-	public function getMountProviderCollection() {
2018
-		return $this->get(IMountProviderCollection::class);
2019
-	}
2020
-
2021
-	/**
2022
-	 * Get the IniWrapper
2023
-	 *
2024
-	 * @return IniGetWrapper
2025
-	 * @deprecated 20.0.0
2026
-	 */
2027
-	public function getIniWrapper() {
2028
-		return $this->get(IniGetWrapper::class);
2029
-	}
2030
-
2031
-	/**
2032
-	 * @return \OCP\Command\IBus
2033
-	 * @deprecated 20.0.0
2034
-	 */
2035
-	public function getCommandBus() {
2036
-		return $this->get(IBus::class);
2037
-	}
2038
-
2039
-	/**
2040
-	 * Get the trusted domain helper
2041
-	 *
2042
-	 * @return TrustedDomainHelper
2043
-	 * @deprecated 20.0.0
2044
-	 */
2045
-	public function getTrustedDomainHelper() {
2046
-		return $this->get(TrustedDomainHelper::class);
2047
-	}
2048
-
2049
-	/**
2050
-	 * Get the locking provider
2051
-	 *
2052
-	 * @return ILockingProvider
2053
-	 * @since 8.1.0
2054
-	 * @deprecated 20.0.0
2055
-	 */
2056
-	public function getLockingProvider() {
2057
-		return $this->get(ILockingProvider::class);
2058
-	}
2059
-
2060
-	/**
2061
-	 * @return IMountManager
2062
-	 * @deprecated 20.0.0
2063
-	 **/
2064
-	public function getMountManager() {
2065
-		return $this->get(IMountManager::class);
2066
-	}
2067
-
2068
-	/**
2069
-	 * @return IUserMountCache
2070
-	 * @deprecated 20.0.0
2071
-	 */
2072
-	public function getUserMountCache() {
2073
-		return $this->get(IUserMountCache::class);
2074
-	}
2075
-
2076
-	/**
2077
-	 * Get the MimeTypeDetector
2078
-	 *
2079
-	 * @return IMimeTypeDetector
2080
-	 * @deprecated 20.0.0
2081
-	 */
2082
-	public function getMimeTypeDetector() {
2083
-		return $this->get(IMimeTypeDetector::class);
2084
-	}
2085
-
2086
-	/**
2087
-	 * Get the MimeTypeLoader
2088
-	 *
2089
-	 * @return IMimeTypeLoader
2090
-	 * @deprecated 20.0.0
2091
-	 */
2092
-	public function getMimeTypeLoader() {
2093
-		return $this->get(IMimeTypeLoader::class);
2094
-	}
2095
-
2096
-	/**
2097
-	 * Get the manager of all the capabilities
2098
-	 *
2099
-	 * @return CapabilitiesManager
2100
-	 * @deprecated 20.0.0
2101
-	 */
2102
-	public function getCapabilitiesManager() {
2103
-		return $this->get(CapabilitiesManager::class);
2104
-	}
2105
-
2106
-	/**
2107
-	 * Get the EventDispatcher
2108
-	 *
2109
-	 * @return EventDispatcherInterface
2110
-	 * @since 8.2.0
2111
-	 * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher
2112
-	 */
2113
-	public function getEventDispatcher() {
2114
-		return $this->get(\OC\EventDispatcher\SymfonyAdapter::class);
2115
-	}
2116
-
2117
-	/**
2118
-	 * Get the Notification Manager
2119
-	 *
2120
-	 * @return \OCP\Notification\IManager
2121
-	 * @since 8.2.0
2122
-	 * @deprecated 20.0.0
2123
-	 */
2124
-	public function getNotificationManager() {
2125
-		return $this->get(\OCP\Notification\IManager::class);
2126
-	}
2127
-
2128
-	/**
2129
-	 * @return ICommentsManager
2130
-	 * @deprecated 20.0.0
2131
-	 */
2132
-	public function getCommentsManager() {
2133
-		return $this->get(ICommentsManager::class);
2134
-	}
2135
-
2136
-	/**
2137
-	 * @return \OCA\Theming\ThemingDefaults
2138
-	 * @deprecated 20.0.0
2139
-	 */
2140
-	public function getThemingDefaults() {
2141
-		return $this->get('ThemingDefaults');
2142
-	}
2143
-
2144
-	/**
2145
-	 * @return \OC\IntegrityCheck\Checker
2146
-	 * @deprecated 20.0.0
2147
-	 */
2148
-	public function getIntegrityCodeChecker() {
2149
-		return $this->get('IntegrityCodeChecker');
2150
-	}
2151
-
2152
-	/**
2153
-	 * @return \OC\Session\CryptoWrapper
2154
-	 * @deprecated 20.0.0
2155
-	 */
2156
-	public function getSessionCryptoWrapper() {
2157
-		return $this->get('CryptoWrapper');
2158
-	}
2159
-
2160
-	/**
2161
-	 * @return CsrfTokenManager
2162
-	 * @deprecated 20.0.0
2163
-	 */
2164
-	public function getCsrfTokenManager() {
2165
-		return $this->get(CsrfTokenManager::class);
2166
-	}
2167
-
2168
-	/**
2169
-	 * @return Throttler
2170
-	 * @deprecated 20.0.0
2171
-	 */
2172
-	public function getBruteForceThrottler() {
2173
-		return $this->get(Throttler::class);
2174
-	}
2175
-
2176
-	/**
2177
-	 * @return IContentSecurityPolicyManager
2178
-	 * @deprecated 20.0.0
2179
-	 */
2180
-	public function getContentSecurityPolicyManager() {
2181
-		return $this->get(ContentSecurityPolicyManager::class);
2182
-	}
2183
-
2184
-	/**
2185
-	 * @return ContentSecurityPolicyNonceManager
2186
-	 * @deprecated 20.0.0
2187
-	 */
2188
-	public function getContentSecurityPolicyNonceManager() {
2189
-		return $this->get(ContentSecurityPolicyNonceManager::class);
2190
-	}
2191
-
2192
-	/**
2193
-	 * Not a public API as of 8.2, wait for 9.0
2194
-	 *
2195
-	 * @return \OCA\Files_External\Service\BackendService
2196
-	 * @deprecated 20.0.0
2197
-	 */
2198
-	public function getStoragesBackendService() {
2199
-		return $this->get(BackendService::class);
2200
-	}
2201
-
2202
-	/**
2203
-	 * Not a public API as of 8.2, wait for 9.0
2204
-	 *
2205
-	 * @return \OCA\Files_External\Service\GlobalStoragesService
2206
-	 * @deprecated 20.0.0
2207
-	 */
2208
-	public function getGlobalStoragesService() {
2209
-		return $this->get(GlobalStoragesService::class);
2210
-	}
2211
-
2212
-	/**
2213
-	 * Not a public API as of 8.2, wait for 9.0
2214
-	 *
2215
-	 * @return \OCA\Files_External\Service\UserGlobalStoragesService
2216
-	 * @deprecated 20.0.0
2217
-	 */
2218
-	public function getUserGlobalStoragesService() {
2219
-		return $this->get(UserGlobalStoragesService::class);
2220
-	}
2221
-
2222
-	/**
2223
-	 * Not a public API as of 8.2, wait for 9.0
2224
-	 *
2225
-	 * @return \OCA\Files_External\Service\UserStoragesService
2226
-	 * @deprecated 20.0.0
2227
-	 */
2228
-	public function getUserStoragesService() {
2229
-		return $this->get(UserStoragesService::class);
2230
-	}
2231
-
2232
-	/**
2233
-	 * @return \OCP\Share\IManager
2234
-	 * @deprecated 20.0.0
2235
-	 */
2236
-	public function getShareManager() {
2237
-		return $this->get(\OCP\Share\IManager::class);
2238
-	}
2239
-
2240
-	/**
2241
-	 * @return \OCP\Collaboration\Collaborators\ISearch
2242
-	 * @deprecated 20.0.0
2243
-	 */
2244
-	public function getCollaboratorSearch() {
2245
-		return $this->get(\OCP\Collaboration\Collaborators\ISearch::class);
2246
-	}
2247
-
2248
-	/**
2249
-	 * @return \OCP\Collaboration\AutoComplete\IManager
2250
-	 * @deprecated 20.0.0
2251
-	 */
2252
-	public function getAutoCompleteManager() {
2253
-		return $this->get(IManager::class);
2254
-	}
2255
-
2256
-	/**
2257
-	 * Returns the LDAP Provider
2258
-	 *
2259
-	 * @return \OCP\LDAP\ILDAPProvider
2260
-	 * @deprecated 20.0.0
2261
-	 */
2262
-	public function getLDAPProvider() {
2263
-		return $this->get('LDAPProvider');
2264
-	}
2265
-
2266
-	/**
2267
-	 * @return \OCP\Settings\IManager
2268
-	 * @deprecated 20.0.0
2269
-	 */
2270
-	public function getSettingsManager() {
2271
-		return $this->get(\OC\Settings\Manager::class);
2272
-	}
2273
-
2274
-	/**
2275
-	 * @return \OCP\Files\IAppData
2276
-	 * @deprecated 20.0.0 Use get(\OCP\Files\AppData\IAppDataFactory::class)->get($app) instead
2277
-	 */
2278
-	public function getAppDataDir($app) {
2279
-		/** @var \OC\Files\AppData\Factory $factory */
2280
-		$factory = $this->get(\OC\Files\AppData\Factory::class);
2281
-		return $factory->get($app);
2282
-	}
2283
-
2284
-	/**
2285
-	 * @return \OCP\Lockdown\ILockdownManager
2286
-	 * @deprecated 20.0.0
2287
-	 */
2288
-	public function getLockdownManager() {
2289
-		return $this->get('LockdownManager');
2290
-	}
2291
-
2292
-	/**
2293
-	 * @return \OCP\Federation\ICloudIdManager
2294
-	 * @deprecated 20.0.0
2295
-	 */
2296
-	public function getCloudIdManager() {
2297
-		return $this->get(ICloudIdManager::class);
2298
-	}
2299
-
2300
-	/**
2301
-	 * @return \OCP\GlobalScale\IConfig
2302
-	 * @deprecated 20.0.0
2303
-	 */
2304
-	public function getGlobalScaleConfig() {
2305
-		return $this->get(IConfig::class);
2306
-	}
2307
-
2308
-	/**
2309
-	 * @return \OCP\Federation\ICloudFederationProviderManager
2310
-	 * @deprecated 20.0.0
2311
-	 */
2312
-	public function getCloudFederationProviderManager() {
2313
-		return $this->get(ICloudFederationProviderManager::class);
2314
-	}
2315
-
2316
-	/**
2317
-	 * @return \OCP\Remote\Api\IApiFactory
2318
-	 * @deprecated 20.0.0
2319
-	 */
2320
-	public function getRemoteApiFactory() {
2321
-		return $this->get(IApiFactory::class);
2322
-	}
2323
-
2324
-	/**
2325
-	 * @return \OCP\Federation\ICloudFederationFactory
2326
-	 * @deprecated 20.0.0
2327
-	 */
2328
-	public function getCloudFederationFactory() {
2329
-		return $this->get(ICloudFederationFactory::class);
2330
-	}
2331
-
2332
-	/**
2333
-	 * @return \OCP\Remote\IInstanceFactory
2334
-	 * @deprecated 20.0.0
2335
-	 */
2336
-	public function getRemoteInstanceFactory() {
2337
-		return $this->get(IInstanceFactory::class);
2338
-	}
2339
-
2340
-	/**
2341
-	 * @return IStorageFactory
2342
-	 * @deprecated 20.0.0
2343
-	 */
2344
-	public function getStorageFactory() {
2345
-		return $this->get(IStorageFactory::class);
2346
-	}
2347
-
2348
-	/**
2349
-	 * Get the Preview GeneratorHelper
2350
-	 *
2351
-	 * @return GeneratorHelper
2352
-	 * @since 17.0.0
2353
-	 * @deprecated 20.0.0
2354
-	 */
2355
-	public function getGeneratorHelper() {
2356
-		return $this->get(\OC\Preview\GeneratorHelper::class);
2357
-	}
2358
-
2359
-	private function registerDeprecatedAlias(string $alias, string $target) {
2360
-		$this->registerService($alias, function (ContainerInterface $container) use ($target, $alias) {
2361
-			try {
2362
-				/** @var LoggerInterface $logger */
2363
-				$logger = $container->get(LoggerInterface::class);
2364
-				$logger->debug('The requested alias "' . $alias . '" is deprecated. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']);
2365
-			} catch (ContainerExceptionInterface $e) {
2366
-				// Could not get logger. Continue
2367
-			}
2368
-
2369
-			return $container->get($target);
2370
-		}, false);
2371
-	}
1204
+            $prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
1205
+            if (isset($prefixes['OCA\\Theming\\'])) {
1206
+                $classExists = true;
1207
+            } else {
1208
+                $classExists = false;
1209
+            }
1210
+
1211
+            if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValue('installed', false) && $c->get(IAppManager::class)->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
1212
+                return new ThemingDefaults(
1213
+                    $c->get(\OCP\IConfig::class),
1214
+                    $c->getL10N('theming'),
1215
+                    $c->get(IUserSession::class),
1216
+                    $c->get(IURLGenerator::class),
1217
+                    $c->get(ICacheFactory::class),
1218
+                    new Util($c->get(\OCP\IConfig::class), $this->get(IAppManager::class), $c->getAppDataDir('theming')),
1219
+                    new ImageManager(
1220
+                        $c->get(\OCP\IConfig::class),
1221
+                        $c->getAppDataDir('theming'),
1222
+                        $c->get(IURLGenerator::class),
1223
+                        $this->get(ICacheFactory::class),
1224
+                        $this->get(ILogger::class),
1225
+                        $this->get(ITempManager::class)
1226
+                    ),
1227
+                    $c->get(IAppManager::class),
1228
+                    $c->get(INavigationManager::class)
1229
+                );
1230
+            }
1231
+            return new \OC_Defaults();
1232
+        });
1233
+        $this->registerService(JSCombiner::class, function (Server $c) {
1234
+            return new JSCombiner(
1235
+                $c->getAppDataDir('js'),
1236
+                $c->get(IURLGenerator::class),
1237
+                $this->get(ICacheFactory::class),
1238
+                $c->get(SystemConfig::class),
1239
+                $c->get(LoggerInterface::class)
1240
+            );
1241
+        });
1242
+        $this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class);
1243
+        /** @deprecated 19.0.0 */
1244
+        $this->registerDeprecatedAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class);
1245
+        $this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class);
1246
+
1247
+        $this->registerService('CryptoWrapper', function (ContainerInterface $c) {
1248
+            // FIXME: Instantiated here due to cyclic dependency
1249
+            $request = new Request(
1250
+                [
1251
+                    'get' => $_GET,
1252
+                    'post' => $_POST,
1253
+                    'files' => $_FILES,
1254
+                    'server' => $_SERVER,
1255
+                    'env' => $_ENV,
1256
+                    'cookies' => $_COOKIE,
1257
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1258
+                        ? $_SERVER['REQUEST_METHOD']
1259
+                        : null,
1260
+                ],
1261
+                $c->get(IRequestId::class),
1262
+                $c->get(\OCP\IConfig::class)
1263
+            );
1264
+
1265
+            return new CryptoWrapper(
1266
+                $c->get(\OCP\IConfig::class),
1267
+                $c->get(ICrypto::class),
1268
+                $c->get(ISecureRandom::class),
1269
+                $request
1270
+            );
1271
+        });
1272
+        /** @deprecated 19.0.0 */
1273
+        $this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class);
1274
+        $this->registerService(SessionStorage::class, function (ContainerInterface $c) {
1275
+            return new SessionStorage($c->get(ISession::class));
1276
+        });
1277
+        $this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class);
1278
+        /** @deprecated 19.0.0 */
1279
+        $this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class);
1280
+
1281
+        $this->registerService(\OCP\Share\IManager::class, function (IServerContainer $c) {
1282
+            $config = $c->get(\OCP\IConfig::class);
1283
+            $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
1284
+            /** @var \OCP\Share\IProviderFactory $factory */
1285
+            $factory = new $factoryClass($this);
1286
+
1287
+            $manager = new \OC\Share20\Manager(
1288
+                $c->get(LoggerInterface::class),
1289
+                $c->get(\OCP\IConfig::class),
1290
+                $c->get(ISecureRandom::class),
1291
+                $c->get(IHasher::class),
1292
+                $c->get(IMountManager::class),
1293
+                $c->get(IGroupManager::class),
1294
+                $c->getL10N('lib'),
1295
+                $c->get(IFactory::class),
1296
+                $factory,
1297
+                $c->get(IUserManager::class),
1298
+                $c->get(IRootFolder::class),
1299
+                $c->get(SymfonyAdapter::class),
1300
+                $c->get(IMailer::class),
1301
+                $c->get(IURLGenerator::class),
1302
+                $c->get('ThemingDefaults'),
1303
+                $c->get(IEventDispatcher::class),
1304
+                $c->get(IUserSession::class),
1305
+                $c->get(KnownUserService::class)
1306
+            );
1307
+
1308
+            return $manager;
1309
+        });
1310
+        /** @deprecated 19.0.0 */
1311
+        $this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class);
1312
+
1313
+        $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) {
1314
+            $instance = new Collaboration\Collaborators\Search($c);
1315
+
1316
+            // register default plugins
1317
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
1318
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
1319
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
1320
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
1321
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
1322
+
1323
+            return $instance;
1324
+        });
1325
+        /** @deprecated 19.0.0 */
1326
+        $this->registerDeprecatedAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class);
1327
+        $this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class);
1328
+
1329
+        $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
1330
+
1331
+        $this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class);
1332
+        $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
1333
+
1334
+        $this->registerAlias(IReferenceManager::class, ReferenceManager::class);
1335
+
1336
+        $this->registerDeprecatedAlias('SettingsManager', \OC\Settings\Manager::class);
1337
+        $this->registerAlias(\OCP\Settings\IManager::class, \OC\Settings\Manager::class);
1338
+        $this->registerService(\OC\Files\AppData\Factory::class, function (ContainerInterface $c) {
1339
+            return new \OC\Files\AppData\Factory(
1340
+                $c->get(IRootFolder::class),
1341
+                $c->get(SystemConfig::class)
1342
+            );
1343
+        });
1344
+
1345
+        $this->registerService('LockdownManager', function (ContainerInterface $c) {
1346
+            return new LockdownManager(function () use ($c) {
1347
+                return $c->get(ISession::class);
1348
+            });
1349
+        });
1350
+
1351
+        $this->registerService(\OCP\OCS\IDiscoveryService::class, function (ContainerInterface $c) {
1352
+            return new DiscoveryService(
1353
+                $c->get(ICacheFactory::class),
1354
+                $c->get(IClientService::class)
1355
+            );
1356
+        });
1357
+
1358
+        $this->registerService(ICloudIdManager::class, function (ContainerInterface $c) {
1359
+            return new CloudIdManager(
1360
+                $c->get(\OCP\Contacts\IManager::class),
1361
+                $c->get(IURLGenerator::class),
1362
+                $c->get(IUserManager::class),
1363
+                $c->get(ICacheFactory::class),
1364
+                $c->get(IEventDispatcher::class),
1365
+            );
1366
+        });
1367
+
1368
+        $this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class);
1369
+
1370
+        $this->registerService(ICloudFederationProviderManager::class, function (ContainerInterface $c) {
1371
+            return new CloudFederationProviderManager(
1372
+                $c->get(IAppManager::class),
1373
+                $c->get(IClientService::class),
1374
+                $c->get(ICloudIdManager::class),
1375
+                $c->get(LoggerInterface::class)
1376
+            );
1377
+        });
1378
+
1379
+        $this->registerService(ICloudFederationFactory::class, function (Server $c) {
1380
+            return new CloudFederationFactory();
1381
+        });
1382
+
1383
+        $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1384
+        /** @deprecated 19.0.0 */
1385
+        $this->registerDeprecatedAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
1386
+
1387
+        $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1388
+        /** @deprecated 19.0.0 */
1389
+        $this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1390
+
1391
+        $this->registerService(Defaults::class, function (Server $c) {
1392
+            return new Defaults(
1393
+                $c->getThemingDefaults()
1394
+            );
1395
+        });
1396
+        /** @deprecated 19.0.0 */
1397
+        $this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class);
1398
+
1399
+        $this->registerService(\OCP\ISession::class, function (ContainerInterface $c) {
1400
+            return $c->get(\OCP\IUserSession::class)->getSession();
1401
+        }, false);
1402
+
1403
+        $this->registerService(IShareHelper::class, function (ContainerInterface $c) {
1404
+            return new ShareHelper(
1405
+                $c->get(\OCP\Share\IManager::class)
1406
+            );
1407
+        });
1408
+
1409
+        $this->registerService(Installer::class, function (ContainerInterface $c) {
1410
+            return new Installer(
1411
+                $c->get(AppFetcher::class),
1412
+                $c->get(IClientService::class),
1413
+                $c->get(ITempManager::class),
1414
+                $c->get(LoggerInterface::class),
1415
+                $c->get(\OCP\IConfig::class),
1416
+                \OC::$CLI
1417
+            );
1418
+        });
1419
+
1420
+        $this->registerService(IApiFactory::class, function (ContainerInterface $c) {
1421
+            return new ApiFactory($c->get(IClientService::class));
1422
+        });
1423
+
1424
+        $this->registerService(IInstanceFactory::class, function (ContainerInterface $c) {
1425
+            $memcacheFactory = $c->get(ICacheFactory::class);
1426
+            return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->get(IClientService::class));
1427
+        });
1428
+
1429
+        $this->registerAlias(IContactsStore::class, ContactsStore::class);
1430
+        $this->registerAlias(IAccountManager::class, AccountManager::class);
1431
+
1432
+        $this->registerAlias(IStorageFactory::class, StorageFactory::class);
1433
+
1434
+        $this->registerAlias(IDashboardManager::class, DashboardManager::class);
1435
+        $this->registerAlias(\OCP\Dashboard\IManager::class, \OC\Dashboard\Manager::class);
1436
+        $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class);
1437
+
1438
+        $this->registerAlias(ISubAdmin::class, SubAdmin::class);
1439
+
1440
+        $this->registerAlias(IInitialStateService::class, InitialStateService::class);
1441
+
1442
+        $this->registerAlias(\OCP\IEmojiHelper::class, \OC\EmojiHelper::class);
1443
+
1444
+        $this->registerAlias(\OCP\UserStatus\IManager::class, \OC\UserStatus\Manager::class);
1445
+
1446
+        $this->registerAlias(IBroker::class, Broker::class);
1447
+
1448
+        $this->registerAlias(IMetadataManager::class, MetadataManager::class);
1449
+
1450
+        $this->registerAlias(\OCP\Files\AppData\IAppDataFactory::class, \OC\Files\AppData\Factory::class);
1451
+
1452
+        $this->registerAlias(IBinaryFinder::class, BinaryFinder::class);
1453
+
1454
+        $this->connectDispatcher();
1455
+    }
1456
+
1457
+    public function boot() {
1458
+        /** @var HookConnector $hookConnector */
1459
+        $hookConnector = $this->get(HookConnector::class);
1460
+        $hookConnector->viewToNode();
1461
+    }
1462
+
1463
+    /**
1464
+     * @return \OCP\Calendar\IManager
1465
+     * @deprecated 20.0.0
1466
+     */
1467
+    public function getCalendarManager() {
1468
+        return $this->get(\OC\Calendar\Manager::class);
1469
+    }
1470
+
1471
+    /**
1472
+     * @return \OCP\Calendar\Resource\IManager
1473
+     * @deprecated 20.0.0
1474
+     */
1475
+    public function getCalendarResourceBackendManager() {
1476
+        return $this->get(\OC\Calendar\Resource\Manager::class);
1477
+    }
1478
+
1479
+    /**
1480
+     * @return \OCP\Calendar\Room\IManager
1481
+     * @deprecated 20.0.0
1482
+     */
1483
+    public function getCalendarRoomBackendManager() {
1484
+        return $this->get(\OC\Calendar\Room\Manager::class);
1485
+    }
1486
+
1487
+    private function connectDispatcher(): void {
1488
+        /** @var IEventDispatcher $eventDispatcher */
1489
+        $eventDispatcher = $this->get(IEventDispatcher::class);
1490
+        $eventDispatcher->addServiceListener(LoginFailed::class, LoginFailedListener::class);
1491
+        $eventDispatcher->addServiceListener(PostLoginEvent::class, UserLoggedInListener::class);
1492
+        $eventDispatcher->addServiceListener(UserChangedEvent::class, UserChangedListener::class);
1493
+        $eventDispatcher->addServiceListener(BeforeUserDeletedEvent::class, BeforeUserDeletedListener::class);
1494
+    }
1495
+
1496
+    /**
1497
+     * @return \OCP\Contacts\IManager
1498
+     * @deprecated 20.0.0
1499
+     */
1500
+    public function getContactsManager() {
1501
+        return $this->get(\OCP\Contacts\IManager::class);
1502
+    }
1503
+
1504
+    /**
1505
+     * @return \OC\Encryption\Manager
1506
+     * @deprecated 20.0.0
1507
+     */
1508
+    public function getEncryptionManager() {
1509
+        return $this->get(\OCP\Encryption\IManager::class);
1510
+    }
1511
+
1512
+    /**
1513
+     * @return \OC\Encryption\File
1514
+     * @deprecated 20.0.0
1515
+     */
1516
+    public function getEncryptionFilesHelper() {
1517
+        return $this->get(IFile::class);
1518
+    }
1519
+
1520
+    /**
1521
+     * @return \OCP\Encryption\Keys\IStorage
1522
+     * @deprecated 20.0.0
1523
+     */
1524
+    public function getEncryptionKeyStorage() {
1525
+        return $this->get(IStorage::class);
1526
+    }
1527
+
1528
+    /**
1529
+     * The current request object holding all information about the request
1530
+     * currently being processed is returned from this method.
1531
+     * In case the current execution was not initiated by a web request null is returned
1532
+     *
1533
+     * @return \OCP\IRequest
1534
+     * @deprecated 20.0.0
1535
+     */
1536
+    public function getRequest() {
1537
+        return $this->get(IRequest::class);
1538
+    }
1539
+
1540
+    /**
1541
+     * Returns the preview manager which can create preview images for a given file
1542
+     *
1543
+     * @return IPreview
1544
+     * @deprecated 20.0.0
1545
+     */
1546
+    public function getPreviewManager() {
1547
+        return $this->get(IPreview::class);
1548
+    }
1549
+
1550
+    /**
1551
+     * Returns the tag manager which can get and set tags for different object types
1552
+     *
1553
+     * @see \OCP\ITagManager::load()
1554
+     * @return ITagManager
1555
+     * @deprecated 20.0.0
1556
+     */
1557
+    public function getTagManager() {
1558
+        return $this->get(ITagManager::class);
1559
+    }
1560
+
1561
+    /**
1562
+     * Returns the system-tag manager
1563
+     *
1564
+     * @return ISystemTagManager
1565
+     *
1566
+     * @since 9.0.0
1567
+     * @deprecated 20.0.0
1568
+     */
1569
+    public function getSystemTagManager() {
1570
+        return $this->get(ISystemTagManager::class);
1571
+    }
1572
+
1573
+    /**
1574
+     * Returns the system-tag object mapper
1575
+     *
1576
+     * @return ISystemTagObjectMapper
1577
+     *
1578
+     * @since 9.0.0
1579
+     * @deprecated 20.0.0
1580
+     */
1581
+    public function getSystemTagObjectMapper() {
1582
+        return $this->get(ISystemTagObjectMapper::class);
1583
+    }
1584
+
1585
+    /**
1586
+     * Returns the avatar manager, used for avatar functionality
1587
+     *
1588
+     * @return IAvatarManager
1589
+     * @deprecated 20.0.0
1590
+     */
1591
+    public function getAvatarManager() {
1592
+        return $this->get(IAvatarManager::class);
1593
+    }
1594
+
1595
+    /**
1596
+     * Returns the root folder of ownCloud's data directory
1597
+     *
1598
+     * @return IRootFolder
1599
+     * @deprecated 20.0.0
1600
+     */
1601
+    public function getRootFolder() {
1602
+        return $this->get(IRootFolder::class);
1603
+    }
1604
+
1605
+    /**
1606
+     * Returns the root folder of ownCloud's data directory
1607
+     * This is the lazy variant so this gets only initialized once it
1608
+     * is actually used.
1609
+     *
1610
+     * @return IRootFolder
1611
+     * @deprecated 20.0.0
1612
+     */
1613
+    public function getLazyRootFolder() {
1614
+        return $this->get(IRootFolder::class);
1615
+    }
1616
+
1617
+    /**
1618
+     * Returns a view to ownCloud's files folder
1619
+     *
1620
+     * @param string $userId user ID
1621
+     * @return \OCP\Files\Folder|null
1622
+     * @deprecated 20.0.0
1623
+     */
1624
+    public function getUserFolder($userId = null) {
1625
+        if ($userId === null) {
1626
+            $user = $this->get(IUserSession::class)->getUser();
1627
+            if (!$user) {
1628
+                return null;
1629
+            }
1630
+            $userId = $user->getUID();
1631
+        }
1632
+        $root = $this->get(IRootFolder::class);
1633
+        return $root->getUserFolder($userId);
1634
+    }
1635
+
1636
+    /**
1637
+     * @return \OC\User\Manager
1638
+     * @deprecated 20.0.0
1639
+     */
1640
+    public function getUserManager() {
1641
+        return $this->get(IUserManager::class);
1642
+    }
1643
+
1644
+    /**
1645
+     * @return \OC\Group\Manager
1646
+     * @deprecated 20.0.0
1647
+     */
1648
+    public function getGroupManager() {
1649
+        return $this->get(IGroupManager::class);
1650
+    }
1651
+
1652
+    /**
1653
+     * @return \OC\User\Session
1654
+     * @deprecated 20.0.0
1655
+     */
1656
+    public function getUserSession() {
1657
+        return $this->get(IUserSession::class);
1658
+    }
1659
+
1660
+    /**
1661
+     * @return \OCP\ISession
1662
+     * @deprecated 20.0.0
1663
+     */
1664
+    public function getSession() {
1665
+        return $this->get(Session::class)->getSession();
1666
+    }
1667
+
1668
+    /**
1669
+     * @param \OCP\ISession $session
1670
+     */
1671
+    public function setSession(\OCP\ISession $session) {
1672
+        $this->get(SessionStorage::class)->setSession($session);
1673
+        $this->get(Session::class)->setSession($session);
1674
+        $this->get(Store::class)->setSession($session);
1675
+    }
1676
+
1677
+    /**
1678
+     * @return \OC\Authentication\TwoFactorAuth\Manager
1679
+     * @deprecated 20.0.0
1680
+     */
1681
+    public function getTwoFactorAuthManager() {
1682
+        return $this->get(\OC\Authentication\TwoFactorAuth\Manager::class);
1683
+    }
1684
+
1685
+    /**
1686
+     * @return \OC\NavigationManager
1687
+     * @deprecated 20.0.0
1688
+     */
1689
+    public function getNavigationManager() {
1690
+        return $this->get(INavigationManager::class);
1691
+    }
1692
+
1693
+    /**
1694
+     * @return \OCP\IConfig
1695
+     * @deprecated 20.0.0
1696
+     */
1697
+    public function getConfig() {
1698
+        return $this->get(AllConfig::class);
1699
+    }
1700
+
1701
+    /**
1702
+     * @return \OC\SystemConfig
1703
+     * @deprecated 20.0.0
1704
+     */
1705
+    public function getSystemConfig() {
1706
+        return $this->get(SystemConfig::class);
1707
+    }
1708
+
1709
+    /**
1710
+     * Returns the app config manager
1711
+     *
1712
+     * @return IAppConfig
1713
+     * @deprecated 20.0.0
1714
+     */
1715
+    public function getAppConfig() {
1716
+        return $this->get(IAppConfig::class);
1717
+    }
1718
+
1719
+    /**
1720
+     * @return IFactory
1721
+     * @deprecated 20.0.0
1722
+     */
1723
+    public function getL10NFactory() {
1724
+        return $this->get(IFactory::class);
1725
+    }
1726
+
1727
+    /**
1728
+     * get an L10N instance
1729
+     *
1730
+     * @param string $app appid
1731
+     * @param string $lang
1732
+     * @return IL10N
1733
+     * @deprecated 20.0.0
1734
+     */
1735
+    public function getL10N($app, $lang = null) {
1736
+        return $this->get(IFactory::class)->get($app, $lang);
1737
+    }
1738
+
1739
+    /**
1740
+     * @return IURLGenerator
1741
+     * @deprecated 20.0.0
1742
+     */
1743
+    public function getURLGenerator() {
1744
+        return $this->get(IURLGenerator::class);
1745
+    }
1746
+
1747
+    /**
1748
+     * @return AppFetcher
1749
+     * @deprecated 20.0.0
1750
+     */
1751
+    public function getAppFetcher() {
1752
+        return $this->get(AppFetcher::class);
1753
+    }
1754
+
1755
+    /**
1756
+     * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1757
+     * getMemCacheFactory() instead.
1758
+     *
1759
+     * @return ICache
1760
+     * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1761
+     */
1762
+    public function getCache() {
1763
+        return $this->get(ICache::class);
1764
+    }
1765
+
1766
+    /**
1767
+     * Returns an \OCP\CacheFactory instance
1768
+     *
1769
+     * @return \OCP\ICacheFactory
1770
+     * @deprecated 20.0.0
1771
+     */
1772
+    public function getMemCacheFactory() {
1773
+        return $this->get(ICacheFactory::class);
1774
+    }
1775
+
1776
+    /**
1777
+     * Returns an \OC\RedisFactory instance
1778
+     *
1779
+     * @return \OC\RedisFactory
1780
+     * @deprecated 20.0.0
1781
+     */
1782
+    public function getGetRedisFactory() {
1783
+        return $this->get('RedisFactory');
1784
+    }
1785
+
1786
+
1787
+    /**
1788
+     * Returns the current session
1789
+     *
1790
+     * @return \OCP\IDBConnection
1791
+     * @deprecated 20.0.0
1792
+     */
1793
+    public function getDatabaseConnection() {
1794
+        return $this->get(IDBConnection::class);
1795
+    }
1796
+
1797
+    /**
1798
+     * Returns the activity manager
1799
+     *
1800
+     * @return \OCP\Activity\IManager
1801
+     * @deprecated 20.0.0
1802
+     */
1803
+    public function getActivityManager() {
1804
+        return $this->get(\OCP\Activity\IManager::class);
1805
+    }
1806
+
1807
+    /**
1808
+     * Returns an job list for controlling background jobs
1809
+     *
1810
+     * @return IJobList
1811
+     * @deprecated 20.0.0
1812
+     */
1813
+    public function getJobList() {
1814
+        return $this->get(IJobList::class);
1815
+    }
1816
+
1817
+    /**
1818
+     * Returns a logger instance
1819
+     *
1820
+     * @return ILogger
1821
+     * @deprecated 20.0.0
1822
+     */
1823
+    public function getLogger() {
1824
+        return $this->get(ILogger::class);
1825
+    }
1826
+
1827
+    /**
1828
+     * @return ILogFactory
1829
+     * @throws \OCP\AppFramework\QueryException
1830
+     * @deprecated 20.0.0
1831
+     */
1832
+    public function getLogFactory() {
1833
+        return $this->get(ILogFactory::class);
1834
+    }
1835
+
1836
+    /**
1837
+     * Returns a router for generating and matching urls
1838
+     *
1839
+     * @return IRouter
1840
+     * @deprecated 20.0.0
1841
+     */
1842
+    public function getRouter() {
1843
+        return $this->get(IRouter::class);
1844
+    }
1845
+
1846
+    /**
1847
+     * Returns a search instance
1848
+     *
1849
+     * @return ISearch
1850
+     * @deprecated 20.0.0
1851
+     */
1852
+    public function getSearch() {
1853
+        return $this->get(ISearch::class);
1854
+    }
1855
+
1856
+    /**
1857
+     * Returns a SecureRandom instance
1858
+     *
1859
+     * @return \OCP\Security\ISecureRandom
1860
+     * @deprecated 20.0.0
1861
+     */
1862
+    public function getSecureRandom() {
1863
+        return $this->get(ISecureRandom::class);
1864
+    }
1865
+
1866
+    /**
1867
+     * Returns a Crypto instance
1868
+     *
1869
+     * @return ICrypto
1870
+     * @deprecated 20.0.0
1871
+     */
1872
+    public function getCrypto() {
1873
+        return $this->get(ICrypto::class);
1874
+    }
1875
+
1876
+    /**
1877
+     * Returns a Hasher instance
1878
+     *
1879
+     * @return IHasher
1880
+     * @deprecated 20.0.0
1881
+     */
1882
+    public function getHasher() {
1883
+        return $this->get(IHasher::class);
1884
+    }
1885
+
1886
+    /**
1887
+     * Returns a CredentialsManager instance
1888
+     *
1889
+     * @return ICredentialsManager
1890
+     * @deprecated 20.0.0
1891
+     */
1892
+    public function getCredentialsManager() {
1893
+        return $this->get(ICredentialsManager::class);
1894
+    }
1895
+
1896
+    /**
1897
+     * Get the certificate manager
1898
+     *
1899
+     * @return \OCP\ICertificateManager
1900
+     */
1901
+    public function getCertificateManager() {
1902
+        return $this->get(ICertificateManager::class);
1903
+    }
1904
+
1905
+    /**
1906
+     * Returns an instance of the HTTP client service
1907
+     *
1908
+     * @return IClientService
1909
+     * @deprecated 20.0.0
1910
+     */
1911
+    public function getHTTPClientService() {
1912
+        return $this->get(IClientService::class);
1913
+    }
1914
+
1915
+    /**
1916
+     * Create a new event source
1917
+     *
1918
+     * @return \OCP\IEventSource
1919
+     * @deprecated 20.0.0
1920
+     */
1921
+    public function createEventSource() {
1922
+        return new \OC_EventSource();
1923
+    }
1924
+
1925
+    /**
1926
+     * Get the active event logger
1927
+     *
1928
+     * The returned logger only logs data when debug mode is enabled
1929
+     *
1930
+     * @return IEventLogger
1931
+     * @deprecated 20.0.0
1932
+     */
1933
+    public function getEventLogger() {
1934
+        return $this->get(IEventLogger::class);
1935
+    }
1936
+
1937
+    /**
1938
+     * Get the active query logger
1939
+     *
1940
+     * The returned logger only logs data when debug mode is enabled
1941
+     *
1942
+     * @return IQueryLogger
1943
+     * @deprecated 20.0.0
1944
+     */
1945
+    public function getQueryLogger() {
1946
+        return $this->get(IQueryLogger::class);
1947
+    }
1948
+
1949
+    /**
1950
+     * Get the manager for temporary files and folders
1951
+     *
1952
+     * @return \OCP\ITempManager
1953
+     * @deprecated 20.0.0
1954
+     */
1955
+    public function getTempManager() {
1956
+        return $this->get(ITempManager::class);
1957
+    }
1958
+
1959
+    /**
1960
+     * Get the app manager
1961
+     *
1962
+     * @return \OCP\App\IAppManager
1963
+     * @deprecated 20.0.0
1964
+     */
1965
+    public function getAppManager() {
1966
+        return $this->get(IAppManager::class);
1967
+    }
1968
+
1969
+    /**
1970
+     * Creates a new mailer
1971
+     *
1972
+     * @return IMailer
1973
+     * @deprecated 20.0.0
1974
+     */
1975
+    public function getMailer() {
1976
+        return $this->get(IMailer::class);
1977
+    }
1978
+
1979
+    /**
1980
+     * Get the webroot
1981
+     *
1982
+     * @return string
1983
+     * @deprecated 20.0.0
1984
+     */
1985
+    public function getWebRoot() {
1986
+        return $this->webRoot;
1987
+    }
1988
+
1989
+    /**
1990
+     * @return \OC\OCSClient
1991
+     * @deprecated 20.0.0
1992
+     */
1993
+    public function getOcsClient() {
1994
+        return $this->get('OcsClient');
1995
+    }
1996
+
1997
+    /**
1998
+     * @return IDateTimeZone
1999
+     * @deprecated 20.0.0
2000
+     */
2001
+    public function getDateTimeZone() {
2002
+        return $this->get(IDateTimeZone::class);
2003
+    }
2004
+
2005
+    /**
2006
+     * @return IDateTimeFormatter
2007
+     * @deprecated 20.0.0
2008
+     */
2009
+    public function getDateTimeFormatter() {
2010
+        return $this->get(IDateTimeFormatter::class);
2011
+    }
2012
+
2013
+    /**
2014
+     * @return IMountProviderCollection
2015
+     * @deprecated 20.0.0
2016
+     */
2017
+    public function getMountProviderCollection() {
2018
+        return $this->get(IMountProviderCollection::class);
2019
+    }
2020
+
2021
+    /**
2022
+     * Get the IniWrapper
2023
+     *
2024
+     * @return IniGetWrapper
2025
+     * @deprecated 20.0.0
2026
+     */
2027
+    public function getIniWrapper() {
2028
+        return $this->get(IniGetWrapper::class);
2029
+    }
2030
+
2031
+    /**
2032
+     * @return \OCP\Command\IBus
2033
+     * @deprecated 20.0.0
2034
+     */
2035
+    public function getCommandBus() {
2036
+        return $this->get(IBus::class);
2037
+    }
2038
+
2039
+    /**
2040
+     * Get the trusted domain helper
2041
+     *
2042
+     * @return TrustedDomainHelper
2043
+     * @deprecated 20.0.0
2044
+     */
2045
+    public function getTrustedDomainHelper() {
2046
+        return $this->get(TrustedDomainHelper::class);
2047
+    }
2048
+
2049
+    /**
2050
+     * Get the locking provider
2051
+     *
2052
+     * @return ILockingProvider
2053
+     * @since 8.1.0
2054
+     * @deprecated 20.0.0
2055
+     */
2056
+    public function getLockingProvider() {
2057
+        return $this->get(ILockingProvider::class);
2058
+    }
2059
+
2060
+    /**
2061
+     * @return IMountManager
2062
+     * @deprecated 20.0.0
2063
+     **/
2064
+    public function getMountManager() {
2065
+        return $this->get(IMountManager::class);
2066
+    }
2067
+
2068
+    /**
2069
+     * @return IUserMountCache
2070
+     * @deprecated 20.0.0
2071
+     */
2072
+    public function getUserMountCache() {
2073
+        return $this->get(IUserMountCache::class);
2074
+    }
2075
+
2076
+    /**
2077
+     * Get the MimeTypeDetector
2078
+     *
2079
+     * @return IMimeTypeDetector
2080
+     * @deprecated 20.0.0
2081
+     */
2082
+    public function getMimeTypeDetector() {
2083
+        return $this->get(IMimeTypeDetector::class);
2084
+    }
2085
+
2086
+    /**
2087
+     * Get the MimeTypeLoader
2088
+     *
2089
+     * @return IMimeTypeLoader
2090
+     * @deprecated 20.0.0
2091
+     */
2092
+    public function getMimeTypeLoader() {
2093
+        return $this->get(IMimeTypeLoader::class);
2094
+    }
2095
+
2096
+    /**
2097
+     * Get the manager of all the capabilities
2098
+     *
2099
+     * @return CapabilitiesManager
2100
+     * @deprecated 20.0.0
2101
+     */
2102
+    public function getCapabilitiesManager() {
2103
+        return $this->get(CapabilitiesManager::class);
2104
+    }
2105
+
2106
+    /**
2107
+     * Get the EventDispatcher
2108
+     *
2109
+     * @return EventDispatcherInterface
2110
+     * @since 8.2.0
2111
+     * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher
2112
+     */
2113
+    public function getEventDispatcher() {
2114
+        return $this->get(\OC\EventDispatcher\SymfonyAdapter::class);
2115
+    }
2116
+
2117
+    /**
2118
+     * Get the Notification Manager
2119
+     *
2120
+     * @return \OCP\Notification\IManager
2121
+     * @since 8.2.0
2122
+     * @deprecated 20.0.0
2123
+     */
2124
+    public function getNotificationManager() {
2125
+        return $this->get(\OCP\Notification\IManager::class);
2126
+    }
2127
+
2128
+    /**
2129
+     * @return ICommentsManager
2130
+     * @deprecated 20.0.0
2131
+     */
2132
+    public function getCommentsManager() {
2133
+        return $this->get(ICommentsManager::class);
2134
+    }
2135
+
2136
+    /**
2137
+     * @return \OCA\Theming\ThemingDefaults
2138
+     * @deprecated 20.0.0
2139
+     */
2140
+    public function getThemingDefaults() {
2141
+        return $this->get('ThemingDefaults');
2142
+    }
2143
+
2144
+    /**
2145
+     * @return \OC\IntegrityCheck\Checker
2146
+     * @deprecated 20.0.0
2147
+     */
2148
+    public function getIntegrityCodeChecker() {
2149
+        return $this->get('IntegrityCodeChecker');
2150
+    }
2151
+
2152
+    /**
2153
+     * @return \OC\Session\CryptoWrapper
2154
+     * @deprecated 20.0.0
2155
+     */
2156
+    public function getSessionCryptoWrapper() {
2157
+        return $this->get('CryptoWrapper');
2158
+    }
2159
+
2160
+    /**
2161
+     * @return CsrfTokenManager
2162
+     * @deprecated 20.0.0
2163
+     */
2164
+    public function getCsrfTokenManager() {
2165
+        return $this->get(CsrfTokenManager::class);
2166
+    }
2167
+
2168
+    /**
2169
+     * @return Throttler
2170
+     * @deprecated 20.0.0
2171
+     */
2172
+    public function getBruteForceThrottler() {
2173
+        return $this->get(Throttler::class);
2174
+    }
2175
+
2176
+    /**
2177
+     * @return IContentSecurityPolicyManager
2178
+     * @deprecated 20.0.0
2179
+     */
2180
+    public function getContentSecurityPolicyManager() {
2181
+        return $this->get(ContentSecurityPolicyManager::class);
2182
+    }
2183
+
2184
+    /**
2185
+     * @return ContentSecurityPolicyNonceManager
2186
+     * @deprecated 20.0.0
2187
+     */
2188
+    public function getContentSecurityPolicyNonceManager() {
2189
+        return $this->get(ContentSecurityPolicyNonceManager::class);
2190
+    }
2191
+
2192
+    /**
2193
+     * Not a public API as of 8.2, wait for 9.0
2194
+     *
2195
+     * @return \OCA\Files_External\Service\BackendService
2196
+     * @deprecated 20.0.0
2197
+     */
2198
+    public function getStoragesBackendService() {
2199
+        return $this->get(BackendService::class);
2200
+    }
2201
+
2202
+    /**
2203
+     * Not a public API as of 8.2, wait for 9.0
2204
+     *
2205
+     * @return \OCA\Files_External\Service\GlobalStoragesService
2206
+     * @deprecated 20.0.0
2207
+     */
2208
+    public function getGlobalStoragesService() {
2209
+        return $this->get(GlobalStoragesService::class);
2210
+    }
2211
+
2212
+    /**
2213
+     * Not a public API as of 8.2, wait for 9.0
2214
+     *
2215
+     * @return \OCA\Files_External\Service\UserGlobalStoragesService
2216
+     * @deprecated 20.0.0
2217
+     */
2218
+    public function getUserGlobalStoragesService() {
2219
+        return $this->get(UserGlobalStoragesService::class);
2220
+    }
2221
+
2222
+    /**
2223
+     * Not a public API as of 8.2, wait for 9.0
2224
+     *
2225
+     * @return \OCA\Files_External\Service\UserStoragesService
2226
+     * @deprecated 20.0.0
2227
+     */
2228
+    public function getUserStoragesService() {
2229
+        return $this->get(UserStoragesService::class);
2230
+    }
2231
+
2232
+    /**
2233
+     * @return \OCP\Share\IManager
2234
+     * @deprecated 20.0.0
2235
+     */
2236
+    public function getShareManager() {
2237
+        return $this->get(\OCP\Share\IManager::class);
2238
+    }
2239
+
2240
+    /**
2241
+     * @return \OCP\Collaboration\Collaborators\ISearch
2242
+     * @deprecated 20.0.0
2243
+     */
2244
+    public function getCollaboratorSearch() {
2245
+        return $this->get(\OCP\Collaboration\Collaborators\ISearch::class);
2246
+    }
2247
+
2248
+    /**
2249
+     * @return \OCP\Collaboration\AutoComplete\IManager
2250
+     * @deprecated 20.0.0
2251
+     */
2252
+    public function getAutoCompleteManager() {
2253
+        return $this->get(IManager::class);
2254
+    }
2255
+
2256
+    /**
2257
+     * Returns the LDAP Provider
2258
+     *
2259
+     * @return \OCP\LDAP\ILDAPProvider
2260
+     * @deprecated 20.0.0
2261
+     */
2262
+    public function getLDAPProvider() {
2263
+        return $this->get('LDAPProvider');
2264
+    }
2265
+
2266
+    /**
2267
+     * @return \OCP\Settings\IManager
2268
+     * @deprecated 20.0.0
2269
+     */
2270
+    public function getSettingsManager() {
2271
+        return $this->get(\OC\Settings\Manager::class);
2272
+    }
2273
+
2274
+    /**
2275
+     * @return \OCP\Files\IAppData
2276
+     * @deprecated 20.0.0 Use get(\OCP\Files\AppData\IAppDataFactory::class)->get($app) instead
2277
+     */
2278
+    public function getAppDataDir($app) {
2279
+        /** @var \OC\Files\AppData\Factory $factory */
2280
+        $factory = $this->get(\OC\Files\AppData\Factory::class);
2281
+        return $factory->get($app);
2282
+    }
2283
+
2284
+    /**
2285
+     * @return \OCP\Lockdown\ILockdownManager
2286
+     * @deprecated 20.0.0
2287
+     */
2288
+    public function getLockdownManager() {
2289
+        return $this->get('LockdownManager');
2290
+    }
2291
+
2292
+    /**
2293
+     * @return \OCP\Federation\ICloudIdManager
2294
+     * @deprecated 20.0.0
2295
+     */
2296
+    public function getCloudIdManager() {
2297
+        return $this->get(ICloudIdManager::class);
2298
+    }
2299
+
2300
+    /**
2301
+     * @return \OCP\GlobalScale\IConfig
2302
+     * @deprecated 20.0.0
2303
+     */
2304
+    public function getGlobalScaleConfig() {
2305
+        return $this->get(IConfig::class);
2306
+    }
2307
+
2308
+    /**
2309
+     * @return \OCP\Federation\ICloudFederationProviderManager
2310
+     * @deprecated 20.0.0
2311
+     */
2312
+    public function getCloudFederationProviderManager() {
2313
+        return $this->get(ICloudFederationProviderManager::class);
2314
+    }
2315
+
2316
+    /**
2317
+     * @return \OCP\Remote\Api\IApiFactory
2318
+     * @deprecated 20.0.0
2319
+     */
2320
+    public function getRemoteApiFactory() {
2321
+        return $this->get(IApiFactory::class);
2322
+    }
2323
+
2324
+    /**
2325
+     * @return \OCP\Federation\ICloudFederationFactory
2326
+     * @deprecated 20.0.0
2327
+     */
2328
+    public function getCloudFederationFactory() {
2329
+        return $this->get(ICloudFederationFactory::class);
2330
+    }
2331
+
2332
+    /**
2333
+     * @return \OCP\Remote\IInstanceFactory
2334
+     * @deprecated 20.0.0
2335
+     */
2336
+    public function getRemoteInstanceFactory() {
2337
+        return $this->get(IInstanceFactory::class);
2338
+    }
2339
+
2340
+    /**
2341
+     * @return IStorageFactory
2342
+     * @deprecated 20.0.0
2343
+     */
2344
+    public function getStorageFactory() {
2345
+        return $this->get(IStorageFactory::class);
2346
+    }
2347
+
2348
+    /**
2349
+     * Get the Preview GeneratorHelper
2350
+     *
2351
+     * @return GeneratorHelper
2352
+     * @since 17.0.0
2353
+     * @deprecated 20.0.0
2354
+     */
2355
+    public function getGeneratorHelper() {
2356
+        return $this->get(\OC\Preview\GeneratorHelper::class);
2357
+    }
2358
+
2359
+    private function registerDeprecatedAlias(string $alias, string $target) {
2360
+        $this->registerService($alias, function (ContainerInterface $container) use ($target, $alias) {
2361
+            try {
2362
+                /** @var LoggerInterface $logger */
2363
+                $logger = $container->get(LoggerInterface::class);
2364
+                $logger->debug('The requested alias "' . $alias . '" is deprecated. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']);
2365
+            } catch (ContainerExceptionInterface $e) {
2366
+                // Could not get logger. Continue
2367
+            }
2368
+
2369
+            return $container->get($target);
2370
+        }, false);
2371
+    }
2372 2372
 }
Please login to merge, or discard this patch.
Spacing   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
 		$this->registerParameter('isCLI', \OC::$CLI);
294 294
 		$this->registerParameter('serverRoot', \OC::$SERVERROOT);
295 295
 
296
-		$this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
296
+		$this->registerService(ContainerInterface::class, function(ContainerInterface $c) {
297 297
 			return $c;
298 298
 		});
299
-		$this->registerService(\OCP\IServerContainer::class, function (ContainerInterface $c) {
299
+		$this->registerService(\OCP\IServerContainer::class, function(ContainerInterface $c) {
300 300
 			return $c;
301 301
 		});
302 302
 
@@ -321,11 +321,11 @@  discard block
 block discarded – undo
321 321
 
322 322
 		$this->registerAlias(IActionFactory::class, ActionFactory::class);
323 323
 
324
-		$this->registerService(View::class, function (Server $c) {
324
+		$this->registerService(View::class, function(Server $c) {
325 325
 			return new View();
326 326
 		}, false);
327 327
 
328
-		$this->registerService(IPreview::class, function (ContainerInterface $c) {
328
+		$this->registerService(IPreview::class, function(ContainerInterface $c) {
329 329
 			return new PreviewManager(
330 330
 				$c->get(\OCP\IConfig::class),
331 331
 				$c->get(IRootFolder::class),
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 		/** @deprecated 19.0.0 */
346 346
 		$this->registerDeprecatedAlias('PreviewManager', IPreview::class);
347 347
 
348
-		$this->registerService(\OC\Preview\Watcher::class, function (ContainerInterface $c) {
348
+		$this->registerService(\OC\Preview\Watcher::class, function(ContainerInterface $c) {
349 349
 			return new \OC\Preview\Watcher(
350 350
 				new \OC\Preview\Storage\Root(
351 351
 					$c->get(IRootFolder::class),
@@ -354,11 +354,11 @@  discard block
 block discarded – undo
354 354
 			);
355 355
 		});
356 356
 
357
-		$this->registerService(IProfiler::class, function (Server $c) {
357
+		$this->registerService(IProfiler::class, function(Server $c) {
358 358
 			return new Profiler($c->get(SystemConfig::class));
359 359
 		});
360 360
 
361
-		$this->registerService(\OCP\Encryption\IManager::class, function (Server $c): Encryption\Manager {
361
+		$this->registerService(\OCP\Encryption\IManager::class, function(Server $c): Encryption\Manager {
362 362
 			$view = new View();
363 363
 			$util = new Encryption\Util(
364 364
 				$view,
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 
381 381
 		/** @deprecated 21.0.0 */
382 382
 		$this->registerDeprecatedAlias('EncryptionFileHelper', IFile::class);
383
-		$this->registerService(IFile::class, function (ContainerInterface $c) {
383
+		$this->registerService(IFile::class, function(ContainerInterface $c) {
384 384
 			$util = new Encryption\Util(
385 385
 				new View(),
386 386
 				$c->get(IUserManager::class),
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 
397 397
 		/** @deprecated 21.0.0 */
398 398
 		$this->registerDeprecatedAlias('EncryptionKeyStorage', IStorage::class);
399
-		$this->registerService(IStorage::class, function (ContainerInterface $c) {
399
+		$this->registerService(IStorage::class, function(ContainerInterface $c) {
400 400
 			$view = new View();
401 401
 			$util = new Encryption\Util(
402 402
 				$view,
@@ -419,22 +419,22 @@  discard block
 block discarded – undo
419 419
 		/** @deprecated 19.0.0 */
420 420
 		$this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class);
421 421
 
422
-		$this->registerService('SystemTagManagerFactory', function (ContainerInterface $c) {
422
+		$this->registerService('SystemTagManagerFactory', function(ContainerInterface $c) {
423 423
 			/** @var \OCP\IConfig $config */
424 424
 			$config = $c->get(\OCP\IConfig::class);
425 425
 			$factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
426 426
 			return new $factoryClass($this);
427 427
 		});
428
-		$this->registerService(ISystemTagManager::class, function (ContainerInterface $c) {
428
+		$this->registerService(ISystemTagManager::class, function(ContainerInterface $c) {
429 429
 			return $c->get('SystemTagManagerFactory')->getManager();
430 430
 		});
431 431
 		/** @deprecated 19.0.0 */
432 432
 		$this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class);
433 433
 
434
-		$this->registerService(ISystemTagObjectMapper::class, function (ContainerInterface $c) {
434
+		$this->registerService(ISystemTagObjectMapper::class, function(ContainerInterface $c) {
435 435
 			return $c->get('SystemTagManagerFactory')->getObjectMapper();
436 436
 		});
437
-		$this->registerService('RootFolder', function (ContainerInterface $c) {
437
+		$this->registerService('RootFolder', function(ContainerInterface $c) {
438 438
 			$manager = \OC\Files\Filesystem::getMountManager(null);
439 439
 			$view = new View();
440 440
 			$root = new Root(
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 
456 456
 			return $root;
457 457
 		});
458
-		$this->registerService(HookConnector::class, function (ContainerInterface $c) {
458
+		$this->registerService(HookConnector::class, function(ContainerInterface $c) {
459 459
 			return new HookConnector(
460 460
 				$c->get(IRootFolder::class),
461 461
 				new View(),
@@ -467,8 +467,8 @@  discard block
 block discarded – undo
467 467
 		/** @deprecated 19.0.0 */
468 468
 		$this->registerDeprecatedAlias('SystemTagObjectMapper', ISystemTagObjectMapper::class);
469 469
 
470
-		$this->registerService(IRootFolder::class, function (ContainerInterface $c) {
471
-			return new LazyRoot(function () use ($c) {
470
+		$this->registerService(IRootFolder::class, function(ContainerInterface $c) {
471
+			return new LazyRoot(function() use ($c) {
472 472
 				return $c->get('RootFolder');
473 473
 			});
474 474
 		});
@@ -479,52 +479,52 @@  discard block
 block discarded – undo
479 479
 		$this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class);
480 480
 		$this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
481 481
 
482
-		$this->registerService(DisplayNameCache::class, function (ContainerInterface $c) {
482
+		$this->registerService(DisplayNameCache::class, function(ContainerInterface $c) {
483 483
 			return $c->get(\OC\User\Manager::class)->getDisplayNameCache();
484 484
 		});
485 485
 
486
-		$this->registerService(\OCP\IGroupManager::class, function (ContainerInterface $c) {
486
+		$this->registerService(\OCP\IGroupManager::class, function(ContainerInterface $c) {
487 487
 			$groupManager = new \OC\Group\Manager(
488 488
 				$this->get(IUserManager::class),
489 489
 				$c->get(SymfonyAdapter::class),
490 490
 				$this->get(LoggerInterface::class)
491 491
 			);
492
-			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
492
+			$groupManager->listen('\OC\Group', 'preCreate', function($gid) {
493 493
 				/** @var IEventDispatcher $dispatcher */
494 494
 				$dispatcher = $this->get(IEventDispatcher::class);
495 495
 				$dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid));
496 496
 			});
497
-			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) {
497
+			$groupManager->listen('\OC\Group', 'postCreate', function(\OC\Group\Group $group) {
498 498
 				/** @var IEventDispatcher $dispatcher */
499 499
 				$dispatcher = $this->get(IEventDispatcher::class);
500 500
 				$dispatcher->dispatchTyped(new GroupCreatedEvent($group));
501 501
 			});
502
-			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
502
+			$groupManager->listen('\OC\Group', 'preDelete', function(\OC\Group\Group $group) {
503 503
 				/** @var IEventDispatcher $dispatcher */
504 504
 				$dispatcher = $this->get(IEventDispatcher::class);
505 505
 				$dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group));
506 506
 			});
507
-			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
507
+			$groupManager->listen('\OC\Group', 'postDelete', function(\OC\Group\Group $group) {
508 508
 				/** @var IEventDispatcher $dispatcher */
509 509
 				$dispatcher = $this->get(IEventDispatcher::class);
510 510
 				$dispatcher->dispatchTyped(new GroupDeletedEvent($group));
511 511
 			});
512
-			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
512
+			$groupManager->listen('\OC\Group', 'preAddUser', function(\OC\Group\Group $group, \OC\User\User $user) {
513 513
 				/** @var IEventDispatcher $dispatcher */
514 514
 				$dispatcher = $this->get(IEventDispatcher::class);
515 515
 				$dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user));
516 516
 			});
517
-			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
517
+			$groupManager->listen('\OC\Group', 'postAddUser', function(\OC\Group\Group $group, \OC\User\User $user) {
518 518
 				/** @var IEventDispatcher $dispatcher */
519 519
 				$dispatcher = $this->get(IEventDispatcher::class);
520 520
 				$dispatcher->dispatchTyped(new UserAddedEvent($group, $user));
521 521
 			});
522
-			$groupManager->listen('\OC\Group', 'preRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
522
+			$groupManager->listen('\OC\Group', 'preRemoveUser', function(\OC\Group\Group $group, \OC\User\User $user) {
523 523
 				/** @var IEventDispatcher $dispatcher */
524 524
 				$dispatcher = $this->get(IEventDispatcher::class);
525 525
 				$dispatcher->dispatchTyped(new BeforeUserRemovedEvent($group, $user));
526 526
 			});
527
-			$groupManager->listen('\OC\Group', 'postRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
527
+			$groupManager->listen('\OC\Group', 'postRemoveUser', function(\OC\Group\Group $group, \OC\User\User $user) {
528 528
 				/** @var IEventDispatcher $dispatcher */
529 529
 				$dispatcher = $this->get(IEventDispatcher::class);
530 530
 				$dispatcher->dispatchTyped(new UserRemovedEvent($group, $user));
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 		/** @deprecated 19.0.0 */
535 535
 		$this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class);
536 536
 
537
-		$this->registerService(Store::class, function (ContainerInterface $c) {
537
+		$this->registerService(Store::class, function(ContainerInterface $c) {
538 538
 			$session = $c->get(ISession::class);
539 539
 			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
540 540
 				$tokenProvider = $c->get(IProvider::class);
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 		$this->registerAlias(IStore::class, Store::class);
548 548
 		$this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
549 549
 
550
-		$this->registerService(\OC\User\Session::class, function (Server $c) {
550
+		$this->registerService(\OC\User\Session::class, function(Server $c) {
551 551
 			$manager = $c->get(IUserManager::class);
552 552
 			$session = new \OC\Session\Memory('');
553 553
 			$timeFactory = new TimeFactory();
@@ -573,26 +573,26 @@  discard block
 block discarded – undo
573 573
 				$c->get(IEventDispatcher::class)
574 574
 			);
575 575
 			/** @deprecated 21.0.0 use BeforeUserCreatedEvent event with the IEventDispatcher instead */
576
-			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
576
+			$userSession->listen('\OC\User', 'preCreateUser', function($uid, $password) {
577 577
 				\OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]);
578 578
 			});
579 579
 			/** @deprecated 21.0.0 use UserCreatedEvent event with the IEventDispatcher instead */
580
-			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
580
+			$userSession->listen('\OC\User', 'postCreateUser', function($user, $password) {
581 581
 				/** @var \OC\User\User $user */
582 582
 				\OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]);
583 583
 			});
584 584
 			/** @deprecated 21.0.0 use BeforeUserDeletedEvent event with the IEventDispatcher instead */
585
-			$userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) {
585
+			$userSession->listen('\OC\User', 'preDelete', function($user) use ($legacyDispatcher) {
586 586
 				/** @var \OC\User\User $user */
587 587
 				\OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]);
588 588
 				$legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user));
589 589
 			});
590 590
 			/** @deprecated 21.0.0 use UserDeletedEvent event with the IEventDispatcher instead */
591
-			$userSession->listen('\OC\User', 'postDelete', function ($user) {
591
+			$userSession->listen('\OC\User', 'postDelete', function($user) {
592 592
 				/** @var \OC\User\User $user */
593 593
 				\OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]);
594 594
 			});
595
-			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
595
+			$userSession->listen('\OC\User', 'preSetPassword', function($user, $password, $recoveryPassword) {
596 596
 				/** @var \OC\User\User $user */
597 597
 				\OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
598 598
 
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 				$dispatcher = $this->get(IEventDispatcher::class);
601 601
 				$dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword));
602 602
 			});
603
-			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
603
+			$userSession->listen('\OC\User', 'postSetPassword', function($user, $password, $recoveryPassword) {
604 604
 				/** @var \OC\User\User $user */
605 605
 				\OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
606 606
 
@@ -608,14 +608,14 @@  discard block
 block discarded – undo
608 608
 				$dispatcher = $this->get(IEventDispatcher::class);
609 609
 				$dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword));
610 610
 			});
611
-			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
611
+			$userSession->listen('\OC\User', 'preLogin', function($uid, $password) {
612 612
 				\OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]);
613 613
 
614 614
 				/** @var IEventDispatcher $dispatcher */
615 615
 				$dispatcher = $this->get(IEventDispatcher::class);
616 616
 				$dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
617 617
 			});
618
-			$userSession->listen('\OC\User', 'postLogin', function ($user, $loginName, $password, $isTokenLogin) {
618
+			$userSession->listen('\OC\User', 'postLogin', function($user, $loginName, $password, $isTokenLogin) {
619 619
 				/** @var \OC\User\User $user */
620 620
 				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'loginName' => $loginName, 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
621 621
 
@@ -623,12 +623,12 @@  discard block
 block discarded – undo
623 623
 				$dispatcher = $this->get(IEventDispatcher::class);
624 624
 				$dispatcher->dispatchTyped(new UserLoggedInEvent($user, $loginName, $password, $isTokenLogin));
625 625
 			});
626
-			$userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
626
+			$userSession->listen('\OC\User', 'preRememberedLogin', function($uid) {
627 627
 				/** @var IEventDispatcher $dispatcher */
628 628
 				$dispatcher = $this->get(IEventDispatcher::class);
629 629
 				$dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
630 630
 			});
631
-			$userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
631
+			$userSession->listen('\OC\User', 'postRememberedLogin', function($user, $password) {
632 632
 				/** @var \OC\User\User $user */
633 633
 				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]);
634 634
 
@@ -636,19 +636,19 @@  discard block
 block discarded – undo
636 636
 				$dispatcher = $this->get(IEventDispatcher::class);
637 637
 				$dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
638 638
 			});
639
-			$userSession->listen('\OC\User', 'logout', function ($user) {
639
+			$userSession->listen('\OC\User', 'logout', function($user) {
640 640
 				\OC_Hook::emit('OC_User', 'logout', []);
641 641
 
642 642
 				/** @var IEventDispatcher $dispatcher */
643 643
 				$dispatcher = $this->get(IEventDispatcher::class);
644 644
 				$dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
645 645
 			});
646
-			$userSession->listen('\OC\User', 'postLogout', function ($user) {
646
+			$userSession->listen('\OC\User', 'postLogout', function($user) {
647 647
 				/** @var IEventDispatcher $dispatcher */
648 648
 				$dispatcher = $this->get(IEventDispatcher::class);
649 649
 				$dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
650 650
 			});
651
-			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
651
+			$userSession->listen('\OC\User', 'changeUser', function($user, $feature, $value, $oldValue) {
652 652
 				/** @var \OC\User\User $user */
653 653
 				\OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]);
654 654
 
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
 		$this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class);
673 673
 		$this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
674 674
 
675
-		$this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
675
+		$this->registerService(\OC\SystemConfig::class, function($c) use ($config) {
676 676
 			return new \OC\SystemConfig($config);
677 677
 		});
678 678
 		/** @deprecated 19.0.0 */
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
 		$this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class);
683 683
 		$this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
684 684
 
685
-		$this->registerService(IFactory::class, function (Server $c) {
685
+		$this->registerService(IFactory::class, function(Server $c) {
686 686
 			return new \OC\L10N\Factory(
687 687
 				$c->get(\OCP\IConfig::class),
688 688
 				$c->getRequest(),
@@ -702,13 +702,13 @@  discard block
 block discarded – undo
702 702
 		/** @deprecated 19.0.0 */
703 703
 		$this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class);
704 704
 
705
-		$this->registerService(ICache::class, function ($c) {
705
+		$this->registerService(ICache::class, function($c) {
706 706
 			return new Cache\File();
707 707
 		});
708 708
 		/** @deprecated 19.0.0 */
709 709
 		$this->registerDeprecatedAlias('UserCache', ICache::class);
710 710
 
711
-		$this->registerService(Factory::class, function (Server $c) {
711
+		$this->registerService(Factory::class, function(Server $c) {
712 712
 			$profiler = $c->get(IProfiler::class);
713 713
 			$arrayCacheFactory = new \OC\Memcache\Factory('', $c->get(LoggerInterface::class),
714 714
 				$profiler,
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 				$version = implode(',', $v);
735 735
 				$instanceId = \OC_Util::getInstanceId();
736 736
 				$path = \OC::$SERVERROOT;
737
-				$prefix = md5($instanceId . '-' . $version . '-' . $path);
737
+				$prefix = md5($instanceId.'-'.$version.'-'.$path);
738 738
 				return new \OC\Memcache\Factory($prefix,
739 739
 					$c->get(LoggerInterface::class),
740 740
 					$profiler,
@@ -750,12 +750,12 @@  discard block
 block discarded – undo
750 750
 		$this->registerDeprecatedAlias('MemCacheFactory', Factory::class);
751 751
 		$this->registerAlias(ICacheFactory::class, Factory::class);
752 752
 
753
-		$this->registerService('RedisFactory', function (Server $c) {
753
+		$this->registerService('RedisFactory', function(Server $c) {
754 754
 			$systemConfig = $c->get(SystemConfig::class);
755 755
 			return new RedisFactory($systemConfig, $c->getEventLogger());
756 756
 		});
757 757
 
758
-		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
758
+		$this->registerService(\OCP\Activity\IManager::class, function(Server $c) {
759 759
 			$l10n = $this->get(IFactory::class)->get('lib');
760 760
 			return new \OC\Activity\Manager(
761 761
 				$c->getRequest(),
@@ -768,14 +768,14 @@  discard block
 block discarded – undo
768 768
 		/** @deprecated 19.0.0 */
769 769
 		$this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class);
770 770
 
771
-		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
771
+		$this->registerService(\OCP\Activity\IEventMerger::class, function(Server $c) {
772 772
 			return new \OC\Activity\EventMerger(
773 773
 				$c->getL10N('lib')
774 774
 			);
775 775
 		});
776 776
 		$this->registerAlias(IValidator::class, Validator::class);
777 777
 
778
-		$this->registerService(AvatarManager::class, function (Server $c) {
778
+		$this->registerService(AvatarManager::class, function(Server $c) {
779 779
 			return new AvatarManager(
780 780
 				$c->get(IUserSession::class),
781 781
 				$c->get(\OC\User\Manager::class),
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
 		$this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
797 797
 		$this->registerAlias(\OCP\Support\Subscription\IAssertion::class, \OC\Support\Subscription\Assertion::class);
798 798
 
799
-		$this->registerService(\OC\Log::class, function (Server $c) {
799
+		$this->registerService(\OC\Log::class, function(Server $c) {
800 800
 			$logType = $c->get(AllConfig::class)->getSystemValue('log_type', 'file');
801 801
 			$factory = new LogFactory($c, $this->get(SystemConfig::class));
802 802
 			$logger = $factory->get($logType);
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
 		// PSR-3 logger
811 811
 		$this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class);
812 812
 
813
-		$this->registerService(ILogFactory::class, function (Server $c) {
813
+		$this->registerService(ILogFactory::class, function(Server $c) {
814 814
 			return new LogFactory($c, $this->get(SystemConfig::class));
815 815
 		});
816 816
 
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
 		/** @deprecated 19.0.0 */
819 819
 		$this->registerDeprecatedAlias('JobList', IJobList::class);
820 820
 
821
-		$this->registerService(Router::class, function (Server $c) {
821
+		$this->registerService(Router::class, function(Server $c) {
822 822
 			$cacheFactory = $c->get(ICacheFactory::class);
823 823
 			$logger = $c->get(LoggerInterface::class);
824 824
 			if ($cacheFactory->isLocalCacheAvailable()) {
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
 		/** @deprecated 19.0.0 */
837 837
 		$this->registerDeprecatedAlias('Search', ISearch::class);
838 838
 
839
-		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
839
+		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function($c) {
840 840
 			$cacheFactory = $c->get(ICacheFactory::class);
841 841
 			if ($cacheFactory->isAvailable()) {
842 842
 				$backend = new \OC\Security\RateLimiting\Backend\MemoryCacheBackend(
@@ -872,7 +872,7 @@  discard block
 block discarded – undo
872 872
 		$this->registerDeprecatedAlias('CredentialsManager', ICredentialsManager::class);
873 873
 
874 874
 		$this->registerAlias(IDBConnection::class, ConnectionAdapter::class);
875
-		$this->registerService(Connection::class, function (Server $c) {
875
+		$this->registerService(Connection::class, function(Server $c) {
876 876
 			$systemConfig = $c->get(SystemConfig::class);
877 877
 			$factory = new \OC\DB\ConnectionFactory($systemConfig);
878 878
 			$type = $systemConfig->getValue('dbtype', 'sqlite');
@@ -888,19 +888,19 @@  discard block
 block discarded – undo
888 888
 
889 889
 		$this->registerAlias(ICertificateManager::class, CertificateManager::class);
890 890
 		$this->registerAlias(IClientService::class, ClientService::class);
891
-		$this->registerService(NegativeDnsCache::class, function (ContainerInterface $c) {
891
+		$this->registerService(NegativeDnsCache::class, function(ContainerInterface $c) {
892 892
 			return new NegativeDnsCache(
893 893
 				$c->get(ICacheFactory::class),
894 894
 			);
895 895
 		});
896 896
 		$this->registerDeprecatedAlias('HttpClientService', IClientService::class);
897
-		$this->registerService(IEventLogger::class, function (ContainerInterface $c) {
897
+		$this->registerService(IEventLogger::class, function(ContainerInterface $c) {
898 898
 			return new EventLogger($c->get(SystemConfig::class), $c->get(LoggerInterface::class), $c->get(Log::class));
899 899
 		});
900 900
 		/** @deprecated 19.0.0 */
901 901
 		$this->registerDeprecatedAlias('EventLogger', IEventLogger::class);
902 902
 
903
-		$this->registerService(IQueryLogger::class, function (ContainerInterface $c) {
903
+		$this->registerService(IQueryLogger::class, function(ContainerInterface $c) {
904 904
 			$queryLogger = new QueryLogger();
905 905
 			if ($c->get(SystemConfig::class)->getValue('debug', false)) {
906 906
 				// In debug mode, module is being activated by default
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
 		$this->registerDeprecatedAlias('TempManager', TempManager::class);
916 916
 		$this->registerAlias(ITempManager::class, TempManager::class);
917 917
 
918
-		$this->registerService(AppManager::class, function (ContainerInterface $c) {
918
+		$this->registerService(AppManager::class, function(ContainerInterface $c) {
919 919
 			// TODO: use auto-wiring
920 920
 			return new \OC\App\AppManager(
921 921
 				$c->get(IUserSession::class),
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
 		/** @deprecated 19.0.0 */
936 936
 		$this->registerDeprecatedAlias('DateTimeZone', IDateTimeZone::class);
937 937
 
938
-		$this->registerService(IDateTimeFormatter::class, function (Server $c) {
938
+		$this->registerService(IDateTimeFormatter::class, function(Server $c) {
939 939
 			$language = $c->get(\OCP\IConfig::class)->getUserValue($c->get(ISession::class)->get('user_id'), 'core', 'lang', null);
940 940
 
941 941
 			return new DateTimeFormatter(
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
 		/** @deprecated 19.0.0 */
947 947
 		$this->registerDeprecatedAlias('DateTimeFormatter', IDateTimeFormatter::class);
948 948
 
949
-		$this->registerService(IUserMountCache::class, function (ContainerInterface $c) {
949
+		$this->registerService(IUserMountCache::class, function(ContainerInterface $c) {
950 950
 			$mountCache = new UserMountCache(
951 951
 				$c->get(IDBConnection::class),
952 952
 				$c->get(IUserManager::class),
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
 		/** @deprecated 19.0.0 */
960 960
 		$this->registerDeprecatedAlias('UserMountCache', IUserMountCache::class);
961 961
 
962
-		$this->registerService(IMountProviderCollection::class, function (ContainerInterface $c) {
962
+		$this->registerService(IMountProviderCollection::class, function(ContainerInterface $c) {
963 963
 			$loader = \OC\Files\Filesystem::getLoader();
964 964
 			$mountCache = $c->get(IUserMountCache::class);
965 965
 			$manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
 
982 982
 		/** @deprecated 20.0.0 */
983 983
 		$this->registerDeprecatedAlias('IniWrapper', IniGetWrapper::class);
984
-		$this->registerService(IBus::class, function (ContainerInterface $c) {
984
+		$this->registerService(IBus::class, function(ContainerInterface $c) {
985 985
 			$busClass = $c->get(\OCP\IConfig::class)->getSystemValue('commandbus');
986 986
 			if ($busClass) {
987 987
 				[$app, $class] = explode('::', $busClass, 2);
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
 		/** @deprecated 19.0.0 */
1004 1004
 		$this->registerDeprecatedAlias('Throttler', Throttler::class);
1005 1005
 		$this->registerAlias(IThrottler::class, Throttler::class);
1006
-		$this->registerService('IntegrityCodeChecker', function (ContainerInterface $c) {
1006
+		$this->registerService('IntegrityCodeChecker', function(ContainerInterface $c) {
1007 1007
 			// IConfig and IAppManager requires a working database. This code
1008 1008
 			// might however be called when ownCloud is not yet setup.
1009 1009
 			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
 				$c->get(IMimeTypeDetector::class)
1025 1025
 			);
1026 1026
 		});
1027
-		$this->registerService(\OCP\IRequest::class, function (ContainerInterface $c) {
1027
+		$this->registerService(\OCP\IRequest::class, function(ContainerInterface $c) {
1028 1028
 			if (isset($this['urlParams'])) {
1029 1029
 				$urlParams = $this['urlParams'];
1030 1030
 			} else {
@@ -1061,14 +1061,14 @@  discard block
 block discarded – undo
1061 1061
 		/** @deprecated 19.0.0 */
1062 1062
 		$this->registerDeprecatedAlias('Request', \OCP\IRequest::class);
1063 1063
 
1064
-		$this->registerService(IRequestId::class, function (ContainerInterface $c): IRequestId {
1064
+		$this->registerService(IRequestId::class, function(ContainerInterface $c): IRequestId {
1065 1065
 			return new RequestId(
1066 1066
 				$_SERVER['UNIQUE_ID'] ?? '',
1067 1067
 				$this->get(ISecureRandom::class)
1068 1068
 			);
1069 1069
 		});
1070 1070
 
1071
-		$this->registerService(IMailer::class, function (Server $c) {
1071
+		$this->registerService(IMailer::class, function(Server $c) {
1072 1072
 			return new Mailer(
1073 1073
 				$c->get(\OCP\IConfig::class),
1074 1074
 				$c->get(LoggerInterface::class),
@@ -1085,7 +1085,7 @@  discard block
 block discarded – undo
1085 1085
 		/** @deprecated 21.0.0 */
1086 1086
 		$this->registerDeprecatedAlias('LDAPProvider', ILDAPProvider::class);
1087 1087
 
1088
-		$this->registerService(ILDAPProviderFactory::class, function (ContainerInterface $c) {
1088
+		$this->registerService(ILDAPProviderFactory::class, function(ContainerInterface $c) {
1089 1089
 			$config = $c->get(\OCP\IConfig::class);
1090 1090
 			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
1091 1091
 			if (is_null($factoryClass) || !class_exists($factoryClass)) {
@@ -1094,11 +1094,11 @@  discard block
 block discarded – undo
1094 1094
 			/** @var \OCP\LDAP\ILDAPProviderFactory $factory */
1095 1095
 			return new $factoryClass($this);
1096 1096
 		});
1097
-		$this->registerService(ILDAPProvider::class, function (ContainerInterface $c) {
1097
+		$this->registerService(ILDAPProvider::class, function(ContainerInterface $c) {
1098 1098
 			$factory = $c->get(ILDAPProviderFactory::class);
1099 1099
 			return $factory->getLDAPProvider();
1100 1100
 		});
1101
-		$this->registerService(ILockingProvider::class, function (ContainerInterface $c) {
1101
+		$this->registerService(ILockingProvider::class, function(ContainerInterface $c) {
1102 1102
 			$ini = $c->get(IniGetWrapper::class);
1103 1103
 			$config = $c->get(\OCP\IConfig::class);
1104 1104
 			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
@@ -1121,12 +1121,12 @@  discard block
 block discarded – undo
1121 1121
 		/** @deprecated 19.0.0 */
1122 1122
 		$this->registerDeprecatedAlias('LockingProvider', ILockingProvider::class);
1123 1123
 
1124
-		$this->registerService(ILockManager::class, function (Server $c): LockManager {
1124
+		$this->registerService(ILockManager::class, function(Server $c): LockManager {
1125 1125
 			return new LockManager();
1126 1126
 		});
1127 1127
 
1128 1128
 		$this->registerAlias(ILockdownManager::class, 'LockdownManager');
1129
-		$this->registerService(SetupManager::class, function ($c) {
1129
+		$this->registerService(SetupManager::class, function($c) {
1130 1130
 			// create the setupmanager through the mount manager to resolve the cyclic dependency
1131 1131
 			return $c->get(\OC\Files\Mount\Manager::class)->getSetupManager();
1132 1132
 		});
@@ -1134,12 +1134,12 @@  discard block
 block discarded – undo
1134 1134
 		/** @deprecated 19.0.0 */
1135 1135
 		$this->registerDeprecatedAlias('MountManager', IMountManager::class);
1136 1136
 
1137
-		$this->registerService(IMimeTypeDetector::class, function (ContainerInterface $c) {
1137
+		$this->registerService(IMimeTypeDetector::class, function(ContainerInterface $c) {
1138 1138
 			return new \OC\Files\Type\Detection(
1139 1139
 				$c->get(IURLGenerator::class),
1140 1140
 				$c->get(LoggerInterface::class),
1141 1141
 				\OC::$configDir,
1142
-				\OC::$SERVERROOT . '/resources/config/'
1142
+				\OC::$SERVERROOT.'/resources/config/'
1143 1143
 			);
1144 1144
 		});
1145 1145
 		/** @deprecated 19.0.0 */
@@ -1148,22 +1148,22 @@  discard block
 block discarded – undo
1148 1148
 		$this->registerAlias(IMimeTypeLoader::class, Loader::class);
1149 1149
 		/** @deprecated 19.0.0 */
1150 1150
 		$this->registerDeprecatedAlias('MimeTypeLoader', IMimeTypeLoader::class);
1151
-		$this->registerService(BundleFetcher::class, function () {
1151
+		$this->registerService(BundleFetcher::class, function() {
1152 1152
 			return new BundleFetcher($this->getL10N('lib'));
1153 1153
 		});
1154 1154
 		$this->registerAlias(\OCP\Notification\IManager::class, Manager::class);
1155 1155
 		/** @deprecated 19.0.0 */
1156 1156
 		$this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class);
1157 1157
 
1158
-		$this->registerService(CapabilitiesManager::class, function (ContainerInterface $c) {
1158
+		$this->registerService(CapabilitiesManager::class, function(ContainerInterface $c) {
1159 1159
 			$manager = new CapabilitiesManager($c->get(LoggerInterface::class));
1160
-			$manager->registerCapability(function () use ($c) {
1160
+			$manager->registerCapability(function() use ($c) {
1161 1161
 				return new \OC\OCS\CoreCapabilities($c->get(\OCP\IConfig::class));
1162 1162
 			});
1163
-			$manager->registerCapability(function () use ($c) {
1163
+			$manager->registerCapability(function() use ($c) {
1164 1164
 				return $c->get(\OC\Security\Bruteforce\Capabilities::class);
1165 1165
 			});
1166
-			$manager->registerCapability(function () use ($c) {
1166
+			$manager->registerCapability(function() use ($c) {
1167 1167
 				return $c->get(MetadataCapabilities::class);
1168 1168
 			});
1169 1169
 			return $manager;
@@ -1171,14 +1171,14 @@  discard block
 block discarded – undo
1171 1171
 		/** @deprecated 19.0.0 */
1172 1172
 		$this->registerDeprecatedAlias('CapabilitiesManager', CapabilitiesManager::class);
1173 1173
 
1174
-		$this->registerService(ICommentsManager::class, function (Server $c) {
1174
+		$this->registerService(ICommentsManager::class, function(Server $c) {
1175 1175
 			$config = $c->get(\OCP\IConfig::class);
1176 1176
 			$factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
1177 1177
 			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
1178 1178
 			$factory = new $factoryClass($this);
1179 1179
 			$manager = $factory->getManager();
1180 1180
 
1181
-			$manager->registerDisplayNameResolver('user', function ($id) use ($c) {
1181
+			$manager->registerDisplayNameResolver('user', function($id) use ($c) {
1182 1182
 				$manager = $c->get(IUserManager::class);
1183 1183
 				$userDisplayName = $manager->getDisplayName($id);
1184 1184
 				if ($userDisplayName === null) {
@@ -1194,7 +1194,7 @@  discard block
 block discarded – undo
1194 1194
 		$this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class);
1195 1195
 
1196 1196
 		$this->registerAlias(\OC_Defaults::class, 'ThemingDefaults');
1197
-		$this->registerService('ThemingDefaults', function (Server $c) {
1197
+		$this->registerService('ThemingDefaults', function(Server $c) {
1198 1198
 			/*
1199 1199
 			 * Dark magic for autoloader.
1200 1200
 			 * If we do a class_exists it will try to load the class which will
@@ -1230,7 +1230,7 @@  discard block
 block discarded – undo
1230 1230
 			}
1231 1231
 			return new \OC_Defaults();
1232 1232
 		});
1233
-		$this->registerService(JSCombiner::class, function (Server $c) {
1233
+		$this->registerService(JSCombiner::class, function(Server $c) {
1234 1234
 			return new JSCombiner(
1235 1235
 				$c->getAppDataDir('js'),
1236 1236
 				$c->get(IURLGenerator::class),
@@ -1244,7 +1244,7 @@  discard block
 block discarded – undo
1244 1244
 		$this->registerDeprecatedAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class);
1245 1245
 		$this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class);
1246 1246
 
1247
-		$this->registerService('CryptoWrapper', function (ContainerInterface $c) {
1247
+		$this->registerService('CryptoWrapper', function(ContainerInterface $c) {
1248 1248
 			// FIXME: Instantiated here due to cyclic dependency
1249 1249
 			$request = new Request(
1250 1250
 				[
@@ -1271,14 +1271,14 @@  discard block
 block discarded – undo
1271 1271
 		});
1272 1272
 		/** @deprecated 19.0.0 */
1273 1273
 		$this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class);
1274
-		$this->registerService(SessionStorage::class, function (ContainerInterface $c) {
1274
+		$this->registerService(SessionStorage::class, function(ContainerInterface $c) {
1275 1275
 			return new SessionStorage($c->get(ISession::class));
1276 1276
 		});
1277 1277
 		$this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class);
1278 1278
 		/** @deprecated 19.0.0 */
1279 1279
 		$this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class);
1280 1280
 
1281
-		$this->registerService(\OCP\Share\IManager::class, function (IServerContainer $c) {
1281
+		$this->registerService(\OCP\Share\IManager::class, function(IServerContainer $c) {
1282 1282
 			$config = $c->get(\OCP\IConfig::class);
1283 1283
 			$factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
1284 1284
 			/** @var \OCP\Share\IProviderFactory $factory */
@@ -1310,7 +1310,7 @@  discard block
 block discarded – undo
1310 1310
 		/** @deprecated 19.0.0 */
1311 1311
 		$this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class);
1312 1312
 
1313
-		$this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) {
1313
+		$this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) {
1314 1314
 			$instance = new Collaboration\Collaborators\Search($c);
1315 1315
 
1316 1316
 			// register default plugins
@@ -1335,27 +1335,27 @@  discard block
 block discarded – undo
1335 1335
 
1336 1336
 		$this->registerDeprecatedAlias('SettingsManager', \OC\Settings\Manager::class);
1337 1337
 		$this->registerAlias(\OCP\Settings\IManager::class, \OC\Settings\Manager::class);
1338
-		$this->registerService(\OC\Files\AppData\Factory::class, function (ContainerInterface $c) {
1338
+		$this->registerService(\OC\Files\AppData\Factory::class, function(ContainerInterface $c) {
1339 1339
 			return new \OC\Files\AppData\Factory(
1340 1340
 				$c->get(IRootFolder::class),
1341 1341
 				$c->get(SystemConfig::class)
1342 1342
 			);
1343 1343
 		});
1344 1344
 
1345
-		$this->registerService('LockdownManager', function (ContainerInterface $c) {
1346
-			return new LockdownManager(function () use ($c) {
1345
+		$this->registerService('LockdownManager', function(ContainerInterface $c) {
1346
+			return new LockdownManager(function() use ($c) {
1347 1347
 				return $c->get(ISession::class);
1348 1348
 			});
1349 1349
 		});
1350 1350
 
1351
-		$this->registerService(\OCP\OCS\IDiscoveryService::class, function (ContainerInterface $c) {
1351
+		$this->registerService(\OCP\OCS\IDiscoveryService::class, function(ContainerInterface $c) {
1352 1352
 			return new DiscoveryService(
1353 1353
 				$c->get(ICacheFactory::class),
1354 1354
 				$c->get(IClientService::class)
1355 1355
 			);
1356 1356
 		});
1357 1357
 
1358
-		$this->registerService(ICloudIdManager::class, function (ContainerInterface $c) {
1358
+		$this->registerService(ICloudIdManager::class, function(ContainerInterface $c) {
1359 1359
 			return new CloudIdManager(
1360 1360
 				$c->get(\OCP\Contacts\IManager::class),
1361 1361
 				$c->get(IURLGenerator::class),
@@ -1367,7 +1367,7 @@  discard block
 block discarded – undo
1367 1367
 
1368 1368
 		$this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class);
1369 1369
 
1370
-		$this->registerService(ICloudFederationProviderManager::class, function (ContainerInterface $c) {
1370
+		$this->registerService(ICloudFederationProviderManager::class, function(ContainerInterface $c) {
1371 1371
 			return new CloudFederationProviderManager(
1372 1372
 				$c->get(IAppManager::class),
1373 1373
 				$c->get(IClientService::class),
@@ -1376,7 +1376,7 @@  discard block
 block discarded – undo
1376 1376
 			);
1377 1377
 		});
1378 1378
 
1379
-		$this->registerService(ICloudFederationFactory::class, function (Server $c) {
1379
+		$this->registerService(ICloudFederationFactory::class, function(Server $c) {
1380 1380
 			return new CloudFederationFactory();
1381 1381
 		});
1382 1382
 
@@ -1388,7 +1388,7 @@  discard block
 block discarded – undo
1388 1388
 		/** @deprecated 19.0.0 */
1389 1389
 		$this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1390 1390
 
1391
-		$this->registerService(Defaults::class, function (Server $c) {
1391
+		$this->registerService(Defaults::class, function(Server $c) {
1392 1392
 			return new Defaults(
1393 1393
 				$c->getThemingDefaults()
1394 1394
 			);
@@ -1396,17 +1396,17 @@  discard block
 block discarded – undo
1396 1396
 		/** @deprecated 19.0.0 */
1397 1397
 		$this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class);
1398 1398
 
1399
-		$this->registerService(\OCP\ISession::class, function (ContainerInterface $c) {
1399
+		$this->registerService(\OCP\ISession::class, function(ContainerInterface $c) {
1400 1400
 			return $c->get(\OCP\IUserSession::class)->getSession();
1401 1401
 		}, false);
1402 1402
 
1403
-		$this->registerService(IShareHelper::class, function (ContainerInterface $c) {
1403
+		$this->registerService(IShareHelper::class, function(ContainerInterface $c) {
1404 1404
 			return new ShareHelper(
1405 1405
 				$c->get(\OCP\Share\IManager::class)
1406 1406
 			);
1407 1407
 		});
1408 1408
 
1409
-		$this->registerService(Installer::class, function (ContainerInterface $c) {
1409
+		$this->registerService(Installer::class, function(ContainerInterface $c) {
1410 1410
 			return new Installer(
1411 1411
 				$c->get(AppFetcher::class),
1412 1412
 				$c->get(IClientService::class),
@@ -1417,11 +1417,11 @@  discard block
 block discarded – undo
1417 1417
 			);
1418 1418
 		});
1419 1419
 
1420
-		$this->registerService(IApiFactory::class, function (ContainerInterface $c) {
1420
+		$this->registerService(IApiFactory::class, function(ContainerInterface $c) {
1421 1421
 			return new ApiFactory($c->get(IClientService::class));
1422 1422
 		});
1423 1423
 
1424
-		$this->registerService(IInstanceFactory::class, function (ContainerInterface $c) {
1424
+		$this->registerService(IInstanceFactory::class, function(ContainerInterface $c) {
1425 1425
 			$memcacheFactory = $c->get(ICacheFactory::class);
1426 1426
 			return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->get(IClientService::class));
1427 1427
 		});
@@ -2357,11 +2357,11 @@  discard block
 block discarded – undo
2357 2357
 	}
2358 2358
 
2359 2359
 	private function registerDeprecatedAlias(string $alias, string $target) {
2360
-		$this->registerService($alias, function (ContainerInterface $container) use ($target, $alias) {
2360
+		$this->registerService($alias, function(ContainerInterface $container) use ($target, $alias) {
2361 2361
 			try {
2362 2362
 				/** @var LoggerInterface $logger */
2363 2363
 				$logger = $container->get(LoggerInterface::class);
2364
-				$logger->debug('The requested alias "' . $alias . '" is deprecated. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']);
2364
+				$logger->debug('The requested alias "'.$alias.'" is deprecated. Please request "'.$target.'" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']);
2365 2365
 			} catch (ContainerExceptionInterface $e) {
2366 2366
 				// Could not get logger. Continue
2367 2367
 			}
Please login to merge, or discard this patch.
lib/private/Net/HostnameClassifier.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -37,38 +37,38 @@
 block discarded – undo
37 37
  * @internal
38 38
  */
39 39
 class HostnameClassifier {
40
-	private const LOCAL_TOPLEVEL_DOMAINS = [
41
-		'local',
42
-		'localhost',
43
-		'intranet',
44
-		'internal',
45
-		'private',
46
-		'corp',
47
-		'home',
48
-		'lan',
49
-	];
40
+    private const LOCAL_TOPLEVEL_DOMAINS = [
41
+        'local',
42
+        'localhost',
43
+        'intranet',
44
+        'internal',
45
+        'private',
46
+        'corp',
47
+        'home',
48
+        'lan',
49
+    ];
50 50
 
51
-	/**
52
-	 * Check host identifier for local hostname
53
-	 *
54
-	 * IP addresses are not considered local. Use the IpAddressClassifier for those.
55
-	 *
56
-	 * @param string $hostname
57
-	 *
58
-	 * @return bool
59
-	 */
60
-	public function isLocalHostname(string $hostname): bool {
61
-		// Disallow local network top-level domains from RFC 6762
62
-		$topLevelDomain = substr((strrchr($hostname, '.') ?: ''), 1);
63
-		if (in_array($topLevelDomain, self::LOCAL_TOPLEVEL_DOMAINS)) {
64
-			return true;
65
-		}
51
+    /**
52
+     * Check host identifier for local hostname
53
+     *
54
+     * IP addresses are not considered local. Use the IpAddressClassifier for those.
55
+     *
56
+     * @param string $hostname
57
+     *
58
+     * @return bool
59
+     */
60
+    public function isLocalHostname(string $hostname): bool {
61
+        // Disallow local network top-level domains from RFC 6762
62
+        $topLevelDomain = substr((strrchr($hostname, '.') ?: ''), 1);
63
+        if (in_array($topLevelDomain, self::LOCAL_TOPLEVEL_DOMAINS)) {
64
+            return true;
65
+        }
66 66
 
67
-		// Disallow hostname only
68
-		if (substr_count($hostname, '.') === 0 && !filter_var($hostname, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
69
-			return true;
70
-		}
67
+        // Disallow hostname only
68
+        if (substr_count($hostname, '.') === 0 && !filter_var($hostname, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
69
+            return true;
70
+        }
71 71
 
72
-		return false;
73
-	}
72
+        return false;
73
+    }
74 74
 }
Please login to merge, or discard this patch.
lib/private/Net/IpAddressClassifier.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -37,45 +37,45 @@
 block discarded – undo
37 37
  * @internal
38 38
  */
39 39
 class IpAddressClassifier {
40
-	private const LOCAL_ADDRESS_RANGES = [
41
-		'100.64.0.0/10', // See RFC 6598
42
-		'192.0.0.0/24', // See RFC 6890
43
-	];
40
+    private const LOCAL_ADDRESS_RANGES = [
41
+        '100.64.0.0/10', // See RFC 6598
42
+        '192.0.0.0/24', // See RFC 6890
43
+    ];
44 44
 
45
-	/**
46
-	 * Check host identifier for local IPv4 and IPv6 address ranges
47
-	 *
48
-	 * Hostnames are not considered local. Use the HostnameClassifier for those.
49
-	 *
50
-	 * @param string $ip
51
-	 *
52
-	 * @return bool
53
-	 */
54
-	public function isLocalAddress(string $ip): bool {
55
-		$parsedIp = Factory::parseAddressString(
56
-			$ip,
57
-			ParseStringFlag::IPV4_MAYBE_NON_DECIMAL | ParseStringFlag::IPV4ADDRESS_MAYBE_NON_QUAD_DOTTED
58
-		);
59
-		if ($parsedIp === null) {
60
-			/* Not an IP */
61
-			return false;
62
-		}
63
-		/* Replace by normalized form */
64
-		if ($parsedIp instanceof IPv6) {
65
-			$ip = (string)($parsedIp->toIPv4() ?? $parsedIp);
66
-		} else {
67
-			$ip = (string)$parsedIp;
68
-		}
45
+    /**
46
+     * Check host identifier for local IPv4 and IPv6 address ranges
47
+     *
48
+     * Hostnames are not considered local. Use the HostnameClassifier for those.
49
+     *
50
+     * @param string $ip
51
+     *
52
+     * @return bool
53
+     */
54
+    public function isLocalAddress(string $ip): bool {
55
+        $parsedIp = Factory::parseAddressString(
56
+            $ip,
57
+            ParseStringFlag::IPV4_MAYBE_NON_DECIMAL | ParseStringFlag::IPV4ADDRESS_MAYBE_NON_QUAD_DOTTED
58
+        );
59
+        if ($parsedIp === null) {
60
+            /* Not an IP */
61
+            return false;
62
+        }
63
+        /* Replace by normalized form */
64
+        if ($parsedIp instanceof IPv6) {
65
+            $ip = (string)($parsedIp->toIPv4() ?? $parsedIp);
66
+        } else {
67
+            $ip = (string)$parsedIp;
68
+        }
69 69
 
70
-		if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
71
-			/* Range address */
72
-			return true;
73
-		}
74
-		if (IpUtils::checkIp($ip, self::LOCAL_ADDRESS_RANGES)) {
75
-			/* Within local range */
76
-			return true;
77
-		}
70
+        if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
71
+            /* Range address */
72
+            return true;
73
+        }
74
+        if (IpUtils::checkIp($ip, self::LOCAL_ADDRESS_RANGES)) {
75
+            /* Within local range */
76
+            return true;
77
+        }
78 78
 
79
-		return false;
80
-	}
79
+        return false;
80
+    }
81 81
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,9 +62,9 @@
 block discarded – undo
62 62
 		}
63 63
 		/* Replace by normalized form */
64 64
 		if ($parsedIp instanceof IPv6) {
65
-			$ip = (string)($parsedIp->toIPv4() ?? $parsedIp);
65
+			$ip = (string) ($parsedIp->toIPv4() ?? $parsedIp);
66 66
 		} else {
67
-			$ip = (string)$parsedIp;
67
+			$ip = (string) $parsedIp;
68 68
 		}
69 69
 
70 70
 		if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
Please login to merge, or discard this patch.
lib/private/Http/Client/Client.php 1 patch
Indentation   +354 added lines, -354 removed lines patch added patch discarded remove patch
@@ -49,358 +49,358 @@
 block discarded – undo
49 49
  * @package OC\Http
50 50
  */
51 51
 class Client implements IClient {
52
-	/** @var GuzzleClient */
53
-	private $client;
54
-	/** @var IConfig */
55
-	private $config;
56
-	/** @var ICertificateManager */
57
-	private $certificateManager;
58
-	private IRemoteHostValidator $remoteHostValidator;
59
-
60
-	public function __construct(
61
-		IConfig $config,
62
-		ICertificateManager $certificateManager,
63
-		GuzzleClient $client,
64
-		IRemoteHostValidator $remoteHostValidator
65
-	) {
66
-		$this->config = $config;
67
-		$this->client = $client;
68
-		$this->certificateManager = $certificateManager;
69
-		$this->remoteHostValidator = $remoteHostValidator;
70
-	}
71
-
72
-	private function buildRequestOptions(array $options): array {
73
-		$proxy = $this->getProxyUri();
74
-
75
-		$defaults = [
76
-			RequestOptions::VERIFY => $this->getCertBundle(),
77
-			RequestOptions::TIMEOUT => 30,
78
-		];
79
-
80
-		$options['nextcloud']['allow_local_address'] = $this->isLocalAddressAllowed($options);
81
-		if ($options['nextcloud']['allow_local_address'] === false) {
82
-			$onRedirectFunction = function (
83
-				\Psr\Http\Message\RequestInterface $request,
84
-				\Psr\Http\Message\ResponseInterface $response,
85
-				\Psr\Http\Message\UriInterface $uri
86
-			) use ($options) {
87
-				$this->preventLocalAddress($uri->__toString(), $options);
88
-			};
89
-
90
-			$defaults[RequestOptions::ALLOW_REDIRECTS] = [
91
-				'on_redirect' => $onRedirectFunction
92
-			];
93
-		}
94
-
95
-		// Only add RequestOptions::PROXY if Nextcloud is explicitly
96
-		// configured to use a proxy. This is needed in order not to override
97
-		// Guzzle default values.
98
-		if ($proxy !== null) {
99
-			$defaults[RequestOptions::PROXY] = $proxy;
100
-		}
101
-
102
-		$options = array_merge($defaults, $options);
103
-
104
-		if (!isset($options[RequestOptions::HEADERS]['User-Agent'])) {
105
-			$options[RequestOptions::HEADERS]['User-Agent'] = 'Nextcloud Server Crawler';
106
-		}
107
-
108
-		if (!isset($options[RequestOptions::HEADERS]['Accept-Encoding'])) {
109
-			$options[RequestOptions::HEADERS]['Accept-Encoding'] = 'gzip';
110
-		}
111
-
112
-		// Fallback for save_to
113
-		if (isset($options['save_to'])) {
114
-			$options['sink'] = $options['save_to'];
115
-			unset($options['save_to']);
116
-		}
117
-
118
-		return $options;
119
-	}
120
-
121
-	private function getCertBundle(): string {
122
-		// If the instance is not yet setup we need to use the static path as
123
-		// $this->certificateManager->getAbsoluteBundlePath() tries to instantiate
124
-		// a view
125
-		if ($this->config->getSystemValue('installed', false) === false) {
126
-			return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
127
-		}
128
-
129
-		return $this->certificateManager->getAbsoluteBundlePath();
130
-	}
131
-
132
-	/**
133
-	 * Returns a null or an associative array specifying the proxy URI for
134
-	 * 'http' and 'https' schemes, in addition to a 'no' key value pair
135
-	 * providing a list of host names that should not be proxied to.
136
-	 *
137
-	 * @return array|null
138
-	 *
139
-	 * The return array looks like:
140
-	 * [
141
-	 *   'http' => 'username:[email protected]',
142
-	 *   'https' => 'username:[email protected]',
143
-	 *   'no' => ['foo.com', 'bar.com']
144
-	 * ]
145
-	 *
146
-	 */
147
-	private function getProxyUri(): ?array {
148
-		$proxyHost = $this->config->getSystemValue('proxy', '');
149
-
150
-		if ($proxyHost === '' || $proxyHost === null) {
151
-			return null;
152
-		}
153
-
154
-		$proxyUserPwd = $this->config->getSystemValue('proxyuserpwd', '');
155
-		if ($proxyUserPwd !== '' && $proxyUserPwd !== null) {
156
-			$proxyHost = $proxyUserPwd . '@' . $proxyHost;
157
-		}
158
-
159
-		$proxy = [
160
-			'http' => $proxyHost,
161
-			'https' => $proxyHost,
162
-		];
163
-
164
-		$proxyExclude = $this->config->getSystemValue('proxyexclude', []);
165
-		if ($proxyExclude !== [] && $proxyExclude !== null) {
166
-			$proxy['no'] = $proxyExclude;
167
-		}
168
-
169
-		return $proxy;
170
-	}
171
-
172
-	private function isLocalAddressAllowed(array $options) : bool {
173
-		if (($options['nextcloud']['allow_local_address'] ?? false) ||
174
-			$this->config->getSystemValueBool('allow_local_remote_servers', false)) {
175
-			return true;
176
-		}
177
-
178
-		return false;
179
-	}
180
-
181
-	protected function preventLocalAddress(string $uri, array $options): void {
182
-		if ($this->isLocalAddressAllowed($options)) {
183
-			return;
184
-		}
185
-
186
-		$host = parse_url($uri, PHP_URL_HOST);
187
-		if ($host === false || $host === null) {
188
-			throw new LocalServerException('Could not detect any host');
189
-		}
190
-		if (!$this->remoteHostValidator->isValid($host)) {
191
-			throw new LocalServerException('Host violates local access rules');
192
-		}
193
-	}
194
-
195
-	/**
196
-	 * Sends a GET request
197
-	 *
198
-	 * @param string $uri
199
-	 * @param array $options Array such as
200
-	 *              'query' => [
201
-	 *                  'field' => 'abc',
202
-	 *                  'other_field' => '123',
203
-	 *                  'file_name' => fopen('/path/to/file', 'r'),
204
-	 *              ],
205
-	 *              'headers' => [
206
-	 *                  'foo' => 'bar',
207
-	 *              ],
208
-	 *              'cookies' => ['
209
-	 *                  'foo' => 'bar',
210
-	 *              ],
211
-	 *              'allow_redirects' => [
212
-	 *                   'max'       => 10,  // allow at most 10 redirects.
213
-	 *                   'strict'    => true,     // use "strict" RFC compliant redirects.
214
-	 *                   'referer'   => true,     // add a Referer header
215
-	 *                   'protocols' => ['https'] // only allow https URLs
216
-	 *              ],
217
-	 *              'sink' => '/path/to/file', // save to a file or a stream
218
-	 *              'verify' => true, // bool or string to CA file
219
-	 *              'debug' => true,
220
-	 *              'timeout' => 5,
221
-	 * @return IResponse
222
-	 * @throws \Exception If the request could not get completed
223
-	 */
224
-	public function get(string $uri, array $options = []): IResponse {
225
-		$this->preventLocalAddress($uri, $options);
226
-		$response = $this->client->request('get', $uri, $this->buildRequestOptions($options));
227
-		$isStream = isset($options['stream']) && $options['stream'];
228
-		return new Response($response, $isStream);
229
-	}
230
-
231
-	/**
232
-	 * Sends a HEAD request
233
-	 *
234
-	 * @param string $uri
235
-	 * @param array $options Array such as
236
-	 *              'headers' => [
237
-	 *                  'foo' => 'bar',
238
-	 *              ],
239
-	 *              'cookies' => ['
240
-	 *                  'foo' => 'bar',
241
-	 *              ],
242
-	 *              'allow_redirects' => [
243
-	 *                   'max'       => 10,  // allow at most 10 redirects.
244
-	 *                   'strict'    => true,     // use "strict" RFC compliant redirects.
245
-	 *                   'referer'   => true,     // add a Referer header
246
-	 *                   'protocols' => ['https'] // only allow https URLs
247
-	 *              ],
248
-	 *              'sink' => '/path/to/file', // save to a file or a stream
249
-	 *              'verify' => true, // bool or string to CA file
250
-	 *              'debug' => true,
251
-	 *              'timeout' => 5,
252
-	 * @return IResponse
253
-	 * @throws \Exception If the request could not get completed
254
-	 */
255
-	public function head(string $uri, array $options = []): IResponse {
256
-		$this->preventLocalAddress($uri, $options);
257
-		$response = $this->client->request('head', $uri, $this->buildRequestOptions($options));
258
-		return new Response($response);
259
-	}
260
-
261
-	/**
262
-	 * Sends a POST request
263
-	 *
264
-	 * @param string $uri
265
-	 * @param array $options Array such as
266
-	 *              'body' => [
267
-	 *                  'field' => 'abc',
268
-	 *                  'other_field' => '123',
269
-	 *                  'file_name' => fopen('/path/to/file', 'r'),
270
-	 *              ],
271
-	 *              'headers' => [
272
-	 *                  'foo' => 'bar',
273
-	 *              ],
274
-	 *              'cookies' => ['
275
-	 *                  'foo' => 'bar',
276
-	 *              ],
277
-	 *              'allow_redirects' => [
278
-	 *                   'max'       => 10,  // allow at most 10 redirects.
279
-	 *                   'strict'    => true,     // use "strict" RFC compliant redirects.
280
-	 *                   'referer'   => true,     // add a Referer header
281
-	 *                   'protocols' => ['https'] // only allow https URLs
282
-	 *              ],
283
-	 *              'sink' => '/path/to/file', // save to a file or a stream
284
-	 *              'verify' => true, // bool or string to CA file
285
-	 *              'debug' => true,
286
-	 *              'timeout' => 5,
287
-	 * @return IResponse
288
-	 * @throws \Exception If the request could not get completed
289
-	 */
290
-	public function post(string $uri, array $options = []): IResponse {
291
-		$this->preventLocalAddress($uri, $options);
292
-
293
-		if (isset($options['body']) && is_array($options['body'])) {
294
-			$options['form_params'] = $options['body'];
295
-			unset($options['body']);
296
-		}
297
-		$response = $this->client->request('post', $uri, $this->buildRequestOptions($options));
298
-		$isStream = isset($options['stream']) && $options['stream'];
299
-		return new Response($response, $isStream);
300
-	}
301
-
302
-	/**
303
-	 * Sends a PUT request
304
-	 *
305
-	 * @param string $uri
306
-	 * @param array $options Array such as
307
-	 *              'body' => [
308
-	 *                  'field' => 'abc',
309
-	 *                  'other_field' => '123',
310
-	 *                  'file_name' => fopen('/path/to/file', 'r'),
311
-	 *              ],
312
-	 *              'headers' => [
313
-	 *                  'foo' => 'bar',
314
-	 *              ],
315
-	 *              'cookies' => ['
316
-	 *                  'foo' => 'bar',
317
-	 *              ],
318
-	 *              'allow_redirects' => [
319
-	 *                   'max'       => 10,  // allow at most 10 redirects.
320
-	 *                   'strict'    => true,     // use "strict" RFC compliant redirects.
321
-	 *                   'referer'   => true,     // add a Referer header
322
-	 *                   'protocols' => ['https'] // only allow https URLs
323
-	 *              ],
324
-	 *              'sink' => '/path/to/file', // save to a file or a stream
325
-	 *              'verify' => true, // bool or string to CA file
326
-	 *              'debug' => true,
327
-	 *              'timeout' => 5,
328
-	 * @return IResponse
329
-	 * @throws \Exception If the request could not get completed
330
-	 */
331
-	public function put(string $uri, array $options = []): IResponse {
332
-		$this->preventLocalAddress($uri, $options);
333
-		$response = $this->client->request('put', $uri, $this->buildRequestOptions($options));
334
-		return new Response($response);
335
-	}
336
-
337
-	/**
338
-	 * Sends a DELETE request
339
-	 *
340
-	 * @param string $uri
341
-	 * @param array $options Array such as
342
-	 *              'body' => [
343
-	 *                  'field' => 'abc',
344
-	 *                  'other_field' => '123',
345
-	 *                  'file_name' => fopen('/path/to/file', 'r'),
346
-	 *              ],
347
-	 *              'headers' => [
348
-	 *                  'foo' => 'bar',
349
-	 *              ],
350
-	 *              'cookies' => ['
351
-	 *                  'foo' => 'bar',
352
-	 *              ],
353
-	 *              'allow_redirects' => [
354
-	 *                   'max'       => 10,  // allow at most 10 redirects.
355
-	 *                   'strict'    => true,     // use "strict" RFC compliant redirects.
356
-	 *                   'referer'   => true,     // add a Referer header
357
-	 *                   'protocols' => ['https'] // only allow https URLs
358
-	 *              ],
359
-	 *              'sink' => '/path/to/file', // save to a file or a stream
360
-	 *              'verify' => true, // bool or string to CA file
361
-	 *              'debug' => true,
362
-	 *              'timeout' => 5,
363
-	 * @return IResponse
364
-	 * @throws \Exception If the request could not get completed
365
-	 */
366
-	public function delete(string $uri, array $options = []): IResponse {
367
-		$this->preventLocalAddress($uri, $options);
368
-		$response = $this->client->request('delete', $uri, $this->buildRequestOptions($options));
369
-		return new Response($response);
370
-	}
371
-
372
-	/**
373
-	 * Sends a options request
374
-	 *
375
-	 * @param string $uri
376
-	 * @param array $options Array such as
377
-	 *              'body' => [
378
-	 *                  'field' => 'abc',
379
-	 *                  'other_field' => '123',
380
-	 *                  'file_name' => fopen('/path/to/file', 'r'),
381
-	 *              ],
382
-	 *              'headers' => [
383
-	 *                  'foo' => 'bar',
384
-	 *              ],
385
-	 *              'cookies' => ['
386
-	 *                  'foo' => 'bar',
387
-	 *              ],
388
-	 *              'allow_redirects' => [
389
-	 *                   'max'       => 10,  // allow at most 10 redirects.
390
-	 *                   'strict'    => true,     // use "strict" RFC compliant redirects.
391
-	 *                   'referer'   => true,     // add a Referer header
392
-	 *                   'protocols' => ['https'] // only allow https URLs
393
-	 *              ],
394
-	 *              'sink' => '/path/to/file', // save to a file or a stream
395
-	 *              'verify' => true, // bool or string to CA file
396
-	 *              'debug' => true,
397
-	 *              'timeout' => 5,
398
-	 * @return IResponse
399
-	 * @throws \Exception If the request could not get completed
400
-	 */
401
-	public function options(string $uri, array $options = []): IResponse {
402
-		$this->preventLocalAddress($uri, $options);
403
-		$response = $this->client->request('options', $uri, $this->buildRequestOptions($options));
404
-		return new Response($response);
405
-	}
52
+    /** @var GuzzleClient */
53
+    private $client;
54
+    /** @var IConfig */
55
+    private $config;
56
+    /** @var ICertificateManager */
57
+    private $certificateManager;
58
+    private IRemoteHostValidator $remoteHostValidator;
59
+
60
+    public function __construct(
61
+        IConfig $config,
62
+        ICertificateManager $certificateManager,
63
+        GuzzleClient $client,
64
+        IRemoteHostValidator $remoteHostValidator
65
+    ) {
66
+        $this->config = $config;
67
+        $this->client = $client;
68
+        $this->certificateManager = $certificateManager;
69
+        $this->remoteHostValidator = $remoteHostValidator;
70
+    }
71
+
72
+    private function buildRequestOptions(array $options): array {
73
+        $proxy = $this->getProxyUri();
74
+
75
+        $defaults = [
76
+            RequestOptions::VERIFY => $this->getCertBundle(),
77
+            RequestOptions::TIMEOUT => 30,
78
+        ];
79
+
80
+        $options['nextcloud']['allow_local_address'] = $this->isLocalAddressAllowed($options);
81
+        if ($options['nextcloud']['allow_local_address'] === false) {
82
+            $onRedirectFunction = function (
83
+                \Psr\Http\Message\RequestInterface $request,
84
+                \Psr\Http\Message\ResponseInterface $response,
85
+                \Psr\Http\Message\UriInterface $uri
86
+            ) use ($options) {
87
+                $this->preventLocalAddress($uri->__toString(), $options);
88
+            };
89
+
90
+            $defaults[RequestOptions::ALLOW_REDIRECTS] = [
91
+                'on_redirect' => $onRedirectFunction
92
+            ];
93
+        }
94
+
95
+        // Only add RequestOptions::PROXY if Nextcloud is explicitly
96
+        // configured to use a proxy. This is needed in order not to override
97
+        // Guzzle default values.
98
+        if ($proxy !== null) {
99
+            $defaults[RequestOptions::PROXY] = $proxy;
100
+        }
101
+
102
+        $options = array_merge($defaults, $options);
103
+
104
+        if (!isset($options[RequestOptions::HEADERS]['User-Agent'])) {
105
+            $options[RequestOptions::HEADERS]['User-Agent'] = 'Nextcloud Server Crawler';
106
+        }
107
+
108
+        if (!isset($options[RequestOptions::HEADERS]['Accept-Encoding'])) {
109
+            $options[RequestOptions::HEADERS]['Accept-Encoding'] = 'gzip';
110
+        }
111
+
112
+        // Fallback for save_to
113
+        if (isset($options['save_to'])) {
114
+            $options['sink'] = $options['save_to'];
115
+            unset($options['save_to']);
116
+        }
117
+
118
+        return $options;
119
+    }
120
+
121
+    private function getCertBundle(): string {
122
+        // If the instance is not yet setup we need to use the static path as
123
+        // $this->certificateManager->getAbsoluteBundlePath() tries to instantiate
124
+        // a view
125
+        if ($this->config->getSystemValue('installed', false) === false) {
126
+            return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
127
+        }
128
+
129
+        return $this->certificateManager->getAbsoluteBundlePath();
130
+    }
131
+
132
+    /**
133
+     * Returns a null or an associative array specifying the proxy URI for
134
+     * 'http' and 'https' schemes, in addition to a 'no' key value pair
135
+     * providing a list of host names that should not be proxied to.
136
+     *
137
+     * @return array|null
138
+     *
139
+     * The return array looks like:
140
+     * [
141
+     *   'http' => 'username:[email protected]',
142
+     *   'https' => 'username:[email protected]',
143
+     *   'no' => ['foo.com', 'bar.com']
144
+     * ]
145
+     *
146
+     */
147
+    private function getProxyUri(): ?array {
148
+        $proxyHost = $this->config->getSystemValue('proxy', '');
149
+
150
+        if ($proxyHost === '' || $proxyHost === null) {
151
+            return null;
152
+        }
153
+
154
+        $proxyUserPwd = $this->config->getSystemValue('proxyuserpwd', '');
155
+        if ($proxyUserPwd !== '' && $proxyUserPwd !== null) {
156
+            $proxyHost = $proxyUserPwd . '@' . $proxyHost;
157
+        }
158
+
159
+        $proxy = [
160
+            'http' => $proxyHost,
161
+            'https' => $proxyHost,
162
+        ];
163
+
164
+        $proxyExclude = $this->config->getSystemValue('proxyexclude', []);
165
+        if ($proxyExclude !== [] && $proxyExclude !== null) {
166
+            $proxy['no'] = $proxyExclude;
167
+        }
168
+
169
+        return $proxy;
170
+    }
171
+
172
+    private function isLocalAddressAllowed(array $options) : bool {
173
+        if (($options['nextcloud']['allow_local_address'] ?? false) ||
174
+            $this->config->getSystemValueBool('allow_local_remote_servers', false)) {
175
+            return true;
176
+        }
177
+
178
+        return false;
179
+    }
180
+
181
+    protected function preventLocalAddress(string $uri, array $options): void {
182
+        if ($this->isLocalAddressAllowed($options)) {
183
+            return;
184
+        }
185
+
186
+        $host = parse_url($uri, PHP_URL_HOST);
187
+        if ($host === false || $host === null) {
188
+            throw new LocalServerException('Could not detect any host');
189
+        }
190
+        if (!$this->remoteHostValidator->isValid($host)) {
191
+            throw new LocalServerException('Host violates local access rules');
192
+        }
193
+    }
194
+
195
+    /**
196
+     * Sends a GET request
197
+     *
198
+     * @param string $uri
199
+     * @param array $options Array such as
200
+     *              'query' => [
201
+     *                  'field' => 'abc',
202
+     *                  'other_field' => '123',
203
+     *                  'file_name' => fopen('/path/to/file', 'r'),
204
+     *              ],
205
+     *              'headers' => [
206
+     *                  'foo' => 'bar',
207
+     *              ],
208
+     *              'cookies' => ['
209
+     *                  'foo' => 'bar',
210
+     *              ],
211
+     *              'allow_redirects' => [
212
+     *                   'max'       => 10,  // allow at most 10 redirects.
213
+     *                   'strict'    => true,     // use "strict" RFC compliant redirects.
214
+     *                   'referer'   => true,     // add a Referer header
215
+     *                   'protocols' => ['https'] // only allow https URLs
216
+     *              ],
217
+     *              'sink' => '/path/to/file', // save to a file or a stream
218
+     *              'verify' => true, // bool or string to CA file
219
+     *              'debug' => true,
220
+     *              'timeout' => 5,
221
+     * @return IResponse
222
+     * @throws \Exception If the request could not get completed
223
+     */
224
+    public function get(string $uri, array $options = []): IResponse {
225
+        $this->preventLocalAddress($uri, $options);
226
+        $response = $this->client->request('get', $uri, $this->buildRequestOptions($options));
227
+        $isStream = isset($options['stream']) && $options['stream'];
228
+        return new Response($response, $isStream);
229
+    }
230
+
231
+    /**
232
+     * Sends a HEAD request
233
+     *
234
+     * @param string $uri
235
+     * @param array $options Array such as
236
+     *              'headers' => [
237
+     *                  'foo' => 'bar',
238
+     *              ],
239
+     *              'cookies' => ['
240
+     *                  'foo' => 'bar',
241
+     *              ],
242
+     *              'allow_redirects' => [
243
+     *                   'max'       => 10,  // allow at most 10 redirects.
244
+     *                   'strict'    => true,     // use "strict" RFC compliant redirects.
245
+     *                   'referer'   => true,     // add a Referer header
246
+     *                   'protocols' => ['https'] // only allow https URLs
247
+     *              ],
248
+     *              'sink' => '/path/to/file', // save to a file or a stream
249
+     *              'verify' => true, // bool or string to CA file
250
+     *              'debug' => true,
251
+     *              'timeout' => 5,
252
+     * @return IResponse
253
+     * @throws \Exception If the request could not get completed
254
+     */
255
+    public function head(string $uri, array $options = []): IResponse {
256
+        $this->preventLocalAddress($uri, $options);
257
+        $response = $this->client->request('head', $uri, $this->buildRequestOptions($options));
258
+        return new Response($response);
259
+    }
260
+
261
+    /**
262
+     * Sends a POST request
263
+     *
264
+     * @param string $uri
265
+     * @param array $options Array such as
266
+     *              'body' => [
267
+     *                  'field' => 'abc',
268
+     *                  'other_field' => '123',
269
+     *                  'file_name' => fopen('/path/to/file', 'r'),
270
+     *              ],
271
+     *              'headers' => [
272
+     *                  'foo' => 'bar',
273
+     *              ],
274
+     *              'cookies' => ['
275
+     *                  'foo' => 'bar',
276
+     *              ],
277
+     *              'allow_redirects' => [
278
+     *                   'max'       => 10,  // allow at most 10 redirects.
279
+     *                   'strict'    => true,     // use "strict" RFC compliant redirects.
280
+     *                   'referer'   => true,     // add a Referer header
281
+     *                   'protocols' => ['https'] // only allow https URLs
282
+     *              ],
283
+     *              'sink' => '/path/to/file', // save to a file or a stream
284
+     *              'verify' => true, // bool or string to CA file
285
+     *              'debug' => true,
286
+     *              'timeout' => 5,
287
+     * @return IResponse
288
+     * @throws \Exception If the request could not get completed
289
+     */
290
+    public function post(string $uri, array $options = []): IResponse {
291
+        $this->preventLocalAddress($uri, $options);
292
+
293
+        if (isset($options['body']) && is_array($options['body'])) {
294
+            $options['form_params'] = $options['body'];
295
+            unset($options['body']);
296
+        }
297
+        $response = $this->client->request('post', $uri, $this->buildRequestOptions($options));
298
+        $isStream = isset($options['stream']) && $options['stream'];
299
+        return new Response($response, $isStream);
300
+    }
301
+
302
+    /**
303
+     * Sends a PUT request
304
+     *
305
+     * @param string $uri
306
+     * @param array $options Array such as
307
+     *              'body' => [
308
+     *                  'field' => 'abc',
309
+     *                  'other_field' => '123',
310
+     *                  'file_name' => fopen('/path/to/file', 'r'),
311
+     *              ],
312
+     *              'headers' => [
313
+     *                  'foo' => 'bar',
314
+     *              ],
315
+     *              'cookies' => ['
316
+     *                  'foo' => 'bar',
317
+     *              ],
318
+     *              'allow_redirects' => [
319
+     *                   'max'       => 10,  // allow at most 10 redirects.
320
+     *                   'strict'    => true,     // use "strict" RFC compliant redirects.
321
+     *                   'referer'   => true,     // add a Referer header
322
+     *                   'protocols' => ['https'] // only allow https URLs
323
+     *              ],
324
+     *              'sink' => '/path/to/file', // save to a file or a stream
325
+     *              'verify' => true, // bool or string to CA file
326
+     *              'debug' => true,
327
+     *              'timeout' => 5,
328
+     * @return IResponse
329
+     * @throws \Exception If the request could not get completed
330
+     */
331
+    public function put(string $uri, array $options = []): IResponse {
332
+        $this->preventLocalAddress($uri, $options);
333
+        $response = $this->client->request('put', $uri, $this->buildRequestOptions($options));
334
+        return new Response($response);
335
+    }
336
+
337
+    /**
338
+     * Sends a DELETE request
339
+     *
340
+     * @param string $uri
341
+     * @param array $options Array such as
342
+     *              'body' => [
343
+     *                  'field' => 'abc',
344
+     *                  'other_field' => '123',
345
+     *                  'file_name' => fopen('/path/to/file', 'r'),
346
+     *              ],
347
+     *              'headers' => [
348
+     *                  'foo' => 'bar',
349
+     *              ],
350
+     *              'cookies' => ['
351
+     *                  'foo' => 'bar',
352
+     *              ],
353
+     *              'allow_redirects' => [
354
+     *                   'max'       => 10,  // allow at most 10 redirects.
355
+     *                   'strict'    => true,     // use "strict" RFC compliant redirects.
356
+     *                   'referer'   => true,     // add a Referer header
357
+     *                   'protocols' => ['https'] // only allow https URLs
358
+     *              ],
359
+     *              'sink' => '/path/to/file', // save to a file or a stream
360
+     *              'verify' => true, // bool or string to CA file
361
+     *              'debug' => true,
362
+     *              'timeout' => 5,
363
+     * @return IResponse
364
+     * @throws \Exception If the request could not get completed
365
+     */
366
+    public function delete(string $uri, array $options = []): IResponse {
367
+        $this->preventLocalAddress($uri, $options);
368
+        $response = $this->client->request('delete', $uri, $this->buildRequestOptions($options));
369
+        return new Response($response);
370
+    }
371
+
372
+    /**
373
+     * Sends a options request
374
+     *
375
+     * @param string $uri
376
+     * @param array $options Array such as
377
+     *              'body' => [
378
+     *                  'field' => 'abc',
379
+     *                  'other_field' => '123',
380
+     *                  'file_name' => fopen('/path/to/file', 'r'),
381
+     *              ],
382
+     *              'headers' => [
383
+     *                  'foo' => 'bar',
384
+     *              ],
385
+     *              'cookies' => ['
386
+     *                  'foo' => 'bar',
387
+     *              ],
388
+     *              'allow_redirects' => [
389
+     *                   'max'       => 10,  // allow at most 10 redirects.
390
+     *                   'strict'    => true,     // use "strict" RFC compliant redirects.
391
+     *                   'referer'   => true,     // add a Referer header
392
+     *                   'protocols' => ['https'] // only allow https URLs
393
+     *              ],
394
+     *              'sink' => '/path/to/file', // save to a file or a stream
395
+     *              'verify' => true, // bool or string to CA file
396
+     *              'debug' => true,
397
+     *              'timeout' => 5,
398
+     * @return IResponse
399
+     * @throws \Exception If the request could not get completed
400
+     */
401
+    public function options(string $uri, array $options = []): IResponse {
402
+        $this->preventLocalAddress($uri, $options);
403
+        $response = $this->client->request('options', $uri, $this->buildRequestOptions($options));
404
+        return new Response($response);
405
+    }
406 406
 }
Please login to merge, or discard this patch.
lib/private/Http/Client/ClientService.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -41,39 +41,39 @@
 block discarded – undo
41 41
  * @package OC\Http
42 42
  */
43 43
 class ClientService implements IClientService {
44
-	/** @var IConfig */
45
-	private $config;
46
-	/** @var ICertificateManager */
47
-	private $certificateManager;
48
-	/** @var DnsPinMiddleware */
49
-	private $dnsPinMiddleware;
50
-	private IRemoteHostValidator $remoteHostValidator;
44
+    /** @var IConfig */
45
+    private $config;
46
+    /** @var ICertificateManager */
47
+    private $certificateManager;
48
+    /** @var DnsPinMiddleware */
49
+    private $dnsPinMiddleware;
50
+    private IRemoteHostValidator $remoteHostValidator;
51 51
 
52
-	public function __construct(IConfig $config,
53
-								ICertificateManager $certificateManager,
54
-								DnsPinMiddleware $dnsPinMiddleware,
55
-								IRemoteHostValidator $remoteHostValidator) {
56
-		$this->config = $config;
57
-		$this->certificateManager = $certificateManager;
58
-		$this->dnsPinMiddleware = $dnsPinMiddleware;
59
-		$this->remoteHostValidator = $remoteHostValidator;
60
-	}
52
+    public function __construct(IConfig $config,
53
+                                ICertificateManager $certificateManager,
54
+                                DnsPinMiddleware $dnsPinMiddleware,
55
+                                IRemoteHostValidator $remoteHostValidator) {
56
+        $this->config = $config;
57
+        $this->certificateManager = $certificateManager;
58
+        $this->dnsPinMiddleware = $dnsPinMiddleware;
59
+        $this->remoteHostValidator = $remoteHostValidator;
60
+    }
61 61
 
62
-	/**
63
-	 * @return Client
64
-	 */
65
-	public function newClient(): IClient {
66
-		$handler = new CurlHandler();
67
-		$stack = HandlerStack::create($handler);
68
-		$stack->push($this->dnsPinMiddleware->addDnsPinning());
62
+    /**
63
+     * @return Client
64
+     */
65
+    public function newClient(): IClient {
66
+        $handler = new CurlHandler();
67
+        $stack = HandlerStack::create($handler);
68
+        $stack->push($this->dnsPinMiddleware->addDnsPinning());
69 69
 
70
-		$client = new GuzzleClient(['handler' => $stack]);
70
+        $client = new GuzzleClient(['handler' => $stack]);
71 71
 
72
-		return new Client(
73
-			$this->config,
74
-			$this->certificateManager,
75
-			$client,
76
-			$this->remoteHostValidator,
77
-		);
78
-	}
72
+        return new Client(
73
+            $this->config,
74
+            $this->certificateManager,
75
+            $client,
76
+            $this->remoteHostValidator,
77
+        );
78
+    }
79 79
 }
Please login to merge, or discard this patch.
lib/private/Http/Client/DnsPinMiddleware.php 1 patch
Indentation   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -30,125 +30,125 @@
 block discarded – undo
30 30
 use Psr\Http\Message\RequestInterface;
31 31
 
32 32
 class DnsPinMiddleware {
33
-	/** @var NegativeDnsCache */
34
-	private $negativeDnsCache;
35
-	private IpAddressClassifier $ipAddressClassifier;
36
-
37
-	public function __construct(
38
-		NegativeDnsCache $negativeDnsCache,
39
-		IpAddressClassifier $ipAddressClassifier
40
-	) {
41
-		$this->negativeDnsCache = $negativeDnsCache;
42
-		$this->ipAddressClassifier = $ipAddressClassifier;
43
-	}
44
-
45
-	/**
46
-	 * Fetch soa record for a target
47
-	 *
48
-	 * @param string $target
49
-	 * @return array|null
50
-	 */
51
-	private function soaRecord(string $target): ?array {
52
-		$labels = explode('.', $target);
53
-
54
-		$top = count($labels) >= 2 ? array_pop($labels) : '';
55
-		$second = array_pop($labels);
56
-
57
-		$hostname = $second . '.' . $top;
58
-		$responses = dns_get_record($hostname, DNS_SOA);
59
-
60
-		if ($responses === false || count($responses) === 0) {
61
-			return null;
62
-		}
63
-
64
-		return reset($responses);
65
-	}
66
-
67
-	private function dnsResolve(string $target, int $recursionCount) : array {
68
-		if ($recursionCount >= 10) {
69
-			return [];
70
-		}
71
-
72
-		$recursionCount++;
73
-		$targetIps = [];
74
-
75
-		$soaDnsEntry = $this->soaRecord($target);
76
-		$dnsNegativeTtl = $soaDnsEntry['minimum-ttl'] ?? null;
77
-
78
-		$dnsTypes = [DNS_A, DNS_AAAA, DNS_CNAME];
79
-		foreach ($dnsTypes as $dnsType) {
80
-			if ($this->negativeDnsCache->isNegativeCached($target, $dnsType)) {
81
-				continue;
82
-			}
83
-
84
-			$dnsResponses = dns_get_record($target, $dnsType);
85
-			$canHaveCnameRecord = true;
86
-			if ($dnsResponses !== false && count($dnsResponses) > 0) {
87
-				foreach ($dnsResponses as $dnsResponse) {
88
-					if (isset($dnsResponse['ip'])) {
89
-						$targetIps[] = $dnsResponse['ip'];
90
-						$canHaveCnameRecord = false;
91
-					} elseif (isset($dnsResponse['ipv6'])) {
92
-						$targetIps[] = $dnsResponse['ipv6'];
93
-						$canHaveCnameRecord = false;
94
-					} elseif (isset($dnsResponse['target']) && $canHaveCnameRecord) {
95
-						$targetIps = array_merge($targetIps, $this->dnsResolve($dnsResponse['target'], $recursionCount));
96
-						$canHaveCnameRecord = true;
97
-					}
98
-				}
99
-			} elseif ($dnsNegativeTtl !== null) {
100
-				$this->negativeDnsCache->setNegativeCacheForDnsType($target, $dnsType, $dnsNegativeTtl);
101
-			}
102
-		}
103
-
104
-		return $targetIps;
105
-	}
106
-
107
-	public function addDnsPinning() {
108
-		return function (callable $handler) {
109
-			return function (
110
-				RequestInterface $request,
111
-				array $options
112
-			) use ($handler) {
113
-				if ($options['nextcloud']['allow_local_address'] === true) {
114
-					return $handler($request, $options);
115
-				}
116
-
117
-				$hostName = (string)$request->getUri()->getHost();
118
-				$port = $request->getUri()->getPort();
119
-
120
-				$ports = [
121
-					'80',
122
-					'443',
123
-				];
124
-
125
-				if ($port !== null) {
126
-					$ports[] = (string)$port;
127
-				}
128
-
129
-				$targetIps = $this->dnsResolve(idn_to_utf8($hostName), 0);
130
-
131
-				$curlResolves = [];
132
-
133
-				foreach ($ports as $port) {
134
-					$curlResolves["$hostName:$port"] = [];
135
-
136
-					foreach ($targetIps as $ip) {
137
-						if (!$this->ipAddressClassifier->isLocalAddress($ip)) {
138
-							// TODO: continue with all non-local IPs?
139
-							throw new LocalServerException('Host violates local access rules');
140
-						}
141
-						$curlResolves["$hostName:$port"][] = $ip;
142
-					}
143
-				}
144
-
145
-				// Coalesce the per-host:port ips back into a comma separated list
146
-				foreach ($curlResolves as $hostport => $ips) {
147
-					$options['curl'][CURLOPT_RESOLVE][] = "$hostport:" . implode(',', $ips);
148
-				}
149
-
150
-				return $handler($request, $options);
151
-			};
152
-		};
153
-	}
33
+    /** @var NegativeDnsCache */
34
+    private $negativeDnsCache;
35
+    private IpAddressClassifier $ipAddressClassifier;
36
+
37
+    public function __construct(
38
+        NegativeDnsCache $negativeDnsCache,
39
+        IpAddressClassifier $ipAddressClassifier
40
+    ) {
41
+        $this->negativeDnsCache = $negativeDnsCache;
42
+        $this->ipAddressClassifier = $ipAddressClassifier;
43
+    }
44
+
45
+    /**
46
+     * Fetch soa record for a target
47
+     *
48
+     * @param string $target
49
+     * @return array|null
50
+     */
51
+    private function soaRecord(string $target): ?array {
52
+        $labels = explode('.', $target);
53
+
54
+        $top = count($labels) >= 2 ? array_pop($labels) : '';
55
+        $second = array_pop($labels);
56
+
57
+        $hostname = $second . '.' . $top;
58
+        $responses = dns_get_record($hostname, DNS_SOA);
59
+
60
+        if ($responses === false || count($responses) === 0) {
61
+            return null;
62
+        }
63
+
64
+        return reset($responses);
65
+    }
66
+
67
+    private function dnsResolve(string $target, int $recursionCount) : array {
68
+        if ($recursionCount >= 10) {
69
+            return [];
70
+        }
71
+
72
+        $recursionCount++;
73
+        $targetIps = [];
74
+
75
+        $soaDnsEntry = $this->soaRecord($target);
76
+        $dnsNegativeTtl = $soaDnsEntry['minimum-ttl'] ?? null;
77
+
78
+        $dnsTypes = [DNS_A, DNS_AAAA, DNS_CNAME];
79
+        foreach ($dnsTypes as $dnsType) {
80
+            if ($this->negativeDnsCache->isNegativeCached($target, $dnsType)) {
81
+                continue;
82
+            }
83
+
84
+            $dnsResponses = dns_get_record($target, $dnsType);
85
+            $canHaveCnameRecord = true;
86
+            if ($dnsResponses !== false && count($dnsResponses) > 0) {
87
+                foreach ($dnsResponses as $dnsResponse) {
88
+                    if (isset($dnsResponse['ip'])) {
89
+                        $targetIps[] = $dnsResponse['ip'];
90
+                        $canHaveCnameRecord = false;
91
+                    } elseif (isset($dnsResponse['ipv6'])) {
92
+                        $targetIps[] = $dnsResponse['ipv6'];
93
+                        $canHaveCnameRecord = false;
94
+                    } elseif (isset($dnsResponse['target']) && $canHaveCnameRecord) {
95
+                        $targetIps = array_merge($targetIps, $this->dnsResolve($dnsResponse['target'], $recursionCount));
96
+                        $canHaveCnameRecord = true;
97
+                    }
98
+                }
99
+            } elseif ($dnsNegativeTtl !== null) {
100
+                $this->negativeDnsCache->setNegativeCacheForDnsType($target, $dnsType, $dnsNegativeTtl);
101
+            }
102
+        }
103
+
104
+        return $targetIps;
105
+    }
106
+
107
+    public function addDnsPinning() {
108
+        return function (callable $handler) {
109
+            return function (
110
+                RequestInterface $request,
111
+                array $options
112
+            ) use ($handler) {
113
+                if ($options['nextcloud']['allow_local_address'] === true) {
114
+                    return $handler($request, $options);
115
+                }
116
+
117
+                $hostName = (string)$request->getUri()->getHost();
118
+                $port = $request->getUri()->getPort();
119
+
120
+                $ports = [
121
+                    '80',
122
+                    '443',
123
+                ];
124
+
125
+                if ($port !== null) {
126
+                    $ports[] = (string)$port;
127
+                }
128
+
129
+                $targetIps = $this->dnsResolve(idn_to_utf8($hostName), 0);
130
+
131
+                $curlResolves = [];
132
+
133
+                foreach ($ports as $port) {
134
+                    $curlResolves["$hostName:$port"] = [];
135
+
136
+                    foreach ($targetIps as $ip) {
137
+                        if (!$this->ipAddressClassifier->isLocalAddress($ip)) {
138
+                            // TODO: continue with all non-local IPs?
139
+                            throw new LocalServerException('Host violates local access rules');
140
+                        }
141
+                        $curlResolves["$hostName:$port"][] = $ip;
142
+                    }
143
+                }
144
+
145
+                // Coalesce the per-host:port ips back into a comma separated list
146
+                foreach ($curlResolves as $hostport => $ips) {
147
+                    $options['curl'][CURLOPT_RESOLVE][] = "$hostport:" . implode(',', $ips);
148
+                }
149
+
150
+                return $handler($request, $options);
151
+            };
152
+        };
153
+    }
154 154
 }
Please login to merge, or discard this patch.
lib/private/Security/RemoteHostValidator.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -39,38 +39,38 @@
 block discarded – undo
39 39
  * @internal
40 40
  */
41 41
 final class RemoteHostValidator implements IRemoteHostValidator {
42
-	private IConfig $config;
43
-	private HostnameClassifier $hostnameClassifier;
44
-	private IpAddressClassifier $ipAddressClassifier;
45
-	private LoggerInterface $logger;
42
+    private IConfig $config;
43
+    private HostnameClassifier $hostnameClassifier;
44
+    private IpAddressClassifier $ipAddressClassifier;
45
+    private LoggerInterface $logger;
46 46
 
47
-	public function __construct(IConfig $config,
48
-								HostnameClassifier $hostnameClassifier,
49
-								IpAddressClassifier $ipAddressClassifier,
50
-								LoggerInterface $logger) {
51
-		$this->config = $config;
52
-		$this->hostnameClassifier = $hostnameClassifier;
53
-		$this->ipAddressClassifier = $ipAddressClassifier;
54
-		$this->logger = $logger;
55
-	}
47
+    public function __construct(IConfig $config,
48
+                                HostnameClassifier $hostnameClassifier,
49
+                                IpAddressClassifier $ipAddressClassifier,
50
+                                LoggerInterface $logger) {
51
+        $this->config = $config;
52
+        $this->hostnameClassifier = $hostnameClassifier;
53
+        $this->ipAddressClassifier = $ipAddressClassifier;
54
+        $this->logger = $logger;
55
+    }
56 56
 
57
-	public function isValid(string $host): bool {
58
-		if ($this->config->getSystemValueBool('allow_local_remote_servers', false)) {
59
-			return true;
60
-		}
57
+    public function isValid(string $host): bool {
58
+        if ($this->config->getSystemValueBool('allow_local_remote_servers', false)) {
59
+            return true;
60
+        }
61 61
 
62
-		$host = idn_to_utf8(strtolower(urldecode($host)));
63
-		// Remove brackets from IPv6 addresses
64
-		if (strpos($host, '[') === 0 && substr($host, -1) === ']') {
65
-			$host = substr($host, 1, -1);
66
-		}
62
+        $host = idn_to_utf8(strtolower(urldecode($host)));
63
+        // Remove brackets from IPv6 addresses
64
+        if (strpos($host, '[') === 0 && substr($host, -1) === ']') {
65
+            $host = substr($host, 1, -1);
66
+        }
67 67
 
68
-		if ($this->hostnameClassifier->isLocalHostname($host)
69
-			|| $this->ipAddressClassifier->isLocalAddress($host)) {
70
-			$this->logger->warning("Host $host was not connected to because it violates local access rules");
71
-			return false;
72
-		}
68
+        if ($this->hostnameClassifier->isLocalHostname($host)
69
+            || $this->ipAddressClassifier->isLocalAddress($host)) {
70
+            $this->logger->warning("Host $host was not connected to because it violates local access rules");
71
+            return false;
72
+        }
73 73
 
74
-		return true;
75
-	}
74
+        return true;
75
+    }
76 76
 }
Please login to merge, or discard this patch.