Server.php 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Bart Visscher <bartv@thisnet.nl>
  7. * @author Bernhard Posselt <dev@bernhard-posselt.com>
  8. * @author Bernhard Reiter <ockham@raz.or.at>
  9. * @author Bjoern Schiessle <bjoern@schiessle.org>
  10. * @author Björn Schießle <bjoern@schiessle.org>
  11. * @author Christopher Schäpers <kondou@ts.unde.re>
  12. * @author Christoph Wurst <christoph@owncloud.com>
  13. * @author Joas Schilling <coding@schilljs.com>
  14. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  15. * @author Lukas Reschke <lukas@statuscode.ch>
  16. * @author Morris Jobke <hey@morrisjobke.de>
  17. * @author Robin Appelman <robin@icewind.nl>
  18. * @author Robin McCorkell <robin@mccorkell.me.uk>
  19. * @author Roeland Jago Douma <roeland@famdouma.nl>
  20. * @author Sander <brantje@gmail.com>
  21. * @author Thomas Müller <thomas.mueller@tmit.eu>
  22. * @author Thomas Tanghus <thomas@tanghus.net>
  23. * @author Vincent Petry <pvince81@owncloud.com>
  24. * @author Roger Szabo <roger.szabo@web.de>
  25. *
  26. * @license AGPL-3.0
  27. *
  28. * This code is free software: you can redistribute it and/or modify
  29. * it under the terms of the GNU Affero General Public License, version 3,
  30. * as published by the Free Software Foundation.
  31. *
  32. * This program is distributed in the hope that it will be useful,
  33. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  34. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  35. * GNU Affero General Public License for more details.
  36. *
  37. * You should have received a copy of the GNU Affero General Public License, version 3,
  38. * along with this program. If not, see <http://www.gnu.org/licenses/>
  39. *
  40. */
  41. namespace OC;
  42. use bantu\IniGetWrapper\IniGetWrapper;
  43. use OC\AppFramework\Http\Request;
  44. use OC\AppFramework\Db\Db;
  45. use OC\AppFramework\Utility\TimeFactory;
  46. use OC\Command\AsyncBus;
  47. use OC\Diagnostics\EventLogger;
  48. use OC\Diagnostics\NullEventLogger;
  49. use OC\Diagnostics\NullQueryLogger;
  50. use OC\Diagnostics\QueryLogger;
  51. use OC\Files\Config\UserMountCache;
  52. use OC\Files\Config\UserMountCacheListener;
  53. use OC\Files\Mount\CacheMountProvider;
  54. use OC\Files\Mount\LocalHomeMountProvider;
  55. use OC\Files\Mount\ObjectHomeMountProvider;
  56. use OC\Files\Node\HookConnector;
  57. use OC\Files\Node\LazyRoot;
  58. use OC\Files\Node\Root;
  59. use OC\Files\View;
  60. use OC\Http\Client\ClientService;
  61. use OC\IntegrityCheck\Checker;
  62. use OC\IntegrityCheck\Helpers\AppLocator;
  63. use OC\IntegrityCheck\Helpers\EnvironmentHelper;
  64. use OC\IntegrityCheck\Helpers\FileAccessHelper;
  65. use OC\Lock\DBLockingProvider;
  66. use OC\Lock\MemcacheLockingProvider;
  67. use OC\Lock\NoopLockingProvider;
  68. use OC\Mail\Mailer;
  69. use OC\Memcache\ArrayCache;
  70. use OC\Notification\Manager;
  71. use OC\Security\Bruteforce\Throttler;
  72. use OC\Security\CertificateManager;
  73. use OC\Security\CSP\ContentSecurityPolicyManager;
  74. use OC\Security\Crypto;
  75. use OC\Security\CSRF\CsrfTokenGenerator;
  76. use OC\Security\CSRF\CsrfTokenManager;
  77. use OC\Security\CSRF\TokenStorage\SessionStorage;
  78. use OC\Security\Hasher;
  79. use OC\Security\CredentialsManager;
  80. use OC\Security\SecureRandom;
  81. use OC\Security\TrustedDomainHelper;
  82. use OC\Session\CryptoWrapper;
  83. use OC\Tagging\TagMapper;
  84. use OCA\Theming\ThemingDefaults;
  85. use OCP\IL10N;
  86. use OCP\IServerContainer;
  87. use OCP\Security\IContentSecurityPolicyManager;
  88. use Symfony\Component\EventDispatcher\EventDispatcher;
  89. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  90. /**
  91. * Class Server
  92. *
  93. * @package OC
  94. *
  95. * TODO: hookup all manager classes
  96. */
  97. class Server extends ServerContainer implements IServerContainer {
  98. /** @var string */
  99. private $webRoot;
  100. /**
  101. * @param string $webRoot
  102. * @param \OC\Config $config
  103. */
  104. public function __construct($webRoot, \OC\Config $config) {
  105. parent::__construct();
  106. $this->webRoot = $webRoot;
  107. $this->registerService('ContactsManager', function ($c) {
  108. return new ContactsManager();
  109. });
  110. $this->registerService('PreviewManager', function (Server $c) {
  111. return new PreviewManager($c->getConfig());
  112. });
  113. $this->registerService('EncryptionManager', function (Server $c) {
  114. $view = new View();
  115. $util = new Encryption\Util(
  116. $view,
  117. $c->getUserManager(),
  118. $c->getGroupManager(),
  119. $c->getConfig()
  120. );
  121. return new Encryption\Manager(
  122. $c->getConfig(),
  123. $c->getLogger(),
  124. $c->getL10N('core'),
  125. new View(),
  126. $util,
  127. new ArrayCache()
  128. );
  129. });
  130. $this->registerService('EncryptionFileHelper', function (Server $c) {
  131. $util = new Encryption\Util(
  132. new View(),
  133. $c->getUserManager(),
  134. $c->getGroupManager(),
  135. $c->getConfig()
  136. );
  137. return new Encryption\File($util);
  138. });
  139. $this->registerService('EncryptionKeyStorage', function (Server $c) {
  140. $view = new View();
  141. $util = new Encryption\Util(
  142. $view,
  143. $c->getUserManager(),
  144. $c->getGroupManager(),
  145. $c->getConfig()
  146. );
  147. return new Encryption\Keys\Storage($view, $util);
  148. });
  149. $this->registerService('TagMapper', function (Server $c) {
  150. return new TagMapper($c->getDatabaseConnection());
  151. });
  152. $this->registerService('TagManager', function (Server $c) {
  153. $tagMapper = $c->query('TagMapper');
  154. return new TagManager($tagMapper, $c->getUserSession());
  155. });
  156. $this->registerService('SystemTagManagerFactory', function (Server $c) {
  157. $config = $c->getConfig();
  158. $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory');
  159. /** @var \OC\SystemTag\ManagerFactory $factory */
  160. $factory = new $factoryClass($this);
  161. return $factory;
  162. });
  163. $this->registerService('SystemTagManager', function (Server $c) {
  164. return $c->query('SystemTagManagerFactory')->getManager();
  165. });
  166. $this->registerService('SystemTagObjectMapper', function (Server $c) {
  167. return $c->query('SystemTagManagerFactory')->getObjectMapper();
  168. });
  169. $this->registerService('RootFolder', function () {
  170. $manager = \OC\Files\Filesystem::getMountManager(null);
  171. $view = new View();
  172. $root = new Root($manager, $view, null);
  173. $connector = new HookConnector($root, $view);
  174. $connector->viewToNode();
  175. return $root;
  176. });
  177. $this->registerService('LazyRootFolder', function(Server $c) {
  178. return new LazyRoot(function() use ($c) {
  179. return $c->query('RootFolder');
  180. });
  181. });
  182. $this->registerService('UserManager', function (Server $c) {
  183. $config = $c->getConfig();
  184. return new \OC\User\Manager($config);
  185. });
  186. $this->registerService('GroupManager', function (Server $c) {
  187. $groupManager = new \OC\Group\Manager($this->getUserManager());
  188. $groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
  189. \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
  190. });
  191. $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) {
  192. \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
  193. });
  194. $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
  195. \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
  196. });
  197. $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
  198. \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
  199. });
  200. $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
  201. \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
  202. });
  203. $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
  204. \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
  205. //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
  206. \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
  207. });
  208. return $groupManager;
  209. });
  210. $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) {
  211. $dbConnection = $c->getDatabaseConnection();
  212. return new Authentication\Token\DefaultTokenMapper($dbConnection);
  213. });
  214. $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) {
  215. $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper');
  216. $crypto = $c->getCrypto();
  217. $config = $c->getConfig();
  218. $logger = $c->getLogger();
  219. $timeFactory = new TimeFactory();
  220. return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory);
  221. });
  222. $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider');
  223. $this->registerService('UserSession', function (Server $c) {
  224. $manager = $c->getUserManager();
  225. $session = new \OC\Session\Memory('');
  226. $timeFactory = new TimeFactory();
  227. // Token providers might require a working database. This code
  228. // might however be called when ownCloud is not yet setup.
  229. if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
  230. $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider');
  231. } else {
  232. $defaultTokenProvider = null;
  233. }
  234. $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig());
  235. $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
  236. \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
  237. });
  238. $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
  239. /** @var $user \OC\User\User */
  240. \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
  241. });
  242. $userSession->listen('\OC\User', 'preDelete', function ($user) {
  243. /** @var $user \OC\User\User */
  244. \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
  245. });
  246. $userSession->listen('\OC\User', 'postDelete', function ($user) {
  247. /** @var $user \OC\User\User */
  248. \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
  249. });
  250. $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
  251. /** @var $user \OC\User\User */
  252. \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
  253. });
  254. $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
  255. /** @var $user \OC\User\User */
  256. \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
  257. });
  258. $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
  259. \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
  260. });
  261. $userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
  262. /** @var $user \OC\User\User */
  263. \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
  264. });
  265. $userSession->listen('\OC\User', 'logout', function () {
  266. \OC_Hook::emit('OC_User', 'logout', array());
  267. });
  268. $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) {
  269. /** @var $user \OC\User\User */
  270. \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value));
  271. });
  272. return $userSession;
  273. });
  274. $this->registerService('\OC\Authentication\TwoFactorAuth\Manager', function (Server $c) {
  275. return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig());
  276. });
  277. $this->registerService('NavigationManager', function ($c) {
  278. return new \OC\NavigationManager();
  279. });
  280. $this->registerService('AllConfig', function (Server $c) {
  281. return new \OC\AllConfig(
  282. $c->getSystemConfig()
  283. );
  284. });
  285. $this->registerService('SystemConfig', function ($c) use ($config) {
  286. return new \OC\SystemConfig($config);
  287. });
  288. $this->registerService('AppConfig', function (Server $c) {
  289. return new \OC\AppConfig($c->getDatabaseConnection());
  290. });
  291. $this->registerService('L10NFactory', function (Server $c) {
  292. return new \OC\L10N\Factory(
  293. $c->getConfig(),
  294. $c->getRequest(),
  295. $c->getUserSession(),
  296. \OC::$SERVERROOT
  297. );
  298. });
  299. $this->registerService('URLGenerator', function (Server $c) {
  300. $config = $c->getConfig();
  301. $cacheFactory = $c->getMemCacheFactory();
  302. return new \OC\URLGenerator(
  303. $config,
  304. $cacheFactory
  305. );
  306. });
  307. $this->registerService('AppHelper', function ($c) {
  308. return new \OC\AppHelper();
  309. });
  310. $this->registerService('UserCache', function ($c) {
  311. return new Cache\File();
  312. });
  313. $this->registerService('MemCacheFactory', function (Server $c) {
  314. $config = $c->getConfig();
  315. if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
  316. $v = \OC_App::getAppVersions();
  317. $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php'));
  318. $version = implode(',', $v);
  319. $instanceId = \OC_Util::getInstanceId();
  320. $path = \OC::$SERVERROOT;
  321. $prefix = md5($instanceId . '-' . $version . '-' . $path);
  322. return new \OC\Memcache\Factory($prefix, $c->getLogger(),
  323. $config->getSystemValue('memcache.local', null),
  324. $config->getSystemValue('memcache.distributed', null),
  325. $config->getSystemValue('memcache.locking', null)
  326. );
  327. }
  328. return new \OC\Memcache\Factory('', $c->getLogger(),
  329. '\\OC\\Memcache\\ArrayCache',
  330. '\\OC\\Memcache\\ArrayCache',
  331. '\\OC\\Memcache\\ArrayCache'
  332. );
  333. });
  334. $this->registerService('RedisFactory', function (Server $c) {
  335. $systemConfig = $c->getSystemConfig();
  336. return new RedisFactory($systemConfig);
  337. });
  338. $this->registerService('ActivityManager', function (Server $c) {
  339. return new \OC\Activity\Manager(
  340. $c->getRequest(),
  341. $c->getUserSession(),
  342. $c->getConfig()
  343. );
  344. });
  345. $this->registerService('AvatarManager', function (Server $c) {
  346. return new AvatarManager(
  347. $c->getUserManager(),
  348. $c->getRootFolder(),
  349. $c->getL10N('lib'),
  350. $c->getLogger(),
  351. $c->getConfig()
  352. );
  353. });
  354. $this->registerService('Logger', function (Server $c) {
  355. $logClass = $c->query('AllConfig')->getSystemValue('log_type', 'file');
  356. // TODO: Drop backwards compatibility for config in the future
  357. $logger = 'OC\\Log\\' . ucfirst($logClass=='owncloud' ? 'file' : $logClass);
  358. call_user_func(array($logger, 'init'));
  359. return new Log($logger);
  360. });
  361. $this->registerService('JobList', function (Server $c) {
  362. $config = $c->getConfig();
  363. return new \OC\BackgroundJob\JobList(
  364. $c->getDatabaseConnection(),
  365. $config,
  366. new TimeFactory()
  367. );
  368. });
  369. $this->registerService('Router', function (Server $c) {
  370. $cacheFactory = $c->getMemCacheFactory();
  371. $logger = $c->getLogger();
  372. if ($cacheFactory->isAvailable()) {
  373. $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger);
  374. } else {
  375. $router = new \OC\Route\Router($logger);
  376. }
  377. return $router;
  378. });
  379. $this->registerService('Search', function ($c) {
  380. return new Search();
  381. });
  382. $this->registerService('SecureRandom', function ($c) {
  383. return new SecureRandom();
  384. });
  385. $this->registerService('Crypto', function (Server $c) {
  386. return new Crypto($c->getConfig(), $c->getSecureRandom());
  387. });
  388. $this->registerService('Hasher', function (Server $c) {
  389. return new Hasher($c->getConfig());
  390. });
  391. $this->registerService('CredentialsManager', function (Server $c) {
  392. return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
  393. });
  394. $this->registerService('DatabaseConnection', function (Server $c) {
  395. $factory = new \OC\DB\ConnectionFactory();
  396. $systemConfig = $c->getSystemConfig();
  397. $type = $systemConfig->getValue('dbtype', 'sqlite');
  398. if (!$factory->isValidType($type)) {
  399. throw new \OC\DatabaseException('Invalid database type');
  400. }
  401. $connectionParams = $factory->createConnectionParams($systemConfig);
  402. $connection = $factory->getConnection($type, $connectionParams);
  403. $connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
  404. return $connection;
  405. });
  406. $this->registerService('Db', function (Server $c) {
  407. return new Db($c->getDatabaseConnection());
  408. });
  409. $this->registerService('HTTPHelper', function (Server $c) {
  410. $config = $c->getConfig();
  411. return new HTTPHelper(
  412. $config,
  413. $c->getHTTPClientService()
  414. );
  415. });
  416. $this->registerService('HttpClientService', function (Server $c) {
  417. $user = \OC_User::getUser();
  418. $uid = $user ? $user : null;
  419. return new ClientService(
  420. $c->getConfig(),
  421. new \OC\Security\CertificateManager($uid, new View(), $c->getConfig())
  422. );
  423. });
  424. $this->registerService('EventLogger', function (Server $c) {
  425. if ($c->getSystemConfig()->getValue('debug', false)) {
  426. return new EventLogger();
  427. } else {
  428. return new NullEventLogger();
  429. }
  430. });
  431. $this->registerService('QueryLogger', function (Server $c) {
  432. if ($c->getSystemConfig()->getValue('debug', false)) {
  433. return new QueryLogger();
  434. } else {
  435. return new NullQueryLogger();
  436. }
  437. });
  438. $this->registerService('TempManager', function (Server $c) {
  439. return new TempManager(
  440. $c->getLogger(),
  441. $c->getConfig()
  442. );
  443. });
  444. $this->registerService('AppManager', function (Server $c) {
  445. return new \OC\App\AppManager(
  446. $c->getUserSession(),
  447. $c->getAppConfig(),
  448. $c->getGroupManager(),
  449. $c->getMemCacheFactory(),
  450. $c->getEventDispatcher()
  451. );
  452. });
  453. $this->registerService('DateTimeZone', function (Server $c) {
  454. return new DateTimeZone(
  455. $c->getConfig(),
  456. $c->getSession()
  457. );
  458. });
  459. $this->registerService('DateTimeFormatter', function (Server $c) {
  460. $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
  461. return new DateTimeFormatter(
  462. $c->getDateTimeZone()->getTimeZone(),
  463. $c->getL10N('lib', $language)
  464. );
  465. });
  466. $this->registerService('UserMountCache', function (Server $c) {
  467. $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
  468. $listener = new UserMountCacheListener($mountCache);
  469. $listener->listen($c->getUserManager());
  470. return $mountCache;
  471. });
  472. $this->registerService('MountConfigManager', function (Server $c) {
  473. $loader = \OC\Files\Filesystem::getLoader();
  474. $mountCache = $c->query('UserMountCache');
  475. $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
  476. // builtin providers
  477. $config = $c->getConfig();
  478. $manager->registerProvider(new CacheMountProvider($config));
  479. $manager->registerHomeProvider(new LocalHomeMountProvider());
  480. $manager->registerHomeProvider(new ObjectHomeMountProvider($config));
  481. return $manager;
  482. });
  483. $this->registerService('IniWrapper', function ($c) {
  484. return new IniGetWrapper();
  485. });
  486. $this->registerService('AsyncCommandBus', function (Server $c) {
  487. $jobList = $c->getJobList();
  488. return new AsyncBus($jobList);
  489. });
  490. $this->registerService('TrustedDomainHelper', function ($c) {
  491. return new TrustedDomainHelper($this->getConfig());
  492. });
  493. $this->registerService('Throttler', function(Server $c) {
  494. return new Throttler(
  495. $c->getDatabaseConnection(),
  496. new TimeFactory(),
  497. $c->getLogger(),
  498. $c->getConfig()
  499. );
  500. });
  501. $this->registerService('IntegrityCodeChecker', function (Server $c) {
  502. // IConfig and IAppManager requires a working database. This code
  503. // might however be called when ownCloud is not yet setup.
  504. if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
  505. $config = $c->getConfig();
  506. $appManager = $c->getAppManager();
  507. } else {
  508. $config = null;
  509. $appManager = null;
  510. }
  511. return new Checker(
  512. new EnvironmentHelper(),
  513. new FileAccessHelper(),
  514. new AppLocator(),
  515. $config,
  516. $c->getMemCacheFactory(),
  517. $appManager,
  518. $c->getTempManager()
  519. );
  520. });
  521. $this->registerService('Request', function ($c) {
  522. if (isset($this['urlParams'])) {
  523. $urlParams = $this['urlParams'];
  524. } else {
  525. $urlParams = [];
  526. }
  527. if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
  528. && in_array('fakeinput', stream_get_wrappers())
  529. ) {
  530. $stream = 'fakeinput://data';
  531. } else {
  532. $stream = 'php://input';
  533. }
  534. return new Request(
  535. [
  536. 'get' => $_GET,
  537. 'post' => $_POST,
  538. 'files' => $_FILES,
  539. 'server' => $_SERVER,
  540. 'env' => $_ENV,
  541. 'cookies' => $_COOKIE,
  542. 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
  543. ? $_SERVER['REQUEST_METHOD']
  544. : null,
  545. 'urlParams' => $urlParams,
  546. ],
  547. $this->getSecureRandom(),
  548. $this->getConfig(),
  549. $this->getCsrfTokenManager(),
  550. $stream
  551. );
  552. });
  553. $this->registerService('Mailer', function (Server $c) {
  554. return new Mailer(
  555. $c->getConfig(),
  556. $c->getLogger(),
  557. $c->getThemingDefaults()
  558. );
  559. });
  560. $this->registerService('OcsClient', function (Server $c) {
  561. return new OCSClient(
  562. $this->getHTTPClientService(),
  563. $this->getConfig(),
  564. $this->getLogger()
  565. );
  566. });
  567. $this->registerService('LDAPProvider', function(Server $c) {
  568. $config = $c->getConfig();
  569. $factoryClass = $config->getSystemValue('ldapProviderFactory', null);
  570. if(is_null($factoryClass)) {
  571. throw new \Exception('ldapProviderFactory not set');
  572. }
  573. /** @var \OCP\LDAP\ILDAPProviderFactory $factory */
  574. $factory = new $factoryClass($this);
  575. return $factory->getLDAPProvider();
  576. });
  577. $this->registerService('LockingProvider', function (Server $c) {
  578. $ini = $c->getIniWrapper();
  579. $config = $c->getConfig();
  580. $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
  581. if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
  582. /** @var \OC\Memcache\Factory $memcacheFactory */
  583. $memcacheFactory = $c->getMemCacheFactory();
  584. $memcache = $memcacheFactory->createLocking('lock');
  585. if (!($memcache instanceof \OC\Memcache\NullCache)) {
  586. return new MemcacheLockingProvider($memcache, $ttl);
  587. }
  588. return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl);
  589. }
  590. return new NoopLockingProvider();
  591. });
  592. $this->registerService('MountManager', function () {
  593. return new \OC\Files\Mount\Manager();
  594. });
  595. $this->registerService('MimeTypeDetector', function (Server $c) {
  596. return new \OC\Files\Type\Detection(
  597. $c->getURLGenerator(),
  598. \OC::$configDir,
  599. \OC::$SERVERROOT . '/resources/config/'
  600. );
  601. });
  602. $this->registerService('MimeTypeLoader', function (Server $c) {
  603. return new \OC\Files\Type\Loader(
  604. $c->getDatabaseConnection()
  605. );
  606. });
  607. $this->registerService('NotificationManager', function () {
  608. return new Manager();
  609. });
  610. $this->registerService('CapabilitiesManager', function (Server $c) {
  611. $manager = new \OC\CapabilitiesManager($c->getLogger());
  612. $manager->registerCapability(function () use ($c) {
  613. return new \OC\OCS\CoreCapabilities($c->getConfig());
  614. });
  615. return $manager;
  616. });
  617. $this->registerService('CommentsManager', function(Server $c) {
  618. $config = $c->getConfig();
  619. $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
  620. /** @var \OCP\Comments\ICommentsManagerFactory $factory */
  621. $factory = new $factoryClass($this);
  622. return $factory->getManager();
  623. });
  624. $this->registerService('ThemingDefaults', function(Server $c) {
  625. /*
  626. * Dark magic for autoloader.
  627. * If we do a class_exists it will try to load the class which will
  628. * make composer cache the result. Resulting in errors when enabling
  629. * the theming app.
  630. */
  631. $prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
  632. if (isset($prefixes['OCA\\Theming\\'])) {
  633. $classExists = true;
  634. } else {
  635. $classExists = false;
  636. }
  637. if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) {
  638. return new ThemingDefaults(
  639. $c->getConfig(),
  640. $c->getL10N('theming'),
  641. $c->getURLGenerator(),
  642. new \OC_Defaults(),
  643. $c->getLazyRootFolder()
  644. );
  645. }
  646. return new \OC_Defaults();
  647. });
  648. $this->registerService('EventDispatcher', function () {
  649. return new EventDispatcher();
  650. });
  651. $this->registerService('CryptoWrapper', function (Server $c) {
  652. // FIXME: Instantiiated here due to cyclic dependency
  653. $request = new Request(
  654. [
  655. 'get' => $_GET,
  656. 'post' => $_POST,
  657. 'files' => $_FILES,
  658. 'server' => $_SERVER,
  659. 'env' => $_ENV,
  660. 'cookies' => $_COOKIE,
  661. 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
  662. ? $_SERVER['REQUEST_METHOD']
  663. : null,
  664. ],
  665. $c->getSecureRandom(),
  666. $c->getConfig()
  667. );
  668. return new CryptoWrapper(
  669. $c->getConfig(),
  670. $c->getCrypto(),
  671. $c->getSecureRandom(),
  672. $request
  673. );
  674. });
  675. $this->registerService('CsrfTokenManager', function (Server $c) {
  676. $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
  677. $sessionStorage = new SessionStorage($c->getSession());
  678. return new CsrfTokenManager(
  679. $tokenGenerator,
  680. $sessionStorage
  681. );
  682. });
  683. $this->registerService('ContentSecurityPolicyManager', function (Server $c) {
  684. return new ContentSecurityPolicyManager();
  685. });
  686. $this->registerService('ShareManager', function(Server $c) {
  687. $config = $c->getConfig();
  688. $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory');
  689. /** @var \OCP\Share\IProviderFactory $factory */
  690. $factory = new $factoryClass($this);
  691. $manager = new \OC\Share20\Manager(
  692. $c->getLogger(),
  693. $c->getConfig(),
  694. $c->getSecureRandom(),
  695. $c->getHasher(),
  696. $c->getMountManager(),
  697. $c->getGroupManager(),
  698. $c->getL10N('core'),
  699. $factory,
  700. $c->getUserManager(),
  701. $c->getLazyRootFolder(),
  702. $c->getEventDispatcher()
  703. );
  704. return $manager;
  705. });
  706. $this->registerService('SettingsManager', function(Server $c) {
  707. $manager = new \OC\Settings\Manager(
  708. $c->getLogger(),
  709. $c->getDatabaseConnection(),
  710. $c->getL10N('core'),
  711. $c->getConfig(),
  712. $c->getEncryptionManager(),
  713. $c->getUserManager(),
  714. $c->getLockingProvider()
  715. );
  716. return $manager;
  717. });
  718. }
  719. /**
  720. * @return \OCP\Contacts\IManager
  721. */
  722. public function getContactsManager() {
  723. return $this->query('ContactsManager');
  724. }
  725. /**
  726. * @return \OC\Encryption\Manager
  727. */
  728. public function getEncryptionManager() {
  729. return $this->query('EncryptionManager');
  730. }
  731. /**
  732. * @return \OC\Encryption\File
  733. */
  734. public function getEncryptionFilesHelper() {
  735. return $this->query('EncryptionFileHelper');
  736. }
  737. /**
  738. * @return \OCP\Encryption\Keys\IStorage
  739. */
  740. public function getEncryptionKeyStorage() {
  741. return $this->query('EncryptionKeyStorage');
  742. }
  743. /**
  744. * The current request object holding all information about the request
  745. * currently being processed is returned from this method.
  746. * In case the current execution was not initiated by a web request null is returned
  747. *
  748. * @return \OCP\IRequest
  749. */
  750. public function getRequest() {
  751. return $this->query('Request');
  752. }
  753. /**
  754. * Returns the preview manager which can create preview images for a given file
  755. *
  756. * @return \OCP\IPreview
  757. */
  758. public function getPreviewManager() {
  759. return $this->query('PreviewManager');
  760. }
  761. /**
  762. * Returns the tag manager which can get and set tags for different object types
  763. *
  764. * @see \OCP\ITagManager::load()
  765. * @return \OCP\ITagManager
  766. */
  767. public function getTagManager() {
  768. return $this->query('TagManager');
  769. }
  770. /**
  771. * Returns the system-tag manager
  772. *
  773. * @return \OCP\SystemTag\ISystemTagManager
  774. *
  775. * @since 9.0.0
  776. */
  777. public function getSystemTagManager() {
  778. return $this->query('SystemTagManager');
  779. }
  780. /**
  781. * Returns the system-tag object mapper
  782. *
  783. * @return \OCP\SystemTag\ISystemTagObjectMapper
  784. *
  785. * @since 9.0.0
  786. */
  787. public function getSystemTagObjectMapper() {
  788. return $this->query('SystemTagObjectMapper');
  789. }
  790. /**
  791. * Returns the avatar manager, used for avatar functionality
  792. *
  793. * @return \OCP\IAvatarManager
  794. */
  795. public function getAvatarManager() {
  796. return $this->query('AvatarManager');
  797. }
  798. /**
  799. * Returns the root folder of ownCloud's data directory
  800. *
  801. * @return \OCP\Files\IRootFolder
  802. */
  803. public function getRootFolder() {
  804. return $this->query('LazyRootFolder');
  805. }
  806. /**
  807. * Returns the root folder of ownCloud's data directory
  808. * This is the lazy variant so this gets only initialized once it
  809. * is actually used.
  810. *
  811. * @return \OCP\Files\IRootFolder
  812. */
  813. public function getLazyRootFolder() {
  814. return $this->query('LazyRootFolder');
  815. }
  816. /**
  817. * Returns a view to ownCloud's files folder
  818. *
  819. * @param string $userId user ID
  820. * @return \OCP\Files\Folder|null
  821. */
  822. public function getUserFolder($userId = null) {
  823. if ($userId === null) {
  824. $user = $this->getUserSession()->getUser();
  825. if (!$user) {
  826. return null;
  827. }
  828. $userId = $user->getUID();
  829. }
  830. $root = $this->getRootFolder();
  831. return $root->getUserFolder($userId);
  832. }
  833. /**
  834. * Returns an app-specific view in ownClouds data directory
  835. *
  836. * @return \OCP\Files\Folder
  837. */
  838. public function getAppFolder() {
  839. $dir = '/' . \OC_App::getCurrentApp();
  840. $root = $this->getRootFolder();
  841. if (!$root->nodeExists($dir)) {
  842. $folder = $root->newFolder($dir);
  843. } else {
  844. $folder = $root->get($dir);
  845. }
  846. return $folder;
  847. }
  848. /**
  849. * @return \OC\User\Manager
  850. */
  851. public function getUserManager() {
  852. return $this->query('UserManager');
  853. }
  854. /**
  855. * @return \OC\Group\Manager
  856. */
  857. public function getGroupManager() {
  858. return $this->query('GroupManager');
  859. }
  860. /**
  861. * @return \OC\User\Session
  862. */
  863. public function getUserSession() {
  864. return $this->query('UserSession');
  865. }
  866. /**
  867. * @return \OCP\ISession
  868. */
  869. public function getSession() {
  870. return $this->query('UserSession')->getSession();
  871. }
  872. /**
  873. * @param \OCP\ISession $session
  874. */
  875. public function setSession(\OCP\ISession $session) {
  876. return $this->query('UserSession')->setSession($session);
  877. }
  878. /**
  879. * @return \OC\Authentication\TwoFactorAuth\Manager
  880. */
  881. public function getTwoFactorAuthManager() {
  882. return $this->query('\OC\Authentication\TwoFactorAuth\Manager');
  883. }
  884. /**
  885. * @return \OC\NavigationManager
  886. */
  887. public function getNavigationManager() {
  888. return $this->query('NavigationManager');
  889. }
  890. /**
  891. * @return \OCP\IConfig
  892. */
  893. public function getConfig() {
  894. return $this->query('AllConfig');
  895. }
  896. /**
  897. * @internal For internal use only
  898. * @return \OC\SystemConfig
  899. */
  900. public function getSystemConfig() {
  901. return $this->query('SystemConfig');
  902. }
  903. /**
  904. * Returns the app config manager
  905. *
  906. * @return \OCP\IAppConfig
  907. */
  908. public function getAppConfig() {
  909. return $this->query('AppConfig');
  910. }
  911. /**
  912. * @return \OCP\L10N\IFactory
  913. */
  914. public function getL10NFactory() {
  915. return $this->query('L10NFactory');
  916. }
  917. /**
  918. * get an L10N instance
  919. *
  920. * @param string $app appid
  921. * @param string $lang
  922. * @return IL10N
  923. */
  924. public function getL10N($app, $lang = null) {
  925. return $this->getL10NFactory()->get($app, $lang);
  926. }
  927. /**
  928. * @return \OCP\IURLGenerator
  929. */
  930. public function getURLGenerator() {
  931. return $this->query('URLGenerator');
  932. }
  933. /**
  934. * @return \OCP\IHelper
  935. */
  936. public function getHelper() {
  937. return $this->query('AppHelper');
  938. }
  939. /**
  940. * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
  941. * getMemCacheFactory() instead.
  942. *
  943. * @return \OCP\ICache
  944. * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
  945. */
  946. public function getCache() {
  947. return $this->query('UserCache');
  948. }
  949. /**
  950. * Returns an \OCP\CacheFactory instance
  951. *
  952. * @return \OCP\ICacheFactory
  953. */
  954. public function getMemCacheFactory() {
  955. return $this->query('MemCacheFactory');
  956. }
  957. /**
  958. * Returns an \OC\RedisFactory instance
  959. *
  960. * @return \OC\RedisFactory
  961. */
  962. public function getGetRedisFactory() {
  963. return $this->query('RedisFactory');
  964. }
  965. /**
  966. * Returns the current session
  967. *
  968. * @return \OCP\IDBConnection
  969. */
  970. public function getDatabaseConnection() {
  971. return $this->query('DatabaseConnection');
  972. }
  973. /**
  974. * Returns the activity manager
  975. *
  976. * @return \OCP\Activity\IManager
  977. */
  978. public function getActivityManager() {
  979. return $this->query('ActivityManager');
  980. }
  981. /**
  982. * Returns an job list for controlling background jobs
  983. *
  984. * @return \OCP\BackgroundJob\IJobList
  985. */
  986. public function getJobList() {
  987. return $this->query('JobList');
  988. }
  989. /**
  990. * Returns a logger instance
  991. *
  992. * @return \OCP\ILogger
  993. */
  994. public function getLogger() {
  995. return $this->query('Logger');
  996. }
  997. /**
  998. * Returns a router for generating and matching urls
  999. *
  1000. * @return \OCP\Route\IRouter
  1001. */
  1002. public function getRouter() {
  1003. return $this->query('Router');
  1004. }
  1005. /**
  1006. * Returns a search instance
  1007. *
  1008. * @return \OCP\ISearch
  1009. */
  1010. public function getSearch() {
  1011. return $this->query('Search');
  1012. }
  1013. /**
  1014. * Returns a SecureRandom instance
  1015. *
  1016. * @return \OCP\Security\ISecureRandom
  1017. */
  1018. public function getSecureRandom() {
  1019. return $this->query('SecureRandom');
  1020. }
  1021. /**
  1022. * Returns a Crypto instance
  1023. *
  1024. * @return \OCP\Security\ICrypto
  1025. */
  1026. public function getCrypto() {
  1027. return $this->query('Crypto');
  1028. }
  1029. /**
  1030. * Returns a Hasher instance
  1031. *
  1032. * @return \OCP\Security\IHasher
  1033. */
  1034. public function getHasher() {
  1035. return $this->query('Hasher');
  1036. }
  1037. /**
  1038. * Returns a CredentialsManager instance
  1039. *
  1040. * @return \OCP\Security\ICredentialsManager
  1041. */
  1042. public function getCredentialsManager() {
  1043. return $this->query('CredentialsManager');
  1044. }
  1045. /**
  1046. * Returns an instance of the db facade
  1047. *
  1048. * @deprecated use getDatabaseConnection, will be removed in ownCloud 10
  1049. * @return \OCP\IDb
  1050. */
  1051. public function getDb() {
  1052. return $this->query('Db');
  1053. }
  1054. /**
  1055. * Returns an instance of the HTTP helper class
  1056. *
  1057. * @deprecated Use getHTTPClientService()
  1058. * @return \OC\HTTPHelper
  1059. */
  1060. public function getHTTPHelper() {
  1061. return $this->query('HTTPHelper');
  1062. }
  1063. /**
  1064. * Get the certificate manager for the user
  1065. *
  1066. * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
  1067. * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in
  1068. */
  1069. public function getCertificateManager($userId = '') {
  1070. if ($userId === '') {
  1071. $userSession = $this->getUserSession();
  1072. $user = $userSession->getUser();
  1073. if (is_null($user)) {
  1074. return null;
  1075. }
  1076. $userId = $user->getUID();
  1077. }
  1078. return new CertificateManager($userId, new View(), $this->getConfig());
  1079. }
  1080. /**
  1081. * Returns an instance of the HTTP client service
  1082. *
  1083. * @return \OCP\Http\Client\IClientService
  1084. */
  1085. public function getHTTPClientService() {
  1086. return $this->query('HttpClientService');
  1087. }
  1088. /**
  1089. * Create a new event source
  1090. *
  1091. * @return \OCP\IEventSource
  1092. */
  1093. public function createEventSource() {
  1094. return new \OC_EventSource();
  1095. }
  1096. /**
  1097. * Get the active event logger
  1098. *
  1099. * The returned logger only logs data when debug mode is enabled
  1100. *
  1101. * @return \OCP\Diagnostics\IEventLogger
  1102. */
  1103. public function getEventLogger() {
  1104. return $this->query('EventLogger');
  1105. }
  1106. /**
  1107. * Get the active query logger
  1108. *
  1109. * The returned logger only logs data when debug mode is enabled
  1110. *
  1111. * @return \OCP\Diagnostics\IQueryLogger
  1112. */
  1113. public function getQueryLogger() {
  1114. return $this->query('QueryLogger');
  1115. }
  1116. /**
  1117. * Get the manager for temporary files and folders
  1118. *
  1119. * @return \OCP\ITempManager
  1120. */
  1121. public function getTempManager() {
  1122. return $this->query('TempManager');
  1123. }
  1124. /**
  1125. * Get the app manager
  1126. *
  1127. * @return \OCP\App\IAppManager
  1128. */
  1129. public function getAppManager() {
  1130. return $this->query('AppManager');
  1131. }
  1132. /**
  1133. * Creates a new mailer
  1134. *
  1135. * @return \OCP\Mail\IMailer
  1136. */
  1137. public function getMailer() {
  1138. return $this->query('Mailer');
  1139. }
  1140. /**
  1141. * Get the webroot
  1142. *
  1143. * @return string
  1144. */
  1145. public function getWebRoot() {
  1146. return $this->webRoot;
  1147. }
  1148. /**
  1149. * @return \OC\OCSClient
  1150. */
  1151. public function getOcsClient() {
  1152. return $this->query('OcsClient');
  1153. }
  1154. /**
  1155. * @return \OCP\IDateTimeZone
  1156. */
  1157. public function getDateTimeZone() {
  1158. return $this->query('DateTimeZone');
  1159. }
  1160. /**
  1161. * @return \OCP\IDateTimeFormatter
  1162. */
  1163. public function getDateTimeFormatter() {
  1164. return $this->query('DateTimeFormatter');
  1165. }
  1166. /**
  1167. * @return \OCP\Files\Config\IMountProviderCollection
  1168. */
  1169. public function getMountProviderCollection() {
  1170. return $this->query('MountConfigManager');
  1171. }
  1172. /**
  1173. * Get the IniWrapper
  1174. *
  1175. * @return IniGetWrapper
  1176. */
  1177. public function getIniWrapper() {
  1178. return $this->query('IniWrapper');
  1179. }
  1180. /**
  1181. * @return \OCP\Command\IBus
  1182. */
  1183. public function getCommandBus() {
  1184. return $this->query('AsyncCommandBus');
  1185. }
  1186. /**
  1187. * Get the trusted domain helper
  1188. *
  1189. * @return TrustedDomainHelper
  1190. */
  1191. public function getTrustedDomainHelper() {
  1192. return $this->query('TrustedDomainHelper');
  1193. }
  1194. /**
  1195. * Get the locking provider
  1196. *
  1197. * @return \OCP\Lock\ILockingProvider
  1198. * @since 8.1.0
  1199. */
  1200. public function getLockingProvider() {
  1201. return $this->query('LockingProvider');
  1202. }
  1203. /**
  1204. * @return \OCP\Files\Mount\IMountManager
  1205. **/
  1206. function getMountManager() {
  1207. return $this->query('MountManager');
  1208. }
  1209. /** @return \OCP\Files\Config\IUserMountCache */
  1210. function getUserMountCache() {
  1211. return $this->query('UserMountCache');
  1212. }
  1213. /**
  1214. * Get the MimeTypeDetector
  1215. *
  1216. * @return \OCP\Files\IMimeTypeDetector
  1217. */
  1218. public function getMimeTypeDetector() {
  1219. return $this->query('MimeTypeDetector');
  1220. }
  1221. /**
  1222. * Get the MimeTypeLoader
  1223. *
  1224. * @return \OCP\Files\IMimeTypeLoader
  1225. */
  1226. public function getMimeTypeLoader() {
  1227. return $this->query('MimeTypeLoader');
  1228. }
  1229. /**
  1230. * Get the manager of all the capabilities
  1231. *
  1232. * @return \OC\CapabilitiesManager
  1233. */
  1234. public function getCapabilitiesManager() {
  1235. return $this->query('CapabilitiesManager');
  1236. }
  1237. /**
  1238. * Get the EventDispatcher
  1239. *
  1240. * @return EventDispatcherInterface
  1241. * @since 8.2.0
  1242. */
  1243. public function getEventDispatcher() {
  1244. return $this->query('EventDispatcher');
  1245. }
  1246. /**
  1247. * Get the Notification Manager
  1248. *
  1249. * @return \OCP\Notification\IManager
  1250. * @since 8.2.0
  1251. */
  1252. public function getNotificationManager() {
  1253. return $this->query('NotificationManager');
  1254. }
  1255. /**
  1256. * @return \OCP\Comments\ICommentsManager
  1257. */
  1258. public function getCommentsManager() {
  1259. return $this->query('CommentsManager');
  1260. }
  1261. /**
  1262. * @return \OC_Defaults
  1263. */
  1264. public function getThemingDefaults() {
  1265. return $this->query('ThemingDefaults');
  1266. }
  1267. /**
  1268. * @return \OC\IntegrityCheck\Checker
  1269. */
  1270. public function getIntegrityCodeChecker() {
  1271. return $this->query('IntegrityCodeChecker');
  1272. }
  1273. /**
  1274. * @return \OC\Session\CryptoWrapper
  1275. */
  1276. public function getSessionCryptoWrapper() {
  1277. return $this->query('CryptoWrapper');
  1278. }
  1279. /**
  1280. * @return CsrfTokenManager
  1281. */
  1282. public function getCsrfTokenManager() {
  1283. return $this->query('CsrfTokenManager');
  1284. }
  1285. /**
  1286. * @return Throttler
  1287. */
  1288. public function getBruteForceThrottler() {
  1289. return $this->query('Throttler');
  1290. }
  1291. /**
  1292. * @return IContentSecurityPolicyManager
  1293. */
  1294. public function getContentSecurityPolicyManager() {
  1295. return $this->query('ContentSecurityPolicyManager');
  1296. }
  1297. /**
  1298. * Not a public API as of 8.2, wait for 9.0
  1299. *
  1300. * @return \OCA\Files_External\Service\BackendService
  1301. */
  1302. public function getStoragesBackendService() {
  1303. return $this->query('OCA\\Files_External\\Service\\BackendService');
  1304. }
  1305. /**
  1306. * Not a public API as of 8.2, wait for 9.0
  1307. *
  1308. * @return \OCA\Files_External\Service\GlobalStoragesService
  1309. */
  1310. public function getGlobalStoragesService() {
  1311. return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService');
  1312. }
  1313. /**
  1314. * Not a public API as of 8.2, wait for 9.0
  1315. *
  1316. * @return \OCA\Files_External\Service\UserGlobalStoragesService
  1317. */
  1318. public function getUserGlobalStoragesService() {
  1319. return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService');
  1320. }
  1321. /**
  1322. * Not a public API as of 8.2, wait for 9.0
  1323. *
  1324. * @return \OCA\Files_External\Service\UserStoragesService
  1325. */
  1326. public function getUserStoragesService() {
  1327. return $this->query('OCA\\Files_External\\Service\\UserStoragesService');
  1328. }
  1329. /**
  1330. * @return \OCP\Share\IManager
  1331. */
  1332. public function getShareManager() {
  1333. return $this->query('ShareManager');
  1334. }
  1335. /**
  1336. * Returns the LDAP Provider
  1337. *
  1338. * @return \OCP\LDAP\ILDAPProvider
  1339. */
  1340. public function getLDAPProvider() {
  1341. return $this->query('LDAPProvider');
  1342. }
  1343. /**
  1344. * @return \OCP\Settings\IManager
  1345. */
  1346. public function getSettingsManager() {
  1347. return $this->query('SettingsManager');
  1348. }
  1349. }