Completed
Push — master ( 8160d0...b9bbb8 )
by Morris
25:32
created
lib/private/Authentication/TwoFactorAuth/Manager.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 /**
4 4
  * @copyright Copyright (c) 2016, ownCloud, Inc.
5 5
  *
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 			}
183 183
 		}
184 184
 
185
-		return array_filter($providers, function ($provider) use ($user) {
185
+		return array_filter($providers, function($provider) use ($user) {
186 186
 			/* @var $provider IProvider */
187 187
 			return $provider->isTwoFactorAuthEnabledForUser($user);
188 188
 		});
Please login to merge, or discard this patch.
Indentation   +302 added lines, -302 removed lines patch added patch discarded remove patch
@@ -46,310 +46,310 @@
 block discarded – undo
46 46
 
47 47
 class Manager {
48 48
 
49
-	const SESSION_UID_KEY = 'two_factor_auth_uid';
50
-	const SESSION_UID_DONE = 'two_factor_auth_passed';
51
-	const BACKUP_CODES_APP_ID = 'twofactor_backupcodes';
52
-	const BACKUP_CODES_PROVIDER_ID = 'backup_codes';
53
-	const REMEMBER_LOGIN = 'two_factor_remember_login';
54
-
55
-	/** @var AppManager */
56
-	private $appManager;
57
-
58
-	/** @var ISession */
59
-	private $session;
60
-
61
-	/** @var IConfig */
62
-	private $config;
63
-
64
-	/** @var IManager */
65
-	private $activityManager;
66
-
67
-	/** @var ILogger */
68
-	private $logger;
69
-
70
-	/** @var TokenProvider */
71
-	private $tokenProvider;
72
-
73
-	/** @var ITimeFactory */
74
-	private $timeFactory;
75
-
76
-	/** @var EventDispatcherInterface */
77
-	private $dispatcher;
78
-
79
-	/**
80
-	 * @param AppManager $appManager
81
-	 * @param ISession $session
82
-	 * @param IConfig $config
83
-	 * @param IManager $activityManager
84
-	 * @param ILogger $logger
85
-	 * @param TokenProvider $tokenProvider
86
-	 * @param ITimeFactory $timeFactory
87
-	 * @param EventDispatcherInterface $eventDispatcher
88
-	 */
89
-	public function __construct(AppManager $appManager,
90
-								ISession $session,
91
-								IConfig $config,
92
-								IManager $activityManager,
93
-								ILogger $logger,
94
-								TokenProvider $tokenProvider,
95
-								ITimeFactory $timeFactory,
96
-								EventDispatcherInterface $eventDispatcher) {
97
-		$this->appManager = $appManager;
98
-		$this->session = $session;
99
-		$this->config = $config;
100
-		$this->activityManager = $activityManager;
101
-		$this->logger = $logger;
102
-		$this->tokenProvider = $tokenProvider;
103
-		$this->timeFactory = $timeFactory;
104
-		$this->dispatcher = $eventDispatcher;
105
-	}
106
-
107
-	/**
108
-	 * Determine whether the user must provide a second factor challenge
109
-	 *
110
-	 * @param IUser $user
111
-	 * @return boolean
112
-	 */
113
-	public function isTwoFactorAuthenticated(IUser $user): bool {
114
-		$twoFactorEnabled = ((int) $this->config->getUserValue($user->getUID(), 'core', 'two_factor_auth_disabled', 0)) === 0;
115
-		return $twoFactorEnabled && \count($this->getProviders($user)) > 0;
116
-	}
117
-
118
-	/**
119
-	 * Disable 2FA checks for the given user
120
-	 *
121
-	 * @param IUser $user
122
-	 */
123
-	public function disableTwoFactorAuthentication(IUser $user) {
124
-		$this->config->setUserValue($user->getUID(), 'core', 'two_factor_auth_disabled', 1);
125
-	}
126
-
127
-	/**
128
-	 * Enable all 2FA checks for the given user
129
-	 *
130
-	 * @param IUser $user
131
-	 */
132
-	public function enableTwoFactorAuthentication(IUser $user) {
133
-		$this->config->deleteUserValue($user->getUID(), 'core', 'two_factor_auth_disabled');
134
-	}
135
-
136
-	/**
137
-	 * Get a 2FA provider by its ID
138
-	 *
139
-	 * @param IUser $user
140
-	 * @param string $challengeProviderId
141
-	 * @return IProvider|null
142
-	 */
143
-	public function getProvider(IUser $user, string $challengeProviderId) {
144
-		$providers = $this->getProviders($user, true);
145
-		return $providers[$challengeProviderId] ?? null;
146
-	}
147
-
148
-	/**
149
-	 * @param IUser $user
150
-	 * @return IProvider|null the backup provider, if enabled for the given user
151
-	 */
152
-	public function getBackupProvider(IUser $user) {
153
-		$providers = $this->getProviders($user, true);
154
-		if (!isset($providers[self::BACKUP_CODES_PROVIDER_ID])) {
155
-			return null;
156
-		}
157
-		return $providers[self::BACKUP_CODES_PROVIDER_ID];
158
-	}
159
-
160
-	/**
161
-	 * Get the list of 2FA providers for the given user
162
-	 *
163
-	 * @param IUser $user
164
-	 * @param bool $includeBackupApp
165
-	 * @return IProvider[]
166
-	 * @throws Exception
167
-	 */
168
-	public function getProviders(IUser $user, bool $includeBackupApp = false): array {
169
-		$allApps = $this->appManager->getEnabledAppsForUser($user);
170
-		$providers = [];
171
-
172
-		foreach ($allApps as $appId) {
173
-			if (!$includeBackupApp && $appId === self::BACKUP_CODES_APP_ID) {
174
-				continue;
175
-			}
176
-
177
-			$info = $this->appManager->getAppInfo($appId);
178
-			if (isset($info['two-factor-providers'])) {
179
-				/** @var string[] $providerClasses */
180
-				$providerClasses = $info['two-factor-providers'];
181
-				foreach ($providerClasses as $class) {
182
-					try {
183
-						$this->loadTwoFactorApp($appId);
184
-						$provider = OC::$server->query($class);
185
-						$providers[$provider->getId()] = $provider;
186
-					} catch (QueryException $exc) {
187
-						// Provider class can not be resolved
188
-						throw new Exception("Could not load two-factor auth provider $class");
189
-					}
190
-				}
191
-			}
192
-		}
193
-
194
-		return array_filter($providers, function ($provider) use ($user) {
195
-			/* @var $provider IProvider */
196
-			return $provider->isTwoFactorAuthEnabledForUser($user);
197
-		});
198
-	}
199
-
200
-	/**
201
-	 * Load an app by ID if it has not been loaded yet
202
-	 *
203
-	 * @param string $appId
204
-	 */
205
-	protected function loadTwoFactorApp(string $appId) {
206
-		if (!OC_App::isAppLoaded($appId)) {
207
-			OC_App::loadApp($appId);
208
-		}
209
-	}
210
-
211
-	/**
212
-	 * Verify the given challenge
213
-	 *
214
-	 * @param string $providerId
215
-	 * @param IUser $user
216
-	 * @param string $challenge
217
-	 * @return boolean
218
-	 */
219
-	public function verifyChallenge(string $providerId, IUser $user, string $challenge): bool {
220
-		$provider = $this->getProvider($user, $providerId);
221
-		if ($provider === null) {
222
-			return false;
223
-		}
224
-
225
-		$passed = $provider->verifyChallenge($user, $challenge);
226
-		if ($passed) {
227
-			if ($this->session->get(self::REMEMBER_LOGIN) === true) {
228
-				// TODO: resolve cyclic dependency and use DI
229
-				\OC::$server->getUserSession()->createRememberMeToken($user);
230
-			}
231
-			$this->session->remove(self::SESSION_UID_KEY);
232
-			$this->session->remove(self::REMEMBER_LOGIN);
233
-			$this->session->set(self::SESSION_UID_DONE, $user->getUID());
234
-
235
-			// Clear token from db
236
-			$sessionId = $this->session->getId();
237
-			$token = $this->tokenProvider->getToken($sessionId);
238
-			$tokenId = $token->getId();
239
-			$this->config->deleteUserValue($user->getUID(), 'login_token_2fa', $tokenId);
240
-
241
-			$dispatchEvent = new GenericEvent($user, ['provider' => $provider->getDisplayName()]);
242
-			$this->dispatcher->dispatch(IProvider::EVENT_SUCCESS, $dispatchEvent);
243
-
244
-			$this->publishEvent($user, 'twofactor_success', [
245
-				'provider' => $provider->getDisplayName(),
246
-			]);
247
-		} else {
248
-			$dispatchEvent = new GenericEvent($user, ['provider' => $provider->getDisplayName()]);
249
-			$this->dispatcher->dispatch(IProvider::EVENT_FAILED, $dispatchEvent);
250
-
251
-			$this->publishEvent($user, 'twofactor_failed', [
252
-				'provider' => $provider->getDisplayName(),
253
-			]);
254
-		}
255
-		return $passed;
256
-	}
257
-
258
-	/**
259
-	 * Push a 2fa event the user's activity stream
260
-	 *
261
-	 * @param IUser $user
262
-	 * @param string $event
263
-	 * @param array $params
264
-	 */
265
-	private function publishEvent(IUser $user, string $event, array $params) {
266
-		$activity = $this->activityManager->generateEvent();
267
-		$activity->setApp('core')
268
-			->setType('security')
269
-			->setAuthor($user->getUID())
270
-			->setAffectedUser($user->getUID())
271
-			->setSubject($event, $params);
272
-		try {
273
-			$this->activityManager->publish($activity);
274
-		} catch (BadMethodCallException $e) {
275
-			$this->logger->warning('could not publish backup code creation activity', ['app' => 'core']);
276
-			$this->logger->logException($e, ['app' => 'core']);
277
-		}
278
-	}
279
-
280
-	/**
281
-	 * Check if the currently logged in user needs to pass 2FA
282
-	 *
283
-	 * @param IUser $user the currently logged in user
284
-	 * @return boolean
285
-	 */
286
-	public function needsSecondFactor(IUser $user = null): bool {
287
-		if ($user === null) {
288
-			return false;
289
-		}
290
-
291
-		// If we are authenticated using an app password skip all this
292
-		if ($this->session->exists('app_password')) {
293
-			return false;
294
-		}
295
-
296
-		// First check if the session tells us we should do 2FA (99% case)
297
-		if (!$this->session->exists(self::SESSION_UID_KEY)) {
298
-
299
-			// Check if the session tells us it is 2FA authenticated already
300
-			if ($this->session->exists(self::SESSION_UID_DONE) &&
301
-				$this->session->get(self::SESSION_UID_DONE) === $user->getUID()) {
302
-				return false;
303
-			}
304
-
305
-			/*
49
+    const SESSION_UID_KEY = 'two_factor_auth_uid';
50
+    const SESSION_UID_DONE = 'two_factor_auth_passed';
51
+    const BACKUP_CODES_APP_ID = 'twofactor_backupcodes';
52
+    const BACKUP_CODES_PROVIDER_ID = 'backup_codes';
53
+    const REMEMBER_LOGIN = 'two_factor_remember_login';
54
+
55
+    /** @var AppManager */
56
+    private $appManager;
57
+
58
+    /** @var ISession */
59
+    private $session;
60
+
61
+    /** @var IConfig */
62
+    private $config;
63
+
64
+    /** @var IManager */
65
+    private $activityManager;
66
+
67
+    /** @var ILogger */
68
+    private $logger;
69
+
70
+    /** @var TokenProvider */
71
+    private $tokenProvider;
72
+
73
+    /** @var ITimeFactory */
74
+    private $timeFactory;
75
+
76
+    /** @var EventDispatcherInterface */
77
+    private $dispatcher;
78
+
79
+    /**
80
+     * @param AppManager $appManager
81
+     * @param ISession $session
82
+     * @param IConfig $config
83
+     * @param IManager $activityManager
84
+     * @param ILogger $logger
85
+     * @param TokenProvider $tokenProvider
86
+     * @param ITimeFactory $timeFactory
87
+     * @param EventDispatcherInterface $eventDispatcher
88
+     */
89
+    public function __construct(AppManager $appManager,
90
+                                ISession $session,
91
+                                IConfig $config,
92
+                                IManager $activityManager,
93
+                                ILogger $logger,
94
+                                TokenProvider $tokenProvider,
95
+                                ITimeFactory $timeFactory,
96
+                                EventDispatcherInterface $eventDispatcher) {
97
+        $this->appManager = $appManager;
98
+        $this->session = $session;
99
+        $this->config = $config;
100
+        $this->activityManager = $activityManager;
101
+        $this->logger = $logger;
102
+        $this->tokenProvider = $tokenProvider;
103
+        $this->timeFactory = $timeFactory;
104
+        $this->dispatcher = $eventDispatcher;
105
+    }
106
+
107
+    /**
108
+     * Determine whether the user must provide a second factor challenge
109
+     *
110
+     * @param IUser $user
111
+     * @return boolean
112
+     */
113
+    public function isTwoFactorAuthenticated(IUser $user): bool {
114
+        $twoFactorEnabled = ((int) $this->config->getUserValue($user->getUID(), 'core', 'two_factor_auth_disabled', 0)) === 0;
115
+        return $twoFactorEnabled && \count($this->getProviders($user)) > 0;
116
+    }
117
+
118
+    /**
119
+     * Disable 2FA checks for the given user
120
+     *
121
+     * @param IUser $user
122
+     */
123
+    public function disableTwoFactorAuthentication(IUser $user) {
124
+        $this->config->setUserValue($user->getUID(), 'core', 'two_factor_auth_disabled', 1);
125
+    }
126
+
127
+    /**
128
+     * Enable all 2FA checks for the given user
129
+     *
130
+     * @param IUser $user
131
+     */
132
+    public function enableTwoFactorAuthentication(IUser $user) {
133
+        $this->config->deleteUserValue($user->getUID(), 'core', 'two_factor_auth_disabled');
134
+    }
135
+
136
+    /**
137
+     * Get a 2FA provider by its ID
138
+     *
139
+     * @param IUser $user
140
+     * @param string $challengeProviderId
141
+     * @return IProvider|null
142
+     */
143
+    public function getProvider(IUser $user, string $challengeProviderId) {
144
+        $providers = $this->getProviders($user, true);
145
+        return $providers[$challengeProviderId] ?? null;
146
+    }
147
+
148
+    /**
149
+     * @param IUser $user
150
+     * @return IProvider|null the backup provider, if enabled for the given user
151
+     */
152
+    public function getBackupProvider(IUser $user) {
153
+        $providers = $this->getProviders($user, true);
154
+        if (!isset($providers[self::BACKUP_CODES_PROVIDER_ID])) {
155
+            return null;
156
+        }
157
+        return $providers[self::BACKUP_CODES_PROVIDER_ID];
158
+    }
159
+
160
+    /**
161
+     * Get the list of 2FA providers for the given user
162
+     *
163
+     * @param IUser $user
164
+     * @param bool $includeBackupApp
165
+     * @return IProvider[]
166
+     * @throws Exception
167
+     */
168
+    public function getProviders(IUser $user, bool $includeBackupApp = false): array {
169
+        $allApps = $this->appManager->getEnabledAppsForUser($user);
170
+        $providers = [];
171
+
172
+        foreach ($allApps as $appId) {
173
+            if (!$includeBackupApp && $appId === self::BACKUP_CODES_APP_ID) {
174
+                continue;
175
+            }
176
+
177
+            $info = $this->appManager->getAppInfo($appId);
178
+            if (isset($info['two-factor-providers'])) {
179
+                /** @var string[] $providerClasses */
180
+                $providerClasses = $info['two-factor-providers'];
181
+                foreach ($providerClasses as $class) {
182
+                    try {
183
+                        $this->loadTwoFactorApp($appId);
184
+                        $provider = OC::$server->query($class);
185
+                        $providers[$provider->getId()] = $provider;
186
+                    } catch (QueryException $exc) {
187
+                        // Provider class can not be resolved
188
+                        throw new Exception("Could not load two-factor auth provider $class");
189
+                    }
190
+                }
191
+            }
192
+        }
193
+
194
+        return array_filter($providers, function ($provider) use ($user) {
195
+            /* @var $provider IProvider */
196
+            return $provider->isTwoFactorAuthEnabledForUser($user);
197
+        });
198
+    }
199
+
200
+    /**
201
+     * Load an app by ID if it has not been loaded yet
202
+     *
203
+     * @param string $appId
204
+     */
205
+    protected function loadTwoFactorApp(string $appId) {
206
+        if (!OC_App::isAppLoaded($appId)) {
207
+            OC_App::loadApp($appId);
208
+        }
209
+    }
210
+
211
+    /**
212
+     * Verify the given challenge
213
+     *
214
+     * @param string $providerId
215
+     * @param IUser $user
216
+     * @param string $challenge
217
+     * @return boolean
218
+     */
219
+    public function verifyChallenge(string $providerId, IUser $user, string $challenge): bool {
220
+        $provider = $this->getProvider($user, $providerId);
221
+        if ($provider === null) {
222
+            return false;
223
+        }
224
+
225
+        $passed = $provider->verifyChallenge($user, $challenge);
226
+        if ($passed) {
227
+            if ($this->session->get(self::REMEMBER_LOGIN) === true) {
228
+                // TODO: resolve cyclic dependency and use DI
229
+                \OC::$server->getUserSession()->createRememberMeToken($user);
230
+            }
231
+            $this->session->remove(self::SESSION_UID_KEY);
232
+            $this->session->remove(self::REMEMBER_LOGIN);
233
+            $this->session->set(self::SESSION_UID_DONE, $user->getUID());
234
+
235
+            // Clear token from db
236
+            $sessionId = $this->session->getId();
237
+            $token = $this->tokenProvider->getToken($sessionId);
238
+            $tokenId = $token->getId();
239
+            $this->config->deleteUserValue($user->getUID(), 'login_token_2fa', $tokenId);
240
+
241
+            $dispatchEvent = new GenericEvent($user, ['provider' => $provider->getDisplayName()]);
242
+            $this->dispatcher->dispatch(IProvider::EVENT_SUCCESS, $dispatchEvent);
243
+
244
+            $this->publishEvent($user, 'twofactor_success', [
245
+                'provider' => $provider->getDisplayName(),
246
+            ]);
247
+        } else {
248
+            $dispatchEvent = new GenericEvent($user, ['provider' => $provider->getDisplayName()]);
249
+            $this->dispatcher->dispatch(IProvider::EVENT_FAILED, $dispatchEvent);
250
+
251
+            $this->publishEvent($user, 'twofactor_failed', [
252
+                'provider' => $provider->getDisplayName(),
253
+            ]);
254
+        }
255
+        return $passed;
256
+    }
257
+
258
+    /**
259
+     * Push a 2fa event the user's activity stream
260
+     *
261
+     * @param IUser $user
262
+     * @param string $event
263
+     * @param array $params
264
+     */
265
+    private function publishEvent(IUser $user, string $event, array $params) {
266
+        $activity = $this->activityManager->generateEvent();
267
+        $activity->setApp('core')
268
+            ->setType('security')
269
+            ->setAuthor($user->getUID())
270
+            ->setAffectedUser($user->getUID())
271
+            ->setSubject($event, $params);
272
+        try {
273
+            $this->activityManager->publish($activity);
274
+        } catch (BadMethodCallException $e) {
275
+            $this->logger->warning('could not publish backup code creation activity', ['app' => 'core']);
276
+            $this->logger->logException($e, ['app' => 'core']);
277
+        }
278
+    }
279
+
280
+    /**
281
+     * Check if the currently logged in user needs to pass 2FA
282
+     *
283
+     * @param IUser $user the currently logged in user
284
+     * @return boolean
285
+     */
286
+    public function needsSecondFactor(IUser $user = null): bool {
287
+        if ($user === null) {
288
+            return false;
289
+        }
290
+
291
+        // If we are authenticated using an app password skip all this
292
+        if ($this->session->exists('app_password')) {
293
+            return false;
294
+        }
295
+
296
+        // First check if the session tells us we should do 2FA (99% case)
297
+        if (!$this->session->exists(self::SESSION_UID_KEY)) {
298
+
299
+            // Check if the session tells us it is 2FA authenticated already
300
+            if ($this->session->exists(self::SESSION_UID_DONE) &&
301
+                $this->session->get(self::SESSION_UID_DONE) === $user->getUID()) {
302
+                return false;
303
+            }
304
+
305
+            /*
306 306
 			 * If the session is expired check if we are not logged in by a token
307 307
 			 * that still needs 2FA auth
308 308
 			 */
309
-			try {
310
-				$sessionId = $this->session->getId();
311
-				$token = $this->tokenProvider->getToken($sessionId);
312
-				$tokenId = $token->getId();
313
-				$tokensNeeding2FA = $this->config->getUserKeys($user->getUID(), 'login_token_2fa');
314
-
315
-				if (!\in_array($tokenId, $tokensNeeding2FA, true)) {
316
-					$this->session->set(self::SESSION_UID_DONE, $user->getUID());
317
-					return false;
318
-				}
319
-			} catch (InvalidTokenException $e) {
320
-			}
321
-		}
322
-
323
-		if (!$this->isTwoFactorAuthenticated($user)) {
324
-			// There is no second factor any more -> let the user pass
325
-			//   This prevents infinite redirect loops when a user is about
326
-			//   to solve the 2FA challenge, and the provider app is
327
-			//   disabled the same time
328
-			$this->session->remove(self::SESSION_UID_KEY);
329
-
330
-			$keys = $this->config->getUserKeys($user->getUID(), 'login_token_2fa');
331
-			foreach ($keys as $key) {
332
-				$this->config->deleteUserValue($user->getUID(), 'login_token_2fa', $key);
333
-			}
334
-			return false;
335
-		}
336
-
337
-		return true;
338
-	}
339
-
340
-	/**
341
-	 * Prepare the 2FA login
342
-	 *
343
-	 * @param IUser $user
344
-	 * @param boolean $rememberMe
345
-	 */
346
-	public function prepareTwoFactorLogin(IUser $user, bool $rememberMe) {
347
-		$this->session->set(self::SESSION_UID_KEY, $user->getUID());
348
-		$this->session->set(self::REMEMBER_LOGIN, $rememberMe);
349
-
350
-		$id = $this->session->getId();
351
-		$token = $this->tokenProvider->getToken($id);
352
-		$this->config->setUserValue($user->getUID(), 'login_token_2fa', $token->getId(), $this->timeFactory->getTime());
353
-	}
309
+            try {
310
+                $sessionId = $this->session->getId();
311
+                $token = $this->tokenProvider->getToken($sessionId);
312
+                $tokenId = $token->getId();
313
+                $tokensNeeding2FA = $this->config->getUserKeys($user->getUID(), 'login_token_2fa');
314
+
315
+                if (!\in_array($tokenId, $tokensNeeding2FA, true)) {
316
+                    $this->session->set(self::SESSION_UID_DONE, $user->getUID());
317
+                    return false;
318
+                }
319
+            } catch (InvalidTokenException $e) {
320
+            }
321
+        }
322
+
323
+        if (!$this->isTwoFactorAuthenticated($user)) {
324
+            // There is no second factor any more -> let the user pass
325
+            //   This prevents infinite redirect loops when a user is about
326
+            //   to solve the 2FA challenge, and the provider app is
327
+            //   disabled the same time
328
+            $this->session->remove(self::SESSION_UID_KEY);
329
+
330
+            $keys = $this->config->getUserKeys($user->getUID(), 'login_token_2fa');
331
+            foreach ($keys as $key) {
332
+                $this->config->deleteUserValue($user->getUID(), 'login_token_2fa', $key);
333
+            }
334
+            return false;
335
+        }
336
+
337
+        return true;
338
+    }
339
+
340
+    /**
341
+     * Prepare the 2FA login
342
+     *
343
+     * @param IUser $user
344
+     * @param boolean $rememberMe
345
+     */
346
+    public function prepareTwoFactorLogin(IUser $user, bool $rememberMe) {
347
+        $this->session->set(self::SESSION_UID_KEY, $user->getUID());
348
+        $this->session->set(self::REMEMBER_LOGIN, $rememberMe);
349
+
350
+        $id = $this->session->getId();
351
+        $token = $this->tokenProvider->getToken($id);
352
+        $this->config->setUserValue($user->getUID(), 'login_token_2fa', $token->getId(), $this->timeFactory->getTime());
353
+    }
354 354
 
355 355
 }
Please login to merge, or discard this patch.
apps/admin_audit/lib/Actions/Security.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 /**
4 4
  * @copyright Copyright (c) 2018 Roeland Jago Douma <[email protected]>
5 5
  *
Please login to merge, or discard this patch.
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -31,45 +31,45 @@
 block discarded – undo
31 31
  * @package OCA\AdminAudit\Actions
32 32
  */
33 33
 class Security extends Action {
34
-	/**
35
-	 * Log twofactor auth enabled
36
-	 *
37
-	 * @param IUser $user
38
-	 * @param array $params
39
-	 */
40
-	public function twofactorFailed(IUser $user, array $params) {
41
-		$params['uid'] = $user->getUID();
42
-		$params['displayName'] = $user->getDisplayName();
34
+    /**
35
+     * Log twofactor auth enabled
36
+     *
37
+     * @param IUser $user
38
+     * @param array $params
39
+     */
40
+    public function twofactorFailed(IUser $user, array $params) {
41
+        $params['uid'] = $user->getUID();
42
+        $params['displayName'] = $user->getDisplayName();
43 43
 
44
-		$this->log(
45
-			'Failed two factor attempt by user %s (%s) with provider %s',
46
-			$params,
47
-			[
48
-				'displayName',
49
-				'uid',
50
-				'provider',
51
-			]
52
-		);
53
-	}
44
+        $this->log(
45
+            'Failed two factor attempt by user %s (%s) with provider %s',
46
+            $params,
47
+            [
48
+                'displayName',
49
+                'uid',
50
+                'provider',
51
+            ]
52
+        );
53
+    }
54 54
 
55
-	/**
56
-	 * Logs unsharing of data
57
-	 *
58
-	 * @param IUser $user
59
-	 * @param array $params
60
-	 */
61
-	public function twofactorSuccess(IUser $user, array $params) {
62
-		$params['uid'] = $user->getUID();
63
-		$params['displayName'] = $user->getDisplayName();
55
+    /**
56
+     * Logs unsharing of data
57
+     *
58
+     * @param IUser $user
59
+     * @param array $params
60
+     */
61
+    public function twofactorSuccess(IUser $user, array $params) {
62
+        $params['uid'] = $user->getUID();
63
+        $params['displayName'] = $user->getDisplayName();
64 64
 
65
-		$this->log(
66
-			'Successful two factor attempt by user %s (%s) with provider %s',
67
-			$params,
68
-			[
69
-				'displayName',
70
-				'uid',
71
-				'provider',
72
-			]
73
-		);
74
-	}
65
+        $this->log(
66
+            'Successful two factor attempt by user %s (%s) with provider %s',
67
+            $params,
68
+            [
69
+                'displayName',
70
+                'uid',
71
+                'provider',
72
+            ]
73
+        );
74
+    }
75 75
 }
Please login to merge, or discard this patch.
apps/admin_audit/lib/AppInfo/Application.php 1 patch
Indentation   +183 added lines, -183 removed lines patch added patch discarded remove patch
@@ -51,187 +51,187 @@
 block discarded – undo
51 51
 
52 52
 class Application extends App {
53 53
 
54
-	public function __construct() {
55
-		parent::__construct('admin_audit');
56
-	}
57
-
58
-	public function register() {
59
-		$this->registerHooks();
60
-	}
61
-
62
-	/**
63
-	 * Register hooks in order to log them
64
-	 */
65
-	protected function registerHooks() {
66
-		$logger = $this->getContainer()->getServer()->getLogger();
67
-
68
-		$this->userManagementHooks($logger);
69
-		$this->groupHooks($logger);
70
-		$this->authHooks($logger);
71
-
72
-		$this->consoleHooks($logger);
73
-		$this->appHooks($logger);
74
-
75
-		$this->sharingHooks($logger);
76
-
77
-		$this->fileHooks($logger);
78
-		$this->trashbinHooks($logger);
79
-		$this->versionsHooks($logger);
80
-
81
-		$this->securityHooks($logger);
82
-	}
83
-
84
-	protected function userManagementHooks(ILogger $logger) {
85
-		$userActions = new UserManagement($logger);
86
-
87
-		Util::connectHook('OC_User', 'post_createUser',	$userActions, 'create');
88
-		Util::connectHook('OC_User', 'post_deleteUser',	$userActions, 'delete');
89
-		Util::connectHook('OC_User', 'changeUser',	$userActions, 'change');
90
-
91
-		/** @var IUserSession|Session $userSession */
92
-		$userSession = $this->getContainer()->getServer()->getUserSession();
93
-		$userSession->listen('\OC\User', 'postSetPassword', [$userActions, 'setPassword']);
94
-	}
95
-
96
-	protected function groupHooks(ILogger $logger)  {
97
-		$groupActions = new GroupManagement($logger);
98
-
99
-		/** @var IGroupManager|Manager $groupManager */
100
-		$groupManager = $this->getContainer()->getServer()->getGroupManager();
101
-		$groupManager->listen('\OC\Group', 'postRemoveUser',  [$groupActions, 'removeUser']);
102
-		$groupManager->listen('\OC\Group', 'postAddUser',  [$groupActions, 'addUser']);
103
-		$groupManager->listen('\OC\Group', 'postDelete',  [$groupActions, 'deleteGroup']);
104
-		$groupManager->listen('\OC\Group', 'postCreate',  [$groupActions, 'createGroup']);
105
-	}
106
-
107
-	protected function sharingHooks(ILogger $logger) {
108
-		$shareActions = new Sharing($logger);
109
-
110
-		Util::connectHook('OCP\Share', 'post_shared', $shareActions, 'shared');
111
-		Util::connectHook('OCP\Share', 'post_unshare', $shareActions, 'unshare');
112
-		Util::connectHook('OCP\Share', 'post_update_permissions', $shareActions, 'updatePermissions');
113
-		Util::connectHook('OCP\Share', 'post_update_password', $shareActions, 'updatePassword');
114
-		Util::connectHook('OCP\Share', 'post_set_expiration_date', $shareActions, 'updateExpirationDate');
115
-		Util::connectHook('OCP\Share', 'share_link_access', $shareActions, 'shareAccessed');
116
-	}
117
-
118
-	protected function authHooks(ILogger $logger) {
119
-		$authActions = new Auth($logger);
120
-
121
-		Util::connectHook('OC_User', 'pre_login', $authActions, 'loginAttempt');
122
-		Util::connectHook('OC_User', 'post_login', $authActions, 'loginSuccessful');
123
-		Util::connectHook('OC_User', 'logout', $authActions, 'logout');
124
-	}
125
-
126
-	protected function appHooks(ILogger $logger) {
127
-
128
-		$eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher();
129
-		$eventDispatcher->addListener(ManagerEvent::EVENT_APP_ENABLE, function(ManagerEvent $event) use ($logger) {
130
-			$appActions = new AppManagement($logger);
131
-			$appActions->enableApp($event->getAppID());
132
-		});
133
-		$eventDispatcher->addListener(ManagerEvent::EVENT_APP_ENABLE_FOR_GROUPS, function(ManagerEvent $event) use ($logger) {
134
-			$appActions = new AppManagement($logger);
135
-			$appActions->enableAppForGroups($event->getAppID(), $event->getGroups());
136
-		});
137
-		$eventDispatcher->addListener(ManagerEvent::EVENT_APP_DISABLE, function(ManagerEvent $event) use ($logger) {
138
-			$appActions = new AppManagement($logger);
139
-			$appActions->disableApp($event->getAppID());
140
-		});
141
-
142
-	}
143
-
144
-	protected function consoleHooks(ILogger $logger) {
145
-		$eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher();
146
-		$eventDispatcher->addListener(ConsoleEvent::EVENT_RUN, function(ConsoleEvent $event) use ($logger) {
147
-			$appActions = new Console($logger);
148
-			$appActions->runCommand($event->getArguments());
149
-		});
150
-	}
151
-
152
-	protected function fileHooks(ILogger $logger) {
153
-		$fileActions = new Files($logger);
154
-		$eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher();
155
-		$eventDispatcher->addListener(
156
-			IPreview::EVENT,
157
-			function(GenericEvent $event) use ($fileActions) {
158
-				/** @var File $file */
159
-				$file = $event->getSubject();
160
-				$fileActions->preview([
161
-					'path' => substr($file->getInternalPath(), 5),
162
-					'width' => $event->getArguments()['width'],
163
-					'height' => $event->getArguments()['height'],
164
-					'crop' => $event->getArguments()['crop'],
165
-					'mode'  => $event->getArguments()['mode']
166
-				]);
167
-			}
168
-		);
169
-
170
-		Util::connectHook(
171
-			Filesystem::CLASSNAME,
172
-			Filesystem::signal_post_rename,
173
-			$fileActions,
174
-			'rename'
175
-		);
176
-		Util::connectHook(
177
-			Filesystem::CLASSNAME,
178
-			Filesystem::signal_post_create,
179
-			$fileActions,
180
-			'create'
181
-		);
182
-		Util::connectHook(
183
-			Filesystem::CLASSNAME,
184
-			Filesystem::signal_post_copy,
185
-			$fileActions,
186
-			'copy'
187
-		);
188
-		Util::connectHook(
189
-			Filesystem::CLASSNAME,
190
-			Filesystem::signal_post_write,
191
-			$fileActions,
192
-			'write'
193
-		);
194
-		Util::connectHook(
195
-			Filesystem::CLASSNAME,
196
-			Filesystem::signal_post_update,
197
-			$fileActions,
198
-			'update'
199
-		);
200
-		Util::connectHook(
201
-			Filesystem::CLASSNAME,
202
-			Filesystem::signal_read,
203
-			$fileActions,
204
-			'read'
205
-		);
206
-		Util::connectHook(
207
-			Filesystem::CLASSNAME,
208
-			Filesystem::signal_delete,
209
-			$fileActions,
210
-			'delete'
211
-		);
212
-	}
213
-
214
-	protected function versionsHooks(ILogger $logger) {
215
-		$versionsActions = new Versions($logger);
216
-		Util::connectHook('\OCP\Versions', 'rollback', $versionsActions, 'rollback');
217
-		Util::connectHook('\OCP\Versions', 'delete',$versionsActions, 'delete');
218
-	}
219
-
220
-	protected function trashbinHooks(ILogger $logger) {
221
-		$trashActions = new Trashbin($logger);
222
-		Util::connectHook('\OCP\Trashbin', 'preDelete', $trashActions, 'delete');
223
-		Util::connectHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', $trashActions, 'restore');
224
-	}
225
-
226
-	protected function securityHooks(ILogger $logger) {
227
-		$eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher();
228
-		$eventDispatcher->addListener(IProvider::EVENT_SUCCESS, function(GenericEvent $event) use ($logger) {
229
-			$security = new Security($logger);
230
-			$security->twofactorSuccess($event->getSubject(), $event->getArguments());
231
-		});
232
-		$eventDispatcher->addListener(IProvider::EVENT_FAILED, function(GenericEvent $event) use ($logger) {
233
-			$security = new Security($logger);
234
-			$security->twofactorFailed($event->getSubject(), $event->getArguments());
235
-		});
236
-	}
54
+    public function __construct() {
55
+        parent::__construct('admin_audit');
56
+    }
57
+
58
+    public function register() {
59
+        $this->registerHooks();
60
+    }
61
+
62
+    /**
63
+     * Register hooks in order to log them
64
+     */
65
+    protected function registerHooks() {
66
+        $logger = $this->getContainer()->getServer()->getLogger();
67
+
68
+        $this->userManagementHooks($logger);
69
+        $this->groupHooks($logger);
70
+        $this->authHooks($logger);
71
+
72
+        $this->consoleHooks($logger);
73
+        $this->appHooks($logger);
74
+
75
+        $this->sharingHooks($logger);
76
+
77
+        $this->fileHooks($logger);
78
+        $this->trashbinHooks($logger);
79
+        $this->versionsHooks($logger);
80
+
81
+        $this->securityHooks($logger);
82
+    }
83
+
84
+    protected function userManagementHooks(ILogger $logger) {
85
+        $userActions = new UserManagement($logger);
86
+
87
+        Util::connectHook('OC_User', 'post_createUser',	$userActions, 'create');
88
+        Util::connectHook('OC_User', 'post_deleteUser',	$userActions, 'delete');
89
+        Util::connectHook('OC_User', 'changeUser',	$userActions, 'change');
90
+
91
+        /** @var IUserSession|Session $userSession */
92
+        $userSession = $this->getContainer()->getServer()->getUserSession();
93
+        $userSession->listen('\OC\User', 'postSetPassword', [$userActions, 'setPassword']);
94
+    }
95
+
96
+    protected function groupHooks(ILogger $logger)  {
97
+        $groupActions = new GroupManagement($logger);
98
+
99
+        /** @var IGroupManager|Manager $groupManager */
100
+        $groupManager = $this->getContainer()->getServer()->getGroupManager();
101
+        $groupManager->listen('\OC\Group', 'postRemoveUser',  [$groupActions, 'removeUser']);
102
+        $groupManager->listen('\OC\Group', 'postAddUser',  [$groupActions, 'addUser']);
103
+        $groupManager->listen('\OC\Group', 'postDelete',  [$groupActions, 'deleteGroup']);
104
+        $groupManager->listen('\OC\Group', 'postCreate',  [$groupActions, 'createGroup']);
105
+    }
106
+
107
+    protected function sharingHooks(ILogger $logger) {
108
+        $shareActions = new Sharing($logger);
109
+
110
+        Util::connectHook('OCP\Share', 'post_shared', $shareActions, 'shared');
111
+        Util::connectHook('OCP\Share', 'post_unshare', $shareActions, 'unshare');
112
+        Util::connectHook('OCP\Share', 'post_update_permissions', $shareActions, 'updatePermissions');
113
+        Util::connectHook('OCP\Share', 'post_update_password', $shareActions, 'updatePassword');
114
+        Util::connectHook('OCP\Share', 'post_set_expiration_date', $shareActions, 'updateExpirationDate');
115
+        Util::connectHook('OCP\Share', 'share_link_access', $shareActions, 'shareAccessed');
116
+    }
117
+
118
+    protected function authHooks(ILogger $logger) {
119
+        $authActions = new Auth($logger);
120
+
121
+        Util::connectHook('OC_User', 'pre_login', $authActions, 'loginAttempt');
122
+        Util::connectHook('OC_User', 'post_login', $authActions, 'loginSuccessful');
123
+        Util::connectHook('OC_User', 'logout', $authActions, 'logout');
124
+    }
125
+
126
+    protected function appHooks(ILogger $logger) {
127
+
128
+        $eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher();
129
+        $eventDispatcher->addListener(ManagerEvent::EVENT_APP_ENABLE, function(ManagerEvent $event) use ($logger) {
130
+            $appActions = new AppManagement($logger);
131
+            $appActions->enableApp($event->getAppID());
132
+        });
133
+        $eventDispatcher->addListener(ManagerEvent::EVENT_APP_ENABLE_FOR_GROUPS, function(ManagerEvent $event) use ($logger) {
134
+            $appActions = new AppManagement($logger);
135
+            $appActions->enableAppForGroups($event->getAppID(), $event->getGroups());
136
+        });
137
+        $eventDispatcher->addListener(ManagerEvent::EVENT_APP_DISABLE, function(ManagerEvent $event) use ($logger) {
138
+            $appActions = new AppManagement($logger);
139
+            $appActions->disableApp($event->getAppID());
140
+        });
141
+
142
+    }
143
+
144
+    protected function consoleHooks(ILogger $logger) {
145
+        $eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher();
146
+        $eventDispatcher->addListener(ConsoleEvent::EVENT_RUN, function(ConsoleEvent $event) use ($logger) {
147
+            $appActions = new Console($logger);
148
+            $appActions->runCommand($event->getArguments());
149
+        });
150
+    }
151
+
152
+    protected function fileHooks(ILogger $logger) {
153
+        $fileActions = new Files($logger);
154
+        $eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher();
155
+        $eventDispatcher->addListener(
156
+            IPreview::EVENT,
157
+            function(GenericEvent $event) use ($fileActions) {
158
+                /** @var File $file */
159
+                $file = $event->getSubject();
160
+                $fileActions->preview([
161
+                    'path' => substr($file->getInternalPath(), 5),
162
+                    'width' => $event->getArguments()['width'],
163
+                    'height' => $event->getArguments()['height'],
164
+                    'crop' => $event->getArguments()['crop'],
165
+                    'mode'  => $event->getArguments()['mode']
166
+                ]);
167
+            }
168
+        );
169
+
170
+        Util::connectHook(
171
+            Filesystem::CLASSNAME,
172
+            Filesystem::signal_post_rename,
173
+            $fileActions,
174
+            'rename'
175
+        );
176
+        Util::connectHook(
177
+            Filesystem::CLASSNAME,
178
+            Filesystem::signal_post_create,
179
+            $fileActions,
180
+            'create'
181
+        );
182
+        Util::connectHook(
183
+            Filesystem::CLASSNAME,
184
+            Filesystem::signal_post_copy,
185
+            $fileActions,
186
+            'copy'
187
+        );
188
+        Util::connectHook(
189
+            Filesystem::CLASSNAME,
190
+            Filesystem::signal_post_write,
191
+            $fileActions,
192
+            'write'
193
+        );
194
+        Util::connectHook(
195
+            Filesystem::CLASSNAME,
196
+            Filesystem::signal_post_update,
197
+            $fileActions,
198
+            'update'
199
+        );
200
+        Util::connectHook(
201
+            Filesystem::CLASSNAME,
202
+            Filesystem::signal_read,
203
+            $fileActions,
204
+            'read'
205
+        );
206
+        Util::connectHook(
207
+            Filesystem::CLASSNAME,
208
+            Filesystem::signal_delete,
209
+            $fileActions,
210
+            'delete'
211
+        );
212
+    }
213
+
214
+    protected function versionsHooks(ILogger $logger) {
215
+        $versionsActions = new Versions($logger);
216
+        Util::connectHook('\OCP\Versions', 'rollback', $versionsActions, 'rollback');
217
+        Util::connectHook('\OCP\Versions', 'delete',$versionsActions, 'delete');
218
+    }
219
+
220
+    protected function trashbinHooks(ILogger $logger) {
221
+        $trashActions = new Trashbin($logger);
222
+        Util::connectHook('\OCP\Trashbin', 'preDelete', $trashActions, 'delete');
223
+        Util::connectHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', $trashActions, 'restore');
224
+    }
225
+
226
+    protected function securityHooks(ILogger $logger) {
227
+        $eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher();
228
+        $eventDispatcher->addListener(IProvider::EVENT_SUCCESS, function(GenericEvent $event) use ($logger) {
229
+            $security = new Security($logger);
230
+            $security->twofactorSuccess($event->getSubject(), $event->getArguments());
231
+        });
232
+        $eventDispatcher->addListener(IProvider::EVENT_FAILED, function(GenericEvent $event) use ($logger) {
233
+            $security = new Security($logger);
234
+            $security->twofactorFailed($event->getSubject(), $event->getArguments());
235
+        });
236
+    }
237 237
 }
Please login to merge, or discard this patch.
lib/public/Authentication/TwoFactorAuth/IProvider.php 2 patches
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -30,70 +30,70 @@
 block discarded – undo
30 30
  */
31 31
 interface IProvider {
32 32
 
33
-	/**
34
-	 * @since 14.0.0
35
-	 */
36
-	const EVENT_SUCCESS = self::class . '::success';
37
-	const EVENT_FAILED  = self::class . '::failed';
33
+    /**
34
+     * @since 14.0.0
35
+     */
36
+    const EVENT_SUCCESS = self::class . '::success';
37
+    const EVENT_FAILED  = self::class . '::failed';
38 38
 
39
-	/**
40
-	 * Get unique identifier of this 2FA provider
41
-	 *
42
-	 * @since 9.1.0
43
-	 *
44
-	 * @return string
45
-	 */
46
-	public function getId();
39
+    /**
40
+     * Get unique identifier of this 2FA provider
41
+     *
42
+     * @since 9.1.0
43
+     *
44
+     * @return string
45
+     */
46
+    public function getId();
47 47
 
48
-	/**
49
-	 * Get the display name for selecting the 2FA provider
50
-	 *
51
-	 * Example: "Email"
52
-	 *
53
-	 * @since 9.1.0
54
-	 *
55
-	 * @return string
56
-	 */
57
-	public function getDisplayName();
48
+    /**
49
+     * Get the display name for selecting the 2FA provider
50
+     *
51
+     * Example: "Email"
52
+     *
53
+     * @since 9.1.0
54
+     *
55
+     * @return string
56
+     */
57
+    public function getDisplayName();
58 58
 
59
-	/**
60
-	 * Get the description for selecting the 2FA provider
61
-	 *
62
-	 * Example: "Get a token via e-mail"
63
-	 *
64
-	 * @since 9.1.0
65
-	 *
66
-	 * @return string
67
-	 */
68
-	public function getDescription();
59
+    /**
60
+     * Get the description for selecting the 2FA provider
61
+     *
62
+     * Example: "Get a token via e-mail"
63
+     *
64
+     * @since 9.1.0
65
+     *
66
+     * @return string
67
+     */
68
+    public function getDescription();
69 69
 
70
-	/**
71
-	 * Get the template for rending the 2FA provider view
72
-	 *
73
-	 * @since 9.1.0
74
-	 *
75
-	 * @param IUser $user
76
-	 * @return Template
77
-	 */
78
-	public function getTemplate(IUser $user);
70
+    /**
71
+     * Get the template for rending the 2FA provider view
72
+     *
73
+     * @since 9.1.0
74
+     *
75
+     * @param IUser $user
76
+     * @return Template
77
+     */
78
+    public function getTemplate(IUser $user);
79 79
 
80
-	/**
81
-	 * Verify the given challenge
82
-	 *
83
-	 * @since 9.1.0
84
-	 *
85
-	 * @param IUser $user
86
-	 * @param string $challenge
87
-	 */
88
-	public function verifyChallenge(IUser $user, $challenge);
80
+    /**
81
+     * Verify the given challenge
82
+     *
83
+     * @since 9.1.0
84
+     *
85
+     * @param IUser $user
86
+     * @param string $challenge
87
+     */
88
+    public function verifyChallenge(IUser $user, $challenge);
89 89
 
90
-	/**
91
-	 * Decides whether 2FA is enabled for the given user
92
-	 *
93
-	 * @since 9.1.0
94
-	 *
95
-	 * @param IUser $user
96
-	 * @return boolean
97
-	 */
98
-	public function isTwoFactorAuthEnabledForUser(IUser $user);
90
+    /**
91
+     * Decides whether 2FA is enabled for the given user
92
+     *
93
+     * @since 9.1.0
94
+     *
95
+     * @param IUser $user
96
+     * @return boolean
97
+     */
98
+    public function isTwoFactorAuthEnabledForUser(IUser $user);
99 99
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,8 +33,8 @@
 block discarded – undo
33 33
 	/**
34 34
 	 * @since 14.0.0
35 35
 	 */
36
-	const EVENT_SUCCESS = self::class . '::success';
37
-	const EVENT_FAILED  = self::class . '::failed';
36
+	const EVENT_SUCCESS = self::class.'::success';
37
+	const EVENT_FAILED  = self::class.'::failed';
38 38
 
39 39
 	/**
40 40
 	 * Get unique identifier of this 2FA provider
Please login to merge, or discard this patch.
apps/admin_audit/composer/composer/autoload_classmap.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -6,16 +6,16 @@
 block discarded – undo
6 6
 $baseDir = $vendorDir;
7 7
 
8 8
 return array(
9
-    'OCA\\AdminAudit\\Actions\\Action' => $baseDir . '/../lib/Actions/Action.php',
10
-    'OCA\\AdminAudit\\Actions\\AppManagement' => $baseDir . '/../lib/Actions/AppManagement.php',
11
-    'OCA\\AdminAudit\\Actions\\Auth' => $baseDir . '/../lib/Actions/Auth.php',
12
-    'OCA\\AdminAudit\\Actions\\Console' => $baseDir . '/../lib/Actions/Console.php',
13
-    'OCA\\AdminAudit\\Actions\\Files' => $baseDir . '/../lib/Actions/Files.php',
14
-    'OCA\\AdminAudit\\Actions\\GroupManagement' => $baseDir . '/../lib/Actions/GroupManagement.php',
15
-    'OCA\\AdminAudit\\Actions\\Security' => $baseDir . '/../lib/Actions/Security.php',
16
-    'OCA\\AdminAudit\\Actions\\Sharing' => $baseDir . '/../lib/Actions/Sharing.php',
17
-    'OCA\\AdminAudit\\Actions\\Trashbin' => $baseDir . '/../lib/Actions/Trashbin.php',
18
-    'OCA\\AdminAudit\\Actions\\UserManagement' => $baseDir . '/../lib/Actions/UserManagement.php',
19
-    'OCA\\AdminAudit\\Actions\\Versions' => $baseDir . '/../lib/Actions/Versions.php',
20
-    'OCA\\AdminAudit\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
9
+    'OCA\\AdminAudit\\Actions\\Action' => $baseDir.'/../lib/Actions/Action.php',
10
+    'OCA\\AdminAudit\\Actions\\AppManagement' => $baseDir.'/../lib/Actions/AppManagement.php',
11
+    'OCA\\AdminAudit\\Actions\\Auth' => $baseDir.'/../lib/Actions/Auth.php',
12
+    'OCA\\AdminAudit\\Actions\\Console' => $baseDir.'/../lib/Actions/Console.php',
13
+    'OCA\\AdminAudit\\Actions\\Files' => $baseDir.'/../lib/Actions/Files.php',
14
+    'OCA\\AdminAudit\\Actions\\GroupManagement' => $baseDir.'/../lib/Actions/GroupManagement.php',
15
+    'OCA\\AdminAudit\\Actions\\Security' => $baseDir.'/../lib/Actions/Security.php',
16
+    'OCA\\AdminAudit\\Actions\\Sharing' => $baseDir.'/../lib/Actions/Sharing.php',
17
+    'OCA\\AdminAudit\\Actions\\Trashbin' => $baseDir.'/../lib/Actions/Trashbin.php',
18
+    'OCA\\AdminAudit\\Actions\\UserManagement' => $baseDir.'/../lib/Actions/UserManagement.php',
19
+    'OCA\\AdminAudit\\Actions\\Versions' => $baseDir.'/../lib/Actions/Versions.php',
20
+    'OCA\\AdminAudit\\AppInfo\\Application' => $baseDir.'/../lib/AppInfo/Application.php',
21 21
 );
Please login to merge, or discard this patch.
apps/admin_audit/composer/composer/autoload_static.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -6,38 +6,38 @@
 block discarded – undo
6 6
 
7 7
 class ComposerStaticInitAdminAudit
8 8
 {
9
-    public static $prefixLengthsPsr4 = array (
9
+    public static $prefixLengthsPsr4 = array(
10 10
         'O' => 
11
-        array (
11
+        array(
12 12
             'OCA\\AdminAudit\\' => 15,
13 13
         ),
14 14
     );
15 15
 
16
-    public static $prefixDirsPsr4 = array (
16
+    public static $prefixDirsPsr4 = array(
17 17
         'OCA\\AdminAudit\\' => 
18
-        array (
19
-            0 => __DIR__ . '/..' . '/../lib',
18
+        array(
19
+            0 => __DIR__.'/..'.'/../lib',
20 20
         ),
21 21
     );
22 22
 
23
-    public static $classMap = array (
24
-        'OCA\\AdminAudit\\Actions\\Action' => __DIR__ . '/..' . '/../lib/Actions/Action.php',
25
-        'OCA\\AdminAudit\\Actions\\AppManagement' => __DIR__ . '/..' . '/../lib/Actions/AppManagement.php',
26
-        'OCA\\AdminAudit\\Actions\\Auth' => __DIR__ . '/..' . '/../lib/Actions/Auth.php',
27
-        'OCA\\AdminAudit\\Actions\\Console' => __DIR__ . '/..' . '/../lib/Actions/Console.php',
28
-        'OCA\\AdminAudit\\Actions\\Files' => __DIR__ . '/..' . '/../lib/Actions/Files.php',
29
-        'OCA\\AdminAudit\\Actions\\GroupManagement' => __DIR__ . '/..' . '/../lib/Actions/GroupManagement.php',
30
-        'OCA\\AdminAudit\\Actions\\Security' => __DIR__ . '/..' . '/../lib/Actions/Security.php',
31
-        'OCA\\AdminAudit\\Actions\\Sharing' => __DIR__ . '/..' . '/../lib/Actions/Sharing.php',
32
-        'OCA\\AdminAudit\\Actions\\Trashbin' => __DIR__ . '/..' . '/../lib/Actions/Trashbin.php',
33
-        'OCA\\AdminAudit\\Actions\\UserManagement' => __DIR__ . '/..' . '/../lib/Actions/UserManagement.php',
34
-        'OCA\\AdminAudit\\Actions\\Versions' => __DIR__ . '/..' . '/../lib/Actions/Versions.php',
35
-        'OCA\\AdminAudit\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
23
+    public static $classMap = array(
24
+        'OCA\\AdminAudit\\Actions\\Action' => __DIR__.'/..'.'/../lib/Actions/Action.php',
25
+        'OCA\\AdminAudit\\Actions\\AppManagement' => __DIR__.'/..'.'/../lib/Actions/AppManagement.php',
26
+        'OCA\\AdminAudit\\Actions\\Auth' => __DIR__.'/..'.'/../lib/Actions/Auth.php',
27
+        'OCA\\AdminAudit\\Actions\\Console' => __DIR__.'/..'.'/../lib/Actions/Console.php',
28
+        'OCA\\AdminAudit\\Actions\\Files' => __DIR__.'/..'.'/../lib/Actions/Files.php',
29
+        'OCA\\AdminAudit\\Actions\\GroupManagement' => __DIR__.'/..'.'/../lib/Actions/GroupManagement.php',
30
+        'OCA\\AdminAudit\\Actions\\Security' => __DIR__.'/..'.'/../lib/Actions/Security.php',
31
+        'OCA\\AdminAudit\\Actions\\Sharing' => __DIR__.'/..'.'/../lib/Actions/Sharing.php',
32
+        'OCA\\AdminAudit\\Actions\\Trashbin' => __DIR__.'/..'.'/../lib/Actions/Trashbin.php',
33
+        'OCA\\AdminAudit\\Actions\\UserManagement' => __DIR__.'/..'.'/../lib/Actions/UserManagement.php',
34
+        'OCA\\AdminAudit\\Actions\\Versions' => __DIR__.'/..'.'/../lib/Actions/Versions.php',
35
+        'OCA\\AdminAudit\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php',
36 36
     );
37 37
 
38 38
     public static function getInitializer(ClassLoader $loader)
39 39
     {
40
-        return \Closure::bind(function () use ($loader) {
40
+        return \Closure::bind(function() use ($loader) {
41 41
             $loader->prefixLengthsPsr4 = ComposerStaticInitAdminAudit::$prefixLengthsPsr4;
42 42
             $loader->prefixDirsPsr4 = ComposerStaticInitAdminAudit::$prefixDirsPsr4;
43 43
             $loader->classMap = ComposerStaticInitAdminAudit::$classMap;
Please login to merge, or discard this patch.
lib/private/Server.php 1 patch
Indentation   +1827 added lines, -1827 removed lines patch added patch discarded remove patch
@@ -146,1836 +146,1836 @@
 block discarded – undo
146 146
  * TODO: hookup all manager classes
147 147
  */
148 148
 class Server extends ServerContainer implements IServerContainer {
149
-	/** @var string */
150
-	private $webRoot;
151
-
152
-	/**
153
-	 * @param string $webRoot
154
-	 * @param \OC\Config $config
155
-	 */
156
-	public function __construct($webRoot, \OC\Config $config) {
157
-		parent::__construct();
158
-		$this->webRoot = $webRoot;
159
-
160
-		$this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) {
161
-			return $c;
162
-		});
163
-
164
-		$this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
165
-		$this->registerAlias('CalendarManager', \OC\Calendar\Manager::class);
166
-
167
-		$this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
168
-		$this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class);
169
-
170
-		$this->registerAlias(IActionFactory::class, ActionFactory::class);
171
-
172
-
173
-		$this->registerService(\OCP\IPreview::class, function (Server $c) {
174
-			return new PreviewManager(
175
-				$c->getConfig(),
176
-				$c->getRootFolder(),
177
-				$c->getAppDataDir('preview'),
178
-				$c->getEventDispatcher(),
179
-				$c->getSession()->get('user_id')
180
-			);
181
-		});
182
-		$this->registerAlias('PreviewManager', \OCP\IPreview::class);
183
-
184
-		$this->registerService(\OC\Preview\Watcher::class, function (Server $c) {
185
-			return new \OC\Preview\Watcher(
186
-				$c->getAppDataDir('preview')
187
-			);
188
-		});
189
-
190
-		$this->registerService('EncryptionManager', function (Server $c) {
191
-			$view = new View();
192
-			$util = new Encryption\Util(
193
-				$view,
194
-				$c->getUserManager(),
195
-				$c->getGroupManager(),
196
-				$c->getConfig()
197
-			);
198
-			return new Encryption\Manager(
199
-				$c->getConfig(),
200
-				$c->getLogger(),
201
-				$c->getL10N('core'),
202
-				new View(),
203
-				$util,
204
-				new ArrayCache()
205
-			);
206
-		});
207
-
208
-		$this->registerService('EncryptionFileHelper', function (Server $c) {
209
-			$util = new Encryption\Util(
210
-				new View(),
211
-				$c->getUserManager(),
212
-				$c->getGroupManager(),
213
-				$c->getConfig()
214
-			);
215
-			return new Encryption\File(
216
-				$util,
217
-				$c->getRootFolder(),
218
-				$c->getShareManager()
219
-			);
220
-		});
221
-
222
-		$this->registerService('EncryptionKeyStorage', function (Server $c) {
223
-			$view = new View();
224
-			$util = new Encryption\Util(
225
-				$view,
226
-				$c->getUserManager(),
227
-				$c->getGroupManager(),
228
-				$c->getConfig()
229
-			);
230
-
231
-			return new Encryption\Keys\Storage($view, $util);
232
-		});
233
-		$this->registerService('TagMapper', function (Server $c) {
234
-			return new TagMapper($c->getDatabaseConnection());
235
-		});
236
-
237
-		$this->registerService(\OCP\ITagManager::class, function (Server $c) {
238
-			$tagMapper = $c->query('TagMapper');
239
-			return new TagManager($tagMapper, $c->getUserSession());
240
-		});
241
-		$this->registerAlias('TagManager', \OCP\ITagManager::class);
242
-
243
-		$this->registerService('SystemTagManagerFactory', function (Server $c) {
244
-			$config = $c->getConfig();
245
-			$factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory');
246
-			/** @var \OC\SystemTag\ManagerFactory $factory */
247
-			$factory = new $factoryClass($this);
248
-			return $factory;
249
-		});
250
-		$this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) {
251
-			return $c->query('SystemTagManagerFactory')->getManager();
252
-		});
253
-		$this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class);
254
-
255
-		$this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) {
256
-			return $c->query('SystemTagManagerFactory')->getObjectMapper();
257
-		});
258
-		$this->registerService('RootFolder', function (Server $c) {
259
-			$manager = \OC\Files\Filesystem::getMountManager(null);
260
-			$view = new View();
261
-			$root = new Root(
262
-				$manager,
263
-				$view,
264
-				null,
265
-				$c->getUserMountCache(),
266
-				$this->getLogger(),
267
-				$this->getUserManager()
268
-			);
269
-			$connector = new HookConnector($root, $view);
270
-			$connector->viewToNode();
271
-
272
-			$previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig());
273
-			$previewConnector->connectWatcher();
274
-
275
-			return $root;
276
-		});
277
-		$this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class);
278
-
279
-		$this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) {
280
-			return new LazyRoot(function () use ($c) {
281
-				return $c->query('RootFolder');
282
-			});
283
-		});
284
-		$this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class);
285
-
286
-		$this->registerService(\OC\User\Manager::class, function (Server $c) {
287
-			$config = $c->getConfig();
288
-			return new \OC\User\Manager($config);
289
-		});
290
-		$this->registerAlias('UserManager', \OC\User\Manager::class);
291
-		$this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
292
-
293
-		$this->registerService(\OCP\IGroupManager::class, function (Server $c) {
294
-			$groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger());
295
-			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
296
-				\OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
297
-			});
298
-			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) {
299
-				\OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
300
-			});
301
-			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
302
-				\OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
303
-			});
304
-			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
305
-				\OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
306
-			});
307
-			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
308
-				\OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
309
-			});
310
-			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
311
-				\OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
312
-				//Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
313
-				\OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
314
-			});
315
-			return $groupManager;
316
-		});
317
-		$this->registerAlias('GroupManager', \OCP\IGroupManager::class);
318
-
319
-		$this->registerService(Store::class, function (Server $c) {
320
-			$session = $c->getSession();
321
-			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
322
-				$tokenProvider = $c->query('OC\Authentication\Token\IProvider');
323
-			} else {
324
-				$tokenProvider = null;
325
-			}
326
-			$logger = $c->getLogger();
327
-			return new Store($session, $logger, $tokenProvider);
328
-		});
329
-		$this->registerAlias(IStore::class, Store::class);
330
-		$this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) {
331
-			$dbConnection = $c->getDatabaseConnection();
332
-			return new Authentication\Token\DefaultTokenMapper($dbConnection);
333
-		});
334
-		$this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) {
335
-			$mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper');
336
-			$crypto = $c->getCrypto();
337
-			$config = $c->getConfig();
338
-			$logger = $c->getLogger();
339
-			$timeFactory = new TimeFactory();
340
-			return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory);
341
-		});
342
-		$this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider');
343
-
344
-		$this->registerService(\OCP\IUserSession::class, function (Server $c) {
345
-			$manager = $c->getUserManager();
346
-			$session = new \OC\Session\Memory('');
347
-			$timeFactory = new TimeFactory();
348
-			// Token providers might require a working database. This code
349
-			// might however be called when ownCloud is not yet setup.
350
-			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
351
-				$defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider');
352
-			} else {
353
-				$defaultTokenProvider = null;
354
-			}
355
-
356
-			$dispatcher = $c->getEventDispatcher();
357
-
358
-			$userSession = new \OC\User\Session(
359
-				$manager,
360
-				$session,
361
-				$timeFactory,
362
-				$defaultTokenProvider,
363
-				$c->getConfig(),
364
-				$c->getSecureRandom(),
365
-				$c->getLockdownManager(),
366
-				$c->getLogger()
367
-			);
368
-			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
369
-				\OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
370
-			});
371
-			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
372
-				/** @var $user \OC\User\User */
373
-				\OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
374
-			});
375
-			$userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) {
376
-				/** @var $user \OC\User\User */
377
-				\OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
378
-				$dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user));
379
-			});
380
-			$userSession->listen('\OC\User', 'postDelete', function ($user) {
381
-				/** @var $user \OC\User\User */
382
-				\OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
383
-			});
384
-			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
385
-				/** @var $user \OC\User\User */
386
-				\OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
387
-			});
388
-			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
389
-				/** @var $user \OC\User\User */
390
-				\OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
391
-			});
392
-			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
393
-				\OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
394
-			});
395
-			$userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
396
-				/** @var $user \OC\User\User */
397
-				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
398
-			});
399
-			$userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
400
-				/** @var $user \OC\User\User */
401
-				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
402
-			});
403
-			$userSession->listen('\OC\User', 'logout', function () {
404
-				\OC_Hook::emit('OC_User', 'logout', array());
405
-			});
406
-			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) use ($dispatcher) {
407
-				/** @var $user \OC\User\User */
408
-				\OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue));
409
-				$dispatcher->dispatch('OCP\IUser::changeUser', new GenericEvent($user, ['feature' => $feature, 'oldValue' => $oldValue, 'value' => $value]));
410
-			});
411
-			return $userSession;
412
-		});
413
-		$this->registerAlias('UserSession', \OCP\IUserSession::class);
414
-
415
-		$this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) {
416
-			return new \OC\Authentication\TwoFactorAuth\Manager(
417
-				$c->getAppManager(),
418
-				$c->getSession(),
419
-				$c->getConfig(),
420
-				$c->getActivityManager(),
421
-				$c->getLogger(),
422
-				$c->query(\OC\Authentication\Token\IProvider::class),
423
-				$c->query(ITimeFactory::class),
424
-				$c->query(EventDispatcherInterface::class)
425
-			);
426
-		});
427
-
428
-		$this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class);
429
-		$this->registerAlias('NavigationManager', \OCP\INavigationManager::class);
430
-
431
-		$this->registerService(\OC\AllConfig::class, function (Server $c) {
432
-			return new \OC\AllConfig(
433
-				$c->getSystemConfig()
434
-			);
435
-		});
436
-		$this->registerAlias('AllConfig', \OC\AllConfig::class);
437
-		$this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
438
-
439
-		$this->registerService('SystemConfig', function ($c) use ($config) {
440
-			return new \OC\SystemConfig($config);
441
-		});
442
-
443
-		$this->registerService(\OC\AppConfig::class, function (Server $c) {
444
-			return new \OC\AppConfig($c->getDatabaseConnection());
445
-		});
446
-		$this->registerAlias('AppConfig', \OC\AppConfig::class);
447
-		$this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class);
448
-
449
-		$this->registerService(\OCP\L10N\IFactory::class, function (Server $c) {
450
-			return new \OC\L10N\Factory(
451
-				$c->getConfig(),
452
-				$c->getRequest(),
453
-				$c->getUserSession(),
454
-				\OC::$SERVERROOT
455
-			);
456
-		});
457
-		$this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class);
458
-
459
-		$this->registerService(\OCP\IURLGenerator::class, function (Server $c) {
460
-			$config = $c->getConfig();
461
-			$cacheFactory = $c->getMemCacheFactory();
462
-			$request = $c->getRequest();
463
-			return new \OC\URLGenerator(
464
-				$config,
465
-				$cacheFactory,
466
-				$request
467
-			);
468
-		});
469
-		$this->registerAlias('URLGenerator', \OCP\IURLGenerator::class);
470
-
471
-		$this->registerService('AppHelper', function ($c) {
472
-			return new \OC\AppHelper();
473
-		});
474
-		$this->registerAlias('AppFetcher', AppFetcher::class);
475
-		$this->registerAlias('CategoryFetcher', CategoryFetcher::class);
476
-
477
-		$this->registerService(\OCP\ICache::class, function ($c) {
478
-			return new Cache\File();
479
-		});
480
-		$this->registerAlias('UserCache', \OCP\ICache::class);
481
-
482
-		$this->registerService(Factory::class, function (Server $c) {
483
-
484
-			$arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(),
485
-				'\\OC\\Memcache\\ArrayCache',
486
-				'\\OC\\Memcache\\ArrayCache',
487
-				'\\OC\\Memcache\\ArrayCache'
488
-			);
489
-			$config = $c->getConfig();
490
-			$request = $c->getRequest();
491
-			$urlGenerator = new URLGenerator($config, $arrayCacheFactory, $request);
492
-
493
-			if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
494
-				$v = \OC_App::getAppVersions();
495
-				$v['core'] = implode(',', \OC_Util::getVersion());
496
-				$version = implode(',', $v);
497
-				$instanceId = \OC_Util::getInstanceId();
498
-				$path = \OC::$SERVERROOT;
499
-				$prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . $urlGenerator->getBaseUrl());
500
-				return new \OC\Memcache\Factory($prefix, $c->getLogger(),
501
-					$config->getSystemValue('memcache.local', null),
502
-					$config->getSystemValue('memcache.distributed', null),
503
-					$config->getSystemValue('memcache.locking', null)
504
-				);
505
-			}
506
-			return $arrayCacheFactory;
507
-
508
-		});
509
-		$this->registerAlias('MemCacheFactory', Factory::class);
510
-		$this->registerAlias(ICacheFactory::class, Factory::class);
511
-
512
-		$this->registerService('RedisFactory', function (Server $c) {
513
-			$systemConfig = $c->getSystemConfig();
514
-			return new RedisFactory($systemConfig);
515
-		});
516
-
517
-		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
518
-			return new \OC\Activity\Manager(
519
-				$c->getRequest(),
520
-				$c->getUserSession(),
521
-				$c->getConfig(),
522
-				$c->query(IValidator::class)
523
-			);
524
-		});
525
-		$this->registerAlias('ActivityManager', \OCP\Activity\IManager::class);
526
-
527
-		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
528
-			return new \OC\Activity\EventMerger(
529
-				$c->getL10N('lib')
530
-			);
531
-		});
532
-		$this->registerAlias(IValidator::class, Validator::class);
533
-
534
-		$this->registerService(\OCP\IAvatarManager::class, function (Server $c) {
535
-			return new AvatarManager(
536
-				$c->query(\OC\User\Manager::class),
537
-				$c->getAppDataDir('avatar'),
538
-				$c->getL10N('lib'),
539
-				$c->getLogger(),
540
-				$c->getConfig()
541
-			);
542
-		});
543
-		$this->registerAlias('AvatarManager', \OCP\IAvatarManager::class);
544
-
545
-		$this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
546
-
547
-		$this->registerService(\OCP\ILogger::class, function (Server $c) {
548
-			$logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
549
-			$logger = Log::getLogClass($logType);
550
-			call_user_func(array($logger, 'init'));
551
-			$config = $this->getSystemConfig();
552
-			$registry = $c->query(\OCP\Support\CrashReport\IRegistry::class);
553
-
554
-			return new Log($logger, $config, null, $registry);
555
-		});
556
-		$this->registerAlias('Logger', \OCP\ILogger::class);
557
-
558
-		$this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) {
559
-			$config = $c->getConfig();
560
-			return new \OC\BackgroundJob\JobList(
561
-				$c->getDatabaseConnection(),
562
-				$config,
563
-				new TimeFactory()
564
-			);
565
-		});
566
-		$this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class);
567
-
568
-		$this->registerService(\OCP\Route\IRouter::class, function (Server $c) {
569
-			$cacheFactory = $c->getMemCacheFactory();
570
-			$logger = $c->getLogger();
571
-			if ($cacheFactory->isAvailableLowLatency()) {
572
-				$router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger);
573
-			} else {
574
-				$router = new \OC\Route\Router($logger);
575
-			}
576
-			return $router;
577
-		});
578
-		$this->registerAlias('Router', \OCP\Route\IRouter::class);
579
-
580
-		$this->registerService(\OCP\ISearch::class, function ($c) {
581
-			return new Search();
582
-		});
583
-		$this->registerAlias('Search', \OCP\ISearch::class);
584
-
585
-		$this->registerService(\OC\Security\RateLimiting\Limiter::class, function ($c) {
586
-			return new \OC\Security\RateLimiting\Limiter(
587
-				$this->getUserSession(),
588
-				$this->getRequest(),
589
-				new \OC\AppFramework\Utility\TimeFactory(),
590
-				$c->query(\OC\Security\RateLimiting\Backend\IBackend::class)
591
-			);
592
-		});
593
-		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
594
-			return new \OC\Security\RateLimiting\Backend\MemoryCache(
595
-				$this->getMemCacheFactory(),
596
-				new \OC\AppFramework\Utility\TimeFactory()
597
-			);
598
-		});
599
-
600
-		$this->registerService(\OCP\Security\ISecureRandom::class, function ($c) {
601
-			return new SecureRandom();
602
-		});
603
-		$this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
604
-
605
-		$this->registerService(\OCP\Security\ICrypto::class, function (Server $c) {
606
-			return new Crypto($c->getConfig(), $c->getSecureRandom());
607
-		});
608
-		$this->registerAlias('Crypto', \OCP\Security\ICrypto::class);
609
-
610
-		$this->registerService(\OCP\Security\IHasher::class, function (Server $c) {
611
-			return new Hasher($c->getConfig());
612
-		});
613
-		$this->registerAlias('Hasher', \OCP\Security\IHasher::class);
614
-
615
-		$this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) {
616
-			return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
617
-		});
618
-		$this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class);
619
-
620
-		$this->registerService(IDBConnection::class, function (Server $c) {
621
-			$systemConfig = $c->getSystemConfig();
622
-			$factory = new \OC\DB\ConnectionFactory($systemConfig);
623
-			$type = $systemConfig->getValue('dbtype', 'sqlite');
624
-			if (!$factory->isValidType($type)) {
625
-				throw new \OC\DatabaseException('Invalid database type');
626
-			}
627
-			$connectionParams = $factory->createConnectionParams();
628
-			$connection = $factory->getConnection($type, $connectionParams);
629
-			$connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
630
-			return $connection;
631
-		});
632
-		$this->registerAlias('DatabaseConnection', IDBConnection::class);
633
-
634
-		$this->registerService('HTTPHelper', function (Server $c) {
635
-			$config = $c->getConfig();
636
-			return new HTTPHelper(
637
-				$config,
638
-				$c->getHTTPClientService()
639
-			);
640
-		});
641
-
642
-		$this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) {
643
-			$user = \OC_User::getUser();
644
-			$uid = $user ? $user : null;
645
-			return new ClientService(
646
-				$c->getConfig(),
647
-				new \OC\Security\CertificateManager(
648
-					$uid,
649
-					new View(),
650
-					$c->getConfig(),
651
-					$c->getLogger(),
652
-					$c->getSecureRandom()
653
-				)
654
-			);
655
-		});
656
-		$this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class);
657
-		$this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) {
658
-			$eventLogger = new EventLogger();
659
-			if ($c->getSystemConfig()->getValue('debug', false)) {
660
-				// In debug mode, module is being activated by default
661
-				$eventLogger->activate();
662
-			}
663
-			return $eventLogger;
664
-		});
665
-		$this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class);
666
-
667
-		$this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) {
668
-			$queryLogger = new QueryLogger();
669
-			if ($c->getSystemConfig()->getValue('debug', false)) {
670
-				// In debug mode, module is being activated by default
671
-				$queryLogger->activate();
672
-			}
673
-			return $queryLogger;
674
-		});
675
-		$this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class);
676
-
677
-		$this->registerService(TempManager::class, function (Server $c) {
678
-			return new TempManager(
679
-				$c->getLogger(),
680
-				$c->getConfig()
681
-			);
682
-		});
683
-		$this->registerAlias('TempManager', TempManager::class);
684
-		$this->registerAlias(ITempManager::class, TempManager::class);
685
-
686
-		$this->registerService(AppManager::class, function (Server $c) {
687
-			return new \OC\App\AppManager(
688
-				$c->getUserSession(),
689
-				$c->query(\OC\AppConfig::class),
690
-				$c->getGroupManager(),
691
-				$c->getMemCacheFactory(),
692
-				$c->getEventDispatcher()
693
-			);
694
-		});
695
-		$this->registerAlias('AppManager', AppManager::class);
696
-		$this->registerAlias(IAppManager::class, AppManager::class);
697
-
698
-		$this->registerService(\OCP\IDateTimeZone::class, function (Server $c) {
699
-			return new DateTimeZone(
700
-				$c->getConfig(),
701
-				$c->getSession()
702
-			);
703
-		});
704
-		$this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class);
705
-
706
-		$this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) {
707
-			$language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
708
-
709
-			return new DateTimeFormatter(
710
-				$c->getDateTimeZone()->getTimeZone(),
711
-				$c->getL10N('lib', $language)
712
-			);
713
-		});
714
-		$this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class);
715
-
716
-		$this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) {
717
-			$mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
718
-			$listener = new UserMountCacheListener($mountCache);
719
-			$listener->listen($c->getUserManager());
720
-			return $mountCache;
721
-		});
722
-		$this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class);
723
-
724
-		$this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) {
725
-			$loader = \OC\Files\Filesystem::getLoader();
726
-			$mountCache = $c->query('UserMountCache');
727
-			$manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
728
-
729
-			// builtin providers
730
-
731
-			$config = $c->getConfig();
732
-			$manager->registerProvider(new CacheMountProvider($config));
733
-			$manager->registerHomeProvider(new LocalHomeMountProvider());
734
-			$manager->registerHomeProvider(new ObjectHomeMountProvider($config));
735
-
736
-			return $manager;
737
-		});
738
-		$this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class);
739
-
740
-		$this->registerService('IniWrapper', function ($c) {
741
-			return new IniGetWrapper();
742
-		});
743
-		$this->registerService('AsyncCommandBus', function (Server $c) {
744
-			$busClass = $c->getConfig()->getSystemValue('commandbus');
745
-			if ($busClass) {
746
-				list($app, $class) = explode('::', $busClass, 2);
747
-				if ($c->getAppManager()->isInstalled($app)) {
748
-					\OC_App::loadApp($app);
749
-					return $c->query($class);
750
-				} else {
751
-					throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
752
-				}
753
-			} else {
754
-				$jobList = $c->getJobList();
755
-				return new CronBus($jobList);
756
-			}
757
-		});
758
-		$this->registerService('TrustedDomainHelper', function ($c) {
759
-			return new TrustedDomainHelper($this->getConfig());
760
-		});
761
-		$this->registerService('Throttler', function (Server $c) {
762
-			return new Throttler(
763
-				$c->getDatabaseConnection(),
764
-				new TimeFactory(),
765
-				$c->getLogger(),
766
-				$c->getConfig()
767
-			);
768
-		});
769
-		$this->registerService('IntegrityCodeChecker', function (Server $c) {
770
-			// IConfig and IAppManager requires a working database. This code
771
-			// might however be called when ownCloud is not yet setup.
772
-			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
773
-				$config = $c->getConfig();
774
-				$appManager = $c->getAppManager();
775
-			} else {
776
-				$config = null;
777
-				$appManager = null;
778
-			}
779
-
780
-			return new Checker(
781
-				new EnvironmentHelper(),
782
-				new FileAccessHelper(),
783
-				new AppLocator(),
784
-				$config,
785
-				$c->getMemCacheFactory(),
786
-				$appManager,
787
-				$c->getTempManager()
788
-			);
789
-		});
790
-		$this->registerService(\OCP\IRequest::class, function ($c) {
791
-			if (isset($this['urlParams'])) {
792
-				$urlParams = $this['urlParams'];
793
-			} else {
794
-				$urlParams = [];
795
-			}
796
-
797
-			if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
798
-				&& in_array('fakeinput', stream_get_wrappers())
799
-			) {
800
-				$stream = 'fakeinput://data';
801
-			} else {
802
-				$stream = 'php://input';
803
-			}
804
-
805
-			return new Request(
806
-				[
807
-					'get' => $_GET,
808
-					'post' => $_POST,
809
-					'files' => $_FILES,
810
-					'server' => $_SERVER,
811
-					'env' => $_ENV,
812
-					'cookies' => $_COOKIE,
813
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
814
-						? $_SERVER['REQUEST_METHOD']
815
-						: null,
816
-					'urlParams' => $urlParams,
817
-				],
818
-				$this->getSecureRandom(),
819
-				$this->getConfig(),
820
-				$this->getCsrfTokenManager(),
821
-				$stream
822
-			);
823
-		});
824
-		$this->registerAlias('Request', \OCP\IRequest::class);
825
-
826
-		$this->registerService(\OCP\Mail\IMailer::class, function (Server $c) {
827
-			return new Mailer(
828
-				$c->getConfig(),
829
-				$c->getLogger(),
830
-				$c->query(Defaults::class),
831
-				$c->getURLGenerator(),
832
-				$c->getL10N('lib')
833
-			);
834
-		});
835
-		$this->registerAlias('Mailer', \OCP\Mail\IMailer::class);
836
-
837
-		$this->registerService('LDAPProvider', function (Server $c) {
838
-			$config = $c->getConfig();
839
-			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
840
-			if (is_null($factoryClass)) {
841
-				throw new \Exception('ldapProviderFactory not set');
842
-			}
843
-			/** @var \OCP\LDAP\ILDAPProviderFactory $factory */
844
-			$factory = new $factoryClass($this);
845
-			return $factory->getLDAPProvider();
846
-		});
847
-		$this->registerService(ILockingProvider::class, function (Server $c) {
848
-			$ini = $c->getIniWrapper();
849
-			$config = $c->getConfig();
850
-			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
851
-			if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
852
-				/** @var \OC\Memcache\Factory $memcacheFactory */
853
-				$memcacheFactory = $c->getMemCacheFactory();
854
-				$memcache = $memcacheFactory->createLocking('lock');
855
-				if (!($memcache instanceof \OC\Memcache\NullCache)) {
856
-					return new MemcacheLockingProvider($memcache, $ttl);
857
-				}
858
-				return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl);
859
-			}
860
-			return new NoopLockingProvider();
861
-		});
862
-		$this->registerAlias('LockingProvider', ILockingProvider::class);
863
-
864
-		$this->registerService(\OCP\Files\Mount\IMountManager::class, function () {
865
-			return new \OC\Files\Mount\Manager();
866
-		});
867
-		$this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class);
868
-
869
-		$this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) {
870
-			return new \OC\Files\Type\Detection(
871
-				$c->getURLGenerator(),
872
-				\OC::$configDir,
873
-				\OC::$SERVERROOT . '/resources/config/'
874
-			);
875
-		});
876
-		$this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class);
877
-
878
-		$this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) {
879
-			return new \OC\Files\Type\Loader(
880
-				$c->getDatabaseConnection()
881
-			);
882
-		});
883
-		$this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class);
884
-		$this->registerService(BundleFetcher::class, function () {
885
-			return new BundleFetcher($this->getL10N('lib'));
886
-		});
887
-		$this->registerService(\OCP\Notification\IManager::class, function (Server $c) {
888
-			return new Manager(
889
-				$c->query(IValidator::class)
890
-			);
891
-		});
892
-		$this->registerAlias('NotificationManager', \OCP\Notification\IManager::class);
893
-
894
-		$this->registerService(\OC\CapabilitiesManager::class, function (Server $c) {
895
-			$manager = new \OC\CapabilitiesManager($c->getLogger());
896
-			$manager->registerCapability(function () use ($c) {
897
-				return new \OC\OCS\CoreCapabilities($c->getConfig());
898
-			});
899
-			$manager->registerCapability(function () use ($c) {
900
-				return $c->query(\OC\Security\Bruteforce\Capabilities::class);
901
-			});
902
-			return $manager;
903
-		});
904
-		$this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class);
905
-
906
-		$this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) {
907
-			$config = $c->getConfig();
908
-			$factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
909
-			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
910
-			$factory = new $factoryClass($this);
911
-			$manager = $factory->getManager();
912
-
913
-			$manager->registerDisplayNameResolver('user', function($id) use ($c) {
914
-				$manager = $c->getUserManager();
915
-				$user = $manager->get($id);
916
-				if(is_null($user)) {
917
-					$l = $c->getL10N('core');
918
-					$displayName = $l->t('Unknown user');
919
-				} else {
920
-					$displayName = $user->getDisplayName();
921
-				}
922
-				return $displayName;
923
-			});
924
-
925
-			return $manager;
926
-		});
927
-		$this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class);
928
-
929
-		$this->registerService('ThemingDefaults', function (Server $c) {
930
-			/*
149
+    /** @var string */
150
+    private $webRoot;
151
+
152
+    /**
153
+     * @param string $webRoot
154
+     * @param \OC\Config $config
155
+     */
156
+    public function __construct($webRoot, \OC\Config $config) {
157
+        parent::__construct();
158
+        $this->webRoot = $webRoot;
159
+
160
+        $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) {
161
+            return $c;
162
+        });
163
+
164
+        $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
165
+        $this->registerAlias('CalendarManager', \OC\Calendar\Manager::class);
166
+
167
+        $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
168
+        $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class);
169
+
170
+        $this->registerAlias(IActionFactory::class, ActionFactory::class);
171
+
172
+
173
+        $this->registerService(\OCP\IPreview::class, function (Server $c) {
174
+            return new PreviewManager(
175
+                $c->getConfig(),
176
+                $c->getRootFolder(),
177
+                $c->getAppDataDir('preview'),
178
+                $c->getEventDispatcher(),
179
+                $c->getSession()->get('user_id')
180
+            );
181
+        });
182
+        $this->registerAlias('PreviewManager', \OCP\IPreview::class);
183
+
184
+        $this->registerService(\OC\Preview\Watcher::class, function (Server $c) {
185
+            return new \OC\Preview\Watcher(
186
+                $c->getAppDataDir('preview')
187
+            );
188
+        });
189
+
190
+        $this->registerService('EncryptionManager', function (Server $c) {
191
+            $view = new View();
192
+            $util = new Encryption\Util(
193
+                $view,
194
+                $c->getUserManager(),
195
+                $c->getGroupManager(),
196
+                $c->getConfig()
197
+            );
198
+            return new Encryption\Manager(
199
+                $c->getConfig(),
200
+                $c->getLogger(),
201
+                $c->getL10N('core'),
202
+                new View(),
203
+                $util,
204
+                new ArrayCache()
205
+            );
206
+        });
207
+
208
+        $this->registerService('EncryptionFileHelper', function (Server $c) {
209
+            $util = new Encryption\Util(
210
+                new View(),
211
+                $c->getUserManager(),
212
+                $c->getGroupManager(),
213
+                $c->getConfig()
214
+            );
215
+            return new Encryption\File(
216
+                $util,
217
+                $c->getRootFolder(),
218
+                $c->getShareManager()
219
+            );
220
+        });
221
+
222
+        $this->registerService('EncryptionKeyStorage', function (Server $c) {
223
+            $view = new View();
224
+            $util = new Encryption\Util(
225
+                $view,
226
+                $c->getUserManager(),
227
+                $c->getGroupManager(),
228
+                $c->getConfig()
229
+            );
230
+
231
+            return new Encryption\Keys\Storage($view, $util);
232
+        });
233
+        $this->registerService('TagMapper', function (Server $c) {
234
+            return new TagMapper($c->getDatabaseConnection());
235
+        });
236
+
237
+        $this->registerService(\OCP\ITagManager::class, function (Server $c) {
238
+            $tagMapper = $c->query('TagMapper');
239
+            return new TagManager($tagMapper, $c->getUserSession());
240
+        });
241
+        $this->registerAlias('TagManager', \OCP\ITagManager::class);
242
+
243
+        $this->registerService('SystemTagManagerFactory', function (Server $c) {
244
+            $config = $c->getConfig();
245
+            $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory');
246
+            /** @var \OC\SystemTag\ManagerFactory $factory */
247
+            $factory = new $factoryClass($this);
248
+            return $factory;
249
+        });
250
+        $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) {
251
+            return $c->query('SystemTagManagerFactory')->getManager();
252
+        });
253
+        $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class);
254
+
255
+        $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) {
256
+            return $c->query('SystemTagManagerFactory')->getObjectMapper();
257
+        });
258
+        $this->registerService('RootFolder', function (Server $c) {
259
+            $manager = \OC\Files\Filesystem::getMountManager(null);
260
+            $view = new View();
261
+            $root = new Root(
262
+                $manager,
263
+                $view,
264
+                null,
265
+                $c->getUserMountCache(),
266
+                $this->getLogger(),
267
+                $this->getUserManager()
268
+            );
269
+            $connector = new HookConnector($root, $view);
270
+            $connector->viewToNode();
271
+
272
+            $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig());
273
+            $previewConnector->connectWatcher();
274
+
275
+            return $root;
276
+        });
277
+        $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class);
278
+
279
+        $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) {
280
+            return new LazyRoot(function () use ($c) {
281
+                return $c->query('RootFolder');
282
+            });
283
+        });
284
+        $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class);
285
+
286
+        $this->registerService(\OC\User\Manager::class, function (Server $c) {
287
+            $config = $c->getConfig();
288
+            return new \OC\User\Manager($config);
289
+        });
290
+        $this->registerAlias('UserManager', \OC\User\Manager::class);
291
+        $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
292
+
293
+        $this->registerService(\OCP\IGroupManager::class, function (Server $c) {
294
+            $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger());
295
+            $groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
296
+                \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
297
+            });
298
+            $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) {
299
+                \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
300
+            });
301
+            $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
302
+                \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
303
+            });
304
+            $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
305
+                \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
306
+            });
307
+            $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
308
+                \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
309
+            });
310
+            $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
311
+                \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
312
+                //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
313
+                \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
314
+            });
315
+            return $groupManager;
316
+        });
317
+        $this->registerAlias('GroupManager', \OCP\IGroupManager::class);
318
+
319
+        $this->registerService(Store::class, function (Server $c) {
320
+            $session = $c->getSession();
321
+            if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
322
+                $tokenProvider = $c->query('OC\Authentication\Token\IProvider');
323
+            } else {
324
+                $tokenProvider = null;
325
+            }
326
+            $logger = $c->getLogger();
327
+            return new Store($session, $logger, $tokenProvider);
328
+        });
329
+        $this->registerAlias(IStore::class, Store::class);
330
+        $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) {
331
+            $dbConnection = $c->getDatabaseConnection();
332
+            return new Authentication\Token\DefaultTokenMapper($dbConnection);
333
+        });
334
+        $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) {
335
+            $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper');
336
+            $crypto = $c->getCrypto();
337
+            $config = $c->getConfig();
338
+            $logger = $c->getLogger();
339
+            $timeFactory = new TimeFactory();
340
+            return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory);
341
+        });
342
+        $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider');
343
+
344
+        $this->registerService(\OCP\IUserSession::class, function (Server $c) {
345
+            $manager = $c->getUserManager();
346
+            $session = new \OC\Session\Memory('');
347
+            $timeFactory = new TimeFactory();
348
+            // Token providers might require a working database. This code
349
+            // might however be called when ownCloud is not yet setup.
350
+            if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
351
+                $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider');
352
+            } else {
353
+                $defaultTokenProvider = null;
354
+            }
355
+
356
+            $dispatcher = $c->getEventDispatcher();
357
+
358
+            $userSession = new \OC\User\Session(
359
+                $manager,
360
+                $session,
361
+                $timeFactory,
362
+                $defaultTokenProvider,
363
+                $c->getConfig(),
364
+                $c->getSecureRandom(),
365
+                $c->getLockdownManager(),
366
+                $c->getLogger()
367
+            );
368
+            $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
369
+                \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
370
+            });
371
+            $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
372
+                /** @var $user \OC\User\User */
373
+                \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
374
+            });
375
+            $userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) {
376
+                /** @var $user \OC\User\User */
377
+                \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
378
+                $dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user));
379
+            });
380
+            $userSession->listen('\OC\User', 'postDelete', function ($user) {
381
+                /** @var $user \OC\User\User */
382
+                \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
383
+            });
384
+            $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
385
+                /** @var $user \OC\User\User */
386
+                \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
387
+            });
388
+            $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
389
+                /** @var $user \OC\User\User */
390
+                \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
391
+            });
392
+            $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
393
+                \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
394
+            });
395
+            $userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
396
+                /** @var $user \OC\User\User */
397
+                \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
398
+            });
399
+            $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
400
+                /** @var $user \OC\User\User */
401
+                \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
402
+            });
403
+            $userSession->listen('\OC\User', 'logout', function () {
404
+                \OC_Hook::emit('OC_User', 'logout', array());
405
+            });
406
+            $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) use ($dispatcher) {
407
+                /** @var $user \OC\User\User */
408
+                \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue));
409
+                $dispatcher->dispatch('OCP\IUser::changeUser', new GenericEvent($user, ['feature' => $feature, 'oldValue' => $oldValue, 'value' => $value]));
410
+            });
411
+            return $userSession;
412
+        });
413
+        $this->registerAlias('UserSession', \OCP\IUserSession::class);
414
+
415
+        $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) {
416
+            return new \OC\Authentication\TwoFactorAuth\Manager(
417
+                $c->getAppManager(),
418
+                $c->getSession(),
419
+                $c->getConfig(),
420
+                $c->getActivityManager(),
421
+                $c->getLogger(),
422
+                $c->query(\OC\Authentication\Token\IProvider::class),
423
+                $c->query(ITimeFactory::class),
424
+                $c->query(EventDispatcherInterface::class)
425
+            );
426
+        });
427
+
428
+        $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class);
429
+        $this->registerAlias('NavigationManager', \OCP\INavigationManager::class);
430
+
431
+        $this->registerService(\OC\AllConfig::class, function (Server $c) {
432
+            return new \OC\AllConfig(
433
+                $c->getSystemConfig()
434
+            );
435
+        });
436
+        $this->registerAlias('AllConfig', \OC\AllConfig::class);
437
+        $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
438
+
439
+        $this->registerService('SystemConfig', function ($c) use ($config) {
440
+            return new \OC\SystemConfig($config);
441
+        });
442
+
443
+        $this->registerService(\OC\AppConfig::class, function (Server $c) {
444
+            return new \OC\AppConfig($c->getDatabaseConnection());
445
+        });
446
+        $this->registerAlias('AppConfig', \OC\AppConfig::class);
447
+        $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class);
448
+
449
+        $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) {
450
+            return new \OC\L10N\Factory(
451
+                $c->getConfig(),
452
+                $c->getRequest(),
453
+                $c->getUserSession(),
454
+                \OC::$SERVERROOT
455
+            );
456
+        });
457
+        $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class);
458
+
459
+        $this->registerService(\OCP\IURLGenerator::class, function (Server $c) {
460
+            $config = $c->getConfig();
461
+            $cacheFactory = $c->getMemCacheFactory();
462
+            $request = $c->getRequest();
463
+            return new \OC\URLGenerator(
464
+                $config,
465
+                $cacheFactory,
466
+                $request
467
+            );
468
+        });
469
+        $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class);
470
+
471
+        $this->registerService('AppHelper', function ($c) {
472
+            return new \OC\AppHelper();
473
+        });
474
+        $this->registerAlias('AppFetcher', AppFetcher::class);
475
+        $this->registerAlias('CategoryFetcher', CategoryFetcher::class);
476
+
477
+        $this->registerService(\OCP\ICache::class, function ($c) {
478
+            return new Cache\File();
479
+        });
480
+        $this->registerAlias('UserCache', \OCP\ICache::class);
481
+
482
+        $this->registerService(Factory::class, function (Server $c) {
483
+
484
+            $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(),
485
+                '\\OC\\Memcache\\ArrayCache',
486
+                '\\OC\\Memcache\\ArrayCache',
487
+                '\\OC\\Memcache\\ArrayCache'
488
+            );
489
+            $config = $c->getConfig();
490
+            $request = $c->getRequest();
491
+            $urlGenerator = new URLGenerator($config, $arrayCacheFactory, $request);
492
+
493
+            if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
494
+                $v = \OC_App::getAppVersions();
495
+                $v['core'] = implode(',', \OC_Util::getVersion());
496
+                $version = implode(',', $v);
497
+                $instanceId = \OC_Util::getInstanceId();
498
+                $path = \OC::$SERVERROOT;
499
+                $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . $urlGenerator->getBaseUrl());
500
+                return new \OC\Memcache\Factory($prefix, $c->getLogger(),
501
+                    $config->getSystemValue('memcache.local', null),
502
+                    $config->getSystemValue('memcache.distributed', null),
503
+                    $config->getSystemValue('memcache.locking', null)
504
+                );
505
+            }
506
+            return $arrayCacheFactory;
507
+
508
+        });
509
+        $this->registerAlias('MemCacheFactory', Factory::class);
510
+        $this->registerAlias(ICacheFactory::class, Factory::class);
511
+
512
+        $this->registerService('RedisFactory', function (Server $c) {
513
+            $systemConfig = $c->getSystemConfig();
514
+            return new RedisFactory($systemConfig);
515
+        });
516
+
517
+        $this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
518
+            return new \OC\Activity\Manager(
519
+                $c->getRequest(),
520
+                $c->getUserSession(),
521
+                $c->getConfig(),
522
+                $c->query(IValidator::class)
523
+            );
524
+        });
525
+        $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class);
526
+
527
+        $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
528
+            return new \OC\Activity\EventMerger(
529
+                $c->getL10N('lib')
530
+            );
531
+        });
532
+        $this->registerAlias(IValidator::class, Validator::class);
533
+
534
+        $this->registerService(\OCP\IAvatarManager::class, function (Server $c) {
535
+            return new AvatarManager(
536
+                $c->query(\OC\User\Manager::class),
537
+                $c->getAppDataDir('avatar'),
538
+                $c->getL10N('lib'),
539
+                $c->getLogger(),
540
+                $c->getConfig()
541
+            );
542
+        });
543
+        $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class);
544
+
545
+        $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
546
+
547
+        $this->registerService(\OCP\ILogger::class, function (Server $c) {
548
+            $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
549
+            $logger = Log::getLogClass($logType);
550
+            call_user_func(array($logger, 'init'));
551
+            $config = $this->getSystemConfig();
552
+            $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class);
553
+
554
+            return new Log($logger, $config, null, $registry);
555
+        });
556
+        $this->registerAlias('Logger', \OCP\ILogger::class);
557
+
558
+        $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) {
559
+            $config = $c->getConfig();
560
+            return new \OC\BackgroundJob\JobList(
561
+                $c->getDatabaseConnection(),
562
+                $config,
563
+                new TimeFactory()
564
+            );
565
+        });
566
+        $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class);
567
+
568
+        $this->registerService(\OCP\Route\IRouter::class, function (Server $c) {
569
+            $cacheFactory = $c->getMemCacheFactory();
570
+            $logger = $c->getLogger();
571
+            if ($cacheFactory->isAvailableLowLatency()) {
572
+                $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger);
573
+            } else {
574
+                $router = new \OC\Route\Router($logger);
575
+            }
576
+            return $router;
577
+        });
578
+        $this->registerAlias('Router', \OCP\Route\IRouter::class);
579
+
580
+        $this->registerService(\OCP\ISearch::class, function ($c) {
581
+            return new Search();
582
+        });
583
+        $this->registerAlias('Search', \OCP\ISearch::class);
584
+
585
+        $this->registerService(\OC\Security\RateLimiting\Limiter::class, function ($c) {
586
+            return new \OC\Security\RateLimiting\Limiter(
587
+                $this->getUserSession(),
588
+                $this->getRequest(),
589
+                new \OC\AppFramework\Utility\TimeFactory(),
590
+                $c->query(\OC\Security\RateLimiting\Backend\IBackend::class)
591
+            );
592
+        });
593
+        $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
594
+            return new \OC\Security\RateLimiting\Backend\MemoryCache(
595
+                $this->getMemCacheFactory(),
596
+                new \OC\AppFramework\Utility\TimeFactory()
597
+            );
598
+        });
599
+
600
+        $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) {
601
+            return new SecureRandom();
602
+        });
603
+        $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
604
+
605
+        $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) {
606
+            return new Crypto($c->getConfig(), $c->getSecureRandom());
607
+        });
608
+        $this->registerAlias('Crypto', \OCP\Security\ICrypto::class);
609
+
610
+        $this->registerService(\OCP\Security\IHasher::class, function (Server $c) {
611
+            return new Hasher($c->getConfig());
612
+        });
613
+        $this->registerAlias('Hasher', \OCP\Security\IHasher::class);
614
+
615
+        $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) {
616
+            return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
617
+        });
618
+        $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class);
619
+
620
+        $this->registerService(IDBConnection::class, function (Server $c) {
621
+            $systemConfig = $c->getSystemConfig();
622
+            $factory = new \OC\DB\ConnectionFactory($systemConfig);
623
+            $type = $systemConfig->getValue('dbtype', 'sqlite');
624
+            if (!$factory->isValidType($type)) {
625
+                throw new \OC\DatabaseException('Invalid database type');
626
+            }
627
+            $connectionParams = $factory->createConnectionParams();
628
+            $connection = $factory->getConnection($type, $connectionParams);
629
+            $connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
630
+            return $connection;
631
+        });
632
+        $this->registerAlias('DatabaseConnection', IDBConnection::class);
633
+
634
+        $this->registerService('HTTPHelper', function (Server $c) {
635
+            $config = $c->getConfig();
636
+            return new HTTPHelper(
637
+                $config,
638
+                $c->getHTTPClientService()
639
+            );
640
+        });
641
+
642
+        $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) {
643
+            $user = \OC_User::getUser();
644
+            $uid = $user ? $user : null;
645
+            return new ClientService(
646
+                $c->getConfig(),
647
+                new \OC\Security\CertificateManager(
648
+                    $uid,
649
+                    new View(),
650
+                    $c->getConfig(),
651
+                    $c->getLogger(),
652
+                    $c->getSecureRandom()
653
+                )
654
+            );
655
+        });
656
+        $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class);
657
+        $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) {
658
+            $eventLogger = new EventLogger();
659
+            if ($c->getSystemConfig()->getValue('debug', false)) {
660
+                // In debug mode, module is being activated by default
661
+                $eventLogger->activate();
662
+            }
663
+            return $eventLogger;
664
+        });
665
+        $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class);
666
+
667
+        $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) {
668
+            $queryLogger = new QueryLogger();
669
+            if ($c->getSystemConfig()->getValue('debug', false)) {
670
+                // In debug mode, module is being activated by default
671
+                $queryLogger->activate();
672
+            }
673
+            return $queryLogger;
674
+        });
675
+        $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class);
676
+
677
+        $this->registerService(TempManager::class, function (Server $c) {
678
+            return new TempManager(
679
+                $c->getLogger(),
680
+                $c->getConfig()
681
+            );
682
+        });
683
+        $this->registerAlias('TempManager', TempManager::class);
684
+        $this->registerAlias(ITempManager::class, TempManager::class);
685
+
686
+        $this->registerService(AppManager::class, function (Server $c) {
687
+            return new \OC\App\AppManager(
688
+                $c->getUserSession(),
689
+                $c->query(\OC\AppConfig::class),
690
+                $c->getGroupManager(),
691
+                $c->getMemCacheFactory(),
692
+                $c->getEventDispatcher()
693
+            );
694
+        });
695
+        $this->registerAlias('AppManager', AppManager::class);
696
+        $this->registerAlias(IAppManager::class, AppManager::class);
697
+
698
+        $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) {
699
+            return new DateTimeZone(
700
+                $c->getConfig(),
701
+                $c->getSession()
702
+            );
703
+        });
704
+        $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class);
705
+
706
+        $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) {
707
+            $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
708
+
709
+            return new DateTimeFormatter(
710
+                $c->getDateTimeZone()->getTimeZone(),
711
+                $c->getL10N('lib', $language)
712
+            );
713
+        });
714
+        $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class);
715
+
716
+        $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) {
717
+            $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
718
+            $listener = new UserMountCacheListener($mountCache);
719
+            $listener->listen($c->getUserManager());
720
+            return $mountCache;
721
+        });
722
+        $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class);
723
+
724
+        $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) {
725
+            $loader = \OC\Files\Filesystem::getLoader();
726
+            $mountCache = $c->query('UserMountCache');
727
+            $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
728
+
729
+            // builtin providers
730
+
731
+            $config = $c->getConfig();
732
+            $manager->registerProvider(new CacheMountProvider($config));
733
+            $manager->registerHomeProvider(new LocalHomeMountProvider());
734
+            $manager->registerHomeProvider(new ObjectHomeMountProvider($config));
735
+
736
+            return $manager;
737
+        });
738
+        $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class);
739
+
740
+        $this->registerService('IniWrapper', function ($c) {
741
+            return new IniGetWrapper();
742
+        });
743
+        $this->registerService('AsyncCommandBus', function (Server $c) {
744
+            $busClass = $c->getConfig()->getSystemValue('commandbus');
745
+            if ($busClass) {
746
+                list($app, $class) = explode('::', $busClass, 2);
747
+                if ($c->getAppManager()->isInstalled($app)) {
748
+                    \OC_App::loadApp($app);
749
+                    return $c->query($class);
750
+                } else {
751
+                    throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
752
+                }
753
+            } else {
754
+                $jobList = $c->getJobList();
755
+                return new CronBus($jobList);
756
+            }
757
+        });
758
+        $this->registerService('TrustedDomainHelper', function ($c) {
759
+            return new TrustedDomainHelper($this->getConfig());
760
+        });
761
+        $this->registerService('Throttler', function (Server $c) {
762
+            return new Throttler(
763
+                $c->getDatabaseConnection(),
764
+                new TimeFactory(),
765
+                $c->getLogger(),
766
+                $c->getConfig()
767
+            );
768
+        });
769
+        $this->registerService('IntegrityCodeChecker', function (Server $c) {
770
+            // IConfig and IAppManager requires a working database. This code
771
+            // might however be called when ownCloud is not yet setup.
772
+            if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
773
+                $config = $c->getConfig();
774
+                $appManager = $c->getAppManager();
775
+            } else {
776
+                $config = null;
777
+                $appManager = null;
778
+            }
779
+
780
+            return new Checker(
781
+                new EnvironmentHelper(),
782
+                new FileAccessHelper(),
783
+                new AppLocator(),
784
+                $config,
785
+                $c->getMemCacheFactory(),
786
+                $appManager,
787
+                $c->getTempManager()
788
+            );
789
+        });
790
+        $this->registerService(\OCP\IRequest::class, function ($c) {
791
+            if (isset($this['urlParams'])) {
792
+                $urlParams = $this['urlParams'];
793
+            } else {
794
+                $urlParams = [];
795
+            }
796
+
797
+            if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
798
+                && in_array('fakeinput', stream_get_wrappers())
799
+            ) {
800
+                $stream = 'fakeinput://data';
801
+            } else {
802
+                $stream = 'php://input';
803
+            }
804
+
805
+            return new Request(
806
+                [
807
+                    'get' => $_GET,
808
+                    'post' => $_POST,
809
+                    'files' => $_FILES,
810
+                    'server' => $_SERVER,
811
+                    'env' => $_ENV,
812
+                    'cookies' => $_COOKIE,
813
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
814
+                        ? $_SERVER['REQUEST_METHOD']
815
+                        : null,
816
+                    'urlParams' => $urlParams,
817
+                ],
818
+                $this->getSecureRandom(),
819
+                $this->getConfig(),
820
+                $this->getCsrfTokenManager(),
821
+                $stream
822
+            );
823
+        });
824
+        $this->registerAlias('Request', \OCP\IRequest::class);
825
+
826
+        $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) {
827
+            return new Mailer(
828
+                $c->getConfig(),
829
+                $c->getLogger(),
830
+                $c->query(Defaults::class),
831
+                $c->getURLGenerator(),
832
+                $c->getL10N('lib')
833
+            );
834
+        });
835
+        $this->registerAlias('Mailer', \OCP\Mail\IMailer::class);
836
+
837
+        $this->registerService('LDAPProvider', function (Server $c) {
838
+            $config = $c->getConfig();
839
+            $factoryClass = $config->getSystemValue('ldapProviderFactory', null);
840
+            if (is_null($factoryClass)) {
841
+                throw new \Exception('ldapProviderFactory not set');
842
+            }
843
+            /** @var \OCP\LDAP\ILDAPProviderFactory $factory */
844
+            $factory = new $factoryClass($this);
845
+            return $factory->getLDAPProvider();
846
+        });
847
+        $this->registerService(ILockingProvider::class, function (Server $c) {
848
+            $ini = $c->getIniWrapper();
849
+            $config = $c->getConfig();
850
+            $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
851
+            if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
852
+                /** @var \OC\Memcache\Factory $memcacheFactory */
853
+                $memcacheFactory = $c->getMemCacheFactory();
854
+                $memcache = $memcacheFactory->createLocking('lock');
855
+                if (!($memcache instanceof \OC\Memcache\NullCache)) {
856
+                    return new MemcacheLockingProvider($memcache, $ttl);
857
+                }
858
+                return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl);
859
+            }
860
+            return new NoopLockingProvider();
861
+        });
862
+        $this->registerAlias('LockingProvider', ILockingProvider::class);
863
+
864
+        $this->registerService(\OCP\Files\Mount\IMountManager::class, function () {
865
+            return new \OC\Files\Mount\Manager();
866
+        });
867
+        $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class);
868
+
869
+        $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) {
870
+            return new \OC\Files\Type\Detection(
871
+                $c->getURLGenerator(),
872
+                \OC::$configDir,
873
+                \OC::$SERVERROOT . '/resources/config/'
874
+            );
875
+        });
876
+        $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class);
877
+
878
+        $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) {
879
+            return new \OC\Files\Type\Loader(
880
+                $c->getDatabaseConnection()
881
+            );
882
+        });
883
+        $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class);
884
+        $this->registerService(BundleFetcher::class, function () {
885
+            return new BundleFetcher($this->getL10N('lib'));
886
+        });
887
+        $this->registerService(\OCP\Notification\IManager::class, function (Server $c) {
888
+            return new Manager(
889
+                $c->query(IValidator::class)
890
+            );
891
+        });
892
+        $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class);
893
+
894
+        $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) {
895
+            $manager = new \OC\CapabilitiesManager($c->getLogger());
896
+            $manager->registerCapability(function () use ($c) {
897
+                return new \OC\OCS\CoreCapabilities($c->getConfig());
898
+            });
899
+            $manager->registerCapability(function () use ($c) {
900
+                return $c->query(\OC\Security\Bruteforce\Capabilities::class);
901
+            });
902
+            return $manager;
903
+        });
904
+        $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class);
905
+
906
+        $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) {
907
+            $config = $c->getConfig();
908
+            $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
909
+            /** @var \OCP\Comments\ICommentsManagerFactory $factory */
910
+            $factory = new $factoryClass($this);
911
+            $manager = $factory->getManager();
912
+
913
+            $manager->registerDisplayNameResolver('user', function($id) use ($c) {
914
+                $manager = $c->getUserManager();
915
+                $user = $manager->get($id);
916
+                if(is_null($user)) {
917
+                    $l = $c->getL10N('core');
918
+                    $displayName = $l->t('Unknown user');
919
+                } else {
920
+                    $displayName = $user->getDisplayName();
921
+                }
922
+                return $displayName;
923
+            });
924
+
925
+            return $manager;
926
+        });
927
+        $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class);
928
+
929
+        $this->registerService('ThemingDefaults', function (Server $c) {
930
+            /*
931 931
 			 * Dark magic for autoloader.
932 932
 			 * If we do a class_exists it will try to load the class which will
933 933
 			 * make composer cache the result. Resulting in errors when enabling
934 934
 			 * the theming app.
935 935
 			 */
936
-			$prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
937
-			if (isset($prefixes['OCA\\Theming\\'])) {
938
-				$classExists = true;
939
-			} else {
940
-				$classExists = false;
941
-			}
942
-
943
-			if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
944
-				return new ThemingDefaults(
945
-					$c->getConfig(),
946
-					$c->getL10N('theming'),
947
-					$c->getURLGenerator(),
948
-					$c->getAppDataDir('theming'),
949
-					$c->getMemCacheFactory(),
950
-					new Util($c->getConfig(), $this->getAppManager(), $this->getAppDataDir('theming')),
951
-					$this->getAppManager()
952
-				);
953
-			}
954
-			return new \OC_Defaults();
955
-		});
956
-		$this->registerService(SCSSCacher::class, function (Server $c) {
957
-			/** @var Factory $cacheFactory */
958
-			$cacheFactory = $c->query(Factory::class);
959
-			return new SCSSCacher(
960
-				$c->getLogger(),
961
-				$c->query(\OC\Files\AppData\Factory::class),
962
-				$c->getURLGenerator(),
963
-				$c->getConfig(),
964
-				$c->getThemingDefaults(),
965
-				\OC::$SERVERROOT,
966
-				$cacheFactory->createDistributed('SCSS')
967
-			);
968
-		});
969
-		$this->registerService(EventDispatcher::class, function () {
970
-			return new EventDispatcher();
971
-		});
972
-		$this->registerAlias('EventDispatcher', EventDispatcher::class);
973
-		$this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class);
974
-
975
-		$this->registerService('CryptoWrapper', function (Server $c) {
976
-			// FIXME: Instantiiated here due to cyclic dependency
977
-			$request = new Request(
978
-				[
979
-					'get' => $_GET,
980
-					'post' => $_POST,
981
-					'files' => $_FILES,
982
-					'server' => $_SERVER,
983
-					'env' => $_ENV,
984
-					'cookies' => $_COOKIE,
985
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
986
-						? $_SERVER['REQUEST_METHOD']
987
-						: null,
988
-				],
989
-				$c->getSecureRandom(),
990
-				$c->getConfig()
991
-			);
992
-
993
-			return new CryptoWrapper(
994
-				$c->getConfig(),
995
-				$c->getCrypto(),
996
-				$c->getSecureRandom(),
997
-				$request
998
-			);
999
-		});
1000
-		$this->registerService('CsrfTokenManager', function (Server $c) {
1001
-			$tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
1002
-
1003
-			return new CsrfTokenManager(
1004
-				$tokenGenerator,
1005
-				$c->query(SessionStorage::class)
1006
-			);
1007
-		});
1008
-		$this->registerService(SessionStorage::class, function (Server $c) {
1009
-			return new SessionStorage($c->getSession());
1010
-		});
1011
-		$this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) {
1012
-			return new ContentSecurityPolicyManager();
1013
-		});
1014
-		$this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class);
1015
-
1016
-		$this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) {
1017
-			return new ContentSecurityPolicyNonceManager(
1018
-				$c->getCsrfTokenManager(),
1019
-				$c->getRequest()
1020
-			);
1021
-		});
1022
-
1023
-		$this->registerService(\OCP\Share\IManager::class, function (Server $c) {
1024
-			$config = $c->getConfig();
1025
-			$factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory');
1026
-			/** @var \OCP\Share\IProviderFactory $factory */
1027
-			$factory = new $factoryClass($this);
1028
-
1029
-			$manager = new \OC\Share20\Manager(
1030
-				$c->getLogger(),
1031
-				$c->getConfig(),
1032
-				$c->getSecureRandom(),
1033
-				$c->getHasher(),
1034
-				$c->getMountManager(),
1035
-				$c->getGroupManager(),
1036
-				$c->getL10N('lib'),
1037
-				$c->getL10NFactory(),
1038
-				$factory,
1039
-				$c->getUserManager(),
1040
-				$c->getLazyRootFolder(),
1041
-				$c->getEventDispatcher(),
1042
-				$c->getMailer(),
1043
-				$c->getURLGenerator(),
1044
-				$c->getThemingDefaults()
1045
-			);
1046
-
1047
-			return $manager;
1048
-		});
1049
-		$this->registerAlias('ShareManager', \OCP\Share\IManager::class);
1050
-
1051
-		$this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) {
1052
-			$instance = new Collaboration\Collaborators\Search($c);
1053
-
1054
-			// register default plugins
1055
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
1056
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
1057
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
1058
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
1059
-
1060
-			return $instance;
1061
-		});
1062
-		$this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class);
1063
-
1064
-		$this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
1065
-
1066
-		$this->registerService('SettingsManager', function (Server $c) {
1067
-			$manager = new \OC\Settings\Manager(
1068
-				$c->getLogger(),
1069
-				$c->getDatabaseConnection(),
1070
-				$c->getL10N('lib'),
1071
-				$c->getConfig(),
1072
-				$c->getEncryptionManager(),
1073
-				$c->getUserManager(),
1074
-				$c->getLockingProvider(),
1075
-				$c->getRequest(),
1076
-				new \OC\Settings\Mapper($c->getDatabaseConnection()),
1077
-				$c->getURLGenerator(),
1078
-				$c->query(AccountManager::class),
1079
-				$c->getGroupManager(),
1080
-				$c->getL10NFactory(),
1081
-				$c->getThemingDefaults(),
1082
-				$c->getAppManager()
1083
-			);
1084
-			return $manager;
1085
-		});
1086
-		$this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
1087
-			return new \OC\Files\AppData\Factory(
1088
-				$c->getRootFolder(),
1089
-				$c->getSystemConfig()
1090
-			);
1091
-		});
1092
-
1093
-		$this->registerService('LockdownManager', function (Server $c) {
1094
-			return new LockdownManager(function () use ($c) {
1095
-				return $c->getSession();
1096
-			});
1097
-		});
1098
-
1099
-		$this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) {
1100
-			return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService());
1101
-		});
1102
-
1103
-		$this->registerService(ICloudIdManager::class, function (Server $c) {
1104
-			return new CloudIdManager();
1105
-		});
1106
-
1107
-		$this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1108
-		$this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
1109
-
1110
-		$this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1111
-		$this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1112
-
1113
-		$this->registerService(Defaults::class, function (Server $c) {
1114
-			return new Defaults(
1115
-				$c->getThemingDefaults()
1116
-			);
1117
-		});
1118
-		$this->registerAlias('Defaults', \OCP\Defaults::class);
1119
-
1120
-		$this->registerService(\OCP\ISession::class, function (SimpleContainer $c) {
1121
-			return $c->query(\OCP\IUserSession::class)->getSession();
1122
-		});
1123
-
1124
-		$this->registerService(IShareHelper::class, function (Server $c) {
1125
-			return new ShareHelper(
1126
-				$c->query(\OCP\Share\IManager::class)
1127
-			);
1128
-		});
1129
-
1130
-		$this->registerService(Installer::class, function(Server $c) {
1131
-			return new Installer(
1132
-				$c->getAppFetcher(),
1133
-				$c->getHTTPClientService(),
1134
-				$c->getTempManager(),
1135
-				$c->getLogger(),
1136
-				$c->getConfig()
1137
-			);
1138
-		});
1139
-
1140
-		$this->registerService(IApiFactory::class, function(Server $c) {
1141
-			return new ApiFactory($c->getHTTPClientService());
1142
-		});
1143
-
1144
-		$this->registerService(IInstanceFactory::class, function(Server $c) {
1145
-			$memcacheFactory = $c->getMemCacheFactory();
1146
-			return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService());
1147
-		});
1148
-
1149
-		$this->registerService(IContactsStore::class, function(Server $c) {
1150
-			return new ContactsStore(
1151
-				$c->getContactsManager(),
1152
-				$c->getConfig(),
1153
-				$c->getUserManager(),
1154
-				$c->getGroupManager()
1155
-			);
1156
-		});
1157
-		$this->registerAlias(IContactsStore::class, ContactsStore::class);
1158
-
1159
-		$this->connectDispatcher();
1160
-	}
1161
-
1162
-	/**
1163
-	 * @return \OCP\Calendar\IManager
1164
-	 */
1165
-	public function getCalendarManager() {
1166
-		return $this->query('CalendarManager');
1167
-	}
1168
-
1169
-	private function connectDispatcher() {
1170
-		$dispatcher = $this->getEventDispatcher();
1171
-
1172
-		// Delete avatar on user deletion
1173
-		$dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) {
1174
-			$logger = $this->getLogger();
1175
-			$manager = $this->getAvatarManager();
1176
-			/** @var IUser $user */
1177
-			$user = $e->getSubject();
1178
-
1179
-			try {
1180
-				$avatar = $manager->getAvatar($user->getUID());
1181
-				$avatar->remove();
1182
-			} catch (NotFoundException $e) {
1183
-				// no avatar to remove
1184
-			} catch (\Exception $e) {
1185
-				// Ignore exceptions
1186
-				$logger->info('Could not cleanup avatar of ' . $user->getUID());
1187
-			}
1188
-		});
1189
-
1190
-		$dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) {
1191
-			$manager = $this->getAvatarManager();
1192
-			/** @var IUser $user */
1193
-			$user = $e->getSubject();
1194
-			$feature = $e->getArgument('feature');
1195
-			$oldValue = $e->getArgument('oldValue');
1196
-			$value = $e->getArgument('value');
1197
-
1198
-			try {
1199
-				$avatar = $manager->getAvatar($user->getUID());
1200
-				$avatar->userChanged($feature, $oldValue, $value);
1201
-			} catch (NotFoundException $e) {
1202
-				// no avatar to remove
1203
-			}
1204
-		});
1205
-	}
1206
-
1207
-	/**
1208
-	 * @return \OCP\Contacts\IManager
1209
-	 */
1210
-	public function getContactsManager() {
1211
-		return $this->query('ContactsManager');
1212
-	}
1213
-
1214
-	/**
1215
-	 * @return \OC\Encryption\Manager
1216
-	 */
1217
-	public function getEncryptionManager() {
1218
-		return $this->query('EncryptionManager');
1219
-	}
1220
-
1221
-	/**
1222
-	 * @return \OC\Encryption\File
1223
-	 */
1224
-	public function getEncryptionFilesHelper() {
1225
-		return $this->query('EncryptionFileHelper');
1226
-	}
1227
-
1228
-	/**
1229
-	 * @return \OCP\Encryption\Keys\IStorage
1230
-	 */
1231
-	public function getEncryptionKeyStorage() {
1232
-		return $this->query('EncryptionKeyStorage');
1233
-	}
1234
-
1235
-	/**
1236
-	 * The current request object holding all information about the request
1237
-	 * currently being processed is returned from this method.
1238
-	 * In case the current execution was not initiated by a web request null is returned
1239
-	 *
1240
-	 * @return \OCP\IRequest
1241
-	 */
1242
-	public function getRequest() {
1243
-		return $this->query('Request');
1244
-	}
1245
-
1246
-	/**
1247
-	 * Returns the preview manager which can create preview images for a given file
1248
-	 *
1249
-	 * @return \OCP\IPreview
1250
-	 */
1251
-	public function getPreviewManager() {
1252
-		return $this->query('PreviewManager');
1253
-	}
1254
-
1255
-	/**
1256
-	 * Returns the tag manager which can get and set tags for different object types
1257
-	 *
1258
-	 * @see \OCP\ITagManager::load()
1259
-	 * @return \OCP\ITagManager
1260
-	 */
1261
-	public function getTagManager() {
1262
-		return $this->query('TagManager');
1263
-	}
1264
-
1265
-	/**
1266
-	 * Returns the system-tag manager
1267
-	 *
1268
-	 * @return \OCP\SystemTag\ISystemTagManager
1269
-	 *
1270
-	 * @since 9.0.0
1271
-	 */
1272
-	public function getSystemTagManager() {
1273
-		return $this->query('SystemTagManager');
1274
-	}
1275
-
1276
-	/**
1277
-	 * Returns the system-tag object mapper
1278
-	 *
1279
-	 * @return \OCP\SystemTag\ISystemTagObjectMapper
1280
-	 *
1281
-	 * @since 9.0.0
1282
-	 */
1283
-	public function getSystemTagObjectMapper() {
1284
-		return $this->query('SystemTagObjectMapper');
1285
-	}
1286
-
1287
-	/**
1288
-	 * Returns the avatar manager, used for avatar functionality
1289
-	 *
1290
-	 * @return \OCP\IAvatarManager
1291
-	 */
1292
-	public function getAvatarManager() {
1293
-		return $this->query('AvatarManager');
1294
-	}
1295
-
1296
-	/**
1297
-	 * Returns the root folder of ownCloud's data directory
1298
-	 *
1299
-	 * @return \OCP\Files\IRootFolder
1300
-	 */
1301
-	public function getRootFolder() {
1302
-		return $this->query('LazyRootFolder');
1303
-	}
1304
-
1305
-	/**
1306
-	 * Returns the root folder of ownCloud's data directory
1307
-	 * This is the lazy variant so this gets only initialized once it
1308
-	 * is actually used.
1309
-	 *
1310
-	 * @return \OCP\Files\IRootFolder
1311
-	 */
1312
-	public function getLazyRootFolder() {
1313
-		return $this->query('LazyRootFolder');
1314
-	}
1315
-
1316
-	/**
1317
-	 * Returns a view to ownCloud's files folder
1318
-	 *
1319
-	 * @param string $userId user ID
1320
-	 * @return \OCP\Files\Folder|null
1321
-	 */
1322
-	public function getUserFolder($userId = null) {
1323
-		if ($userId === null) {
1324
-			$user = $this->getUserSession()->getUser();
1325
-			if (!$user) {
1326
-				return null;
1327
-			}
1328
-			$userId = $user->getUID();
1329
-		}
1330
-		$root = $this->getRootFolder();
1331
-		return $root->getUserFolder($userId);
1332
-	}
1333
-
1334
-	/**
1335
-	 * Returns an app-specific view in ownClouds data directory
1336
-	 *
1337
-	 * @return \OCP\Files\Folder
1338
-	 * @deprecated since 9.2.0 use IAppData
1339
-	 */
1340
-	public function getAppFolder() {
1341
-		$dir = '/' . \OC_App::getCurrentApp();
1342
-		$root = $this->getRootFolder();
1343
-		if (!$root->nodeExists($dir)) {
1344
-			$folder = $root->newFolder($dir);
1345
-		} else {
1346
-			$folder = $root->get($dir);
1347
-		}
1348
-		return $folder;
1349
-	}
1350
-
1351
-	/**
1352
-	 * @return \OC\User\Manager
1353
-	 */
1354
-	public function getUserManager() {
1355
-		return $this->query('UserManager');
1356
-	}
1357
-
1358
-	/**
1359
-	 * @return \OC\Group\Manager
1360
-	 */
1361
-	public function getGroupManager() {
1362
-		return $this->query('GroupManager');
1363
-	}
1364
-
1365
-	/**
1366
-	 * @return \OC\User\Session
1367
-	 */
1368
-	public function getUserSession() {
1369
-		return $this->query('UserSession');
1370
-	}
1371
-
1372
-	/**
1373
-	 * @return \OCP\ISession
1374
-	 */
1375
-	public function getSession() {
1376
-		return $this->query('UserSession')->getSession();
1377
-	}
1378
-
1379
-	/**
1380
-	 * @param \OCP\ISession $session
1381
-	 */
1382
-	public function setSession(\OCP\ISession $session) {
1383
-		$this->query(SessionStorage::class)->setSession($session);
1384
-		$this->query('UserSession')->setSession($session);
1385
-		$this->query(Store::class)->setSession($session);
1386
-	}
1387
-
1388
-	/**
1389
-	 * @return \OC\Authentication\TwoFactorAuth\Manager
1390
-	 */
1391
-	public function getTwoFactorAuthManager() {
1392
-		return $this->query('\OC\Authentication\TwoFactorAuth\Manager');
1393
-	}
1394
-
1395
-	/**
1396
-	 * @return \OC\NavigationManager
1397
-	 */
1398
-	public function getNavigationManager() {
1399
-		return $this->query('NavigationManager');
1400
-	}
1401
-
1402
-	/**
1403
-	 * @return \OCP\IConfig
1404
-	 */
1405
-	public function getConfig() {
1406
-		return $this->query('AllConfig');
1407
-	}
1408
-
1409
-	/**
1410
-	 * @return \OC\SystemConfig
1411
-	 */
1412
-	public function getSystemConfig() {
1413
-		return $this->query('SystemConfig');
1414
-	}
1415
-
1416
-	/**
1417
-	 * Returns the app config manager
1418
-	 *
1419
-	 * @return \OCP\IAppConfig
1420
-	 */
1421
-	public function getAppConfig() {
1422
-		return $this->query('AppConfig');
1423
-	}
1424
-
1425
-	/**
1426
-	 * @return \OCP\L10N\IFactory
1427
-	 */
1428
-	public function getL10NFactory() {
1429
-		return $this->query('L10NFactory');
1430
-	}
1431
-
1432
-	/**
1433
-	 * get an L10N instance
1434
-	 *
1435
-	 * @param string $app appid
1436
-	 * @param string $lang
1437
-	 * @return IL10N
1438
-	 */
1439
-	public function getL10N($app, $lang = null) {
1440
-		return $this->getL10NFactory()->get($app, $lang);
1441
-	}
1442
-
1443
-	/**
1444
-	 * @return \OCP\IURLGenerator
1445
-	 */
1446
-	public function getURLGenerator() {
1447
-		return $this->query('URLGenerator');
1448
-	}
1449
-
1450
-	/**
1451
-	 * @return \OCP\IHelper
1452
-	 */
1453
-	public function getHelper() {
1454
-		return $this->query('AppHelper');
1455
-	}
1456
-
1457
-	/**
1458
-	 * @return AppFetcher
1459
-	 */
1460
-	public function getAppFetcher() {
1461
-		return $this->query(AppFetcher::class);
1462
-	}
1463
-
1464
-	/**
1465
-	 * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1466
-	 * getMemCacheFactory() instead.
1467
-	 *
1468
-	 * @return \OCP\ICache
1469
-	 * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1470
-	 */
1471
-	public function getCache() {
1472
-		return $this->query('UserCache');
1473
-	}
1474
-
1475
-	/**
1476
-	 * Returns an \OCP\CacheFactory instance
1477
-	 *
1478
-	 * @return \OCP\ICacheFactory
1479
-	 */
1480
-	public function getMemCacheFactory() {
1481
-		return $this->query('MemCacheFactory');
1482
-	}
1483
-
1484
-	/**
1485
-	 * Returns an \OC\RedisFactory instance
1486
-	 *
1487
-	 * @return \OC\RedisFactory
1488
-	 */
1489
-	public function getGetRedisFactory() {
1490
-		return $this->query('RedisFactory');
1491
-	}
1492
-
1493
-
1494
-	/**
1495
-	 * Returns the current session
1496
-	 *
1497
-	 * @return \OCP\IDBConnection
1498
-	 */
1499
-	public function getDatabaseConnection() {
1500
-		return $this->query('DatabaseConnection');
1501
-	}
1502
-
1503
-	/**
1504
-	 * Returns the activity manager
1505
-	 *
1506
-	 * @return \OCP\Activity\IManager
1507
-	 */
1508
-	public function getActivityManager() {
1509
-		return $this->query('ActivityManager');
1510
-	}
1511
-
1512
-	/**
1513
-	 * Returns an job list for controlling background jobs
1514
-	 *
1515
-	 * @return \OCP\BackgroundJob\IJobList
1516
-	 */
1517
-	public function getJobList() {
1518
-		return $this->query('JobList');
1519
-	}
1520
-
1521
-	/**
1522
-	 * Returns a logger instance
1523
-	 *
1524
-	 * @return \OCP\ILogger
1525
-	 */
1526
-	public function getLogger() {
1527
-		return $this->query('Logger');
1528
-	}
1529
-
1530
-	/**
1531
-	 * Returns a router for generating and matching urls
1532
-	 *
1533
-	 * @return \OCP\Route\IRouter
1534
-	 */
1535
-	public function getRouter() {
1536
-		return $this->query('Router');
1537
-	}
1538
-
1539
-	/**
1540
-	 * Returns a search instance
1541
-	 *
1542
-	 * @return \OCP\ISearch
1543
-	 */
1544
-	public function getSearch() {
1545
-		return $this->query('Search');
1546
-	}
1547
-
1548
-	/**
1549
-	 * Returns a SecureRandom instance
1550
-	 *
1551
-	 * @return \OCP\Security\ISecureRandom
1552
-	 */
1553
-	public function getSecureRandom() {
1554
-		return $this->query('SecureRandom');
1555
-	}
1556
-
1557
-	/**
1558
-	 * Returns a Crypto instance
1559
-	 *
1560
-	 * @return \OCP\Security\ICrypto
1561
-	 */
1562
-	public function getCrypto() {
1563
-		return $this->query('Crypto');
1564
-	}
1565
-
1566
-	/**
1567
-	 * Returns a Hasher instance
1568
-	 *
1569
-	 * @return \OCP\Security\IHasher
1570
-	 */
1571
-	public function getHasher() {
1572
-		return $this->query('Hasher');
1573
-	}
1574
-
1575
-	/**
1576
-	 * Returns a CredentialsManager instance
1577
-	 *
1578
-	 * @return \OCP\Security\ICredentialsManager
1579
-	 */
1580
-	public function getCredentialsManager() {
1581
-		return $this->query('CredentialsManager');
1582
-	}
1583
-
1584
-	/**
1585
-	 * Returns an instance of the HTTP helper class
1586
-	 *
1587
-	 * @deprecated Use getHTTPClientService()
1588
-	 * @return \OC\HTTPHelper
1589
-	 */
1590
-	public function getHTTPHelper() {
1591
-		return $this->query('HTTPHelper');
1592
-	}
1593
-
1594
-	/**
1595
-	 * Get the certificate manager for the user
1596
-	 *
1597
-	 * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
1598
-	 * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in
1599
-	 */
1600
-	public function getCertificateManager($userId = '') {
1601
-		if ($userId === '') {
1602
-			$userSession = $this->getUserSession();
1603
-			$user = $userSession->getUser();
1604
-			if (is_null($user)) {
1605
-				return null;
1606
-			}
1607
-			$userId = $user->getUID();
1608
-		}
1609
-		return new CertificateManager(
1610
-			$userId,
1611
-			new View(),
1612
-			$this->getConfig(),
1613
-			$this->getLogger(),
1614
-			$this->getSecureRandom()
1615
-		);
1616
-	}
1617
-
1618
-	/**
1619
-	 * Returns an instance of the HTTP client service
1620
-	 *
1621
-	 * @return \OCP\Http\Client\IClientService
1622
-	 */
1623
-	public function getHTTPClientService() {
1624
-		return $this->query('HttpClientService');
1625
-	}
1626
-
1627
-	/**
1628
-	 * Create a new event source
1629
-	 *
1630
-	 * @return \OCP\IEventSource
1631
-	 */
1632
-	public function createEventSource() {
1633
-		return new \OC_EventSource();
1634
-	}
1635
-
1636
-	/**
1637
-	 * Get the active event logger
1638
-	 *
1639
-	 * The returned logger only logs data when debug mode is enabled
1640
-	 *
1641
-	 * @return \OCP\Diagnostics\IEventLogger
1642
-	 */
1643
-	public function getEventLogger() {
1644
-		return $this->query('EventLogger');
1645
-	}
1646
-
1647
-	/**
1648
-	 * Get the active query logger
1649
-	 *
1650
-	 * The returned logger only logs data when debug mode is enabled
1651
-	 *
1652
-	 * @return \OCP\Diagnostics\IQueryLogger
1653
-	 */
1654
-	public function getQueryLogger() {
1655
-		return $this->query('QueryLogger');
1656
-	}
1657
-
1658
-	/**
1659
-	 * Get the manager for temporary files and folders
1660
-	 *
1661
-	 * @return \OCP\ITempManager
1662
-	 */
1663
-	public function getTempManager() {
1664
-		return $this->query('TempManager');
1665
-	}
1666
-
1667
-	/**
1668
-	 * Get the app manager
1669
-	 *
1670
-	 * @return \OCP\App\IAppManager
1671
-	 */
1672
-	public function getAppManager() {
1673
-		return $this->query('AppManager');
1674
-	}
1675
-
1676
-	/**
1677
-	 * Creates a new mailer
1678
-	 *
1679
-	 * @return \OCP\Mail\IMailer
1680
-	 */
1681
-	public function getMailer() {
1682
-		return $this->query('Mailer');
1683
-	}
1684
-
1685
-	/**
1686
-	 * Get the webroot
1687
-	 *
1688
-	 * @return string
1689
-	 */
1690
-	public function getWebRoot() {
1691
-		return $this->webRoot;
1692
-	}
1693
-
1694
-	/**
1695
-	 * @return \OC\OCSClient
1696
-	 */
1697
-	public function getOcsClient() {
1698
-		return $this->query('OcsClient');
1699
-	}
1700
-
1701
-	/**
1702
-	 * @return \OCP\IDateTimeZone
1703
-	 */
1704
-	public function getDateTimeZone() {
1705
-		return $this->query('DateTimeZone');
1706
-	}
1707
-
1708
-	/**
1709
-	 * @return \OCP\IDateTimeFormatter
1710
-	 */
1711
-	public function getDateTimeFormatter() {
1712
-		return $this->query('DateTimeFormatter');
1713
-	}
1714
-
1715
-	/**
1716
-	 * @return \OCP\Files\Config\IMountProviderCollection
1717
-	 */
1718
-	public function getMountProviderCollection() {
1719
-		return $this->query('MountConfigManager');
1720
-	}
1721
-
1722
-	/**
1723
-	 * Get the IniWrapper
1724
-	 *
1725
-	 * @return IniGetWrapper
1726
-	 */
1727
-	public function getIniWrapper() {
1728
-		return $this->query('IniWrapper');
1729
-	}
1730
-
1731
-	/**
1732
-	 * @return \OCP\Command\IBus
1733
-	 */
1734
-	public function getCommandBus() {
1735
-		return $this->query('AsyncCommandBus');
1736
-	}
1737
-
1738
-	/**
1739
-	 * Get the trusted domain helper
1740
-	 *
1741
-	 * @return TrustedDomainHelper
1742
-	 */
1743
-	public function getTrustedDomainHelper() {
1744
-		return $this->query('TrustedDomainHelper');
1745
-	}
1746
-
1747
-	/**
1748
-	 * Get the locking provider
1749
-	 *
1750
-	 * @return \OCP\Lock\ILockingProvider
1751
-	 * @since 8.1.0
1752
-	 */
1753
-	public function getLockingProvider() {
1754
-		return $this->query('LockingProvider');
1755
-	}
1756
-
1757
-	/**
1758
-	 * @return \OCP\Files\Mount\IMountManager
1759
-	 **/
1760
-	function getMountManager() {
1761
-		return $this->query('MountManager');
1762
-	}
1763
-
1764
-	/** @return \OCP\Files\Config\IUserMountCache */
1765
-	function getUserMountCache() {
1766
-		return $this->query('UserMountCache');
1767
-	}
1768
-
1769
-	/**
1770
-	 * Get the MimeTypeDetector
1771
-	 *
1772
-	 * @return \OCP\Files\IMimeTypeDetector
1773
-	 */
1774
-	public function getMimeTypeDetector() {
1775
-		return $this->query('MimeTypeDetector');
1776
-	}
1777
-
1778
-	/**
1779
-	 * Get the MimeTypeLoader
1780
-	 *
1781
-	 * @return \OCP\Files\IMimeTypeLoader
1782
-	 */
1783
-	public function getMimeTypeLoader() {
1784
-		return $this->query('MimeTypeLoader');
1785
-	}
1786
-
1787
-	/**
1788
-	 * Get the manager of all the capabilities
1789
-	 *
1790
-	 * @return \OC\CapabilitiesManager
1791
-	 */
1792
-	public function getCapabilitiesManager() {
1793
-		return $this->query('CapabilitiesManager');
1794
-	}
1795
-
1796
-	/**
1797
-	 * Get the EventDispatcher
1798
-	 *
1799
-	 * @return EventDispatcherInterface
1800
-	 * @since 8.2.0
1801
-	 */
1802
-	public function getEventDispatcher() {
1803
-		return $this->query('EventDispatcher');
1804
-	}
1805
-
1806
-	/**
1807
-	 * Get the Notification Manager
1808
-	 *
1809
-	 * @return \OCP\Notification\IManager
1810
-	 * @since 8.2.0
1811
-	 */
1812
-	public function getNotificationManager() {
1813
-		return $this->query('NotificationManager');
1814
-	}
1815
-
1816
-	/**
1817
-	 * @return \OCP\Comments\ICommentsManager
1818
-	 */
1819
-	public function getCommentsManager() {
1820
-		return $this->query('CommentsManager');
1821
-	}
1822
-
1823
-	/**
1824
-	 * @return \OCA\Theming\ThemingDefaults
1825
-	 */
1826
-	public function getThemingDefaults() {
1827
-		return $this->query('ThemingDefaults');
1828
-	}
1829
-
1830
-	/**
1831
-	 * @return \OC\IntegrityCheck\Checker
1832
-	 */
1833
-	public function getIntegrityCodeChecker() {
1834
-		return $this->query('IntegrityCodeChecker');
1835
-	}
1836
-
1837
-	/**
1838
-	 * @return \OC\Session\CryptoWrapper
1839
-	 */
1840
-	public function getSessionCryptoWrapper() {
1841
-		return $this->query('CryptoWrapper');
1842
-	}
1843
-
1844
-	/**
1845
-	 * @return CsrfTokenManager
1846
-	 */
1847
-	public function getCsrfTokenManager() {
1848
-		return $this->query('CsrfTokenManager');
1849
-	}
1850
-
1851
-	/**
1852
-	 * @return Throttler
1853
-	 */
1854
-	public function getBruteForceThrottler() {
1855
-		return $this->query('Throttler');
1856
-	}
1857
-
1858
-	/**
1859
-	 * @return IContentSecurityPolicyManager
1860
-	 */
1861
-	public function getContentSecurityPolicyManager() {
1862
-		return $this->query('ContentSecurityPolicyManager');
1863
-	}
1864
-
1865
-	/**
1866
-	 * @return ContentSecurityPolicyNonceManager
1867
-	 */
1868
-	public function getContentSecurityPolicyNonceManager() {
1869
-		return $this->query('ContentSecurityPolicyNonceManager');
1870
-	}
1871
-
1872
-	/**
1873
-	 * Not a public API as of 8.2, wait for 9.0
1874
-	 *
1875
-	 * @return \OCA\Files_External\Service\BackendService
1876
-	 */
1877
-	public function getStoragesBackendService() {
1878
-		return $this->query('OCA\\Files_External\\Service\\BackendService');
1879
-	}
1880
-
1881
-	/**
1882
-	 * Not a public API as of 8.2, wait for 9.0
1883
-	 *
1884
-	 * @return \OCA\Files_External\Service\GlobalStoragesService
1885
-	 */
1886
-	public function getGlobalStoragesService() {
1887
-		return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService');
1888
-	}
1889
-
1890
-	/**
1891
-	 * Not a public API as of 8.2, wait for 9.0
1892
-	 *
1893
-	 * @return \OCA\Files_External\Service\UserGlobalStoragesService
1894
-	 */
1895
-	public function getUserGlobalStoragesService() {
1896
-		return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService');
1897
-	}
1898
-
1899
-	/**
1900
-	 * Not a public API as of 8.2, wait for 9.0
1901
-	 *
1902
-	 * @return \OCA\Files_External\Service\UserStoragesService
1903
-	 */
1904
-	public function getUserStoragesService() {
1905
-		return $this->query('OCA\\Files_External\\Service\\UserStoragesService');
1906
-	}
1907
-
1908
-	/**
1909
-	 * @return \OCP\Share\IManager
1910
-	 */
1911
-	public function getShareManager() {
1912
-		return $this->query('ShareManager');
1913
-	}
1914
-
1915
-	/**
1916
-	 * @return \OCP\Collaboration\Collaborators\ISearch
1917
-	 */
1918
-	public function getCollaboratorSearch() {
1919
-		return $this->query('CollaboratorSearch');
1920
-	}
1921
-
1922
-	/**
1923
-	 * @return \OCP\Collaboration\AutoComplete\IManager
1924
-	 */
1925
-	public function getAutoCompleteManager(){
1926
-		return $this->query(IManager::class);
1927
-	}
1928
-
1929
-	/**
1930
-	 * Returns the LDAP Provider
1931
-	 *
1932
-	 * @return \OCP\LDAP\ILDAPProvider
1933
-	 */
1934
-	public function getLDAPProvider() {
1935
-		return $this->query('LDAPProvider');
1936
-	}
1937
-
1938
-	/**
1939
-	 * @return \OCP\Settings\IManager
1940
-	 */
1941
-	public function getSettingsManager() {
1942
-		return $this->query('SettingsManager');
1943
-	}
1944
-
1945
-	/**
1946
-	 * @return \OCP\Files\IAppData
1947
-	 */
1948
-	public function getAppDataDir($app) {
1949
-		/** @var \OC\Files\AppData\Factory $factory */
1950
-		$factory = $this->query(\OC\Files\AppData\Factory::class);
1951
-		return $factory->get($app);
1952
-	}
1953
-
1954
-	/**
1955
-	 * @return \OCP\Lockdown\ILockdownManager
1956
-	 */
1957
-	public function getLockdownManager() {
1958
-		return $this->query('LockdownManager');
1959
-	}
1960
-
1961
-	/**
1962
-	 * @return \OCP\Federation\ICloudIdManager
1963
-	 */
1964
-	public function getCloudIdManager() {
1965
-		return $this->query(ICloudIdManager::class);
1966
-	}
1967
-
1968
-	/**
1969
-	 * @return \OCP\Remote\Api\IApiFactory
1970
-	 */
1971
-	public function getRemoteApiFactory() {
1972
-		return $this->query(IApiFactory::class);
1973
-	}
1974
-
1975
-	/**
1976
-	 * @return \OCP\Remote\IInstanceFactory
1977
-	 */
1978
-	public function getRemoteInstanceFactory() {
1979
-		return $this->query(IInstanceFactory::class);
1980
-	}
936
+            $prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
937
+            if (isset($prefixes['OCA\\Theming\\'])) {
938
+                $classExists = true;
939
+            } else {
940
+                $classExists = false;
941
+            }
942
+
943
+            if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
944
+                return new ThemingDefaults(
945
+                    $c->getConfig(),
946
+                    $c->getL10N('theming'),
947
+                    $c->getURLGenerator(),
948
+                    $c->getAppDataDir('theming'),
949
+                    $c->getMemCacheFactory(),
950
+                    new Util($c->getConfig(), $this->getAppManager(), $this->getAppDataDir('theming')),
951
+                    $this->getAppManager()
952
+                );
953
+            }
954
+            return new \OC_Defaults();
955
+        });
956
+        $this->registerService(SCSSCacher::class, function (Server $c) {
957
+            /** @var Factory $cacheFactory */
958
+            $cacheFactory = $c->query(Factory::class);
959
+            return new SCSSCacher(
960
+                $c->getLogger(),
961
+                $c->query(\OC\Files\AppData\Factory::class),
962
+                $c->getURLGenerator(),
963
+                $c->getConfig(),
964
+                $c->getThemingDefaults(),
965
+                \OC::$SERVERROOT,
966
+                $cacheFactory->createDistributed('SCSS')
967
+            );
968
+        });
969
+        $this->registerService(EventDispatcher::class, function () {
970
+            return new EventDispatcher();
971
+        });
972
+        $this->registerAlias('EventDispatcher', EventDispatcher::class);
973
+        $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class);
974
+
975
+        $this->registerService('CryptoWrapper', function (Server $c) {
976
+            // FIXME: Instantiiated here due to cyclic dependency
977
+            $request = new Request(
978
+                [
979
+                    'get' => $_GET,
980
+                    'post' => $_POST,
981
+                    'files' => $_FILES,
982
+                    'server' => $_SERVER,
983
+                    'env' => $_ENV,
984
+                    'cookies' => $_COOKIE,
985
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
986
+                        ? $_SERVER['REQUEST_METHOD']
987
+                        : null,
988
+                ],
989
+                $c->getSecureRandom(),
990
+                $c->getConfig()
991
+            );
992
+
993
+            return new CryptoWrapper(
994
+                $c->getConfig(),
995
+                $c->getCrypto(),
996
+                $c->getSecureRandom(),
997
+                $request
998
+            );
999
+        });
1000
+        $this->registerService('CsrfTokenManager', function (Server $c) {
1001
+            $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
1002
+
1003
+            return new CsrfTokenManager(
1004
+                $tokenGenerator,
1005
+                $c->query(SessionStorage::class)
1006
+            );
1007
+        });
1008
+        $this->registerService(SessionStorage::class, function (Server $c) {
1009
+            return new SessionStorage($c->getSession());
1010
+        });
1011
+        $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) {
1012
+            return new ContentSecurityPolicyManager();
1013
+        });
1014
+        $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class);
1015
+
1016
+        $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) {
1017
+            return new ContentSecurityPolicyNonceManager(
1018
+                $c->getCsrfTokenManager(),
1019
+                $c->getRequest()
1020
+            );
1021
+        });
1022
+
1023
+        $this->registerService(\OCP\Share\IManager::class, function (Server $c) {
1024
+            $config = $c->getConfig();
1025
+            $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory');
1026
+            /** @var \OCP\Share\IProviderFactory $factory */
1027
+            $factory = new $factoryClass($this);
1028
+
1029
+            $manager = new \OC\Share20\Manager(
1030
+                $c->getLogger(),
1031
+                $c->getConfig(),
1032
+                $c->getSecureRandom(),
1033
+                $c->getHasher(),
1034
+                $c->getMountManager(),
1035
+                $c->getGroupManager(),
1036
+                $c->getL10N('lib'),
1037
+                $c->getL10NFactory(),
1038
+                $factory,
1039
+                $c->getUserManager(),
1040
+                $c->getLazyRootFolder(),
1041
+                $c->getEventDispatcher(),
1042
+                $c->getMailer(),
1043
+                $c->getURLGenerator(),
1044
+                $c->getThemingDefaults()
1045
+            );
1046
+
1047
+            return $manager;
1048
+        });
1049
+        $this->registerAlias('ShareManager', \OCP\Share\IManager::class);
1050
+
1051
+        $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) {
1052
+            $instance = new Collaboration\Collaborators\Search($c);
1053
+
1054
+            // register default plugins
1055
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
1056
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
1057
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
1058
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
1059
+
1060
+            return $instance;
1061
+        });
1062
+        $this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class);
1063
+
1064
+        $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
1065
+
1066
+        $this->registerService('SettingsManager', function (Server $c) {
1067
+            $manager = new \OC\Settings\Manager(
1068
+                $c->getLogger(),
1069
+                $c->getDatabaseConnection(),
1070
+                $c->getL10N('lib'),
1071
+                $c->getConfig(),
1072
+                $c->getEncryptionManager(),
1073
+                $c->getUserManager(),
1074
+                $c->getLockingProvider(),
1075
+                $c->getRequest(),
1076
+                new \OC\Settings\Mapper($c->getDatabaseConnection()),
1077
+                $c->getURLGenerator(),
1078
+                $c->query(AccountManager::class),
1079
+                $c->getGroupManager(),
1080
+                $c->getL10NFactory(),
1081
+                $c->getThemingDefaults(),
1082
+                $c->getAppManager()
1083
+            );
1084
+            return $manager;
1085
+        });
1086
+        $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
1087
+            return new \OC\Files\AppData\Factory(
1088
+                $c->getRootFolder(),
1089
+                $c->getSystemConfig()
1090
+            );
1091
+        });
1092
+
1093
+        $this->registerService('LockdownManager', function (Server $c) {
1094
+            return new LockdownManager(function () use ($c) {
1095
+                return $c->getSession();
1096
+            });
1097
+        });
1098
+
1099
+        $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) {
1100
+            return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService());
1101
+        });
1102
+
1103
+        $this->registerService(ICloudIdManager::class, function (Server $c) {
1104
+            return new CloudIdManager();
1105
+        });
1106
+
1107
+        $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1108
+        $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
1109
+
1110
+        $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1111
+        $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1112
+
1113
+        $this->registerService(Defaults::class, function (Server $c) {
1114
+            return new Defaults(
1115
+                $c->getThemingDefaults()
1116
+            );
1117
+        });
1118
+        $this->registerAlias('Defaults', \OCP\Defaults::class);
1119
+
1120
+        $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) {
1121
+            return $c->query(\OCP\IUserSession::class)->getSession();
1122
+        });
1123
+
1124
+        $this->registerService(IShareHelper::class, function (Server $c) {
1125
+            return new ShareHelper(
1126
+                $c->query(\OCP\Share\IManager::class)
1127
+            );
1128
+        });
1129
+
1130
+        $this->registerService(Installer::class, function(Server $c) {
1131
+            return new Installer(
1132
+                $c->getAppFetcher(),
1133
+                $c->getHTTPClientService(),
1134
+                $c->getTempManager(),
1135
+                $c->getLogger(),
1136
+                $c->getConfig()
1137
+            );
1138
+        });
1139
+
1140
+        $this->registerService(IApiFactory::class, function(Server $c) {
1141
+            return new ApiFactory($c->getHTTPClientService());
1142
+        });
1143
+
1144
+        $this->registerService(IInstanceFactory::class, function(Server $c) {
1145
+            $memcacheFactory = $c->getMemCacheFactory();
1146
+            return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService());
1147
+        });
1148
+
1149
+        $this->registerService(IContactsStore::class, function(Server $c) {
1150
+            return new ContactsStore(
1151
+                $c->getContactsManager(),
1152
+                $c->getConfig(),
1153
+                $c->getUserManager(),
1154
+                $c->getGroupManager()
1155
+            );
1156
+        });
1157
+        $this->registerAlias(IContactsStore::class, ContactsStore::class);
1158
+
1159
+        $this->connectDispatcher();
1160
+    }
1161
+
1162
+    /**
1163
+     * @return \OCP\Calendar\IManager
1164
+     */
1165
+    public function getCalendarManager() {
1166
+        return $this->query('CalendarManager');
1167
+    }
1168
+
1169
+    private function connectDispatcher() {
1170
+        $dispatcher = $this->getEventDispatcher();
1171
+
1172
+        // Delete avatar on user deletion
1173
+        $dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) {
1174
+            $logger = $this->getLogger();
1175
+            $manager = $this->getAvatarManager();
1176
+            /** @var IUser $user */
1177
+            $user = $e->getSubject();
1178
+
1179
+            try {
1180
+                $avatar = $manager->getAvatar($user->getUID());
1181
+                $avatar->remove();
1182
+            } catch (NotFoundException $e) {
1183
+                // no avatar to remove
1184
+            } catch (\Exception $e) {
1185
+                // Ignore exceptions
1186
+                $logger->info('Could not cleanup avatar of ' . $user->getUID());
1187
+            }
1188
+        });
1189
+
1190
+        $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) {
1191
+            $manager = $this->getAvatarManager();
1192
+            /** @var IUser $user */
1193
+            $user = $e->getSubject();
1194
+            $feature = $e->getArgument('feature');
1195
+            $oldValue = $e->getArgument('oldValue');
1196
+            $value = $e->getArgument('value');
1197
+
1198
+            try {
1199
+                $avatar = $manager->getAvatar($user->getUID());
1200
+                $avatar->userChanged($feature, $oldValue, $value);
1201
+            } catch (NotFoundException $e) {
1202
+                // no avatar to remove
1203
+            }
1204
+        });
1205
+    }
1206
+
1207
+    /**
1208
+     * @return \OCP\Contacts\IManager
1209
+     */
1210
+    public function getContactsManager() {
1211
+        return $this->query('ContactsManager');
1212
+    }
1213
+
1214
+    /**
1215
+     * @return \OC\Encryption\Manager
1216
+     */
1217
+    public function getEncryptionManager() {
1218
+        return $this->query('EncryptionManager');
1219
+    }
1220
+
1221
+    /**
1222
+     * @return \OC\Encryption\File
1223
+     */
1224
+    public function getEncryptionFilesHelper() {
1225
+        return $this->query('EncryptionFileHelper');
1226
+    }
1227
+
1228
+    /**
1229
+     * @return \OCP\Encryption\Keys\IStorage
1230
+     */
1231
+    public function getEncryptionKeyStorage() {
1232
+        return $this->query('EncryptionKeyStorage');
1233
+    }
1234
+
1235
+    /**
1236
+     * The current request object holding all information about the request
1237
+     * currently being processed is returned from this method.
1238
+     * In case the current execution was not initiated by a web request null is returned
1239
+     *
1240
+     * @return \OCP\IRequest
1241
+     */
1242
+    public function getRequest() {
1243
+        return $this->query('Request');
1244
+    }
1245
+
1246
+    /**
1247
+     * Returns the preview manager which can create preview images for a given file
1248
+     *
1249
+     * @return \OCP\IPreview
1250
+     */
1251
+    public function getPreviewManager() {
1252
+        return $this->query('PreviewManager');
1253
+    }
1254
+
1255
+    /**
1256
+     * Returns the tag manager which can get and set tags for different object types
1257
+     *
1258
+     * @see \OCP\ITagManager::load()
1259
+     * @return \OCP\ITagManager
1260
+     */
1261
+    public function getTagManager() {
1262
+        return $this->query('TagManager');
1263
+    }
1264
+
1265
+    /**
1266
+     * Returns the system-tag manager
1267
+     *
1268
+     * @return \OCP\SystemTag\ISystemTagManager
1269
+     *
1270
+     * @since 9.0.0
1271
+     */
1272
+    public function getSystemTagManager() {
1273
+        return $this->query('SystemTagManager');
1274
+    }
1275
+
1276
+    /**
1277
+     * Returns the system-tag object mapper
1278
+     *
1279
+     * @return \OCP\SystemTag\ISystemTagObjectMapper
1280
+     *
1281
+     * @since 9.0.0
1282
+     */
1283
+    public function getSystemTagObjectMapper() {
1284
+        return $this->query('SystemTagObjectMapper');
1285
+    }
1286
+
1287
+    /**
1288
+     * Returns the avatar manager, used for avatar functionality
1289
+     *
1290
+     * @return \OCP\IAvatarManager
1291
+     */
1292
+    public function getAvatarManager() {
1293
+        return $this->query('AvatarManager');
1294
+    }
1295
+
1296
+    /**
1297
+     * Returns the root folder of ownCloud's data directory
1298
+     *
1299
+     * @return \OCP\Files\IRootFolder
1300
+     */
1301
+    public function getRootFolder() {
1302
+        return $this->query('LazyRootFolder');
1303
+    }
1304
+
1305
+    /**
1306
+     * Returns the root folder of ownCloud's data directory
1307
+     * This is the lazy variant so this gets only initialized once it
1308
+     * is actually used.
1309
+     *
1310
+     * @return \OCP\Files\IRootFolder
1311
+     */
1312
+    public function getLazyRootFolder() {
1313
+        return $this->query('LazyRootFolder');
1314
+    }
1315
+
1316
+    /**
1317
+     * Returns a view to ownCloud's files folder
1318
+     *
1319
+     * @param string $userId user ID
1320
+     * @return \OCP\Files\Folder|null
1321
+     */
1322
+    public function getUserFolder($userId = null) {
1323
+        if ($userId === null) {
1324
+            $user = $this->getUserSession()->getUser();
1325
+            if (!$user) {
1326
+                return null;
1327
+            }
1328
+            $userId = $user->getUID();
1329
+        }
1330
+        $root = $this->getRootFolder();
1331
+        return $root->getUserFolder($userId);
1332
+    }
1333
+
1334
+    /**
1335
+     * Returns an app-specific view in ownClouds data directory
1336
+     *
1337
+     * @return \OCP\Files\Folder
1338
+     * @deprecated since 9.2.0 use IAppData
1339
+     */
1340
+    public function getAppFolder() {
1341
+        $dir = '/' . \OC_App::getCurrentApp();
1342
+        $root = $this->getRootFolder();
1343
+        if (!$root->nodeExists($dir)) {
1344
+            $folder = $root->newFolder($dir);
1345
+        } else {
1346
+            $folder = $root->get($dir);
1347
+        }
1348
+        return $folder;
1349
+    }
1350
+
1351
+    /**
1352
+     * @return \OC\User\Manager
1353
+     */
1354
+    public function getUserManager() {
1355
+        return $this->query('UserManager');
1356
+    }
1357
+
1358
+    /**
1359
+     * @return \OC\Group\Manager
1360
+     */
1361
+    public function getGroupManager() {
1362
+        return $this->query('GroupManager');
1363
+    }
1364
+
1365
+    /**
1366
+     * @return \OC\User\Session
1367
+     */
1368
+    public function getUserSession() {
1369
+        return $this->query('UserSession');
1370
+    }
1371
+
1372
+    /**
1373
+     * @return \OCP\ISession
1374
+     */
1375
+    public function getSession() {
1376
+        return $this->query('UserSession')->getSession();
1377
+    }
1378
+
1379
+    /**
1380
+     * @param \OCP\ISession $session
1381
+     */
1382
+    public function setSession(\OCP\ISession $session) {
1383
+        $this->query(SessionStorage::class)->setSession($session);
1384
+        $this->query('UserSession')->setSession($session);
1385
+        $this->query(Store::class)->setSession($session);
1386
+    }
1387
+
1388
+    /**
1389
+     * @return \OC\Authentication\TwoFactorAuth\Manager
1390
+     */
1391
+    public function getTwoFactorAuthManager() {
1392
+        return $this->query('\OC\Authentication\TwoFactorAuth\Manager');
1393
+    }
1394
+
1395
+    /**
1396
+     * @return \OC\NavigationManager
1397
+     */
1398
+    public function getNavigationManager() {
1399
+        return $this->query('NavigationManager');
1400
+    }
1401
+
1402
+    /**
1403
+     * @return \OCP\IConfig
1404
+     */
1405
+    public function getConfig() {
1406
+        return $this->query('AllConfig');
1407
+    }
1408
+
1409
+    /**
1410
+     * @return \OC\SystemConfig
1411
+     */
1412
+    public function getSystemConfig() {
1413
+        return $this->query('SystemConfig');
1414
+    }
1415
+
1416
+    /**
1417
+     * Returns the app config manager
1418
+     *
1419
+     * @return \OCP\IAppConfig
1420
+     */
1421
+    public function getAppConfig() {
1422
+        return $this->query('AppConfig');
1423
+    }
1424
+
1425
+    /**
1426
+     * @return \OCP\L10N\IFactory
1427
+     */
1428
+    public function getL10NFactory() {
1429
+        return $this->query('L10NFactory');
1430
+    }
1431
+
1432
+    /**
1433
+     * get an L10N instance
1434
+     *
1435
+     * @param string $app appid
1436
+     * @param string $lang
1437
+     * @return IL10N
1438
+     */
1439
+    public function getL10N($app, $lang = null) {
1440
+        return $this->getL10NFactory()->get($app, $lang);
1441
+    }
1442
+
1443
+    /**
1444
+     * @return \OCP\IURLGenerator
1445
+     */
1446
+    public function getURLGenerator() {
1447
+        return $this->query('URLGenerator');
1448
+    }
1449
+
1450
+    /**
1451
+     * @return \OCP\IHelper
1452
+     */
1453
+    public function getHelper() {
1454
+        return $this->query('AppHelper');
1455
+    }
1456
+
1457
+    /**
1458
+     * @return AppFetcher
1459
+     */
1460
+    public function getAppFetcher() {
1461
+        return $this->query(AppFetcher::class);
1462
+    }
1463
+
1464
+    /**
1465
+     * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1466
+     * getMemCacheFactory() instead.
1467
+     *
1468
+     * @return \OCP\ICache
1469
+     * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1470
+     */
1471
+    public function getCache() {
1472
+        return $this->query('UserCache');
1473
+    }
1474
+
1475
+    /**
1476
+     * Returns an \OCP\CacheFactory instance
1477
+     *
1478
+     * @return \OCP\ICacheFactory
1479
+     */
1480
+    public function getMemCacheFactory() {
1481
+        return $this->query('MemCacheFactory');
1482
+    }
1483
+
1484
+    /**
1485
+     * Returns an \OC\RedisFactory instance
1486
+     *
1487
+     * @return \OC\RedisFactory
1488
+     */
1489
+    public function getGetRedisFactory() {
1490
+        return $this->query('RedisFactory');
1491
+    }
1492
+
1493
+
1494
+    /**
1495
+     * Returns the current session
1496
+     *
1497
+     * @return \OCP\IDBConnection
1498
+     */
1499
+    public function getDatabaseConnection() {
1500
+        return $this->query('DatabaseConnection');
1501
+    }
1502
+
1503
+    /**
1504
+     * Returns the activity manager
1505
+     *
1506
+     * @return \OCP\Activity\IManager
1507
+     */
1508
+    public function getActivityManager() {
1509
+        return $this->query('ActivityManager');
1510
+    }
1511
+
1512
+    /**
1513
+     * Returns an job list for controlling background jobs
1514
+     *
1515
+     * @return \OCP\BackgroundJob\IJobList
1516
+     */
1517
+    public function getJobList() {
1518
+        return $this->query('JobList');
1519
+    }
1520
+
1521
+    /**
1522
+     * Returns a logger instance
1523
+     *
1524
+     * @return \OCP\ILogger
1525
+     */
1526
+    public function getLogger() {
1527
+        return $this->query('Logger');
1528
+    }
1529
+
1530
+    /**
1531
+     * Returns a router for generating and matching urls
1532
+     *
1533
+     * @return \OCP\Route\IRouter
1534
+     */
1535
+    public function getRouter() {
1536
+        return $this->query('Router');
1537
+    }
1538
+
1539
+    /**
1540
+     * Returns a search instance
1541
+     *
1542
+     * @return \OCP\ISearch
1543
+     */
1544
+    public function getSearch() {
1545
+        return $this->query('Search');
1546
+    }
1547
+
1548
+    /**
1549
+     * Returns a SecureRandom instance
1550
+     *
1551
+     * @return \OCP\Security\ISecureRandom
1552
+     */
1553
+    public function getSecureRandom() {
1554
+        return $this->query('SecureRandom');
1555
+    }
1556
+
1557
+    /**
1558
+     * Returns a Crypto instance
1559
+     *
1560
+     * @return \OCP\Security\ICrypto
1561
+     */
1562
+    public function getCrypto() {
1563
+        return $this->query('Crypto');
1564
+    }
1565
+
1566
+    /**
1567
+     * Returns a Hasher instance
1568
+     *
1569
+     * @return \OCP\Security\IHasher
1570
+     */
1571
+    public function getHasher() {
1572
+        return $this->query('Hasher');
1573
+    }
1574
+
1575
+    /**
1576
+     * Returns a CredentialsManager instance
1577
+     *
1578
+     * @return \OCP\Security\ICredentialsManager
1579
+     */
1580
+    public function getCredentialsManager() {
1581
+        return $this->query('CredentialsManager');
1582
+    }
1583
+
1584
+    /**
1585
+     * Returns an instance of the HTTP helper class
1586
+     *
1587
+     * @deprecated Use getHTTPClientService()
1588
+     * @return \OC\HTTPHelper
1589
+     */
1590
+    public function getHTTPHelper() {
1591
+        return $this->query('HTTPHelper');
1592
+    }
1593
+
1594
+    /**
1595
+     * Get the certificate manager for the user
1596
+     *
1597
+     * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
1598
+     * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in
1599
+     */
1600
+    public function getCertificateManager($userId = '') {
1601
+        if ($userId === '') {
1602
+            $userSession = $this->getUserSession();
1603
+            $user = $userSession->getUser();
1604
+            if (is_null($user)) {
1605
+                return null;
1606
+            }
1607
+            $userId = $user->getUID();
1608
+        }
1609
+        return new CertificateManager(
1610
+            $userId,
1611
+            new View(),
1612
+            $this->getConfig(),
1613
+            $this->getLogger(),
1614
+            $this->getSecureRandom()
1615
+        );
1616
+    }
1617
+
1618
+    /**
1619
+     * Returns an instance of the HTTP client service
1620
+     *
1621
+     * @return \OCP\Http\Client\IClientService
1622
+     */
1623
+    public function getHTTPClientService() {
1624
+        return $this->query('HttpClientService');
1625
+    }
1626
+
1627
+    /**
1628
+     * Create a new event source
1629
+     *
1630
+     * @return \OCP\IEventSource
1631
+     */
1632
+    public function createEventSource() {
1633
+        return new \OC_EventSource();
1634
+    }
1635
+
1636
+    /**
1637
+     * Get the active event logger
1638
+     *
1639
+     * The returned logger only logs data when debug mode is enabled
1640
+     *
1641
+     * @return \OCP\Diagnostics\IEventLogger
1642
+     */
1643
+    public function getEventLogger() {
1644
+        return $this->query('EventLogger');
1645
+    }
1646
+
1647
+    /**
1648
+     * Get the active query logger
1649
+     *
1650
+     * The returned logger only logs data when debug mode is enabled
1651
+     *
1652
+     * @return \OCP\Diagnostics\IQueryLogger
1653
+     */
1654
+    public function getQueryLogger() {
1655
+        return $this->query('QueryLogger');
1656
+    }
1657
+
1658
+    /**
1659
+     * Get the manager for temporary files and folders
1660
+     *
1661
+     * @return \OCP\ITempManager
1662
+     */
1663
+    public function getTempManager() {
1664
+        return $this->query('TempManager');
1665
+    }
1666
+
1667
+    /**
1668
+     * Get the app manager
1669
+     *
1670
+     * @return \OCP\App\IAppManager
1671
+     */
1672
+    public function getAppManager() {
1673
+        return $this->query('AppManager');
1674
+    }
1675
+
1676
+    /**
1677
+     * Creates a new mailer
1678
+     *
1679
+     * @return \OCP\Mail\IMailer
1680
+     */
1681
+    public function getMailer() {
1682
+        return $this->query('Mailer');
1683
+    }
1684
+
1685
+    /**
1686
+     * Get the webroot
1687
+     *
1688
+     * @return string
1689
+     */
1690
+    public function getWebRoot() {
1691
+        return $this->webRoot;
1692
+    }
1693
+
1694
+    /**
1695
+     * @return \OC\OCSClient
1696
+     */
1697
+    public function getOcsClient() {
1698
+        return $this->query('OcsClient');
1699
+    }
1700
+
1701
+    /**
1702
+     * @return \OCP\IDateTimeZone
1703
+     */
1704
+    public function getDateTimeZone() {
1705
+        return $this->query('DateTimeZone');
1706
+    }
1707
+
1708
+    /**
1709
+     * @return \OCP\IDateTimeFormatter
1710
+     */
1711
+    public function getDateTimeFormatter() {
1712
+        return $this->query('DateTimeFormatter');
1713
+    }
1714
+
1715
+    /**
1716
+     * @return \OCP\Files\Config\IMountProviderCollection
1717
+     */
1718
+    public function getMountProviderCollection() {
1719
+        return $this->query('MountConfigManager');
1720
+    }
1721
+
1722
+    /**
1723
+     * Get the IniWrapper
1724
+     *
1725
+     * @return IniGetWrapper
1726
+     */
1727
+    public function getIniWrapper() {
1728
+        return $this->query('IniWrapper');
1729
+    }
1730
+
1731
+    /**
1732
+     * @return \OCP\Command\IBus
1733
+     */
1734
+    public function getCommandBus() {
1735
+        return $this->query('AsyncCommandBus');
1736
+    }
1737
+
1738
+    /**
1739
+     * Get the trusted domain helper
1740
+     *
1741
+     * @return TrustedDomainHelper
1742
+     */
1743
+    public function getTrustedDomainHelper() {
1744
+        return $this->query('TrustedDomainHelper');
1745
+    }
1746
+
1747
+    /**
1748
+     * Get the locking provider
1749
+     *
1750
+     * @return \OCP\Lock\ILockingProvider
1751
+     * @since 8.1.0
1752
+     */
1753
+    public function getLockingProvider() {
1754
+        return $this->query('LockingProvider');
1755
+    }
1756
+
1757
+    /**
1758
+     * @return \OCP\Files\Mount\IMountManager
1759
+     **/
1760
+    function getMountManager() {
1761
+        return $this->query('MountManager');
1762
+    }
1763
+
1764
+    /** @return \OCP\Files\Config\IUserMountCache */
1765
+    function getUserMountCache() {
1766
+        return $this->query('UserMountCache');
1767
+    }
1768
+
1769
+    /**
1770
+     * Get the MimeTypeDetector
1771
+     *
1772
+     * @return \OCP\Files\IMimeTypeDetector
1773
+     */
1774
+    public function getMimeTypeDetector() {
1775
+        return $this->query('MimeTypeDetector');
1776
+    }
1777
+
1778
+    /**
1779
+     * Get the MimeTypeLoader
1780
+     *
1781
+     * @return \OCP\Files\IMimeTypeLoader
1782
+     */
1783
+    public function getMimeTypeLoader() {
1784
+        return $this->query('MimeTypeLoader');
1785
+    }
1786
+
1787
+    /**
1788
+     * Get the manager of all the capabilities
1789
+     *
1790
+     * @return \OC\CapabilitiesManager
1791
+     */
1792
+    public function getCapabilitiesManager() {
1793
+        return $this->query('CapabilitiesManager');
1794
+    }
1795
+
1796
+    /**
1797
+     * Get the EventDispatcher
1798
+     *
1799
+     * @return EventDispatcherInterface
1800
+     * @since 8.2.0
1801
+     */
1802
+    public function getEventDispatcher() {
1803
+        return $this->query('EventDispatcher');
1804
+    }
1805
+
1806
+    /**
1807
+     * Get the Notification Manager
1808
+     *
1809
+     * @return \OCP\Notification\IManager
1810
+     * @since 8.2.0
1811
+     */
1812
+    public function getNotificationManager() {
1813
+        return $this->query('NotificationManager');
1814
+    }
1815
+
1816
+    /**
1817
+     * @return \OCP\Comments\ICommentsManager
1818
+     */
1819
+    public function getCommentsManager() {
1820
+        return $this->query('CommentsManager');
1821
+    }
1822
+
1823
+    /**
1824
+     * @return \OCA\Theming\ThemingDefaults
1825
+     */
1826
+    public function getThemingDefaults() {
1827
+        return $this->query('ThemingDefaults');
1828
+    }
1829
+
1830
+    /**
1831
+     * @return \OC\IntegrityCheck\Checker
1832
+     */
1833
+    public function getIntegrityCodeChecker() {
1834
+        return $this->query('IntegrityCodeChecker');
1835
+    }
1836
+
1837
+    /**
1838
+     * @return \OC\Session\CryptoWrapper
1839
+     */
1840
+    public function getSessionCryptoWrapper() {
1841
+        return $this->query('CryptoWrapper');
1842
+    }
1843
+
1844
+    /**
1845
+     * @return CsrfTokenManager
1846
+     */
1847
+    public function getCsrfTokenManager() {
1848
+        return $this->query('CsrfTokenManager');
1849
+    }
1850
+
1851
+    /**
1852
+     * @return Throttler
1853
+     */
1854
+    public function getBruteForceThrottler() {
1855
+        return $this->query('Throttler');
1856
+    }
1857
+
1858
+    /**
1859
+     * @return IContentSecurityPolicyManager
1860
+     */
1861
+    public function getContentSecurityPolicyManager() {
1862
+        return $this->query('ContentSecurityPolicyManager');
1863
+    }
1864
+
1865
+    /**
1866
+     * @return ContentSecurityPolicyNonceManager
1867
+     */
1868
+    public function getContentSecurityPolicyNonceManager() {
1869
+        return $this->query('ContentSecurityPolicyNonceManager');
1870
+    }
1871
+
1872
+    /**
1873
+     * Not a public API as of 8.2, wait for 9.0
1874
+     *
1875
+     * @return \OCA\Files_External\Service\BackendService
1876
+     */
1877
+    public function getStoragesBackendService() {
1878
+        return $this->query('OCA\\Files_External\\Service\\BackendService');
1879
+    }
1880
+
1881
+    /**
1882
+     * Not a public API as of 8.2, wait for 9.0
1883
+     *
1884
+     * @return \OCA\Files_External\Service\GlobalStoragesService
1885
+     */
1886
+    public function getGlobalStoragesService() {
1887
+        return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService');
1888
+    }
1889
+
1890
+    /**
1891
+     * Not a public API as of 8.2, wait for 9.0
1892
+     *
1893
+     * @return \OCA\Files_External\Service\UserGlobalStoragesService
1894
+     */
1895
+    public function getUserGlobalStoragesService() {
1896
+        return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService');
1897
+    }
1898
+
1899
+    /**
1900
+     * Not a public API as of 8.2, wait for 9.0
1901
+     *
1902
+     * @return \OCA\Files_External\Service\UserStoragesService
1903
+     */
1904
+    public function getUserStoragesService() {
1905
+        return $this->query('OCA\\Files_External\\Service\\UserStoragesService');
1906
+    }
1907
+
1908
+    /**
1909
+     * @return \OCP\Share\IManager
1910
+     */
1911
+    public function getShareManager() {
1912
+        return $this->query('ShareManager');
1913
+    }
1914
+
1915
+    /**
1916
+     * @return \OCP\Collaboration\Collaborators\ISearch
1917
+     */
1918
+    public function getCollaboratorSearch() {
1919
+        return $this->query('CollaboratorSearch');
1920
+    }
1921
+
1922
+    /**
1923
+     * @return \OCP\Collaboration\AutoComplete\IManager
1924
+     */
1925
+    public function getAutoCompleteManager(){
1926
+        return $this->query(IManager::class);
1927
+    }
1928
+
1929
+    /**
1930
+     * Returns the LDAP Provider
1931
+     *
1932
+     * @return \OCP\LDAP\ILDAPProvider
1933
+     */
1934
+    public function getLDAPProvider() {
1935
+        return $this->query('LDAPProvider');
1936
+    }
1937
+
1938
+    /**
1939
+     * @return \OCP\Settings\IManager
1940
+     */
1941
+    public function getSettingsManager() {
1942
+        return $this->query('SettingsManager');
1943
+    }
1944
+
1945
+    /**
1946
+     * @return \OCP\Files\IAppData
1947
+     */
1948
+    public function getAppDataDir($app) {
1949
+        /** @var \OC\Files\AppData\Factory $factory */
1950
+        $factory = $this->query(\OC\Files\AppData\Factory::class);
1951
+        return $factory->get($app);
1952
+    }
1953
+
1954
+    /**
1955
+     * @return \OCP\Lockdown\ILockdownManager
1956
+     */
1957
+    public function getLockdownManager() {
1958
+        return $this->query('LockdownManager');
1959
+    }
1960
+
1961
+    /**
1962
+     * @return \OCP\Federation\ICloudIdManager
1963
+     */
1964
+    public function getCloudIdManager() {
1965
+        return $this->query(ICloudIdManager::class);
1966
+    }
1967
+
1968
+    /**
1969
+     * @return \OCP\Remote\Api\IApiFactory
1970
+     */
1971
+    public function getRemoteApiFactory() {
1972
+        return $this->query(IApiFactory::class);
1973
+    }
1974
+
1975
+    /**
1976
+     * @return \OCP\Remote\IInstanceFactory
1977
+     */
1978
+    public function getRemoteInstanceFactory() {
1979
+        return $this->query(IInstanceFactory::class);
1980
+    }
1981 1981
 }
Please login to merge, or discard this patch.