Completed
Pull Request — master (#5689)
by Blizzz
48:01 queued 25:07
created
core/Controller/OCSController.php 2 patches
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -30,122 +30,122 @@
 block discarded – undo
30 30
 
31 31
 class OCSController extends \OCP\AppFramework\OCSController {
32 32
 
33
-	/** @var CapabilitiesManager */
34
-	private $capabilitiesManager;
35
-	/** @var IUserSession */
36
-	private $userSession;
37
-	/** @var IUserManager */
38
-	private $userManager;
39
-	/** @var Manager */
40
-	private $keyManager;
33
+    /** @var CapabilitiesManager */
34
+    private $capabilitiesManager;
35
+    /** @var IUserSession */
36
+    private $userSession;
37
+    /** @var IUserManager */
38
+    private $userManager;
39
+    /** @var Manager */
40
+    private $keyManager;
41 41
 
42
-	/**
43
-	 * OCSController constructor.
44
-	 *
45
-	 * @param string $appName
46
-	 * @param IRequest $request
47
-	 * @param CapabilitiesManager $capabilitiesManager
48
-	 * @param IUserSession $userSession
49
-	 * @param IUserManager $userManager
50
-	 * @param Manager $keyManager
51
-	 */
52
-	public function __construct($appName,
53
-								IRequest $request,
54
-								CapabilitiesManager $capabilitiesManager,
55
-								IUserSession $userSession,
56
-								IUserManager $userManager,
57
-								Manager $keyManager) {
58
-		parent::__construct($appName, $request);
59
-		$this->capabilitiesManager = $capabilitiesManager;
60
-		$this->userSession = $userSession;
61
-		$this->userManager = $userManager;
62
-		$this->keyManager = $keyManager;
63
-	}
42
+    /**
43
+     * OCSController constructor.
44
+     *
45
+     * @param string $appName
46
+     * @param IRequest $request
47
+     * @param CapabilitiesManager $capabilitiesManager
48
+     * @param IUserSession $userSession
49
+     * @param IUserManager $userManager
50
+     * @param Manager $keyManager
51
+     */
52
+    public function __construct($appName,
53
+                                IRequest $request,
54
+                                CapabilitiesManager $capabilitiesManager,
55
+                                IUserSession $userSession,
56
+                                IUserManager $userManager,
57
+                                Manager $keyManager) {
58
+        parent::__construct($appName, $request);
59
+        $this->capabilitiesManager = $capabilitiesManager;
60
+        $this->userSession = $userSession;
61
+        $this->userManager = $userManager;
62
+        $this->keyManager = $keyManager;
63
+    }
64 64
 
65
-	/**
66
-	 * @PublicPage
67
-	 *
68
-	 * @return DataResponse
69
-	 */
70
-	public function getConfig() {
71
-		$data = [
72
-			'version' => '1.7',
73
-			'website' => 'Nextcloud',
74
-			'host' => $this->request->getServerHost(),
75
-			'contact' => '',
76
-			'ssl' => 'false',
77
-		];
65
+    /**
66
+     * @PublicPage
67
+     *
68
+     * @return DataResponse
69
+     */
70
+    public function getConfig() {
71
+        $data = [
72
+            'version' => '1.7',
73
+            'website' => 'Nextcloud',
74
+            'host' => $this->request->getServerHost(),
75
+            'contact' => '',
76
+            'ssl' => 'false',
77
+        ];
78 78
 
79
-		return new DataResponse($data);
80
-	}
79
+        return new DataResponse($data);
80
+    }
81 81
 
82
-	/**
83
-	 * @PublicPage
84
-	 *
85
-	 * @return DataResponse
86
-	 */
87
-	public function getCapabilities() {
88
-		$result = [];
89
-		list($major, $minor, $micro) = \OCP\Util::getVersion();
90
-		$result['version'] = array(
91
-			'major' => $major,
92
-			'minor' => $minor,
93
-			'micro' => $micro,
94
-			'string' => \OC_Util::getVersionString(),
95
-			'edition' => '',
96
-		);
82
+    /**
83
+     * @PublicPage
84
+     *
85
+     * @return DataResponse
86
+     */
87
+    public function getCapabilities() {
88
+        $result = [];
89
+        list($major, $minor, $micro) = \OCP\Util::getVersion();
90
+        $result['version'] = array(
91
+            'major' => $major,
92
+            'minor' => $minor,
93
+            'micro' => $micro,
94
+            'string' => \OC_Util::getVersionString(),
95
+            'edition' => '',
96
+        );
97 97
 
98
-		if($this->userSession->isLoggedIn()) {
99
-			$result['capabilities'] = $this->capabilitiesManager->getCapabilities();
100
-		} else {
101
-			$result['capabilities'] = $this->capabilitiesManager->getCapabilities(true);
102
-		}
98
+        if($this->userSession->isLoggedIn()) {
99
+            $result['capabilities'] = $this->capabilitiesManager->getCapabilities();
100
+        } else {
101
+            $result['capabilities'] = $this->capabilitiesManager->getCapabilities(true);
102
+        }
103 103
 
104
-		return new DataResponse($result);
105
-	}
104
+        return new DataResponse($result);
105
+    }
106 106
 
107
-	/**
108
-	 * @PublicPage
109
-	 * @BruteForceProtection(action=login)
110
-	 *
111
-	 * @param string $login
112
-	 * @param string $password
113
-	 * @return DataResponse
114
-	 */
115
-	public function personCheck($login = '', $password = '') {
116
-		if ($login !== '' && $password !== '') {
117
-			if ($this->userManager->checkPassword($login, $password)) {
118
-				return new DataResponse([
119
-					'person' => [
120
-						'personid' => $login
121
-					]
122
-				]);
123
-			}
107
+    /**
108
+     * @PublicPage
109
+     * @BruteForceProtection(action=login)
110
+     *
111
+     * @param string $login
112
+     * @param string $password
113
+     * @return DataResponse
114
+     */
115
+    public function personCheck($login = '', $password = '') {
116
+        if ($login !== '' && $password !== '') {
117
+            if ($this->userManager->checkPassword($login, $password)) {
118
+                return new DataResponse([
119
+                    'person' => [
120
+                        'personid' => $login
121
+                    ]
122
+                ]);
123
+            }
124 124
 
125
-			$response = new DataResponse(null, 102);
126
-			$response->throttle();
127
-			return $response;
128
-		}
129
-		return new DataResponse(null, 101);
130
-	}
125
+            $response = new DataResponse(null, 102);
126
+            $response->throttle();
127
+            return $response;
128
+        }
129
+        return new DataResponse(null, 101);
130
+    }
131 131
 
132
-	/**
133
-	 * @PublicPage
134
-	 *
135
-	 * @param string $cloudId
136
-	 * @return DataResponse
137
-	 */
138
-	public function getIdentityProof($cloudId) {
139
-		$userObject = $this->userManager->get($cloudId);
132
+    /**
133
+     * @PublicPage
134
+     *
135
+     * @param string $cloudId
136
+     * @return DataResponse
137
+     */
138
+    public function getIdentityProof($cloudId) {
139
+        $userObject = $this->userManager->get($cloudId);
140 140
 
141
-		if($userObject !== null) {
142
-			$key = $this->keyManager->getKey($userObject);
143
-			$data = [
144
-				'public' => $key->getPublic(),
145
-			];
146
-			return new DataResponse($data);
147
-		}
141
+        if($userObject !== null) {
142
+            $key = $this->keyManager->getKey($userObject);
143
+            $data = [
144
+                'public' => $key->getPublic(),
145
+            ];
146
+            return new DataResponse($data);
147
+        }
148 148
 
149
-		return new DataResponse('User not found', 404);
150
-	}
149
+        return new DataResponse('User not found', 404);
150
+    }
151 151
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 			'edition' => '',
96 96
 		);
97 97
 
98
-		if($this->userSession->isLoggedIn()) {
98
+		if ($this->userSession->isLoggedIn()) {
99 99
 			$result['capabilities'] = $this->capabilitiesManager->getCapabilities();
100 100
 		} else {
101 101
 			$result['capabilities'] = $this->capabilitiesManager->getCapabilities(true);
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	public function getIdentityProof($cloudId) {
139 139
 		$userObject = $this->userManager->get($cloudId);
140 140
 
141
-		if($userObject !== null) {
141
+		if ($userObject !== null) {
142 142
 			$key = $this->keyManager->getKey($userObject);
143 143
 			$data = [
144 144
 				'public' => $key->getPublic(),
Please login to merge, or discard this patch.
apps/theming/lib/Capabilities.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -34,45 +34,45 @@
 block discarded – undo
34 34
  */
35 35
 class Capabilities implements IPublicCapability {
36 36
 
37
-	/** @var ThemingDefaults */
38
-	protected $theming;
37
+    /** @var ThemingDefaults */
38
+    protected $theming;
39 39
 
40
-	/** @var IURLGenerator */
41
-	protected $url;
40
+    /** @var IURLGenerator */
41
+    protected $url;
42 42
 
43
-	/** @var IConfig */
44
-	protected $config;
43
+    /** @var IConfig */
44
+    protected $config;
45 45
 
46
-	/**
47
-	 * @param ThemingDefaults $theming
48
-	 * @param IURLGenerator $url
49
-	 * @param IConfig $config
50
-	 */
51
-	public function __construct(ThemingDefaults $theming, IURLGenerator $url, IConfig $config) {
52
-		$this->theming = $theming;
53
-		$this->url = $url;
54
-		$this->config = $config;
55
-	}
46
+    /**
47
+     * @param ThemingDefaults $theming
48
+     * @param IURLGenerator $url
49
+     * @param IConfig $config
50
+     */
51
+    public function __construct(ThemingDefaults $theming, IURLGenerator $url, IConfig $config) {
52
+        $this->theming = $theming;
53
+        $this->url = $url;
54
+        $this->config = $config;
55
+    }
56 56
 
57
-	/**
58
-	 * Return this classes capabilities
59
-	 *
60
-	 * @return array
61
-	 */
62
-	public function getCapabilities() {
63
-		$backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', false);
57
+    /**
58
+     * Return this classes capabilities
59
+     *
60
+     * @return array
61
+     */
62
+    public function getCapabilities() {
63
+        $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', false);
64 64
 
65
-		return [
66
-			'theming' => [
67
-				'name' => $this->theming->getName(),
68
-				'url' => $this->theming->getBaseUrl(),
69
-				'slogan' => $this->theming->getSlogan(),
70
-				'color' => $this->theming->getColorPrimary(),
71
-				'logo' => $this->url->getAbsoluteURL($this->theming->getLogo()),
72
-				'background' => $backgroundLogo === 'backgroundColor' ?
73
-					$this->theming->getColorPrimary() :
74
-					$this->url->getAbsoluteURL($this->theming->getBackground()),
75
-			],
76
-		];
77
-	}
65
+        return [
66
+            'theming' => [
67
+                'name' => $this->theming->getName(),
68
+                'url' => $this->theming->getBaseUrl(),
69
+                'slogan' => $this->theming->getSlogan(),
70
+                'color' => $this->theming->getColorPrimary(),
71
+                'logo' => $this->url->getAbsoluteURL($this->theming->getLogo()),
72
+                'background' => $backgroundLogo === 'backgroundColor' ?
73
+                    $this->theming->getColorPrimary() :
74
+                    $this->url->getAbsoluteURL($this->theming->getBackground()),
75
+            ],
76
+        ];
77
+    }
78 78
 }
Please login to merge, or discard this patch.
lib/private/CapabilitiesManager.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -29,54 +29,54 @@
 block discarded – undo
29 29
 
30 30
 class CapabilitiesManager {
31 31
 
32
-	/** @var \Closure[] */
33
-	private $capabilities = array();
32
+    /** @var \Closure[] */
33
+    private $capabilities = array();
34 34
 
35
-	/** @var ILogger */
36
-	private $logger;
35
+    /** @var ILogger */
36
+    private $logger;
37 37
 
38
-	public function __construct(ILogger $logger) {
39
-		$this->logger = $logger;
40
-	}
38
+    public function __construct(ILogger $logger) {
39
+        $this->logger = $logger;
40
+    }
41 41
 
42
-	/**
43
-	 * Get an array of al the capabilities that are registered at this manager
42
+    /**
43
+     * Get an array of al the capabilities that are registered at this manager
44 44
      *
45
-	 * @param bool $public get public capabilities only
46
-	 * @throws \InvalidArgumentException
47
-	 * @return array
48
-	 */
49
-	public function getCapabilities($public = false) {
50
-		$capabilities = [];
51
-		foreach($this->capabilities as $capability) {
52
-			try {
53
-				$c = $capability();
54
-			} catch (QueryException $e) {
55
-				$this->logger->error('CapabilitiesManager: {message}', ['app' => 'core', 'message' => $e->getMessage()]);
56
-				continue;
57
-			}
45
+     * @param bool $public get public capabilities only
46
+     * @throws \InvalidArgumentException
47
+     * @return array
48
+     */
49
+    public function getCapabilities($public = false) {
50
+        $capabilities = [];
51
+        foreach($this->capabilities as $capability) {
52
+            try {
53
+                $c = $capability();
54
+            } catch (QueryException $e) {
55
+                $this->logger->error('CapabilitiesManager: {message}', ['app' => 'core', 'message' => $e->getMessage()]);
56
+                continue;
57
+            }
58 58
 
59
-			if ($c instanceof ICapability) {
60
-				if(!$public || $c instanceof IPublicCapability) {
61
-					$capabilities = array_replace_recursive($capabilities, $c->getCapabilities());
62
-				}
63
-			} else {
64
-				throw new \InvalidArgumentException('The given Capability (' . get_class($c) . ') does not implement the ICapability interface');
65
-			}
66
-		}
59
+            if ($c instanceof ICapability) {
60
+                if(!$public || $c instanceof IPublicCapability) {
61
+                    $capabilities = array_replace_recursive($capabilities, $c->getCapabilities());
62
+                }
63
+            } else {
64
+                throw new \InvalidArgumentException('The given Capability (' . get_class($c) . ') does not implement the ICapability interface');
65
+            }
66
+        }
67 67
 
68
-		return $capabilities;
69
-	}
68
+        return $capabilities;
69
+    }
70 70
 
71
-	/**
72
-	 * In order to improve lazy loading a closure can be registered which will be called in case
73
-	 * capabilities are actually requested
74
-	 *
75
-	 * $callable has to return an instance of OCP\Capabilities\ICapability
76
-	 *
77
-	 * @param \Closure $callable
78
-	 */
79
-	public function registerCapability(\Closure $callable) {
80
-		array_push($this->capabilities, $callable);
81
-	}
71
+    /**
72
+     * In order to improve lazy loading a closure can be registered which will be called in case
73
+     * capabilities are actually requested
74
+     *
75
+     * $callable has to return an instance of OCP\Capabilities\ICapability
76
+     *
77
+     * @param \Closure $callable
78
+     */
79
+    public function registerCapability(\Closure $callable) {
80
+        array_push($this->capabilities, $callable);
81
+    }
82 82
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 */
49 49
 	public function getCapabilities($public = false) {
50 50
 		$capabilities = [];
51
-		foreach($this->capabilities as $capability) {
51
+		foreach ($this->capabilities as $capability) {
52 52
 			try {
53 53
 				$c = $capability();
54 54
 			} catch (QueryException $e) {
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
 			}
58 58
 
59 59
 			if ($c instanceof ICapability) {
60
-				if(!$public || $c instanceof IPublicCapability) {
60
+				if (!$public || $c instanceof IPublicCapability) {
61 61
 					$capabilities = array_replace_recursive($capabilities, $c->getCapabilities());
62 62
 				}
63 63
 			} else {
64
-				throw new \InvalidArgumentException('The given Capability (' . get_class($c) . ') does not implement the ICapability interface');
64
+				throw new \InvalidArgumentException('The given Capability ('.get_class($c).') does not implement the ICapability interface');
65 65
 			}
66 66
 		}
67 67
 
Please login to merge, or discard this patch.
lib/private/Files/Storage/Wrapper/Jail.php 1 patch
Indentation   +467 added lines, -467 removed lines patch added patch discarded remove patch
@@ -34,471 +34,471 @@
 block discarded – undo
34 34
  * This restricts access to a subfolder of the wrapped storage with the subfolder becoming the root folder new storage
35 35
  */
36 36
 class Jail extends Wrapper {
37
-	/**
38
-	 * @var string
39
-	 */
40
-	protected $rootPath;
41
-
42
-	/**
43
-	 * @param array $arguments ['storage' => $storage, 'mask' => $root]
44
-	 *
45
-	 * $storage: The storage that will be wrapper
46
-	 * $root: The folder in the wrapped storage that will become the root folder of the wrapped storage
47
-	 */
48
-	public function __construct($arguments) {
49
-		parent::__construct($arguments);
50
-		$this->rootPath = $arguments['root'];
51
-	}
52
-
53
-	public function getUnjailedPath($path) {
54
-		if ($path === '') {
55
-			return $this->rootPath;
56
-		} else {
57
-			return $this->rootPath . '/' . $path;
58
-		}
59
-	}
60
-
61
-	public function getId() {
62
-		return parent::getId();
63
-	}
64
-
65
-	/**
66
-	 * see http://php.net/manual/en/function.mkdir.php
67
-	 *
68
-	 * @param string $path
69
-	 * @return bool
70
-	 */
71
-	public function mkdir($path) {
72
-		return $this->getWrapperStorage()->mkdir($this->getUnjailedPath($path));
73
-	}
74
-
75
-	/**
76
-	 * see http://php.net/manual/en/function.rmdir.php
77
-	 *
78
-	 * @param string $path
79
-	 * @return bool
80
-	 */
81
-	public function rmdir($path) {
82
-		return $this->getWrapperStorage()->rmdir($this->getUnjailedPath($path));
83
-	}
84
-
85
-	/**
86
-	 * see http://php.net/manual/en/function.opendir.php
87
-	 *
88
-	 * @param string $path
89
-	 * @return resource
90
-	 */
91
-	public function opendir($path) {
92
-		return $this->getWrapperStorage()->opendir($this->getUnjailedPath($path));
93
-	}
94
-
95
-	/**
96
-	 * see http://php.net/manual/en/function.is_dir.php
97
-	 *
98
-	 * @param string $path
99
-	 * @return bool
100
-	 */
101
-	public function is_dir($path) {
102
-		return $this->getWrapperStorage()->is_dir($this->getUnjailedPath($path));
103
-	}
104
-
105
-	/**
106
-	 * see http://php.net/manual/en/function.is_file.php
107
-	 *
108
-	 * @param string $path
109
-	 * @return bool
110
-	 */
111
-	public function is_file($path) {
112
-		return $this->getWrapperStorage()->is_file($this->getUnjailedPath($path));
113
-	}
114
-
115
-	/**
116
-	 * see http://php.net/manual/en/function.stat.php
117
-	 * only the following keys are required in the result: size and mtime
118
-	 *
119
-	 * @param string $path
120
-	 * @return array
121
-	 */
122
-	public function stat($path) {
123
-		return $this->getWrapperStorage()->stat($this->getUnjailedPath($path));
124
-	}
125
-
126
-	/**
127
-	 * see http://php.net/manual/en/function.filetype.php
128
-	 *
129
-	 * @param string $path
130
-	 * @return bool
131
-	 */
132
-	public function filetype($path) {
133
-		return $this->getWrapperStorage()->filetype($this->getUnjailedPath($path));
134
-	}
135
-
136
-	/**
137
-	 * see http://php.net/manual/en/function.filesize.php
138
-	 * The result for filesize when called on a folder is required to be 0
139
-	 *
140
-	 * @param string $path
141
-	 * @return int
142
-	 */
143
-	public function filesize($path) {
144
-		return $this->getWrapperStorage()->filesize($this->getUnjailedPath($path));
145
-	}
146
-
147
-	/**
148
-	 * check if a file can be created in $path
149
-	 *
150
-	 * @param string $path
151
-	 * @return bool
152
-	 */
153
-	public function isCreatable($path) {
154
-		return $this->getWrapperStorage()->isCreatable($this->getUnjailedPath($path));
155
-	}
156
-
157
-	/**
158
-	 * check if a file can be read
159
-	 *
160
-	 * @param string $path
161
-	 * @return bool
162
-	 */
163
-	public function isReadable($path) {
164
-		return $this->getWrapperStorage()->isReadable($this->getUnjailedPath($path));
165
-	}
166
-
167
-	/**
168
-	 * check if a file can be written to
169
-	 *
170
-	 * @param string $path
171
-	 * @return bool
172
-	 */
173
-	public function isUpdatable($path) {
174
-		return $this->getWrapperStorage()->isUpdatable($this->getUnjailedPath($path));
175
-	}
176
-
177
-	/**
178
-	 * check if a file can be deleted
179
-	 *
180
-	 * @param string $path
181
-	 * @return bool
182
-	 */
183
-	public function isDeletable($path) {
184
-		return $this->getWrapperStorage()->isDeletable($this->getUnjailedPath($path));
185
-	}
186
-
187
-	/**
188
-	 * check if a file can be shared
189
-	 *
190
-	 * @param string $path
191
-	 * @return bool
192
-	 */
193
-	public function isSharable($path) {
194
-		return $this->getWrapperStorage()->isSharable($this->getUnjailedPath($path));
195
-	}
196
-
197
-	/**
198
-	 * get the full permissions of a path.
199
-	 * Should return a combination of the PERMISSION_ constants defined in lib/public/constants.php
200
-	 *
201
-	 * @param string $path
202
-	 * @return int
203
-	 */
204
-	public function getPermissions($path) {
205
-		return $this->getWrapperStorage()->getPermissions($this->getUnjailedPath($path));
206
-	}
207
-
208
-	/**
209
-	 * see http://php.net/manual/en/function.file_exists.php
210
-	 *
211
-	 * @param string $path
212
-	 * @return bool
213
-	 */
214
-	public function file_exists($path) {
215
-		return $this->getWrapperStorage()->file_exists($this->getUnjailedPath($path));
216
-	}
217
-
218
-	/**
219
-	 * see http://php.net/manual/en/function.filemtime.php
220
-	 *
221
-	 * @param string $path
222
-	 * @return int
223
-	 */
224
-	public function filemtime($path) {
225
-		return $this->getWrapperStorage()->filemtime($this->getUnjailedPath($path));
226
-	}
227
-
228
-	/**
229
-	 * see http://php.net/manual/en/function.file_get_contents.php
230
-	 *
231
-	 * @param string $path
232
-	 * @return string
233
-	 */
234
-	public function file_get_contents($path) {
235
-		return $this->getWrapperStorage()->file_get_contents($this->getUnjailedPath($path));
236
-	}
237
-
238
-	/**
239
-	 * see http://php.net/manual/en/function.file_put_contents.php
240
-	 *
241
-	 * @param string $path
242
-	 * @param string $data
243
-	 * @return bool
244
-	 */
245
-	public function file_put_contents($path, $data) {
246
-		return $this->getWrapperStorage()->file_put_contents($this->getUnjailedPath($path), $data);
247
-	}
248
-
249
-	/**
250
-	 * see http://php.net/manual/en/function.unlink.php
251
-	 *
252
-	 * @param string $path
253
-	 * @return bool
254
-	 */
255
-	public function unlink($path) {
256
-		return $this->getWrapperStorage()->unlink($this->getUnjailedPath($path));
257
-	}
258
-
259
-	/**
260
-	 * see http://php.net/manual/en/function.rename.php
261
-	 *
262
-	 * @param string $path1
263
-	 * @param string $path2
264
-	 * @return bool
265
-	 */
266
-	public function rename($path1, $path2) {
267
-		return $this->getWrapperStorage()->rename($this->getUnjailedPath($path1), $this->getUnjailedPath($path2));
268
-	}
269
-
270
-	/**
271
-	 * see http://php.net/manual/en/function.copy.php
272
-	 *
273
-	 * @param string $path1
274
-	 * @param string $path2
275
-	 * @return bool
276
-	 */
277
-	public function copy($path1, $path2) {
278
-		return $this->getWrapperStorage()->copy($this->getUnjailedPath($path1), $this->getUnjailedPath($path2));
279
-	}
280
-
281
-	/**
282
-	 * see http://php.net/manual/en/function.fopen.php
283
-	 *
284
-	 * @param string $path
285
-	 * @param string $mode
286
-	 * @return resource
287
-	 */
288
-	public function fopen($path, $mode) {
289
-		return $this->getWrapperStorage()->fopen($this->getUnjailedPath($path), $mode);
290
-	}
291
-
292
-	/**
293
-	 * get the mimetype for a file or folder
294
-	 * The mimetype for a folder is required to be "httpd/unix-directory"
295
-	 *
296
-	 * @param string $path
297
-	 * @return string
298
-	 */
299
-	public function getMimeType($path) {
300
-		return $this->getWrapperStorage()->getMimeType($this->getUnjailedPath($path));
301
-	}
302
-
303
-	/**
304
-	 * see http://php.net/manual/en/function.hash.php
305
-	 *
306
-	 * @param string $type
307
-	 * @param string $path
308
-	 * @param bool $raw
309
-	 * @return string
310
-	 */
311
-	public function hash($type, $path, $raw = false) {
312
-		return $this->getWrapperStorage()->hash($type, $this->getUnjailedPath($path), $raw);
313
-	}
314
-
315
-	/**
316
-	 * see http://php.net/manual/en/function.free_space.php
317
-	 *
318
-	 * @param string $path
319
-	 * @return int
320
-	 */
321
-	public function free_space($path) {
322
-		return $this->getWrapperStorage()->free_space($this->getUnjailedPath($path));
323
-	}
324
-
325
-	/**
326
-	 * search for occurrences of $query in file names
327
-	 *
328
-	 * @param string $query
329
-	 * @return array
330
-	 */
331
-	public function search($query) {
332
-		return $this->getWrapperStorage()->search($query);
333
-	}
334
-
335
-	/**
336
-	 * see http://php.net/manual/en/function.touch.php
337
-	 * If the backend does not support the operation, false should be returned
338
-	 *
339
-	 * @param string $path
340
-	 * @param int $mtime
341
-	 * @return bool
342
-	 */
343
-	public function touch($path, $mtime = null) {
344
-		return $this->getWrapperStorage()->touch($this->getUnjailedPath($path), $mtime);
345
-	}
346
-
347
-	/**
348
-	 * get the path to a local version of the file.
349
-	 * The local version of the file can be temporary and doesn't have to be persistent across requests
350
-	 *
351
-	 * @param string $path
352
-	 * @return string
353
-	 */
354
-	public function getLocalFile($path) {
355
-		return $this->getWrapperStorage()->getLocalFile($this->getUnjailedPath($path));
356
-	}
357
-
358
-	/**
359
-	 * check if a file or folder has been updated since $time
360
-	 *
361
-	 * @param string $path
362
-	 * @param int $time
363
-	 * @return bool
364
-	 *
365
-	 * hasUpdated for folders should return at least true if a file inside the folder is add, removed or renamed.
366
-	 * returning true for other changes in the folder is optional
367
-	 */
368
-	public function hasUpdated($path, $time) {
369
-		return $this->getWrapperStorage()->hasUpdated($this->getUnjailedPath($path), $time);
370
-	}
371
-
372
-	/**
373
-	 * get a cache instance for the storage
374
-	 *
375
-	 * @param string $path
376
-	 * @param \OC\Files\Storage\Storage (optional) the storage to pass to the cache
377
-	 * @return \OC\Files\Cache\Cache
378
-	 */
379
-	public function getCache($path = '', $storage = null) {
380
-		if (!$storage) {
381
-			$storage = $this->getWrapperStorage();
382
-		}
383
-		$sourceCache = $this->getWrapperStorage()->getCache($this->getUnjailedPath($path), $storage);
384
-		return new CacheJail($sourceCache, $this->rootPath);
385
-	}
386
-
387
-	/**
388
-	 * get the user id of the owner of a file or folder
389
-	 *
390
-	 * @param string $path
391
-	 * @return string
392
-	 */
393
-	public function getOwner($path) {
394
-		return $this->getWrapperStorage()->getOwner($this->getUnjailedPath($path));
395
-	}
396
-
397
-	/**
398
-	 * get a watcher instance for the cache
399
-	 *
400
-	 * @param string $path
401
-	 * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher
402
-	 * @return \OC\Files\Cache\Watcher
403
-	 */
404
-	public function getWatcher($path = '', $storage = null) {
405
-		if (!$storage) {
406
-			$storage = $this;
407
-		}
408
-		return $this->getWrapperStorage()->getWatcher($this->getUnjailedPath($path), $storage);
409
-	}
410
-
411
-	/**
412
-	 * get the ETag for a file or folder
413
-	 *
414
-	 * @param string $path
415
-	 * @return string
416
-	 */
417
-	public function getETag($path) {
418
-		return $this->getWrapperStorage()->getETag($this->getUnjailedPath($path));
419
-	}
420
-
421
-	/**
422
-	 * @param string $path
423
-	 * @return array
424
-	 */
425
-	public function getMetaData($path) {
426
-		return $this->getWrapperStorage()->getMetaData($this->getUnjailedPath($path));
427
-	}
428
-
429
-	/**
430
-	 * @param string $path
431
-	 * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
432
-	 * @param \OCP\Lock\ILockingProvider $provider
433
-	 * @throws \OCP\Lock\LockedException
434
-	 */
435
-	public function acquireLock($path, $type, ILockingProvider $provider) {
436
-		$this->getWrapperStorage()->acquireLock($this->getUnjailedPath($path), $type, $provider);
437
-	}
438
-
439
-	/**
440
-	 * @param string $path
441
-	 * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
442
-	 * @param \OCP\Lock\ILockingProvider $provider
443
-	 */
444
-	public function releaseLock($path, $type, ILockingProvider $provider) {
445
-		$this->getWrapperStorage()->releaseLock($this->getUnjailedPath($path), $type, $provider);
446
-	}
447
-
448
-	/**
449
-	 * @param string $path
450
-	 * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
451
-	 * @param \OCP\Lock\ILockingProvider $provider
452
-	 */
453
-	public function changeLock($path, $type, ILockingProvider $provider) {
454
-		$this->getWrapperStorage()->changeLock($this->getUnjailedPath($path), $type, $provider);
455
-	}
456
-
457
-	/**
458
-	 * Resolve the path for the source of the share
459
-	 *
460
-	 * @param string $path
461
-	 * @return array
462
-	 */
463
-	public function resolvePath($path) {
464
-		return [$this->getWrapperStorage(), $this->getUnjailedPath($path)];
465
-	}
466
-
467
-	/**
468
-	 * @param \OCP\Files\Storage $sourceStorage
469
-	 * @param string $sourceInternalPath
470
-	 * @param string $targetInternalPath
471
-	 * @return bool
472
-	 */
473
-	public function copyFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
474
-		if ($sourceStorage === $this) {
475
-			return $this->copy($sourceInternalPath, $targetInternalPath);
476
-		}
477
-		return $this->getWrapperStorage()->copyFromStorage($sourceStorage, $sourceInternalPath, $this->getUnjailedPath($targetInternalPath));
478
-	}
479
-
480
-	/**
481
-	 * @param \OCP\Files\Storage $sourceStorage
482
-	 * @param string $sourceInternalPath
483
-	 * @param string $targetInternalPath
484
-	 * @return bool
485
-	 */
486
-	public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
487
-		if ($sourceStorage === $this) {
488
-			return $this->rename($sourceInternalPath, $targetInternalPath);
489
-		}
490
-		return $this->getWrapperStorage()->moveFromStorage($sourceStorage, $sourceInternalPath, $this->getUnjailedPath($targetInternalPath));
491
-	}
492
-
493
-	public function getPropagator($storage = null) {
494
-		if (isset($this->propagator)) {
495
-			return $this->propagator;
496
-		}
497
-
498
-		if (!$storage) {
499
-			$storage = $this;
500
-		}
501
-		$this->propagator = new JailPropagator($storage, \OC::$server->getDatabaseConnection());
502
-		return $this->propagator;
503
-	}
37
+    /**
38
+     * @var string
39
+     */
40
+    protected $rootPath;
41
+
42
+    /**
43
+     * @param array $arguments ['storage' => $storage, 'mask' => $root]
44
+     *
45
+     * $storage: The storage that will be wrapper
46
+     * $root: The folder in the wrapped storage that will become the root folder of the wrapped storage
47
+     */
48
+    public function __construct($arguments) {
49
+        parent::__construct($arguments);
50
+        $this->rootPath = $arguments['root'];
51
+    }
52
+
53
+    public function getUnjailedPath($path) {
54
+        if ($path === '') {
55
+            return $this->rootPath;
56
+        } else {
57
+            return $this->rootPath . '/' . $path;
58
+        }
59
+    }
60
+
61
+    public function getId() {
62
+        return parent::getId();
63
+    }
64
+
65
+    /**
66
+     * see http://php.net/manual/en/function.mkdir.php
67
+     *
68
+     * @param string $path
69
+     * @return bool
70
+     */
71
+    public function mkdir($path) {
72
+        return $this->getWrapperStorage()->mkdir($this->getUnjailedPath($path));
73
+    }
74
+
75
+    /**
76
+     * see http://php.net/manual/en/function.rmdir.php
77
+     *
78
+     * @param string $path
79
+     * @return bool
80
+     */
81
+    public function rmdir($path) {
82
+        return $this->getWrapperStorage()->rmdir($this->getUnjailedPath($path));
83
+    }
84
+
85
+    /**
86
+     * see http://php.net/manual/en/function.opendir.php
87
+     *
88
+     * @param string $path
89
+     * @return resource
90
+     */
91
+    public function opendir($path) {
92
+        return $this->getWrapperStorage()->opendir($this->getUnjailedPath($path));
93
+    }
94
+
95
+    /**
96
+     * see http://php.net/manual/en/function.is_dir.php
97
+     *
98
+     * @param string $path
99
+     * @return bool
100
+     */
101
+    public function is_dir($path) {
102
+        return $this->getWrapperStorage()->is_dir($this->getUnjailedPath($path));
103
+    }
104
+
105
+    /**
106
+     * see http://php.net/manual/en/function.is_file.php
107
+     *
108
+     * @param string $path
109
+     * @return bool
110
+     */
111
+    public function is_file($path) {
112
+        return $this->getWrapperStorage()->is_file($this->getUnjailedPath($path));
113
+    }
114
+
115
+    /**
116
+     * see http://php.net/manual/en/function.stat.php
117
+     * only the following keys are required in the result: size and mtime
118
+     *
119
+     * @param string $path
120
+     * @return array
121
+     */
122
+    public function stat($path) {
123
+        return $this->getWrapperStorage()->stat($this->getUnjailedPath($path));
124
+    }
125
+
126
+    /**
127
+     * see http://php.net/manual/en/function.filetype.php
128
+     *
129
+     * @param string $path
130
+     * @return bool
131
+     */
132
+    public function filetype($path) {
133
+        return $this->getWrapperStorage()->filetype($this->getUnjailedPath($path));
134
+    }
135
+
136
+    /**
137
+     * see http://php.net/manual/en/function.filesize.php
138
+     * The result for filesize when called on a folder is required to be 0
139
+     *
140
+     * @param string $path
141
+     * @return int
142
+     */
143
+    public function filesize($path) {
144
+        return $this->getWrapperStorage()->filesize($this->getUnjailedPath($path));
145
+    }
146
+
147
+    /**
148
+     * check if a file can be created in $path
149
+     *
150
+     * @param string $path
151
+     * @return bool
152
+     */
153
+    public function isCreatable($path) {
154
+        return $this->getWrapperStorage()->isCreatable($this->getUnjailedPath($path));
155
+    }
156
+
157
+    /**
158
+     * check if a file can be read
159
+     *
160
+     * @param string $path
161
+     * @return bool
162
+     */
163
+    public function isReadable($path) {
164
+        return $this->getWrapperStorage()->isReadable($this->getUnjailedPath($path));
165
+    }
166
+
167
+    /**
168
+     * check if a file can be written to
169
+     *
170
+     * @param string $path
171
+     * @return bool
172
+     */
173
+    public function isUpdatable($path) {
174
+        return $this->getWrapperStorage()->isUpdatable($this->getUnjailedPath($path));
175
+    }
176
+
177
+    /**
178
+     * check if a file can be deleted
179
+     *
180
+     * @param string $path
181
+     * @return bool
182
+     */
183
+    public function isDeletable($path) {
184
+        return $this->getWrapperStorage()->isDeletable($this->getUnjailedPath($path));
185
+    }
186
+
187
+    /**
188
+     * check if a file can be shared
189
+     *
190
+     * @param string $path
191
+     * @return bool
192
+     */
193
+    public function isSharable($path) {
194
+        return $this->getWrapperStorage()->isSharable($this->getUnjailedPath($path));
195
+    }
196
+
197
+    /**
198
+     * get the full permissions of a path.
199
+     * Should return a combination of the PERMISSION_ constants defined in lib/public/constants.php
200
+     *
201
+     * @param string $path
202
+     * @return int
203
+     */
204
+    public function getPermissions($path) {
205
+        return $this->getWrapperStorage()->getPermissions($this->getUnjailedPath($path));
206
+    }
207
+
208
+    /**
209
+     * see http://php.net/manual/en/function.file_exists.php
210
+     *
211
+     * @param string $path
212
+     * @return bool
213
+     */
214
+    public function file_exists($path) {
215
+        return $this->getWrapperStorage()->file_exists($this->getUnjailedPath($path));
216
+    }
217
+
218
+    /**
219
+     * see http://php.net/manual/en/function.filemtime.php
220
+     *
221
+     * @param string $path
222
+     * @return int
223
+     */
224
+    public function filemtime($path) {
225
+        return $this->getWrapperStorage()->filemtime($this->getUnjailedPath($path));
226
+    }
227
+
228
+    /**
229
+     * see http://php.net/manual/en/function.file_get_contents.php
230
+     *
231
+     * @param string $path
232
+     * @return string
233
+     */
234
+    public function file_get_contents($path) {
235
+        return $this->getWrapperStorage()->file_get_contents($this->getUnjailedPath($path));
236
+    }
237
+
238
+    /**
239
+     * see http://php.net/manual/en/function.file_put_contents.php
240
+     *
241
+     * @param string $path
242
+     * @param string $data
243
+     * @return bool
244
+     */
245
+    public function file_put_contents($path, $data) {
246
+        return $this->getWrapperStorage()->file_put_contents($this->getUnjailedPath($path), $data);
247
+    }
248
+
249
+    /**
250
+     * see http://php.net/manual/en/function.unlink.php
251
+     *
252
+     * @param string $path
253
+     * @return bool
254
+     */
255
+    public function unlink($path) {
256
+        return $this->getWrapperStorage()->unlink($this->getUnjailedPath($path));
257
+    }
258
+
259
+    /**
260
+     * see http://php.net/manual/en/function.rename.php
261
+     *
262
+     * @param string $path1
263
+     * @param string $path2
264
+     * @return bool
265
+     */
266
+    public function rename($path1, $path2) {
267
+        return $this->getWrapperStorage()->rename($this->getUnjailedPath($path1), $this->getUnjailedPath($path2));
268
+    }
269
+
270
+    /**
271
+     * see http://php.net/manual/en/function.copy.php
272
+     *
273
+     * @param string $path1
274
+     * @param string $path2
275
+     * @return bool
276
+     */
277
+    public function copy($path1, $path2) {
278
+        return $this->getWrapperStorage()->copy($this->getUnjailedPath($path1), $this->getUnjailedPath($path2));
279
+    }
280
+
281
+    /**
282
+     * see http://php.net/manual/en/function.fopen.php
283
+     *
284
+     * @param string $path
285
+     * @param string $mode
286
+     * @return resource
287
+     */
288
+    public function fopen($path, $mode) {
289
+        return $this->getWrapperStorage()->fopen($this->getUnjailedPath($path), $mode);
290
+    }
291
+
292
+    /**
293
+     * get the mimetype for a file or folder
294
+     * The mimetype for a folder is required to be "httpd/unix-directory"
295
+     *
296
+     * @param string $path
297
+     * @return string
298
+     */
299
+    public function getMimeType($path) {
300
+        return $this->getWrapperStorage()->getMimeType($this->getUnjailedPath($path));
301
+    }
302
+
303
+    /**
304
+     * see http://php.net/manual/en/function.hash.php
305
+     *
306
+     * @param string $type
307
+     * @param string $path
308
+     * @param bool $raw
309
+     * @return string
310
+     */
311
+    public function hash($type, $path, $raw = false) {
312
+        return $this->getWrapperStorage()->hash($type, $this->getUnjailedPath($path), $raw);
313
+    }
314
+
315
+    /**
316
+     * see http://php.net/manual/en/function.free_space.php
317
+     *
318
+     * @param string $path
319
+     * @return int
320
+     */
321
+    public function free_space($path) {
322
+        return $this->getWrapperStorage()->free_space($this->getUnjailedPath($path));
323
+    }
324
+
325
+    /**
326
+     * search for occurrences of $query in file names
327
+     *
328
+     * @param string $query
329
+     * @return array
330
+     */
331
+    public function search($query) {
332
+        return $this->getWrapperStorage()->search($query);
333
+    }
334
+
335
+    /**
336
+     * see http://php.net/manual/en/function.touch.php
337
+     * If the backend does not support the operation, false should be returned
338
+     *
339
+     * @param string $path
340
+     * @param int $mtime
341
+     * @return bool
342
+     */
343
+    public function touch($path, $mtime = null) {
344
+        return $this->getWrapperStorage()->touch($this->getUnjailedPath($path), $mtime);
345
+    }
346
+
347
+    /**
348
+     * get the path to a local version of the file.
349
+     * The local version of the file can be temporary and doesn't have to be persistent across requests
350
+     *
351
+     * @param string $path
352
+     * @return string
353
+     */
354
+    public function getLocalFile($path) {
355
+        return $this->getWrapperStorage()->getLocalFile($this->getUnjailedPath($path));
356
+    }
357
+
358
+    /**
359
+     * check if a file or folder has been updated since $time
360
+     *
361
+     * @param string $path
362
+     * @param int $time
363
+     * @return bool
364
+     *
365
+     * hasUpdated for folders should return at least true if a file inside the folder is add, removed or renamed.
366
+     * returning true for other changes in the folder is optional
367
+     */
368
+    public function hasUpdated($path, $time) {
369
+        return $this->getWrapperStorage()->hasUpdated($this->getUnjailedPath($path), $time);
370
+    }
371
+
372
+    /**
373
+     * get a cache instance for the storage
374
+     *
375
+     * @param string $path
376
+     * @param \OC\Files\Storage\Storage (optional) the storage to pass to the cache
377
+     * @return \OC\Files\Cache\Cache
378
+     */
379
+    public function getCache($path = '', $storage = null) {
380
+        if (!$storage) {
381
+            $storage = $this->getWrapperStorage();
382
+        }
383
+        $sourceCache = $this->getWrapperStorage()->getCache($this->getUnjailedPath($path), $storage);
384
+        return new CacheJail($sourceCache, $this->rootPath);
385
+    }
386
+
387
+    /**
388
+     * get the user id of the owner of a file or folder
389
+     *
390
+     * @param string $path
391
+     * @return string
392
+     */
393
+    public function getOwner($path) {
394
+        return $this->getWrapperStorage()->getOwner($this->getUnjailedPath($path));
395
+    }
396
+
397
+    /**
398
+     * get a watcher instance for the cache
399
+     *
400
+     * @param string $path
401
+     * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher
402
+     * @return \OC\Files\Cache\Watcher
403
+     */
404
+    public function getWatcher($path = '', $storage = null) {
405
+        if (!$storage) {
406
+            $storage = $this;
407
+        }
408
+        return $this->getWrapperStorage()->getWatcher($this->getUnjailedPath($path), $storage);
409
+    }
410
+
411
+    /**
412
+     * get the ETag for a file or folder
413
+     *
414
+     * @param string $path
415
+     * @return string
416
+     */
417
+    public function getETag($path) {
418
+        return $this->getWrapperStorage()->getETag($this->getUnjailedPath($path));
419
+    }
420
+
421
+    /**
422
+     * @param string $path
423
+     * @return array
424
+     */
425
+    public function getMetaData($path) {
426
+        return $this->getWrapperStorage()->getMetaData($this->getUnjailedPath($path));
427
+    }
428
+
429
+    /**
430
+     * @param string $path
431
+     * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
432
+     * @param \OCP\Lock\ILockingProvider $provider
433
+     * @throws \OCP\Lock\LockedException
434
+     */
435
+    public function acquireLock($path, $type, ILockingProvider $provider) {
436
+        $this->getWrapperStorage()->acquireLock($this->getUnjailedPath($path), $type, $provider);
437
+    }
438
+
439
+    /**
440
+     * @param string $path
441
+     * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
442
+     * @param \OCP\Lock\ILockingProvider $provider
443
+     */
444
+    public function releaseLock($path, $type, ILockingProvider $provider) {
445
+        $this->getWrapperStorage()->releaseLock($this->getUnjailedPath($path), $type, $provider);
446
+    }
447
+
448
+    /**
449
+     * @param string $path
450
+     * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
451
+     * @param \OCP\Lock\ILockingProvider $provider
452
+     */
453
+    public function changeLock($path, $type, ILockingProvider $provider) {
454
+        $this->getWrapperStorage()->changeLock($this->getUnjailedPath($path), $type, $provider);
455
+    }
456
+
457
+    /**
458
+     * Resolve the path for the source of the share
459
+     *
460
+     * @param string $path
461
+     * @return array
462
+     */
463
+    public function resolvePath($path) {
464
+        return [$this->getWrapperStorage(), $this->getUnjailedPath($path)];
465
+    }
466
+
467
+    /**
468
+     * @param \OCP\Files\Storage $sourceStorage
469
+     * @param string $sourceInternalPath
470
+     * @param string $targetInternalPath
471
+     * @return bool
472
+     */
473
+    public function copyFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
474
+        if ($sourceStorage === $this) {
475
+            return $this->copy($sourceInternalPath, $targetInternalPath);
476
+        }
477
+        return $this->getWrapperStorage()->copyFromStorage($sourceStorage, $sourceInternalPath, $this->getUnjailedPath($targetInternalPath));
478
+    }
479
+
480
+    /**
481
+     * @param \OCP\Files\Storage $sourceStorage
482
+     * @param string $sourceInternalPath
483
+     * @param string $targetInternalPath
484
+     * @return bool
485
+     */
486
+    public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
487
+        if ($sourceStorage === $this) {
488
+            return $this->rename($sourceInternalPath, $targetInternalPath);
489
+        }
490
+        return $this->getWrapperStorage()->moveFromStorage($sourceStorage, $sourceInternalPath, $this->getUnjailedPath($targetInternalPath));
491
+    }
492
+
493
+    public function getPropagator($storage = null) {
494
+        if (isset($this->propagator)) {
495
+            return $this->propagator;
496
+        }
497
+
498
+        if (!$storage) {
499
+            $storage = $this;
500
+        }
501
+        $this->propagator = new JailPropagator($storage, \OC::$server->getDatabaseConnection());
502
+        return $this->propagator;
503
+    }
504 504
 }
Please login to merge, or discard this patch.
lib/private/Files/Cache/Wrapper/JailPropagator.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -26,19 +26,19 @@
 block discarded – undo
26 26
 use OC\Files\Storage\Wrapper\Jail;
27 27
 
28 28
 class JailPropagator extends Propagator {
29
-	/**
30
-	 * @var Jail
31
-	 */
32
-	protected $storage;
29
+    /**
30
+     * @var Jail
31
+     */
32
+    protected $storage;
33 33
 
34
-	/**
35
-	 * @param string $internalPath
36
-	 * @param int $time
37
-	 * @param int $sizeDifference
38
-	 */
39
-	public function propagateChange($internalPath, $time, $sizeDifference = 0) {
40
-		/** @var \OC\Files\Storage\Storage $storage */
41
-		list($storage, $sourceInternalPath) = $this->storage->resolvePath($internalPath);
42
-		$storage->getPropagator()->propagateChange($sourceInternalPath, $time, $sizeDifference);
43
-	}
34
+    /**
35
+     * @param string $internalPath
36
+     * @param int $time
37
+     * @param int $sizeDifference
38
+     */
39
+    public function propagateChange($internalPath, $time, $sizeDifference = 0) {
40
+        /** @var \OC\Files\Storage\Storage $storage */
41
+        list($storage, $sourceInternalPath) = $this->storage->resolvePath($internalPath);
42
+        $storage->getPropagator()->propagateChange($sourceInternalPath, $time, $sizeDifference);
43
+    }
44 44
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/SharedStorage.php 1 patch
Indentation   +438 added lines, -438 removed lines patch added patch discarded remove patch
@@ -47,442 +47,442 @@
 block discarded – undo
47 47
  */
48 48
 class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedStorage {
49 49
 
50
-	/** @var \OCP\Share\IShare */
51
-	private $superShare;
52
-
53
-	/** @var \OCP\Share\IShare[] */
54
-	private $groupedShares;
55
-
56
-	/**
57
-	 * @var \OC\Files\View
58
-	 */
59
-	private $ownerView;
60
-
61
-	private $initialized = false;
62
-
63
-	/**
64
-	 * @var ICacheEntry
65
-	 */
66
-	private $sourceRootInfo;
67
-
68
-	/** @var string */
69
-	private $user;
70
-
71
-	/**
72
-	 * @var \OCP\ILogger
73
-	 */
74
-	private $logger;
75
-
76
-	/** @var  IStorage */
77
-	private $nonMaskedStorage;
78
-
79
-	private $options;
80
-
81
-	public function __construct($arguments) {
82
-		$this->ownerView = $arguments['ownerView'];
83
-		$this->logger = \OC::$server->getLogger();
84
-
85
-		$this->superShare = $arguments['superShare'];
86
-		$this->groupedShares = $arguments['groupedShares'];
87
-
88
-		$this->user = $arguments['user'];
89
-
90
-		parent::__construct([
91
-			'storage' => null,
92
-			'root' => null,
93
-		]);
94
-	}
95
-
96
-	/**
97
-	 * @return ICacheEntry
98
-	 */
99
-	private function getSourceRootInfo() {
100
-		if (is_null($this->sourceRootInfo)) {
101
-			if (is_null($this->superShare->getNodeCacheEntry())) {
102
-				$this->init();
103
-				$this->sourceRootInfo = $this->nonMaskedStorage->getCache()->get($this->rootPath);
104
-			} else {
105
-				$this->sourceRootInfo = $this->superShare->getNodeCacheEntry();
106
-			}
107
-		}
108
-		return $this->sourceRootInfo;
109
-	}
110
-
111
-	private function init() {
112
-		if ($this->initialized) {
113
-			return;
114
-		}
115
-		$this->initialized = true;
116
-		try {
117
-			Filesystem::initMountPoints($this->superShare->getShareOwner());
118
-			$sourcePath = $this->ownerView->getPath($this->superShare->getNodeId());
119
-			list($this->nonMaskedStorage, $this->rootPath) = $this->ownerView->resolvePath($sourcePath);
120
-			$this->storage = new PermissionsMask([
121
-				'storage' => $this->nonMaskedStorage,
122
-				'mask' => $this->superShare->getPermissions()
123
-			]);
124
-		} catch (NotFoundException $e) {
125
-			// original file not accessible or deleted, set FailedStorage
126
-			$this->storage = new FailedStorage(['exception' => $e]);
127
-			$this->cache = new FailedCache();
128
-			$this->rootPath = '';
129
-		} catch (NoUserException $e) {
130
-			// sharer user deleted, set FailedStorage
131
-			$this->storage = new FailedStorage(['exception' => $e]);
132
-			$this->cache = new FailedCache();
133
-			$this->rootPath = '';
134
-		} catch (\Exception $e) {
135
-			$this->storage = new FailedStorage(['exception' => $e]);
136
-			$this->cache = new FailedCache();
137
-			$this->rootPath = '';
138
-			$this->logger->logException($e);
139
-		}
140
-
141
-		if (!$this->nonMaskedStorage) {
142
-			$this->nonMaskedStorage = $this->storage;
143
-		}
144
-	}
145
-
146
-	/**
147
-	 * @inheritdoc
148
-	 */
149
-	public function instanceOfStorage($class) {
150
-		if ($class === '\OC\Files\Storage\Common') {
151
-			return true;
152
-		}
153
-		if (in_array($class, ['\OC\Files\Storage\Home', '\OC\Files\ObjectStore\HomeObjectStoreStorage'])) {
154
-			return false;
155
-		}
156
-		return parent::instanceOfStorage($class);
157
-	}
158
-
159
-	/**
160
-	 * @return string
161
-	 */
162
-	public function getShareId() {
163
-		return $this->superShare->getId();
164
-	}
165
-
166
-	private function isValid() {
167
-		return $this->getSourceRootInfo() && ($this->getSourceRootInfo()->getPermissions() & Constants::PERMISSION_SHARE) === Constants::PERMISSION_SHARE;
168
-	}
169
-
170
-	/**
171
-	 * get id of the mount point
172
-	 *
173
-	 * @return string
174
-	 */
175
-	public function getId() {
176
-		return 'shared::' . $this->getMountPoint();
177
-	}
178
-
179
-	/**
180
-	 * Get the permissions granted for a shared file
181
-	 *
182
-	 * @param string $target Shared target file path
183
-	 * @return int CRUDS permissions granted
184
-	 */
185
-	public function getPermissions($target = '') {
186
-		if (!$this->isValid()) {
187
-			return 0;
188
-		}
189
-		$permissions = $this->superShare->getPermissions();
190
-		// part files and the mount point always have delete permissions
191
-		if ($target === '' || pathinfo($target, PATHINFO_EXTENSION) === 'part') {
192
-			$permissions |= \OCP\Constants::PERMISSION_DELETE;
193
-		}
194
-
195
-		if (\OCP\Util::isSharingDisabledForUser()) {
196
-			$permissions &= ~\OCP\Constants::PERMISSION_SHARE;
197
-		}
198
-
199
-		return $permissions;
200
-	}
201
-
202
-	public function isCreatable($path) {
203
-		return ($this->getPermissions($path) & \OCP\Constants::PERMISSION_CREATE);
204
-	}
205
-
206
-	public function isReadable($path) {
207
-		if (!$this->isValid()) {
208
-			return false;
209
-		}
210
-		if (!$this->file_exists($path)) {
211
-			return false;
212
-		}
213
-		/** @var IStorage $storage */
214
-		/** @var string $internalPath */
215
-		list($storage, $internalPath) = $this->resolvePath($path);
216
-		return $storage->isReadable($internalPath);
217
-	}
218
-
219
-	public function isUpdatable($path) {
220
-		return ($this->getPermissions($path) & \OCP\Constants::PERMISSION_UPDATE);
221
-	}
222
-
223
-	public function isDeletable($path) {
224
-		return ($this->getPermissions($path) & \OCP\Constants::PERMISSION_DELETE);
225
-	}
226
-
227
-	public function isSharable($path) {
228
-		if (\OCP\Util::isSharingDisabledForUser() || !\OC\Share\Share::isResharingAllowed()) {
229
-			return false;
230
-		}
231
-		return ($this->getPermissions($path) & \OCP\Constants::PERMISSION_SHARE);
232
-	}
233
-
234
-	public function fopen($path, $mode) {
235
-		if ($source = $this->getUnjailedPath($path)) {
236
-			switch ($mode) {
237
-				case 'r+':
238
-				case 'rb+':
239
-				case 'w+':
240
-				case 'wb+':
241
-				case 'x+':
242
-				case 'xb+':
243
-				case 'a+':
244
-				case 'ab+':
245
-				case 'w':
246
-				case 'wb':
247
-				case 'x':
248
-				case 'xb':
249
-				case 'a':
250
-				case 'ab':
251
-					$creatable = $this->isCreatable($path);
252
-					$updatable = $this->isUpdatable($path);
253
-					// if neither permissions given, no need to continue
254
-					if (!$creatable && !$updatable) {
255
-						return false;
256
-					}
257
-
258
-					$exists = $this->file_exists($path);
259
-					// if a file exists, updatable permissions are required
260
-					if ($exists && !$updatable) {
261
-						return false;
262
-					}
263
-
264
-					// part file is allowed if !$creatable but the final file is $updatable
265
-					if (pathinfo($path, PATHINFO_EXTENSION) !== 'part') {
266
-						if (!$exists && !$creatable) {
267
-							return false;
268
-						}
269
-					}
270
-			}
271
-			$info = array(
272
-				'target' => $this->getMountPoint() . $path,
273
-				'source' => $source,
274
-				'mode' => $mode,
275
-			);
276
-			\OCP\Util::emitHook('\OC\Files\Storage\Shared', 'fopen', $info);
277
-			return $this->nonMaskedStorage->fopen($this->getUnjailedPath($path), $mode);
278
-		}
279
-		return false;
280
-	}
281
-
282
-	/**
283
-	 * see http://php.net/manual/en/function.rename.php
284
-	 *
285
-	 * @param string $path1
286
-	 * @param string $path2
287
-	 * @return bool
288
-	 */
289
-	public function rename($path1, $path2) {
290
-		$this->init();
291
-		$isPartFile = pathinfo($path1, PATHINFO_EXTENSION) === 'part';
292
-		$targetExists = $this->file_exists($path2);
293
-		$sameFodler = dirname($path1) === dirname($path2);
294
-
295
-		if ($targetExists || ($sameFodler && !$isPartFile)) {
296
-			if (!$this->isUpdatable('')) {
297
-				return false;
298
-			}
299
-		} else {
300
-			if (!$this->isCreatable('')) {
301
-				return false;
302
-			}
303
-		}
304
-
305
-		return $this->nonMaskedStorage->rename($this->getUnjailedPath($path1), $this->getUnjailedPath($path2));
306
-	}
307
-
308
-	/**
309
-	 * return mount point of share, relative to data/user/files
310
-	 *
311
-	 * @return string
312
-	 */
313
-	public function getMountPoint() {
314
-		return $this->superShare->getTarget();
315
-	}
316
-
317
-	/**
318
-	 * @param string $path
319
-	 */
320
-	public function setMountPoint($path) {
321
-		$this->superShare->setTarget($path);
322
-
323
-		foreach ($this->groupedShares as $share) {
324
-			$share->setTarget($path);
325
-		}
326
-	}
327
-
328
-	/**
329
-	 * get the user who shared the file
330
-	 *
331
-	 * @return string
332
-	 */
333
-	public function getSharedFrom() {
334
-		return $this->superShare->getShareOwner();
335
-	}
336
-
337
-	/**
338
-	 * @return \OCP\Share\IShare
339
-	 */
340
-	public function getShare() {
341
-		return $this->superShare;
342
-	}
343
-
344
-	/**
345
-	 * return share type, can be "file" or "folder"
346
-	 *
347
-	 * @return string
348
-	 */
349
-	public function getItemType() {
350
-		return $this->superShare->getNodeType();
351
-	}
352
-
353
-	/**
354
-	 * @param string $path
355
-	 * @param null $storage
356
-	 * @return Cache
357
-	 */
358
-	public function getCache($path = '', $storage = null) {
359
-		if ($this->cache) {
360
-			return $this->cache;
361
-		}
362
-		if (!$storage) {
363
-			$storage = $this;
364
-		}
365
-		if ($this->storage instanceof FailedStorage) {
366
-			return new FailedCache();
367
-		}
368
-		$this->cache = new \OCA\Files_Sharing\Cache($storage, $this->getSourceRootInfo(), $this->superShare);
369
-		return $this->cache;
370
-	}
371
-
372
-	public function getScanner($path = '', $storage = null) {
373
-		if (!$storage) {
374
-			$storage = $this;
375
-		}
376
-		return new \OCA\Files_Sharing\Scanner($storage);
377
-	}
378
-
379
-	public function getOwner($path) {
380
-		return $this->superShare->getShareOwner();
381
-	}
382
-
383
-	/**
384
-	 * unshare complete storage, also the grouped shares
385
-	 *
386
-	 * @return bool
387
-	 */
388
-	public function unshareStorage() {
389
-		foreach ($this->groupedShares as $share) {
390
-			\OC::$server->getShareManager()->deleteFromSelf($share, $this->user);
391
-		}
392
-		return true;
393
-	}
394
-
395
-	/**
396
-	 * @param string $path
397
-	 * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
398
-	 * @param \OCP\Lock\ILockingProvider $provider
399
-	 * @throws \OCP\Lock\LockedException
400
-	 */
401
-	public function acquireLock($path, $type, ILockingProvider $provider) {
402
-		/** @var \OCP\Files\Storage $targetStorage */
403
-		list($targetStorage, $targetInternalPath) = $this->resolvePath($path);
404
-		$targetStorage->acquireLock($targetInternalPath, $type, $provider);
405
-		// lock the parent folders of the owner when locking the share as recipient
406
-		if ($path === '') {
407
-			$sourcePath = $this->ownerView->getPath($this->superShare->getNodeId());
408
-			$this->ownerView->lockFile(dirname($sourcePath), ILockingProvider::LOCK_SHARED, true);
409
-		}
410
-	}
411
-
412
-	/**
413
-	 * @param string $path
414
-	 * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
415
-	 * @param \OCP\Lock\ILockingProvider $provider
416
-	 */
417
-	public function releaseLock($path, $type, ILockingProvider $provider) {
418
-		/** @var \OCP\Files\Storage $targetStorage */
419
-		list($targetStorage, $targetInternalPath) = $this->resolvePath($path);
420
-		$targetStorage->releaseLock($targetInternalPath, $type, $provider);
421
-		// unlock the parent folders of the owner when unlocking the share as recipient
422
-		if ($path === '') {
423
-			$sourcePath = $this->ownerView->getPath($this->superShare->getNodeId());
424
-			$this->ownerView->unlockFile(dirname($sourcePath), ILockingProvider::LOCK_SHARED, true);
425
-		}
426
-	}
427
-
428
-	/**
429
-	 * @param string $path
430
-	 * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
431
-	 * @param \OCP\Lock\ILockingProvider $provider
432
-	 */
433
-	public function changeLock($path, $type, ILockingProvider $provider) {
434
-		/** @var \OCP\Files\Storage $targetStorage */
435
-		list($targetStorage, $targetInternalPath) = $this->resolvePath($path);
436
-		$targetStorage->changeLock($targetInternalPath, $type, $provider);
437
-	}
438
-
439
-	/**
440
-	 * @return array [ available, last_checked ]
441
-	 */
442
-	public function getAvailability() {
443
-		// shares do not participate in availability logic
444
-		return [
445
-			'available' => true,
446
-			'last_checked' => 0
447
-		];
448
-	}
449
-
450
-	/**
451
-	 * @param bool $available
452
-	 */
453
-	public function setAvailability($available) {
454
-		// shares do not participate in availability logic
455
-	}
456
-
457
-	public function getSourceStorage() {
458
-		$this->init();
459
-		return $this->nonMaskedStorage;
460
-	}
461
-
462
-	public function getWrapperStorage() {
463
-		$this->init();
464
-		return $this->storage;
465
-	}
466
-
467
-	public function file_get_contents($path) {
468
-		$info = [
469
-			'target' => $this->getMountPoint() . '/' . $path,
470
-			'source' => $this->getUnjailedPath($path),
471
-		];
472
-		\OCP\Util::emitHook('\OC\Files\Storage\Shared', 'file_get_contents', $info);
473
-		return parent::file_get_contents($path);
474
-	}
475
-
476
-	public function file_put_contents($path, $data) {
477
-		$info = [
478
-			'target' => $this->getMountPoint() . '/' . $path,
479
-			'source' => $this->getUnjailedPath($path),
480
-		];
481
-		\OCP\Util::emitHook('\OC\Files\Storage\Shared', 'file_put_contents', $info);
482
-		return parent::file_put_contents($path, $data);
483
-	}
484
-
485
-	public function setMountOptions(array $options) {
486
-		$this->mountOptions = $options;
487
-	}
50
+    /** @var \OCP\Share\IShare */
51
+    private $superShare;
52
+
53
+    /** @var \OCP\Share\IShare[] */
54
+    private $groupedShares;
55
+
56
+    /**
57
+     * @var \OC\Files\View
58
+     */
59
+    private $ownerView;
60
+
61
+    private $initialized = false;
62
+
63
+    /**
64
+     * @var ICacheEntry
65
+     */
66
+    private $sourceRootInfo;
67
+
68
+    /** @var string */
69
+    private $user;
70
+
71
+    /**
72
+     * @var \OCP\ILogger
73
+     */
74
+    private $logger;
75
+
76
+    /** @var  IStorage */
77
+    private $nonMaskedStorage;
78
+
79
+    private $options;
80
+
81
+    public function __construct($arguments) {
82
+        $this->ownerView = $arguments['ownerView'];
83
+        $this->logger = \OC::$server->getLogger();
84
+
85
+        $this->superShare = $arguments['superShare'];
86
+        $this->groupedShares = $arguments['groupedShares'];
87
+
88
+        $this->user = $arguments['user'];
89
+
90
+        parent::__construct([
91
+            'storage' => null,
92
+            'root' => null,
93
+        ]);
94
+    }
95
+
96
+    /**
97
+     * @return ICacheEntry
98
+     */
99
+    private function getSourceRootInfo() {
100
+        if (is_null($this->sourceRootInfo)) {
101
+            if (is_null($this->superShare->getNodeCacheEntry())) {
102
+                $this->init();
103
+                $this->sourceRootInfo = $this->nonMaskedStorage->getCache()->get($this->rootPath);
104
+            } else {
105
+                $this->sourceRootInfo = $this->superShare->getNodeCacheEntry();
106
+            }
107
+        }
108
+        return $this->sourceRootInfo;
109
+    }
110
+
111
+    private function init() {
112
+        if ($this->initialized) {
113
+            return;
114
+        }
115
+        $this->initialized = true;
116
+        try {
117
+            Filesystem::initMountPoints($this->superShare->getShareOwner());
118
+            $sourcePath = $this->ownerView->getPath($this->superShare->getNodeId());
119
+            list($this->nonMaskedStorage, $this->rootPath) = $this->ownerView->resolvePath($sourcePath);
120
+            $this->storage = new PermissionsMask([
121
+                'storage' => $this->nonMaskedStorage,
122
+                'mask' => $this->superShare->getPermissions()
123
+            ]);
124
+        } catch (NotFoundException $e) {
125
+            // original file not accessible or deleted, set FailedStorage
126
+            $this->storage = new FailedStorage(['exception' => $e]);
127
+            $this->cache = new FailedCache();
128
+            $this->rootPath = '';
129
+        } catch (NoUserException $e) {
130
+            // sharer user deleted, set FailedStorage
131
+            $this->storage = new FailedStorage(['exception' => $e]);
132
+            $this->cache = new FailedCache();
133
+            $this->rootPath = '';
134
+        } catch (\Exception $e) {
135
+            $this->storage = new FailedStorage(['exception' => $e]);
136
+            $this->cache = new FailedCache();
137
+            $this->rootPath = '';
138
+            $this->logger->logException($e);
139
+        }
140
+
141
+        if (!$this->nonMaskedStorage) {
142
+            $this->nonMaskedStorage = $this->storage;
143
+        }
144
+    }
145
+
146
+    /**
147
+     * @inheritdoc
148
+     */
149
+    public function instanceOfStorage($class) {
150
+        if ($class === '\OC\Files\Storage\Common') {
151
+            return true;
152
+        }
153
+        if (in_array($class, ['\OC\Files\Storage\Home', '\OC\Files\ObjectStore\HomeObjectStoreStorage'])) {
154
+            return false;
155
+        }
156
+        return parent::instanceOfStorage($class);
157
+    }
158
+
159
+    /**
160
+     * @return string
161
+     */
162
+    public function getShareId() {
163
+        return $this->superShare->getId();
164
+    }
165
+
166
+    private function isValid() {
167
+        return $this->getSourceRootInfo() && ($this->getSourceRootInfo()->getPermissions() & Constants::PERMISSION_SHARE) === Constants::PERMISSION_SHARE;
168
+    }
169
+
170
+    /**
171
+     * get id of the mount point
172
+     *
173
+     * @return string
174
+     */
175
+    public function getId() {
176
+        return 'shared::' . $this->getMountPoint();
177
+    }
178
+
179
+    /**
180
+     * Get the permissions granted for a shared file
181
+     *
182
+     * @param string $target Shared target file path
183
+     * @return int CRUDS permissions granted
184
+     */
185
+    public function getPermissions($target = '') {
186
+        if (!$this->isValid()) {
187
+            return 0;
188
+        }
189
+        $permissions = $this->superShare->getPermissions();
190
+        // part files and the mount point always have delete permissions
191
+        if ($target === '' || pathinfo($target, PATHINFO_EXTENSION) === 'part') {
192
+            $permissions |= \OCP\Constants::PERMISSION_DELETE;
193
+        }
194
+
195
+        if (\OCP\Util::isSharingDisabledForUser()) {
196
+            $permissions &= ~\OCP\Constants::PERMISSION_SHARE;
197
+        }
198
+
199
+        return $permissions;
200
+    }
201
+
202
+    public function isCreatable($path) {
203
+        return ($this->getPermissions($path) & \OCP\Constants::PERMISSION_CREATE);
204
+    }
205
+
206
+    public function isReadable($path) {
207
+        if (!$this->isValid()) {
208
+            return false;
209
+        }
210
+        if (!$this->file_exists($path)) {
211
+            return false;
212
+        }
213
+        /** @var IStorage $storage */
214
+        /** @var string $internalPath */
215
+        list($storage, $internalPath) = $this->resolvePath($path);
216
+        return $storage->isReadable($internalPath);
217
+    }
218
+
219
+    public function isUpdatable($path) {
220
+        return ($this->getPermissions($path) & \OCP\Constants::PERMISSION_UPDATE);
221
+    }
222
+
223
+    public function isDeletable($path) {
224
+        return ($this->getPermissions($path) & \OCP\Constants::PERMISSION_DELETE);
225
+    }
226
+
227
+    public function isSharable($path) {
228
+        if (\OCP\Util::isSharingDisabledForUser() || !\OC\Share\Share::isResharingAllowed()) {
229
+            return false;
230
+        }
231
+        return ($this->getPermissions($path) & \OCP\Constants::PERMISSION_SHARE);
232
+    }
233
+
234
+    public function fopen($path, $mode) {
235
+        if ($source = $this->getUnjailedPath($path)) {
236
+            switch ($mode) {
237
+                case 'r+':
238
+                case 'rb+':
239
+                case 'w+':
240
+                case 'wb+':
241
+                case 'x+':
242
+                case 'xb+':
243
+                case 'a+':
244
+                case 'ab+':
245
+                case 'w':
246
+                case 'wb':
247
+                case 'x':
248
+                case 'xb':
249
+                case 'a':
250
+                case 'ab':
251
+                    $creatable = $this->isCreatable($path);
252
+                    $updatable = $this->isUpdatable($path);
253
+                    // if neither permissions given, no need to continue
254
+                    if (!$creatable && !$updatable) {
255
+                        return false;
256
+                    }
257
+
258
+                    $exists = $this->file_exists($path);
259
+                    // if a file exists, updatable permissions are required
260
+                    if ($exists && !$updatable) {
261
+                        return false;
262
+                    }
263
+
264
+                    // part file is allowed if !$creatable but the final file is $updatable
265
+                    if (pathinfo($path, PATHINFO_EXTENSION) !== 'part') {
266
+                        if (!$exists && !$creatable) {
267
+                            return false;
268
+                        }
269
+                    }
270
+            }
271
+            $info = array(
272
+                'target' => $this->getMountPoint() . $path,
273
+                'source' => $source,
274
+                'mode' => $mode,
275
+            );
276
+            \OCP\Util::emitHook('\OC\Files\Storage\Shared', 'fopen', $info);
277
+            return $this->nonMaskedStorage->fopen($this->getUnjailedPath($path), $mode);
278
+        }
279
+        return false;
280
+    }
281
+
282
+    /**
283
+     * see http://php.net/manual/en/function.rename.php
284
+     *
285
+     * @param string $path1
286
+     * @param string $path2
287
+     * @return bool
288
+     */
289
+    public function rename($path1, $path2) {
290
+        $this->init();
291
+        $isPartFile = pathinfo($path1, PATHINFO_EXTENSION) === 'part';
292
+        $targetExists = $this->file_exists($path2);
293
+        $sameFodler = dirname($path1) === dirname($path2);
294
+
295
+        if ($targetExists || ($sameFodler && !$isPartFile)) {
296
+            if (!$this->isUpdatable('')) {
297
+                return false;
298
+            }
299
+        } else {
300
+            if (!$this->isCreatable('')) {
301
+                return false;
302
+            }
303
+        }
304
+
305
+        return $this->nonMaskedStorage->rename($this->getUnjailedPath($path1), $this->getUnjailedPath($path2));
306
+    }
307
+
308
+    /**
309
+     * return mount point of share, relative to data/user/files
310
+     *
311
+     * @return string
312
+     */
313
+    public function getMountPoint() {
314
+        return $this->superShare->getTarget();
315
+    }
316
+
317
+    /**
318
+     * @param string $path
319
+     */
320
+    public function setMountPoint($path) {
321
+        $this->superShare->setTarget($path);
322
+
323
+        foreach ($this->groupedShares as $share) {
324
+            $share->setTarget($path);
325
+        }
326
+    }
327
+
328
+    /**
329
+     * get the user who shared the file
330
+     *
331
+     * @return string
332
+     */
333
+    public function getSharedFrom() {
334
+        return $this->superShare->getShareOwner();
335
+    }
336
+
337
+    /**
338
+     * @return \OCP\Share\IShare
339
+     */
340
+    public function getShare() {
341
+        return $this->superShare;
342
+    }
343
+
344
+    /**
345
+     * return share type, can be "file" or "folder"
346
+     *
347
+     * @return string
348
+     */
349
+    public function getItemType() {
350
+        return $this->superShare->getNodeType();
351
+    }
352
+
353
+    /**
354
+     * @param string $path
355
+     * @param null $storage
356
+     * @return Cache
357
+     */
358
+    public function getCache($path = '', $storage = null) {
359
+        if ($this->cache) {
360
+            return $this->cache;
361
+        }
362
+        if (!$storage) {
363
+            $storage = $this;
364
+        }
365
+        if ($this->storage instanceof FailedStorage) {
366
+            return new FailedCache();
367
+        }
368
+        $this->cache = new \OCA\Files_Sharing\Cache($storage, $this->getSourceRootInfo(), $this->superShare);
369
+        return $this->cache;
370
+    }
371
+
372
+    public function getScanner($path = '', $storage = null) {
373
+        if (!$storage) {
374
+            $storage = $this;
375
+        }
376
+        return new \OCA\Files_Sharing\Scanner($storage);
377
+    }
378
+
379
+    public function getOwner($path) {
380
+        return $this->superShare->getShareOwner();
381
+    }
382
+
383
+    /**
384
+     * unshare complete storage, also the grouped shares
385
+     *
386
+     * @return bool
387
+     */
388
+    public function unshareStorage() {
389
+        foreach ($this->groupedShares as $share) {
390
+            \OC::$server->getShareManager()->deleteFromSelf($share, $this->user);
391
+        }
392
+        return true;
393
+    }
394
+
395
+    /**
396
+     * @param string $path
397
+     * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
398
+     * @param \OCP\Lock\ILockingProvider $provider
399
+     * @throws \OCP\Lock\LockedException
400
+     */
401
+    public function acquireLock($path, $type, ILockingProvider $provider) {
402
+        /** @var \OCP\Files\Storage $targetStorage */
403
+        list($targetStorage, $targetInternalPath) = $this->resolvePath($path);
404
+        $targetStorage->acquireLock($targetInternalPath, $type, $provider);
405
+        // lock the parent folders of the owner when locking the share as recipient
406
+        if ($path === '') {
407
+            $sourcePath = $this->ownerView->getPath($this->superShare->getNodeId());
408
+            $this->ownerView->lockFile(dirname($sourcePath), ILockingProvider::LOCK_SHARED, true);
409
+        }
410
+    }
411
+
412
+    /**
413
+     * @param string $path
414
+     * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
415
+     * @param \OCP\Lock\ILockingProvider $provider
416
+     */
417
+    public function releaseLock($path, $type, ILockingProvider $provider) {
418
+        /** @var \OCP\Files\Storage $targetStorage */
419
+        list($targetStorage, $targetInternalPath) = $this->resolvePath($path);
420
+        $targetStorage->releaseLock($targetInternalPath, $type, $provider);
421
+        // unlock the parent folders of the owner when unlocking the share as recipient
422
+        if ($path === '') {
423
+            $sourcePath = $this->ownerView->getPath($this->superShare->getNodeId());
424
+            $this->ownerView->unlockFile(dirname($sourcePath), ILockingProvider::LOCK_SHARED, true);
425
+        }
426
+    }
427
+
428
+    /**
429
+     * @param string $path
430
+     * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
431
+     * @param \OCP\Lock\ILockingProvider $provider
432
+     */
433
+    public function changeLock($path, $type, ILockingProvider $provider) {
434
+        /** @var \OCP\Files\Storage $targetStorage */
435
+        list($targetStorage, $targetInternalPath) = $this->resolvePath($path);
436
+        $targetStorage->changeLock($targetInternalPath, $type, $provider);
437
+    }
438
+
439
+    /**
440
+     * @return array [ available, last_checked ]
441
+     */
442
+    public function getAvailability() {
443
+        // shares do not participate in availability logic
444
+        return [
445
+            'available' => true,
446
+            'last_checked' => 0
447
+        ];
448
+    }
449
+
450
+    /**
451
+     * @param bool $available
452
+     */
453
+    public function setAvailability($available) {
454
+        // shares do not participate in availability logic
455
+    }
456
+
457
+    public function getSourceStorage() {
458
+        $this->init();
459
+        return $this->nonMaskedStorage;
460
+    }
461
+
462
+    public function getWrapperStorage() {
463
+        $this->init();
464
+        return $this->storage;
465
+    }
466
+
467
+    public function file_get_contents($path) {
468
+        $info = [
469
+            'target' => $this->getMountPoint() . '/' . $path,
470
+            'source' => $this->getUnjailedPath($path),
471
+        ];
472
+        \OCP\Util::emitHook('\OC\Files\Storage\Shared', 'file_get_contents', $info);
473
+        return parent::file_get_contents($path);
474
+    }
475
+
476
+    public function file_put_contents($path, $data) {
477
+        $info = [
478
+            'target' => $this->getMountPoint() . '/' . $path,
479
+            'source' => $this->getUnjailedPath($path),
480
+        ];
481
+        \OCP\Util::emitHook('\OC\Files\Storage\Shared', 'file_put_contents', $info);
482
+        return parent::file_put_contents($path, $data);
483
+    }
484
+
485
+    public function setMountOptions(array $options) {
486
+        $this->mountOptions = $options;
487
+    }
488 488
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/User/OfflineUser.php 1 patch
Indentation   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -29,205 +29,205 @@
 block discarded – undo
29 29
 use OCP\IDBConnection;
30 30
 
31 31
 class OfflineUser {
32
-	/**
33
-	 * @var string $ocName
34
-	 */
35
-	protected $ocName;
36
-	/**
37
-	 * @var string $dn
38
-	 */
39
-	protected $dn;
40
-	/**
41
-	 * @var string $uid the UID as provided by LDAP
42
-	 */
43
-	protected $uid;
44
-	/**
45
-	 * @var string $displayName
46
-	 */
47
-	protected $displayName;
48
-	/**
49
-	 * @var string $homePath
50
-	 */
51
-	protected $homePath;
52
-	/**
53
-	 * @var string $lastLogin the timestamp of the last login
54
-	 */
55
-	protected $lastLogin;
56
-	/**
57
-	 * @var string $email
58
-	 */
59
-	protected $email;
60
-	/**
61
-	 * @var bool $hasActiveShares
62
-	 */
63
-	protected $hasActiveShares;
64
-	/**
65
-	 * @var IConfig $config
66
-	 */
67
-	protected $config;
68
-	/**
69
-	 * @var IDBConnection $db
70
-	 */
71
-	protected $db;
72
-	/**
73
-	 * @var \OCA\User_LDAP\Mapping\UserMapping
74
-	 */
75
-	protected $mapping;
76
-
77
-	/**
78
-	 * @param string $ocName
79
-	 * @param IConfig $config
80
-	 * @param IDBConnection $db
81
-	 * @param \OCA\User_LDAP\Mapping\UserMapping $mapping
82
-	 */
83
-	public function __construct($ocName, IConfig $config, IDBConnection $db, UserMapping $mapping) {
84
-		$this->ocName = $ocName;
85
-		$this->config = $config;
86
-		$this->db = $db;
87
-		$this->mapping = $mapping;
88
-		$this->fetchDetails();
89
-	}
90
-
91
-	/**
92
-	 * remove the Delete-flag from the user.
93
-	 */
94
-	public function unmark() {
95
-		$this->config->setUserValue($this->ocName, 'user_ldap', 'isDeleted', '0');
96
-	}
97
-
98
-	/**
99
-	 * exports the user details in an assoc array
100
-	 * @return array
101
-	 */
102
-	public function export() {
103
-		$data = array();
104
-		$data['ocName'] = $this->getOCName();
105
-		$data['dn'] = $this->getDN();
106
-		$data['uid'] = $this->getUID();
107
-		$data['displayName'] = $this->getDisplayName();
108
-		$data['homePath'] = $this->getHomePath();
109
-		$data['lastLogin'] = $this->getLastLogin();
110
-		$data['email'] = $this->getEmail();
111
-		$data['hasActiveShares'] = $this->getHasActiveShares();
112
-
113
-		return $data;
114
-	}
115
-
116
-	/**
117
-	 * getter for Nextcloud internal name
118
-	 * @return string
119
-	 */
120
-	public function getOCName() {
121
-		return $this->ocName;
122
-	}
123
-
124
-	/**
125
-	 * getter for LDAP uid
126
-	 * @return string
127
-	 */
128
-	public function getUID() {
129
-		return $this->uid;
130
-	}
131
-
132
-	/**
133
-	 * getter for LDAP DN
134
-	 * @return string
135
-	 */
136
-	public function getDN() {
137
-		return $this->dn;
138
-	}
139
-
140
-	/**
141
-	 * getter for display name
142
-	 * @return string
143
-	 */
144
-	public function getDisplayName() {
145
-		return $this->displayName;
146
-	}
147
-
148
-	/**
149
-	 * getter for email
150
-	 * @return string
151
-	 */
152
-	public function getEmail() {
153
-		return $this->email;
154
-	}
155
-
156
-	/**
157
-	 * getter for home directory path
158
-	 * @return string
159
-	 */
160
-	public function getHomePath() {
161
-		return $this->homePath;
162
-	}
163
-
164
-	/**
165
-	 * getter for the last login timestamp
166
-	 * @return int
167
-	 */
168
-	public function getLastLogin() {
169
-		return intval($this->lastLogin);
170
-	}
171
-
172
-	/**
173
-	 * getter for having active shares
174
-	 * @return bool
175
-	 */
176
-	public function getHasActiveShares() {
177
-		return $this->hasActiveShares;
178
-	}
179
-
180
-	/**
181
-	 * reads the user details
182
-	 */
183
-	protected function fetchDetails() {
184
-		$properties = array (
185
-			'displayName' => 'user_ldap',
186
-			'uid'         => 'user_ldap',
187
-			'homePath'    => 'user_ldap',
188
-			'email'       => 'settings',
189
-			'lastLogin'   => 'login'
190
-		);
191
-		foreach($properties as $property => $app) {
192
-			$this->$property = $this->config->getUserValue($this->ocName, $app, $property, '');
193
-		}
194
-
195
-		$dn = $this->mapping->getDNByName($this->ocName);
196
-		$this->dn = ($dn !== false) ? $dn : '';
197
-
198
-		$this->determineShares();
199
-	}
200
-
201
-
202
-	/**
203
-	 * finds out whether the user has active shares. The result is stored in
204
-	 * $this->hasActiveShares
205
-	 */
206
-	protected function determineShares() {
207
-		$query = $this->db->prepare('
32
+    /**
33
+     * @var string $ocName
34
+     */
35
+    protected $ocName;
36
+    /**
37
+     * @var string $dn
38
+     */
39
+    protected $dn;
40
+    /**
41
+     * @var string $uid the UID as provided by LDAP
42
+     */
43
+    protected $uid;
44
+    /**
45
+     * @var string $displayName
46
+     */
47
+    protected $displayName;
48
+    /**
49
+     * @var string $homePath
50
+     */
51
+    protected $homePath;
52
+    /**
53
+     * @var string $lastLogin the timestamp of the last login
54
+     */
55
+    protected $lastLogin;
56
+    /**
57
+     * @var string $email
58
+     */
59
+    protected $email;
60
+    /**
61
+     * @var bool $hasActiveShares
62
+     */
63
+    protected $hasActiveShares;
64
+    /**
65
+     * @var IConfig $config
66
+     */
67
+    protected $config;
68
+    /**
69
+     * @var IDBConnection $db
70
+     */
71
+    protected $db;
72
+    /**
73
+     * @var \OCA\User_LDAP\Mapping\UserMapping
74
+     */
75
+    protected $mapping;
76
+
77
+    /**
78
+     * @param string $ocName
79
+     * @param IConfig $config
80
+     * @param IDBConnection $db
81
+     * @param \OCA\User_LDAP\Mapping\UserMapping $mapping
82
+     */
83
+    public function __construct($ocName, IConfig $config, IDBConnection $db, UserMapping $mapping) {
84
+        $this->ocName = $ocName;
85
+        $this->config = $config;
86
+        $this->db = $db;
87
+        $this->mapping = $mapping;
88
+        $this->fetchDetails();
89
+    }
90
+
91
+    /**
92
+     * remove the Delete-flag from the user.
93
+     */
94
+    public function unmark() {
95
+        $this->config->setUserValue($this->ocName, 'user_ldap', 'isDeleted', '0');
96
+    }
97
+
98
+    /**
99
+     * exports the user details in an assoc array
100
+     * @return array
101
+     */
102
+    public function export() {
103
+        $data = array();
104
+        $data['ocName'] = $this->getOCName();
105
+        $data['dn'] = $this->getDN();
106
+        $data['uid'] = $this->getUID();
107
+        $data['displayName'] = $this->getDisplayName();
108
+        $data['homePath'] = $this->getHomePath();
109
+        $data['lastLogin'] = $this->getLastLogin();
110
+        $data['email'] = $this->getEmail();
111
+        $data['hasActiveShares'] = $this->getHasActiveShares();
112
+
113
+        return $data;
114
+    }
115
+
116
+    /**
117
+     * getter for Nextcloud internal name
118
+     * @return string
119
+     */
120
+    public function getOCName() {
121
+        return $this->ocName;
122
+    }
123
+
124
+    /**
125
+     * getter for LDAP uid
126
+     * @return string
127
+     */
128
+    public function getUID() {
129
+        return $this->uid;
130
+    }
131
+
132
+    /**
133
+     * getter for LDAP DN
134
+     * @return string
135
+     */
136
+    public function getDN() {
137
+        return $this->dn;
138
+    }
139
+
140
+    /**
141
+     * getter for display name
142
+     * @return string
143
+     */
144
+    public function getDisplayName() {
145
+        return $this->displayName;
146
+    }
147
+
148
+    /**
149
+     * getter for email
150
+     * @return string
151
+     */
152
+    public function getEmail() {
153
+        return $this->email;
154
+    }
155
+
156
+    /**
157
+     * getter for home directory path
158
+     * @return string
159
+     */
160
+    public function getHomePath() {
161
+        return $this->homePath;
162
+    }
163
+
164
+    /**
165
+     * getter for the last login timestamp
166
+     * @return int
167
+     */
168
+    public function getLastLogin() {
169
+        return intval($this->lastLogin);
170
+    }
171
+
172
+    /**
173
+     * getter for having active shares
174
+     * @return bool
175
+     */
176
+    public function getHasActiveShares() {
177
+        return $this->hasActiveShares;
178
+    }
179
+
180
+    /**
181
+     * reads the user details
182
+     */
183
+    protected function fetchDetails() {
184
+        $properties = array (
185
+            'displayName' => 'user_ldap',
186
+            'uid'         => 'user_ldap',
187
+            'homePath'    => 'user_ldap',
188
+            'email'       => 'settings',
189
+            'lastLogin'   => 'login'
190
+        );
191
+        foreach($properties as $property => $app) {
192
+            $this->$property = $this->config->getUserValue($this->ocName, $app, $property, '');
193
+        }
194
+
195
+        $dn = $this->mapping->getDNByName($this->ocName);
196
+        $this->dn = ($dn !== false) ? $dn : '';
197
+
198
+        $this->determineShares();
199
+    }
200
+
201
+
202
+    /**
203
+     * finds out whether the user has active shares. The result is stored in
204
+     * $this->hasActiveShares
205
+     */
206
+    protected function determineShares() {
207
+        $query = $this->db->prepare('
208 208
 			SELECT COUNT(`uid_owner`)
209 209
 			FROM `*PREFIX*share`
210 210
 			WHERE `uid_owner` = ?
211 211
 		', 1);
212
-		$query->execute(array($this->ocName));
213
-		$sResult = $query->fetchColumn(0);
214
-		if(intval($sResult) === 1) {
215
-			$this->hasActiveShares = true;
216
-			return;
217
-		}
218
-
219
-		$query = $this->db->prepare('
212
+        $query->execute(array($this->ocName));
213
+        $sResult = $query->fetchColumn(0);
214
+        if(intval($sResult) === 1) {
215
+            $this->hasActiveShares = true;
216
+            return;
217
+        }
218
+
219
+        $query = $this->db->prepare('
220 220
 			SELECT COUNT(`owner`)
221 221
 			FROM `*PREFIX*share_external`
222 222
 			WHERE `owner` = ?
223 223
 		', 1);
224
-		$query->execute(array($this->ocName));
225
-		$sResult = $query->fetchColumn(0);
226
-		if(intval($sResult) === 1) {
227
-			$this->hasActiveShares = true;
228
-			return;
229
-		}
230
-
231
-		$this->hasActiveShares = false;
232
-	}
224
+        $query->execute(array($this->ocName));
225
+        $sResult = $query->fetchColumn(0);
226
+        if(intval($sResult) === 1) {
227
+            $this->hasActiveShares = true;
228
+            return;
229
+        }
230
+
231
+        $this->hasActiveShares = false;
232
+    }
233 233
 }
Please login to merge, or discard this patch.
lib/private/Security/CertificateManager.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 			return array();
91 91
 		}
92 92
 
93
-		$path = $this->getPathToCertificates() . 'uploads/';
93
+		$path = $this->getPathToCertificates().'uploads/';
94 94
 		if (!$this->view->is_dir($path)) {
95 95
 			return array();
96 96
 		}
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 		while (false !== ($file = readdir($handle))) {
103 103
 			if ($file != '.' && $file != '..') {
104 104
 				try {
105
-					$result[] = new Certificate($this->view->file_get_contents($path . $file), $file);
105
+					$result[] = new Certificate($this->view->file_get_contents($path.$file), $file);
106 106
 				} catch (\Exception $e) {
107 107
 				}
108 108
 			}
@@ -122,20 +122,20 @@  discard block
 block discarded – undo
122 122
 			$this->view->mkdir($path);
123 123
 		}
124 124
 
125
-		$defaultCertificates = file_get_contents(\OC::$SERVERROOT . '/resources/config/ca-bundle.crt');
125
+		$defaultCertificates = file_get_contents(\OC::$SERVERROOT.'/resources/config/ca-bundle.crt');
126 126
 		if (strlen($defaultCertificates) < 1024) { // sanity check to verify that we have some content for our bundle
127 127
 			// log as exception so we have a stacktrace
128 128
 			$this->logger->logException(new \Exception('Shipped ca-bundle is empty, refusing to create certificate bundle'));
129 129
 			return;
130 130
 		}
131 131
 
132
-		$certPath = $path . 'rootcerts.crt';
133
-		$tmpPath = $certPath . '.tmp' . $this->random->generate(10, ISecureRandom::CHAR_DIGITS);
132
+		$certPath = $path.'rootcerts.crt';
133
+		$tmpPath = $certPath.'.tmp'.$this->random->generate(10, ISecureRandom::CHAR_DIGITS);
134 134
 		$fhCerts = $this->view->fopen($tmpPath, 'w');
135 135
 
136 136
 		// Write user certificates
137 137
 		foreach ($certs as $cert) {
138
-			$file = $path . '/uploads/' . $cert->getName();
138
+			$file = $path.'/uploads/'.$cert->getName();
139 139
 			$data = $this->view->file_get_contents($file);
140 140
 			if (strpos($data, 'BEGIN CERTIFICATE')) {
141 141
 				fwrite($fhCerts, $data);
@@ -171,13 +171,13 @@  discard block
 block discarded – undo
171 171
 			throw new \Exception('Filename is not valid');
172 172
 		}
173 173
 
174
-		$dir = $this->getPathToCertificates() . 'uploads/';
174
+		$dir = $this->getPathToCertificates().'uploads/';
175 175
 		if (!$this->view->file_exists($dir)) {
176 176
 			$this->view->mkdir($dir);
177 177
 		}
178 178
 
179 179
 		try {
180
-			$file = $dir . $name;
180
+			$file = $dir.$name;
181 181
 			$certificateObject = new Certificate($certificate, $name);
182 182
 			$this->view->file_put_contents($file, $certificate);
183 183
 			$this->createCertificateBundle();
@@ -198,9 +198,9 @@  discard block
 block discarded – undo
198 198
 		if (!Filesystem::isValidPath($name)) {
199 199
 			return false;
200 200
 		}
201
-		$path = $this->getPathToCertificates() . 'uploads/';
202
-		if ($this->view->file_exists($path . $name)) {
203
-			$this->view->unlink($path . $name);
201
+		$path = $this->getPathToCertificates().'uploads/';
202
+		if ($this->view->file_exists($path.$name)) {
203
+			$this->view->unlink($path.$name);
204 204
 			$this->createCertificateBundle();
205 205
 		}
206 206
 		return true;
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 		if ($uid === '') {
217 217
 			$uid = $this->uid;
218 218
 		}
219
-		return $this->getPathToCertificates($uid) . 'rootcerts.crt';
219
+		return $this->getPathToCertificates($uid).'rootcerts.crt';
220 220
 	}
221 221
 
222 222
 	/**
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 		if ($uid === '') {
249 249
 			$uid = $this->uid;
250 250
 		}
251
-		$path = is_null($uid) ? '/files_external/' : '/' . $uid . '/files_external/';
251
+		$path = is_null($uid) ? '/files_external/' : '/'.$uid.'/files_external/';
252 252
 
253 253
 		return $path;
254 254
 	}
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 			$sourceMTimes[] = $this->view->filemtime($this->getCertificateBundle(null));
275 275
 		}
276 276
 
277
-		$sourceMTime = array_reduce($sourceMTimes, function ($max, $mtime) {
277
+		$sourceMTime = array_reduce($sourceMTimes, function($max, $mtime) {
278 278
 			return max($max, $mtime);
279 279
 		}, 0);
280 280
 		return $sourceMTime > $this->view->filemtime($targetBundle);
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	 * @return int
287 287
 	 */
288 288
 	protected function getFilemtimeOfCaBundle() {
289
-		return filemtime(\OC::$SERVERROOT . '/resources/config/ca-bundle.crt');
289
+		return filemtime(\OC::$SERVERROOT.'/resources/config/ca-bundle.crt');
290 290
 	}
291 291
 
292 292
 }
Please login to merge, or discard this patch.
Indentation   +250 added lines, -250 removed lines patch added patch discarded remove patch
@@ -37,255 +37,255 @@
 block discarded – undo
37 37
  * Manage trusted certificates for users
38 38
  */
39 39
 class CertificateManager implements ICertificateManager {
40
-	/**
41
-	 * @var string
42
-	 */
43
-	protected $uid;
44
-
45
-	/**
46
-	 * @var \OC\Files\View
47
-	 */
48
-	protected $view;
49
-
50
-	/**
51
-	 * @var IConfig
52
-	 */
53
-	protected $config;
54
-
55
-	/**
56
-	 * @var ILogger
57
-	 */
58
-	protected $logger;
59
-
60
-	/** @var ISecureRandom */
61
-	protected $random;
62
-
63
-	/**
64
-	 * @param string $uid
65
-	 * @param \OC\Files\View $view relative to data/
66
-	 * @param IConfig $config
67
-	 * @param ILogger $logger
68
-	 * @param ISecureRandom $random
69
-	 */
70
-	public function __construct($uid,
71
-								\OC\Files\View $view,
72
-								IConfig $config,
73
-								ILogger $logger,
74
-								ISecureRandom $random) {
75
-		$this->uid = $uid;
76
-		$this->view = $view;
77
-		$this->config = $config;
78
-		$this->logger = $logger;
79
-		$this->random = $random;
80
-	}
81
-
82
-	/**
83
-	 * Returns all certificates trusted by the user
84
-	 *
85
-	 * @return \OCP\ICertificate[]
86
-	 */
87
-	public function listCertificates() {
88
-
89
-		if (!$this->config->getSystemValue('installed', false)) {
90
-			return array();
91
-		}
92
-
93
-		$path = $this->getPathToCertificates() . 'uploads/';
94
-		if (!$this->view->is_dir($path)) {
95
-			return array();
96
-		}
97
-		$result = array();
98
-		$handle = $this->view->opendir($path);
99
-		if (!is_resource($handle)) {
100
-			return array();
101
-		}
102
-		while (false !== ($file = readdir($handle))) {
103
-			if ($file != '.' && $file != '..') {
104
-				try {
105
-					$result[] = new Certificate($this->view->file_get_contents($path . $file), $file);
106
-				} catch (\Exception $e) {
107
-				}
108
-			}
109
-		}
110
-		closedir($handle);
111
-		return $result;
112
-	}
113
-
114
-	/**
115
-	 * create the certificate bundle of all trusted certificated
116
-	 */
117
-	public function createCertificateBundle() {
118
-		$path = $this->getPathToCertificates();
119
-		$certs = $this->listCertificates();
120
-
121
-		if (!$this->view->file_exists($path)) {
122
-			$this->view->mkdir($path);
123
-		}
124
-
125
-		$defaultCertificates = file_get_contents(\OC::$SERVERROOT . '/resources/config/ca-bundle.crt');
126
-		if (strlen($defaultCertificates) < 1024) { // sanity check to verify that we have some content for our bundle
127
-			// log as exception so we have a stacktrace
128
-			$this->logger->logException(new \Exception('Shipped ca-bundle is empty, refusing to create certificate bundle'));
129
-			return;
130
-		}
131
-
132
-		$certPath = $path . 'rootcerts.crt';
133
-		$tmpPath = $certPath . '.tmp' . $this->random->generate(10, ISecureRandom::CHAR_DIGITS);
134
-		$fhCerts = $this->view->fopen($tmpPath, 'w');
135
-
136
-		// Write user certificates
137
-		foreach ($certs as $cert) {
138
-			$file = $path . '/uploads/' . $cert->getName();
139
-			$data = $this->view->file_get_contents($file);
140
-			if (strpos($data, 'BEGIN CERTIFICATE')) {
141
-				fwrite($fhCerts, $data);
142
-				fwrite($fhCerts, "\r\n");
143
-			}
144
-		}
145
-
146
-		// Append the default certificates
147
-		fwrite($fhCerts, $defaultCertificates);
148
-
149
-		// Append the system certificate bundle
150
-		$systemBundle = $this->getCertificateBundle(null);
151
-		if ($systemBundle !== $certPath && $this->view->file_exists($systemBundle)) {
152
-			$systemCertificates = $this->view->file_get_contents($systemBundle);
153
-			fwrite($fhCerts, $systemCertificates);
154
-		}
155
-
156
-		fclose($fhCerts);
157
-
158
-		$this->view->rename($tmpPath, $certPath);
159
-	}
160
-
161
-	/**
162
-	 * Save the certificate and re-generate the certificate bundle
163
-	 *
164
-	 * @param string $certificate the certificate data
165
-	 * @param string $name the filename for the certificate
166
-	 * @return \OCP\ICertificate
167
-	 * @throws \Exception If the certificate could not get added
168
-	 */
169
-	public function addCertificate($certificate, $name) {
170
-		if (!Filesystem::isValidPath($name) or Filesystem::isFileBlacklisted($name)) {
171
-			throw new \Exception('Filename is not valid');
172
-		}
173
-
174
-		$dir = $this->getPathToCertificates() . 'uploads/';
175
-		if (!$this->view->file_exists($dir)) {
176
-			$this->view->mkdir($dir);
177
-		}
178
-
179
-		try {
180
-			$file = $dir . $name;
181
-			$certificateObject = new Certificate($certificate, $name);
182
-			$this->view->file_put_contents($file, $certificate);
183
-			$this->createCertificateBundle();
184
-			return $certificateObject;
185
-		} catch (\Exception $e) {
186
-			throw $e;
187
-		}
188
-
189
-	}
190
-
191
-	/**
192
-	 * Remove the certificate and re-generate the certificate bundle
193
-	 *
194
-	 * @param string $name
195
-	 * @return bool
196
-	 */
197
-	public function removeCertificate($name) {
198
-		if (!Filesystem::isValidPath($name)) {
199
-			return false;
200
-		}
201
-		$path = $this->getPathToCertificates() . 'uploads/';
202
-		if ($this->view->file_exists($path . $name)) {
203
-			$this->view->unlink($path . $name);
204
-			$this->createCertificateBundle();
205
-		}
206
-		return true;
207
-	}
208
-
209
-	/**
210
-	 * Get the path to the certificate bundle for this user
211
-	 *
212
-	 * @param string $uid (optional) user to get the certificate bundle for, use `null` to get the system bundle
213
-	 * @return string
214
-	 */
215
-	public function getCertificateBundle($uid = '') {
216
-		if ($uid === '') {
217
-			$uid = $this->uid;
218
-		}
219
-		return $this->getPathToCertificates($uid) . 'rootcerts.crt';
220
-	}
221
-
222
-	/**
223
-	 * Get the full local path to the certificate bundle for this user
224
-	 *
225
-	 * @param string $uid (optional) user to get the certificate bundle for, use `null` to get the system bundle
226
-	 * @return string
227
-	 */
228
-	public function getAbsoluteBundlePath($uid = '') {
229
-		if ($uid === '') {
230
-			$uid = $this->uid;
231
-		}
232
-		if ($this->needsRebundling($uid)) {
233
-			if (is_null($uid)) {
234
-				$manager = new CertificateManager(null, $this->view, $this->config, $this->logger, $this->random);
235
-				$manager->createCertificateBundle();
236
-			} else {
237
-				$this->createCertificateBundle();
238
-			}
239
-		}
240
-		return $this->view->getLocalFile($this->getCertificateBundle($uid));
241
-	}
242
-
243
-	/**
244
-	 * @param string $uid (optional) user to get the certificate path for, use `null` to get the system path
245
-	 * @return string
246
-	 */
247
-	private function getPathToCertificates($uid = '') {
248
-		if ($uid === '') {
249
-			$uid = $this->uid;
250
-		}
251
-		$path = is_null($uid) ? '/files_external/' : '/' . $uid . '/files_external/';
252
-
253
-		return $path;
254
-	}
255
-
256
-	/**
257
-	 * Check if we need to re-bundle the certificates because one of the sources has updated
258
-	 *
259
-	 * @param string $uid (optional) user to get the certificate path for, use `null` to get the system path
260
-	 * @return bool
261
-	 */
262
-	private function needsRebundling($uid = '') {
263
-		if ($uid === '') {
264
-			$uid = $this->uid;
265
-		}
266
-		$sourceMTimes = [$this->getFilemtimeOfCaBundle()];
267
-		$targetBundle = $this->getCertificateBundle($uid);
268
-		if (!$this->view->file_exists($targetBundle)) {
269
-			return true;
270
-		}
271
-
272
-		if (!is_null($uid)) { // also depend on the system bundle
273
-			$sourceMTimes[] = $this->view->filemtime($this->getCertificateBundle(null));
274
-		}
275
-
276
-		$sourceMTime = array_reduce($sourceMTimes, function ($max, $mtime) {
277
-			return max($max, $mtime);
278
-		}, 0);
279
-		return $sourceMTime > $this->view->filemtime($targetBundle);
280
-	}
281
-
282
-	/**
283
-	 * get mtime of ca-bundle shipped by Nextcloud
284
-	 *
285
-	 * @return int
286
-	 */
287
-	protected function getFilemtimeOfCaBundle() {
288
-		return filemtime(\OC::$SERVERROOT . '/resources/config/ca-bundle.crt');
289
-	}
40
+    /**
41
+     * @var string
42
+     */
43
+    protected $uid;
44
+
45
+    /**
46
+     * @var \OC\Files\View
47
+     */
48
+    protected $view;
49
+
50
+    /**
51
+     * @var IConfig
52
+     */
53
+    protected $config;
54
+
55
+    /**
56
+     * @var ILogger
57
+     */
58
+    protected $logger;
59
+
60
+    /** @var ISecureRandom */
61
+    protected $random;
62
+
63
+    /**
64
+     * @param string $uid
65
+     * @param \OC\Files\View $view relative to data/
66
+     * @param IConfig $config
67
+     * @param ILogger $logger
68
+     * @param ISecureRandom $random
69
+     */
70
+    public function __construct($uid,
71
+                                \OC\Files\View $view,
72
+                                IConfig $config,
73
+                                ILogger $logger,
74
+                                ISecureRandom $random) {
75
+        $this->uid = $uid;
76
+        $this->view = $view;
77
+        $this->config = $config;
78
+        $this->logger = $logger;
79
+        $this->random = $random;
80
+    }
81
+
82
+    /**
83
+     * Returns all certificates trusted by the user
84
+     *
85
+     * @return \OCP\ICertificate[]
86
+     */
87
+    public function listCertificates() {
88
+
89
+        if (!$this->config->getSystemValue('installed', false)) {
90
+            return array();
91
+        }
92
+
93
+        $path = $this->getPathToCertificates() . 'uploads/';
94
+        if (!$this->view->is_dir($path)) {
95
+            return array();
96
+        }
97
+        $result = array();
98
+        $handle = $this->view->opendir($path);
99
+        if (!is_resource($handle)) {
100
+            return array();
101
+        }
102
+        while (false !== ($file = readdir($handle))) {
103
+            if ($file != '.' && $file != '..') {
104
+                try {
105
+                    $result[] = new Certificate($this->view->file_get_contents($path . $file), $file);
106
+                } catch (\Exception $e) {
107
+                }
108
+            }
109
+        }
110
+        closedir($handle);
111
+        return $result;
112
+    }
113
+
114
+    /**
115
+     * create the certificate bundle of all trusted certificated
116
+     */
117
+    public function createCertificateBundle() {
118
+        $path = $this->getPathToCertificates();
119
+        $certs = $this->listCertificates();
120
+
121
+        if (!$this->view->file_exists($path)) {
122
+            $this->view->mkdir($path);
123
+        }
124
+
125
+        $defaultCertificates = file_get_contents(\OC::$SERVERROOT . '/resources/config/ca-bundle.crt');
126
+        if (strlen($defaultCertificates) < 1024) { // sanity check to verify that we have some content for our bundle
127
+            // log as exception so we have a stacktrace
128
+            $this->logger->logException(new \Exception('Shipped ca-bundle is empty, refusing to create certificate bundle'));
129
+            return;
130
+        }
131
+
132
+        $certPath = $path . 'rootcerts.crt';
133
+        $tmpPath = $certPath . '.tmp' . $this->random->generate(10, ISecureRandom::CHAR_DIGITS);
134
+        $fhCerts = $this->view->fopen($tmpPath, 'w');
135
+
136
+        // Write user certificates
137
+        foreach ($certs as $cert) {
138
+            $file = $path . '/uploads/' . $cert->getName();
139
+            $data = $this->view->file_get_contents($file);
140
+            if (strpos($data, 'BEGIN CERTIFICATE')) {
141
+                fwrite($fhCerts, $data);
142
+                fwrite($fhCerts, "\r\n");
143
+            }
144
+        }
145
+
146
+        // Append the default certificates
147
+        fwrite($fhCerts, $defaultCertificates);
148
+
149
+        // Append the system certificate bundle
150
+        $systemBundle = $this->getCertificateBundle(null);
151
+        if ($systemBundle !== $certPath && $this->view->file_exists($systemBundle)) {
152
+            $systemCertificates = $this->view->file_get_contents($systemBundle);
153
+            fwrite($fhCerts, $systemCertificates);
154
+        }
155
+
156
+        fclose($fhCerts);
157
+
158
+        $this->view->rename($tmpPath, $certPath);
159
+    }
160
+
161
+    /**
162
+     * Save the certificate and re-generate the certificate bundle
163
+     *
164
+     * @param string $certificate the certificate data
165
+     * @param string $name the filename for the certificate
166
+     * @return \OCP\ICertificate
167
+     * @throws \Exception If the certificate could not get added
168
+     */
169
+    public function addCertificate($certificate, $name) {
170
+        if (!Filesystem::isValidPath($name) or Filesystem::isFileBlacklisted($name)) {
171
+            throw new \Exception('Filename is not valid');
172
+        }
173
+
174
+        $dir = $this->getPathToCertificates() . 'uploads/';
175
+        if (!$this->view->file_exists($dir)) {
176
+            $this->view->mkdir($dir);
177
+        }
178
+
179
+        try {
180
+            $file = $dir . $name;
181
+            $certificateObject = new Certificate($certificate, $name);
182
+            $this->view->file_put_contents($file, $certificate);
183
+            $this->createCertificateBundle();
184
+            return $certificateObject;
185
+        } catch (\Exception $e) {
186
+            throw $e;
187
+        }
188
+
189
+    }
190
+
191
+    /**
192
+     * Remove the certificate and re-generate the certificate bundle
193
+     *
194
+     * @param string $name
195
+     * @return bool
196
+     */
197
+    public function removeCertificate($name) {
198
+        if (!Filesystem::isValidPath($name)) {
199
+            return false;
200
+        }
201
+        $path = $this->getPathToCertificates() . 'uploads/';
202
+        if ($this->view->file_exists($path . $name)) {
203
+            $this->view->unlink($path . $name);
204
+            $this->createCertificateBundle();
205
+        }
206
+        return true;
207
+    }
208
+
209
+    /**
210
+     * Get the path to the certificate bundle for this user
211
+     *
212
+     * @param string $uid (optional) user to get the certificate bundle for, use `null` to get the system bundle
213
+     * @return string
214
+     */
215
+    public function getCertificateBundle($uid = '') {
216
+        if ($uid === '') {
217
+            $uid = $this->uid;
218
+        }
219
+        return $this->getPathToCertificates($uid) . 'rootcerts.crt';
220
+    }
221
+
222
+    /**
223
+     * Get the full local path to the certificate bundle for this user
224
+     *
225
+     * @param string $uid (optional) user to get the certificate bundle for, use `null` to get the system bundle
226
+     * @return string
227
+     */
228
+    public function getAbsoluteBundlePath($uid = '') {
229
+        if ($uid === '') {
230
+            $uid = $this->uid;
231
+        }
232
+        if ($this->needsRebundling($uid)) {
233
+            if (is_null($uid)) {
234
+                $manager = new CertificateManager(null, $this->view, $this->config, $this->logger, $this->random);
235
+                $manager->createCertificateBundle();
236
+            } else {
237
+                $this->createCertificateBundle();
238
+            }
239
+        }
240
+        return $this->view->getLocalFile($this->getCertificateBundle($uid));
241
+    }
242
+
243
+    /**
244
+     * @param string $uid (optional) user to get the certificate path for, use `null` to get the system path
245
+     * @return string
246
+     */
247
+    private function getPathToCertificates($uid = '') {
248
+        if ($uid === '') {
249
+            $uid = $this->uid;
250
+        }
251
+        $path = is_null($uid) ? '/files_external/' : '/' . $uid . '/files_external/';
252
+
253
+        return $path;
254
+    }
255
+
256
+    /**
257
+     * Check if we need to re-bundle the certificates because one of the sources has updated
258
+     *
259
+     * @param string $uid (optional) user to get the certificate path for, use `null` to get the system path
260
+     * @return bool
261
+     */
262
+    private function needsRebundling($uid = '') {
263
+        if ($uid === '') {
264
+            $uid = $this->uid;
265
+        }
266
+        $sourceMTimes = [$this->getFilemtimeOfCaBundle()];
267
+        $targetBundle = $this->getCertificateBundle($uid);
268
+        if (!$this->view->file_exists($targetBundle)) {
269
+            return true;
270
+        }
271
+
272
+        if (!is_null($uid)) { // also depend on the system bundle
273
+            $sourceMTimes[] = $this->view->filemtime($this->getCertificateBundle(null));
274
+        }
275
+
276
+        $sourceMTime = array_reduce($sourceMTimes, function ($max, $mtime) {
277
+            return max($max, $mtime);
278
+        }, 0);
279
+        return $sourceMTime > $this->view->filemtime($targetBundle);
280
+    }
281
+
282
+    /**
283
+     * get mtime of ca-bundle shipped by Nextcloud
284
+     *
285
+     * @return int
286
+     */
287
+    protected function getFilemtimeOfCaBundle() {
288
+        return filemtime(\OC::$SERVERROOT . '/resources/config/ca-bundle.crt');
289
+    }
290 290
 
291 291
 }
Please login to merge, or discard this patch.
lib/private/Server.php 1 patch
Indentation   +1656 added lines, -1656 removed lines patch added patch discarded remove patch
@@ -127,1665 +127,1665 @@
 block discarded – undo
127 127
  * TODO: hookup all manager classes
128 128
  */
129 129
 class Server extends ServerContainer implements IServerContainer {
130
-	/** @var string */
131
-	private $webRoot;
132
-
133
-	/**
134
-	 * @param string $webRoot
135
-	 * @param \OC\Config $config
136
-	 */
137
-	public function __construct($webRoot, \OC\Config $config) {
138
-		parent::__construct();
139
-		$this->webRoot = $webRoot;
140
-
141
-		$this->registerService(\OCP\IServerContainer::class, function(IServerContainer $c) {
142
-			return $c;
143
-		});
144
-
145
-		$this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
146
-		$this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class);
147
-
148
-		$this->registerAlias(IActionFactory::class, ActionFactory::class);
149
-
150
-
151
-
152
-		$this->registerService(\OCP\IPreview::class, function (Server $c) {
153
-			return new PreviewManager(
154
-				$c->getConfig(),
155
-				$c->getRootFolder(),
156
-				$c->getAppDataDir('preview'),
157
-				$c->getEventDispatcher(),
158
-				$c->getSession()->get('user_id')
159
-			);
160
-		});
161
-		$this->registerAlias('PreviewManager', \OCP\IPreview::class);
162
-
163
-		$this->registerService(\OC\Preview\Watcher::class, function (Server $c) {
164
-			return new \OC\Preview\Watcher(
165
-				$c->getAppDataDir('preview')
166
-			);
167
-		});
168
-
169
-		$this->registerService('EncryptionManager', function (Server $c) {
170
-			$view = new View();
171
-			$util = new Encryption\Util(
172
-				$view,
173
-				$c->getUserManager(),
174
-				$c->getGroupManager(),
175
-				$c->getConfig()
176
-			);
177
-			return new Encryption\Manager(
178
-				$c->getConfig(),
179
-				$c->getLogger(),
180
-				$c->getL10N('core'),
181
-				new View(),
182
-				$util,
183
-				new ArrayCache()
184
-			);
185
-		});
186
-
187
-		$this->registerService('EncryptionFileHelper', function (Server $c) {
188
-			$util = new Encryption\Util(
189
-				new View(),
190
-				$c->getUserManager(),
191
-				$c->getGroupManager(),
192
-				$c->getConfig()
193
-			);
194
-			return new Encryption\File(
195
-				$util,
196
-				$c->getRootFolder(),
197
-				$c->getShareManager()
198
-			);
199
-		});
200
-
201
-		$this->registerService('EncryptionKeyStorage', function (Server $c) {
202
-			$view = new View();
203
-			$util = new Encryption\Util(
204
-				$view,
205
-				$c->getUserManager(),
206
-				$c->getGroupManager(),
207
-				$c->getConfig()
208
-			);
209
-
210
-			return new Encryption\Keys\Storage($view, $util);
211
-		});
212
-		$this->registerService('TagMapper', function (Server $c) {
213
-			return new TagMapper($c->getDatabaseConnection());
214
-		});
215
-
216
-		$this->registerService(\OCP\ITagManager::class, function (Server $c) {
217
-			$tagMapper = $c->query('TagMapper');
218
-			return new TagManager($tagMapper, $c->getUserSession());
219
-		});
220
-		$this->registerAlias('TagManager', \OCP\ITagManager::class);
221
-
222
-		$this->registerService('SystemTagManagerFactory', function (Server $c) {
223
-			$config = $c->getConfig();
224
-			$factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory');
225
-			/** @var \OC\SystemTag\ManagerFactory $factory */
226
-			$factory = new $factoryClass($this);
227
-			return $factory;
228
-		});
229
-		$this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) {
230
-			return $c->query('SystemTagManagerFactory')->getManager();
231
-		});
232
-		$this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class);
233
-
234
-		$this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) {
235
-			return $c->query('SystemTagManagerFactory')->getObjectMapper();
236
-		});
237
-		$this->registerService('RootFolder', function (Server $c) {
238
-			$manager = \OC\Files\Filesystem::getMountManager(null);
239
-			$view = new View();
240
-			$root = new Root(
241
-				$manager,
242
-				$view,
243
-				null,
244
-				$c->getUserMountCache(),
245
-				$this->getLogger(),
246
-				$this->getUserManager()
247
-			);
248
-			$connector = new HookConnector($root, $view);
249
-			$connector->viewToNode();
250
-
251
-			$previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig());
252
-			$previewConnector->connectWatcher();
253
-
254
-			return $root;
255
-		});
256
-		$this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class);
257
-
258
-		$this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) {
259
-			return new LazyRoot(function() use ($c) {
260
-				return $c->query('RootFolder');
261
-			});
262
-		});
263
-		$this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class);
264
-
265
-		$this->registerService(\OCP\IUserManager::class, function (Server $c) {
266
-			$config = $c->getConfig();
267
-			return new \OC\User\Manager($config);
268
-		});
269
-		$this->registerAlias('UserManager', \OCP\IUserManager::class);
270
-
271
-		$this->registerService(\OCP\IGroupManager::class, function (Server $c) {
272
-			$groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger());
273
-			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
274
-				\OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
275
-			});
276
-			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) {
277
-				\OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
278
-			});
279
-			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
280
-				\OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
281
-			});
282
-			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
283
-				\OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
284
-			});
285
-			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
286
-				\OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
287
-			});
288
-			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
289
-				\OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
290
-				//Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
291
-				\OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
292
-			});
293
-			return $groupManager;
294
-		});
295
-		$this->registerAlias('GroupManager', \OCP\IGroupManager::class);
296
-
297
-		$this->registerService(Store::class, function(Server $c) {
298
-			$session = $c->getSession();
299
-			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
300
-				$tokenProvider = $c->query('OC\Authentication\Token\IProvider');
301
-			} else {
302
-				$tokenProvider = null;
303
-			}
304
-			$logger = $c->getLogger();
305
-			return new Store($session, $logger, $tokenProvider);
306
-		});
307
-		$this->registerAlias(IStore::class, Store::class);
308
-		$this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) {
309
-			$dbConnection = $c->getDatabaseConnection();
310
-			return new Authentication\Token\DefaultTokenMapper($dbConnection);
311
-		});
312
-		$this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) {
313
-			$mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper');
314
-			$crypto = $c->getCrypto();
315
-			$config = $c->getConfig();
316
-			$logger = $c->getLogger();
317
-			$timeFactory = new TimeFactory();
318
-			return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory);
319
-		});
320
-		$this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider');
321
-
322
-		$this->registerService(\OCP\IUserSession::class, function (Server $c) {
323
-			$manager = $c->getUserManager();
324
-			$session = new \OC\Session\Memory('');
325
-			$timeFactory = new TimeFactory();
326
-			// Token providers might require a working database. This code
327
-			// might however be called when ownCloud is not yet setup.
328
-			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
329
-				$defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider');
330
-			} else {
331
-				$defaultTokenProvider = null;
332
-			}
333
-
334
-			$userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom(), $c->getLockdownManager());
335
-			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
336
-				\OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
337
-			});
338
-			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
339
-				/** @var $user \OC\User\User */
340
-				\OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
341
-			});
342
-			$userSession->listen('\OC\User', 'preDelete', function ($user) {
343
-				/** @var $user \OC\User\User */
344
-				\OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
345
-			});
346
-			$userSession->listen('\OC\User', 'postDelete', function ($user) {
347
-				/** @var $user \OC\User\User */
348
-				\OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
349
-			});
350
-			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
351
-				/** @var $user \OC\User\User */
352
-				\OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
353
-			});
354
-			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
355
-				/** @var $user \OC\User\User */
356
-				\OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
357
-			});
358
-			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
359
-				\OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
360
-			});
361
-			$userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
362
-				/** @var $user \OC\User\User */
363
-				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
364
-			});
365
-			$userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
366
-				/** @var $user \OC\User\User */
367
-				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
368
-			});
369
-			$userSession->listen('\OC\User', 'logout', function () {
370
-				\OC_Hook::emit('OC_User', 'logout', array());
371
-			});
372
-			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
373
-				/** @var $user \OC\User\User */
374
-				\OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue));
375
-			});
376
-			return $userSession;
377
-		});
378
-		$this->registerAlias('UserSession', \OCP\IUserSession::class);
379
-
380
-		$this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) {
381
-			return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger());
382
-		});
383
-
384
-		$this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class);
385
-		$this->registerAlias('NavigationManager', \OCP\INavigationManager::class);
386
-
387
-		$this->registerService(\OC\AllConfig::class, function (Server $c) {
388
-			return new \OC\AllConfig(
389
-				$c->getSystemConfig()
390
-			);
391
-		});
392
-		$this->registerAlias('AllConfig', \OC\AllConfig::class);
393
-		$this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
394
-
395
-		$this->registerService('SystemConfig', function ($c) use ($config) {
396
-			return new \OC\SystemConfig($config);
397
-		});
398
-
399
-		$this->registerService(\OC\AppConfig::class, function (Server $c) {
400
-			return new \OC\AppConfig($c->getDatabaseConnection());
401
-		});
402
-		$this->registerAlias('AppConfig', \OC\AppConfig::class);
403
-		$this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class);
404
-
405
-		$this->registerService(\OCP\L10N\IFactory::class, function (Server $c) {
406
-			return new \OC\L10N\Factory(
407
-				$c->getConfig(),
408
-				$c->getRequest(),
409
-				$c->getUserSession(),
410
-				\OC::$SERVERROOT
411
-			);
412
-		});
413
-		$this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class);
414
-
415
-		$this->registerService(\OCP\IURLGenerator::class, function (Server $c) {
416
-			$config = $c->getConfig();
417
-			$cacheFactory = $c->getMemCacheFactory();
418
-			$request = $c->getRequest();
419
-			return new \OC\URLGenerator(
420
-				$config,
421
-				$cacheFactory,
422
-				$request
423
-			);
424
-		});
425
-		$this->registerAlias('URLGenerator', \OCP\IURLGenerator::class);
426
-
427
-		$this->registerService('AppHelper', function ($c) {
428
-			return new \OC\AppHelper();
429
-		});
430
-		$this->registerAlias('AppFetcher', AppFetcher::class);
431
-		$this->registerAlias('CategoryFetcher', CategoryFetcher::class);
432
-
433
-		$this->registerService(\OCP\ICache::class, function ($c) {
434
-			return new Cache\File();
435
-		});
436
-		$this->registerAlias('UserCache', \OCP\ICache::class);
437
-
438
-		$this->registerService(Factory::class, function (Server $c) {
439
-
440
-			$arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(),
441
-				'\\OC\\Memcache\\ArrayCache',
442
-				'\\OC\\Memcache\\ArrayCache',
443
-				'\\OC\\Memcache\\ArrayCache'
444
-			);
445
-			$config = $c->getConfig();
446
-			$request = $c->getRequest();
447
-			$urlGenerator = new URLGenerator($config, $arrayCacheFactory, $request);
448
-
449
-			if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
450
-				$v = \OC_App::getAppVersions();
451
-				$v['core'] = implode(',', \OC_Util::getVersion());
452
-				$version = implode(',', $v);
453
-				$instanceId = \OC_Util::getInstanceId();
454
-				$path = \OC::$SERVERROOT;
455
-				$prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . $urlGenerator->getBaseUrl());
456
-				return new \OC\Memcache\Factory($prefix, $c->getLogger(),
457
-					$config->getSystemValue('memcache.local', null),
458
-					$config->getSystemValue('memcache.distributed', null),
459
-					$config->getSystemValue('memcache.locking', null)
460
-				);
461
-			}
462
-			return $arrayCacheFactory;
463
-
464
-		});
465
-		$this->registerAlias('MemCacheFactory', Factory::class);
466
-		$this->registerAlias(ICacheFactory::class, Factory::class);
467
-
468
-		$this->registerService('RedisFactory', function (Server $c) {
469
-			$systemConfig = $c->getSystemConfig();
470
-			return new RedisFactory($systemConfig);
471
-		});
472
-
473
-		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
474
-			return new \OC\Activity\Manager(
475
-				$c->getRequest(),
476
-				$c->getUserSession(),
477
-				$c->getConfig(),
478
-				$c->query(IValidator::class)
479
-			);
480
-		});
481
-		$this->registerAlias('ActivityManager', \OCP\Activity\IManager::class);
482
-
483
-		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
484
-			return new \OC\Activity\EventMerger(
485
-				$c->getL10N('lib')
486
-			);
487
-		});
488
-		$this->registerAlias(IValidator::class, Validator::class);
489
-
490
-		$this->registerService(\OCP\IAvatarManager::class, function (Server $c) {
491
-			return new AvatarManager(
492
-				$c->getUserManager(),
493
-				$c->getAppDataDir('avatar'),
494
-				$c->getL10N('lib'),
495
-				$c->getLogger(),
496
-				$c->getConfig()
497
-			);
498
-		});
499
-		$this->registerAlias('AvatarManager', \OCP\IAvatarManager::class);
500
-
501
-		$this->registerService(\OCP\ILogger::class, function (Server $c) {
502
-			$logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
503
-			$logger = Log::getLogClass($logType);
504
-			call_user_func(array($logger, 'init'));
505
-
506
-			return new Log($logger);
507
-		});
508
-		$this->registerAlias('Logger', \OCP\ILogger::class);
509
-
510
-		$this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) {
511
-			$config = $c->getConfig();
512
-			return new \OC\BackgroundJob\JobList(
513
-				$c->getDatabaseConnection(),
514
-				$config,
515
-				new TimeFactory()
516
-			);
517
-		});
518
-		$this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class);
519
-
520
-		$this->registerService(\OCP\Route\IRouter::class, function (Server $c) {
521
-			$cacheFactory = $c->getMemCacheFactory();
522
-			$logger = $c->getLogger();
523
-			if ($cacheFactory->isAvailable()) {
524
-				$router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger);
525
-			} else {
526
-				$router = new \OC\Route\Router($logger);
527
-			}
528
-			return $router;
529
-		});
530
-		$this->registerAlias('Router', \OCP\Route\IRouter::class);
531
-
532
-		$this->registerService(\OCP\ISearch::class, function ($c) {
533
-			return new Search();
534
-		});
535
-		$this->registerAlias('Search', \OCP\ISearch::class);
536
-
537
-		$this->registerService(\OC\Security\RateLimiting\Limiter::class, function($c) {
538
-			return new \OC\Security\RateLimiting\Limiter(
539
-				$this->getUserSession(),
540
-				$this->getRequest(),
541
-				new \OC\AppFramework\Utility\TimeFactory(),
542
-				$c->query(\OC\Security\RateLimiting\Backend\IBackend::class)
543
-			);
544
-		});
545
-		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function($c) {
546
-			return new \OC\Security\RateLimiting\Backend\MemoryCache(
547
-				$this->getMemCacheFactory(),
548
-				new \OC\AppFramework\Utility\TimeFactory()
549
-			);
550
-		});
551
-
552
-		$this->registerService(\OCP\Security\ISecureRandom::class, function ($c) {
553
-			return new SecureRandom();
554
-		});
555
-		$this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
556
-
557
-		$this->registerService(\OCP\Security\ICrypto::class, function (Server $c) {
558
-			return new Crypto($c->getConfig(), $c->getSecureRandom());
559
-		});
560
-		$this->registerAlias('Crypto', \OCP\Security\ICrypto::class);
561
-
562
-		$this->registerService(\OCP\Security\IHasher::class, function (Server $c) {
563
-			return new Hasher($c->getConfig());
564
-		});
565
-		$this->registerAlias('Hasher', \OCP\Security\IHasher::class);
566
-
567
-		$this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) {
568
-			return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
569
-		});
570
-		$this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class);
571
-
572
-		$this->registerService(IDBConnection::class, function (Server $c) {
573
-			$systemConfig = $c->getSystemConfig();
574
-			$factory = new \OC\DB\ConnectionFactory($systemConfig);
575
-			$type = $systemConfig->getValue('dbtype', 'sqlite');
576
-			if (!$factory->isValidType($type)) {
577
-				throw new \OC\DatabaseException('Invalid database type');
578
-			}
579
-			$connectionParams = $factory->createConnectionParams();
580
-			$connection = $factory->getConnection($type, $connectionParams);
581
-			$connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
582
-			return $connection;
583
-		});
584
-		$this->registerAlias('DatabaseConnection', IDBConnection::class);
585
-
586
-		$this->registerService('HTTPHelper', function (Server $c) {
587
-			$config = $c->getConfig();
588
-			return new HTTPHelper(
589
-				$config,
590
-				$c->getHTTPClientService()
591
-			);
592
-		});
593
-
594
-		$this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) {
595
-			$user = \OC_User::getUser();
596
-			$uid = $user ? $user : null;
597
-			return new ClientService(
598
-				$c->getConfig(),
599
-				new \OC\Security\CertificateManager(
600
-					$uid,
601
-					new View(),
602
-					$c->getConfig(),
603
-					$c->getLogger(),
604
-					$c->getSecureRandom()
605
-				)
606
-			);
607
-		});
608
-		$this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class);
609
-		$this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) {
610
-			$eventLogger = new EventLogger();
611
-			if ($c->getSystemConfig()->getValue('debug', false)) {
612
-				// In debug mode, module is being activated by default
613
-				$eventLogger->activate();
614
-			}
615
-			return $eventLogger;
616
-		});
617
-		$this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class);
618
-
619
-		$this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) {
620
-			$queryLogger = new QueryLogger();
621
-			if ($c->getSystemConfig()->getValue('debug', false)) {
622
-				// In debug mode, module is being activated by default
623
-				$queryLogger->activate();
624
-			}
625
-			return $queryLogger;
626
-		});
627
-		$this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class);
628
-
629
-		$this->registerService(TempManager::class, function (Server $c) {
630
-			return new TempManager(
631
-				$c->getLogger(),
632
-				$c->getConfig()
633
-			);
634
-		});
635
-		$this->registerAlias('TempManager', TempManager::class);
636
-		$this->registerAlias(ITempManager::class, TempManager::class);
637
-
638
-		$this->registerService(AppManager::class, function (Server $c) {
639
-			return new \OC\App\AppManager(
640
-				$c->getUserSession(),
641
-				$c->getAppConfig(),
642
-				$c->getGroupManager(),
643
-				$c->getMemCacheFactory(),
644
-				$c->getEventDispatcher()
645
-			);
646
-		});
647
-		$this->registerAlias('AppManager', AppManager::class);
648
-		$this->registerAlias(IAppManager::class, AppManager::class);
649
-
650
-		$this->registerService(\OCP\IDateTimeZone::class, function (Server $c) {
651
-			return new DateTimeZone(
652
-				$c->getConfig(),
653
-				$c->getSession()
654
-			);
655
-		});
656
-		$this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class);
657
-
658
-		$this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) {
659
-			$language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
660
-
661
-			return new DateTimeFormatter(
662
-				$c->getDateTimeZone()->getTimeZone(),
663
-				$c->getL10N('lib', $language)
664
-			);
665
-		});
666
-		$this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class);
667
-
668
-		$this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) {
669
-			$mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
670
-			$listener = new UserMountCacheListener($mountCache);
671
-			$listener->listen($c->getUserManager());
672
-			return $mountCache;
673
-		});
674
-		$this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class);
675
-
676
-		$this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) {
677
-			$loader = \OC\Files\Filesystem::getLoader();
678
-			$mountCache = $c->query('UserMountCache');
679
-			$manager =  new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
680
-
681
-			// builtin providers
682
-
683
-			$config = $c->getConfig();
684
-			$manager->registerProvider(new CacheMountProvider($config));
685
-			$manager->registerHomeProvider(new LocalHomeMountProvider());
686
-			$manager->registerHomeProvider(new ObjectHomeMountProvider($config));
687
-
688
-			return $manager;
689
-		});
690
-		$this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class);
691
-
692
-		$this->registerService('IniWrapper', function ($c) {
693
-			return new IniGetWrapper();
694
-		});
695
-		$this->registerService('AsyncCommandBus', function (Server $c) {
696
-			$jobList = $c->getJobList();
697
-			return new AsyncBus($jobList);
698
-		});
699
-		$this->registerService('TrustedDomainHelper', function ($c) {
700
-			return new TrustedDomainHelper($this->getConfig());
701
-		});
702
-		$this->registerService('Throttler', function(Server $c) {
703
-			return new Throttler(
704
-				$c->getDatabaseConnection(),
705
-				new TimeFactory(),
706
-				$c->getLogger(),
707
-				$c->getConfig()
708
-			);
709
-		});
710
-		$this->registerService('IntegrityCodeChecker', function (Server $c) {
711
-			// IConfig and IAppManager requires a working database. This code
712
-			// might however be called when ownCloud is not yet setup.
713
-			if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
714
-				$config = $c->getConfig();
715
-				$appManager = $c->getAppManager();
716
-			} else {
717
-				$config = null;
718
-				$appManager = null;
719
-			}
720
-
721
-			return new Checker(
722
-					new EnvironmentHelper(),
723
-					new FileAccessHelper(),
724
-					new AppLocator(),
725
-					$config,
726
-					$c->getMemCacheFactory(),
727
-					$appManager,
728
-					$c->getTempManager()
729
-			);
730
-		});
731
-		$this->registerService(\OCP\IRequest::class, function ($c) {
732
-			if (isset($this['urlParams'])) {
733
-				$urlParams = $this['urlParams'];
734
-			} else {
735
-				$urlParams = [];
736
-			}
737
-
738
-			if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
739
-				&& in_array('fakeinput', stream_get_wrappers())
740
-			) {
741
-				$stream = 'fakeinput://data';
742
-			} else {
743
-				$stream = 'php://input';
744
-			}
745
-
746
-			return new Request(
747
-				[
748
-					'get' => $_GET,
749
-					'post' => $_POST,
750
-					'files' => $_FILES,
751
-					'server' => $_SERVER,
752
-					'env' => $_ENV,
753
-					'cookies' => $_COOKIE,
754
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
755
-						? $_SERVER['REQUEST_METHOD']
756
-						: null,
757
-					'urlParams' => $urlParams,
758
-				],
759
-				$this->getSecureRandom(),
760
-				$this->getConfig(),
761
-				$this->getCsrfTokenManager(),
762
-				$stream
763
-			);
764
-		});
765
-		$this->registerAlias('Request', \OCP\IRequest::class);
766
-
767
-		$this->registerService(\OCP\Mail\IMailer::class, function (Server $c) {
768
-			return new Mailer(
769
-				$c->getConfig(),
770
-				$c->getLogger(),
771
-				$c->query(Defaults::class),
772
-				$c->getURLGenerator(),
773
-				$c->getL10N('lib')
774
-			);
775
-		});
776
-		$this->registerAlias('Mailer', \OCP\Mail\IMailer::class);
777
-
778
-		$this->registerService('LDAPProvider', function(Server $c) {
779
-			$config = $c->getConfig();
780
-			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
781
-			if(is_null($factoryClass)) {
782
-				throw new \Exception('ldapProviderFactory not set');
783
-			}
784
-			/** @var \OCP\LDAP\ILDAPProviderFactory $factory */
785
-			$factory = new $factoryClass($this);
786
-			return $factory->getLDAPProvider();
787
-		});
788
-		$this->registerService('LockingProvider', function (Server $c) {
789
-			$ini = $c->getIniWrapper();
790
-			$config = $c->getConfig();
791
-			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
792
-			if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
793
-				/** @var \OC\Memcache\Factory $memcacheFactory */
794
-				$memcacheFactory = $c->getMemCacheFactory();
795
-				$memcache = $memcacheFactory->createLocking('lock');
796
-				if (!($memcache instanceof \OC\Memcache\NullCache)) {
797
-					return new MemcacheLockingProvider($memcache, $ttl);
798
-				}
799
-				return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl);
800
-			}
801
-			return new NoopLockingProvider();
802
-		});
803
-
804
-		$this->registerService(\OCP\Files\Mount\IMountManager::class, function () {
805
-			return new \OC\Files\Mount\Manager();
806
-		});
807
-		$this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class);
808
-
809
-		$this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) {
810
-			return new \OC\Files\Type\Detection(
811
-				$c->getURLGenerator(),
812
-				\OC::$configDir,
813
-				\OC::$SERVERROOT . '/resources/config/'
814
-			);
815
-		});
816
-		$this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class);
817
-
818
-		$this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) {
819
-			return new \OC\Files\Type\Loader(
820
-				$c->getDatabaseConnection()
821
-			);
822
-		});
823
-		$this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class);
824
-		$this->registerService(BundleFetcher::class, function () {
825
-			return new BundleFetcher($this->getL10N('lib'));
826
-		});
827
-		$this->registerService(\OCP\Notification\IManager::class, function (Server $c) {
828
-			return new Manager(
829
-				$c->query(IValidator::class)
830
-			);
831
-		});
832
-		$this->registerAlias('NotificationManager', \OCP\Notification\IManager::class);
833
-
834
-		$this->registerService(\OC\CapabilitiesManager::class, function (Server $c) {
835
-			$manager = new \OC\CapabilitiesManager($c->getLogger());
836
-			$manager->registerCapability(function () use ($c) {
837
-				return new \OC\OCS\CoreCapabilities($c->getConfig());
838
-			});
839
-			return $manager;
840
-		});
841
-		$this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class);
842
-
843
-		$this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) {
844
-			$config = $c->getConfig();
845
-			$factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
846
-			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
847
-			$factory = new $factoryClass($this);
848
-			return $factory->getManager();
849
-		});
850
-		$this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class);
851
-
852
-		$this->registerService('ThemingDefaults', function(Server $c) {
853
-			/*
130
+    /** @var string */
131
+    private $webRoot;
132
+
133
+    /**
134
+     * @param string $webRoot
135
+     * @param \OC\Config $config
136
+     */
137
+    public function __construct($webRoot, \OC\Config $config) {
138
+        parent::__construct();
139
+        $this->webRoot = $webRoot;
140
+
141
+        $this->registerService(\OCP\IServerContainer::class, function(IServerContainer $c) {
142
+            return $c;
143
+        });
144
+
145
+        $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
146
+        $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class);
147
+
148
+        $this->registerAlias(IActionFactory::class, ActionFactory::class);
149
+
150
+
151
+
152
+        $this->registerService(\OCP\IPreview::class, function (Server $c) {
153
+            return new PreviewManager(
154
+                $c->getConfig(),
155
+                $c->getRootFolder(),
156
+                $c->getAppDataDir('preview'),
157
+                $c->getEventDispatcher(),
158
+                $c->getSession()->get('user_id')
159
+            );
160
+        });
161
+        $this->registerAlias('PreviewManager', \OCP\IPreview::class);
162
+
163
+        $this->registerService(\OC\Preview\Watcher::class, function (Server $c) {
164
+            return new \OC\Preview\Watcher(
165
+                $c->getAppDataDir('preview')
166
+            );
167
+        });
168
+
169
+        $this->registerService('EncryptionManager', function (Server $c) {
170
+            $view = new View();
171
+            $util = new Encryption\Util(
172
+                $view,
173
+                $c->getUserManager(),
174
+                $c->getGroupManager(),
175
+                $c->getConfig()
176
+            );
177
+            return new Encryption\Manager(
178
+                $c->getConfig(),
179
+                $c->getLogger(),
180
+                $c->getL10N('core'),
181
+                new View(),
182
+                $util,
183
+                new ArrayCache()
184
+            );
185
+        });
186
+
187
+        $this->registerService('EncryptionFileHelper', function (Server $c) {
188
+            $util = new Encryption\Util(
189
+                new View(),
190
+                $c->getUserManager(),
191
+                $c->getGroupManager(),
192
+                $c->getConfig()
193
+            );
194
+            return new Encryption\File(
195
+                $util,
196
+                $c->getRootFolder(),
197
+                $c->getShareManager()
198
+            );
199
+        });
200
+
201
+        $this->registerService('EncryptionKeyStorage', function (Server $c) {
202
+            $view = new View();
203
+            $util = new Encryption\Util(
204
+                $view,
205
+                $c->getUserManager(),
206
+                $c->getGroupManager(),
207
+                $c->getConfig()
208
+            );
209
+
210
+            return new Encryption\Keys\Storage($view, $util);
211
+        });
212
+        $this->registerService('TagMapper', function (Server $c) {
213
+            return new TagMapper($c->getDatabaseConnection());
214
+        });
215
+
216
+        $this->registerService(\OCP\ITagManager::class, function (Server $c) {
217
+            $tagMapper = $c->query('TagMapper');
218
+            return new TagManager($tagMapper, $c->getUserSession());
219
+        });
220
+        $this->registerAlias('TagManager', \OCP\ITagManager::class);
221
+
222
+        $this->registerService('SystemTagManagerFactory', function (Server $c) {
223
+            $config = $c->getConfig();
224
+            $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory');
225
+            /** @var \OC\SystemTag\ManagerFactory $factory */
226
+            $factory = new $factoryClass($this);
227
+            return $factory;
228
+        });
229
+        $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) {
230
+            return $c->query('SystemTagManagerFactory')->getManager();
231
+        });
232
+        $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class);
233
+
234
+        $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) {
235
+            return $c->query('SystemTagManagerFactory')->getObjectMapper();
236
+        });
237
+        $this->registerService('RootFolder', function (Server $c) {
238
+            $manager = \OC\Files\Filesystem::getMountManager(null);
239
+            $view = new View();
240
+            $root = new Root(
241
+                $manager,
242
+                $view,
243
+                null,
244
+                $c->getUserMountCache(),
245
+                $this->getLogger(),
246
+                $this->getUserManager()
247
+            );
248
+            $connector = new HookConnector($root, $view);
249
+            $connector->viewToNode();
250
+
251
+            $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig());
252
+            $previewConnector->connectWatcher();
253
+
254
+            return $root;
255
+        });
256
+        $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class);
257
+
258
+        $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) {
259
+            return new LazyRoot(function() use ($c) {
260
+                return $c->query('RootFolder');
261
+            });
262
+        });
263
+        $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class);
264
+
265
+        $this->registerService(\OCP\IUserManager::class, function (Server $c) {
266
+            $config = $c->getConfig();
267
+            return new \OC\User\Manager($config);
268
+        });
269
+        $this->registerAlias('UserManager', \OCP\IUserManager::class);
270
+
271
+        $this->registerService(\OCP\IGroupManager::class, function (Server $c) {
272
+            $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger());
273
+            $groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
274
+                \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
275
+            });
276
+            $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) {
277
+                \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
278
+            });
279
+            $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
280
+                \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
281
+            });
282
+            $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
283
+                \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
284
+            });
285
+            $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
286
+                \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
287
+            });
288
+            $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
289
+                \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
290
+                //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
291
+                \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
292
+            });
293
+            return $groupManager;
294
+        });
295
+        $this->registerAlias('GroupManager', \OCP\IGroupManager::class);
296
+
297
+        $this->registerService(Store::class, function(Server $c) {
298
+            $session = $c->getSession();
299
+            if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
300
+                $tokenProvider = $c->query('OC\Authentication\Token\IProvider');
301
+            } else {
302
+                $tokenProvider = null;
303
+            }
304
+            $logger = $c->getLogger();
305
+            return new Store($session, $logger, $tokenProvider);
306
+        });
307
+        $this->registerAlias(IStore::class, Store::class);
308
+        $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) {
309
+            $dbConnection = $c->getDatabaseConnection();
310
+            return new Authentication\Token\DefaultTokenMapper($dbConnection);
311
+        });
312
+        $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) {
313
+            $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper');
314
+            $crypto = $c->getCrypto();
315
+            $config = $c->getConfig();
316
+            $logger = $c->getLogger();
317
+            $timeFactory = new TimeFactory();
318
+            return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory);
319
+        });
320
+        $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider');
321
+
322
+        $this->registerService(\OCP\IUserSession::class, function (Server $c) {
323
+            $manager = $c->getUserManager();
324
+            $session = new \OC\Session\Memory('');
325
+            $timeFactory = new TimeFactory();
326
+            // Token providers might require a working database. This code
327
+            // might however be called when ownCloud is not yet setup.
328
+            if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
329
+                $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider');
330
+            } else {
331
+                $defaultTokenProvider = null;
332
+            }
333
+
334
+            $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom(), $c->getLockdownManager());
335
+            $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
336
+                \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
337
+            });
338
+            $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
339
+                /** @var $user \OC\User\User */
340
+                \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
341
+            });
342
+            $userSession->listen('\OC\User', 'preDelete', function ($user) {
343
+                /** @var $user \OC\User\User */
344
+                \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
345
+            });
346
+            $userSession->listen('\OC\User', 'postDelete', function ($user) {
347
+                /** @var $user \OC\User\User */
348
+                \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
349
+            });
350
+            $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
351
+                /** @var $user \OC\User\User */
352
+                \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
353
+            });
354
+            $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
355
+                /** @var $user \OC\User\User */
356
+                \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
357
+            });
358
+            $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
359
+                \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
360
+            });
361
+            $userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
362
+                /** @var $user \OC\User\User */
363
+                \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
364
+            });
365
+            $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
366
+                /** @var $user \OC\User\User */
367
+                \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
368
+            });
369
+            $userSession->listen('\OC\User', 'logout', function () {
370
+                \OC_Hook::emit('OC_User', 'logout', array());
371
+            });
372
+            $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
373
+                /** @var $user \OC\User\User */
374
+                \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue));
375
+            });
376
+            return $userSession;
377
+        });
378
+        $this->registerAlias('UserSession', \OCP\IUserSession::class);
379
+
380
+        $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) {
381
+            return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger());
382
+        });
383
+
384
+        $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class);
385
+        $this->registerAlias('NavigationManager', \OCP\INavigationManager::class);
386
+
387
+        $this->registerService(\OC\AllConfig::class, function (Server $c) {
388
+            return new \OC\AllConfig(
389
+                $c->getSystemConfig()
390
+            );
391
+        });
392
+        $this->registerAlias('AllConfig', \OC\AllConfig::class);
393
+        $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
394
+
395
+        $this->registerService('SystemConfig', function ($c) use ($config) {
396
+            return new \OC\SystemConfig($config);
397
+        });
398
+
399
+        $this->registerService(\OC\AppConfig::class, function (Server $c) {
400
+            return new \OC\AppConfig($c->getDatabaseConnection());
401
+        });
402
+        $this->registerAlias('AppConfig', \OC\AppConfig::class);
403
+        $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class);
404
+
405
+        $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) {
406
+            return new \OC\L10N\Factory(
407
+                $c->getConfig(),
408
+                $c->getRequest(),
409
+                $c->getUserSession(),
410
+                \OC::$SERVERROOT
411
+            );
412
+        });
413
+        $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class);
414
+
415
+        $this->registerService(\OCP\IURLGenerator::class, function (Server $c) {
416
+            $config = $c->getConfig();
417
+            $cacheFactory = $c->getMemCacheFactory();
418
+            $request = $c->getRequest();
419
+            return new \OC\URLGenerator(
420
+                $config,
421
+                $cacheFactory,
422
+                $request
423
+            );
424
+        });
425
+        $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class);
426
+
427
+        $this->registerService('AppHelper', function ($c) {
428
+            return new \OC\AppHelper();
429
+        });
430
+        $this->registerAlias('AppFetcher', AppFetcher::class);
431
+        $this->registerAlias('CategoryFetcher', CategoryFetcher::class);
432
+
433
+        $this->registerService(\OCP\ICache::class, function ($c) {
434
+            return new Cache\File();
435
+        });
436
+        $this->registerAlias('UserCache', \OCP\ICache::class);
437
+
438
+        $this->registerService(Factory::class, function (Server $c) {
439
+
440
+            $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(),
441
+                '\\OC\\Memcache\\ArrayCache',
442
+                '\\OC\\Memcache\\ArrayCache',
443
+                '\\OC\\Memcache\\ArrayCache'
444
+            );
445
+            $config = $c->getConfig();
446
+            $request = $c->getRequest();
447
+            $urlGenerator = new URLGenerator($config, $arrayCacheFactory, $request);
448
+
449
+            if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
450
+                $v = \OC_App::getAppVersions();
451
+                $v['core'] = implode(',', \OC_Util::getVersion());
452
+                $version = implode(',', $v);
453
+                $instanceId = \OC_Util::getInstanceId();
454
+                $path = \OC::$SERVERROOT;
455
+                $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . $urlGenerator->getBaseUrl());
456
+                return new \OC\Memcache\Factory($prefix, $c->getLogger(),
457
+                    $config->getSystemValue('memcache.local', null),
458
+                    $config->getSystemValue('memcache.distributed', null),
459
+                    $config->getSystemValue('memcache.locking', null)
460
+                );
461
+            }
462
+            return $arrayCacheFactory;
463
+
464
+        });
465
+        $this->registerAlias('MemCacheFactory', Factory::class);
466
+        $this->registerAlias(ICacheFactory::class, Factory::class);
467
+
468
+        $this->registerService('RedisFactory', function (Server $c) {
469
+            $systemConfig = $c->getSystemConfig();
470
+            return new RedisFactory($systemConfig);
471
+        });
472
+
473
+        $this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
474
+            return new \OC\Activity\Manager(
475
+                $c->getRequest(),
476
+                $c->getUserSession(),
477
+                $c->getConfig(),
478
+                $c->query(IValidator::class)
479
+            );
480
+        });
481
+        $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class);
482
+
483
+        $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
484
+            return new \OC\Activity\EventMerger(
485
+                $c->getL10N('lib')
486
+            );
487
+        });
488
+        $this->registerAlias(IValidator::class, Validator::class);
489
+
490
+        $this->registerService(\OCP\IAvatarManager::class, function (Server $c) {
491
+            return new AvatarManager(
492
+                $c->getUserManager(),
493
+                $c->getAppDataDir('avatar'),
494
+                $c->getL10N('lib'),
495
+                $c->getLogger(),
496
+                $c->getConfig()
497
+            );
498
+        });
499
+        $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class);
500
+
501
+        $this->registerService(\OCP\ILogger::class, function (Server $c) {
502
+            $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
503
+            $logger = Log::getLogClass($logType);
504
+            call_user_func(array($logger, 'init'));
505
+
506
+            return new Log($logger);
507
+        });
508
+        $this->registerAlias('Logger', \OCP\ILogger::class);
509
+
510
+        $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) {
511
+            $config = $c->getConfig();
512
+            return new \OC\BackgroundJob\JobList(
513
+                $c->getDatabaseConnection(),
514
+                $config,
515
+                new TimeFactory()
516
+            );
517
+        });
518
+        $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class);
519
+
520
+        $this->registerService(\OCP\Route\IRouter::class, function (Server $c) {
521
+            $cacheFactory = $c->getMemCacheFactory();
522
+            $logger = $c->getLogger();
523
+            if ($cacheFactory->isAvailable()) {
524
+                $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger);
525
+            } else {
526
+                $router = new \OC\Route\Router($logger);
527
+            }
528
+            return $router;
529
+        });
530
+        $this->registerAlias('Router', \OCP\Route\IRouter::class);
531
+
532
+        $this->registerService(\OCP\ISearch::class, function ($c) {
533
+            return new Search();
534
+        });
535
+        $this->registerAlias('Search', \OCP\ISearch::class);
536
+
537
+        $this->registerService(\OC\Security\RateLimiting\Limiter::class, function($c) {
538
+            return new \OC\Security\RateLimiting\Limiter(
539
+                $this->getUserSession(),
540
+                $this->getRequest(),
541
+                new \OC\AppFramework\Utility\TimeFactory(),
542
+                $c->query(\OC\Security\RateLimiting\Backend\IBackend::class)
543
+            );
544
+        });
545
+        $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function($c) {
546
+            return new \OC\Security\RateLimiting\Backend\MemoryCache(
547
+                $this->getMemCacheFactory(),
548
+                new \OC\AppFramework\Utility\TimeFactory()
549
+            );
550
+        });
551
+
552
+        $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) {
553
+            return new SecureRandom();
554
+        });
555
+        $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
556
+
557
+        $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) {
558
+            return new Crypto($c->getConfig(), $c->getSecureRandom());
559
+        });
560
+        $this->registerAlias('Crypto', \OCP\Security\ICrypto::class);
561
+
562
+        $this->registerService(\OCP\Security\IHasher::class, function (Server $c) {
563
+            return new Hasher($c->getConfig());
564
+        });
565
+        $this->registerAlias('Hasher', \OCP\Security\IHasher::class);
566
+
567
+        $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) {
568
+            return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
569
+        });
570
+        $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class);
571
+
572
+        $this->registerService(IDBConnection::class, function (Server $c) {
573
+            $systemConfig = $c->getSystemConfig();
574
+            $factory = new \OC\DB\ConnectionFactory($systemConfig);
575
+            $type = $systemConfig->getValue('dbtype', 'sqlite');
576
+            if (!$factory->isValidType($type)) {
577
+                throw new \OC\DatabaseException('Invalid database type');
578
+            }
579
+            $connectionParams = $factory->createConnectionParams();
580
+            $connection = $factory->getConnection($type, $connectionParams);
581
+            $connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
582
+            return $connection;
583
+        });
584
+        $this->registerAlias('DatabaseConnection', IDBConnection::class);
585
+
586
+        $this->registerService('HTTPHelper', function (Server $c) {
587
+            $config = $c->getConfig();
588
+            return new HTTPHelper(
589
+                $config,
590
+                $c->getHTTPClientService()
591
+            );
592
+        });
593
+
594
+        $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) {
595
+            $user = \OC_User::getUser();
596
+            $uid = $user ? $user : null;
597
+            return new ClientService(
598
+                $c->getConfig(),
599
+                new \OC\Security\CertificateManager(
600
+                    $uid,
601
+                    new View(),
602
+                    $c->getConfig(),
603
+                    $c->getLogger(),
604
+                    $c->getSecureRandom()
605
+                )
606
+            );
607
+        });
608
+        $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class);
609
+        $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) {
610
+            $eventLogger = new EventLogger();
611
+            if ($c->getSystemConfig()->getValue('debug', false)) {
612
+                // In debug mode, module is being activated by default
613
+                $eventLogger->activate();
614
+            }
615
+            return $eventLogger;
616
+        });
617
+        $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class);
618
+
619
+        $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) {
620
+            $queryLogger = new QueryLogger();
621
+            if ($c->getSystemConfig()->getValue('debug', false)) {
622
+                // In debug mode, module is being activated by default
623
+                $queryLogger->activate();
624
+            }
625
+            return $queryLogger;
626
+        });
627
+        $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class);
628
+
629
+        $this->registerService(TempManager::class, function (Server $c) {
630
+            return new TempManager(
631
+                $c->getLogger(),
632
+                $c->getConfig()
633
+            );
634
+        });
635
+        $this->registerAlias('TempManager', TempManager::class);
636
+        $this->registerAlias(ITempManager::class, TempManager::class);
637
+
638
+        $this->registerService(AppManager::class, function (Server $c) {
639
+            return new \OC\App\AppManager(
640
+                $c->getUserSession(),
641
+                $c->getAppConfig(),
642
+                $c->getGroupManager(),
643
+                $c->getMemCacheFactory(),
644
+                $c->getEventDispatcher()
645
+            );
646
+        });
647
+        $this->registerAlias('AppManager', AppManager::class);
648
+        $this->registerAlias(IAppManager::class, AppManager::class);
649
+
650
+        $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) {
651
+            return new DateTimeZone(
652
+                $c->getConfig(),
653
+                $c->getSession()
654
+            );
655
+        });
656
+        $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class);
657
+
658
+        $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) {
659
+            $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
660
+
661
+            return new DateTimeFormatter(
662
+                $c->getDateTimeZone()->getTimeZone(),
663
+                $c->getL10N('lib', $language)
664
+            );
665
+        });
666
+        $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class);
667
+
668
+        $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) {
669
+            $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
670
+            $listener = new UserMountCacheListener($mountCache);
671
+            $listener->listen($c->getUserManager());
672
+            return $mountCache;
673
+        });
674
+        $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class);
675
+
676
+        $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) {
677
+            $loader = \OC\Files\Filesystem::getLoader();
678
+            $mountCache = $c->query('UserMountCache');
679
+            $manager =  new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
680
+
681
+            // builtin providers
682
+
683
+            $config = $c->getConfig();
684
+            $manager->registerProvider(new CacheMountProvider($config));
685
+            $manager->registerHomeProvider(new LocalHomeMountProvider());
686
+            $manager->registerHomeProvider(new ObjectHomeMountProvider($config));
687
+
688
+            return $manager;
689
+        });
690
+        $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class);
691
+
692
+        $this->registerService('IniWrapper', function ($c) {
693
+            return new IniGetWrapper();
694
+        });
695
+        $this->registerService('AsyncCommandBus', function (Server $c) {
696
+            $jobList = $c->getJobList();
697
+            return new AsyncBus($jobList);
698
+        });
699
+        $this->registerService('TrustedDomainHelper', function ($c) {
700
+            return new TrustedDomainHelper($this->getConfig());
701
+        });
702
+        $this->registerService('Throttler', function(Server $c) {
703
+            return new Throttler(
704
+                $c->getDatabaseConnection(),
705
+                new TimeFactory(),
706
+                $c->getLogger(),
707
+                $c->getConfig()
708
+            );
709
+        });
710
+        $this->registerService('IntegrityCodeChecker', function (Server $c) {
711
+            // IConfig and IAppManager requires a working database. This code
712
+            // might however be called when ownCloud is not yet setup.
713
+            if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
714
+                $config = $c->getConfig();
715
+                $appManager = $c->getAppManager();
716
+            } else {
717
+                $config = null;
718
+                $appManager = null;
719
+            }
720
+
721
+            return new Checker(
722
+                    new EnvironmentHelper(),
723
+                    new FileAccessHelper(),
724
+                    new AppLocator(),
725
+                    $config,
726
+                    $c->getMemCacheFactory(),
727
+                    $appManager,
728
+                    $c->getTempManager()
729
+            );
730
+        });
731
+        $this->registerService(\OCP\IRequest::class, function ($c) {
732
+            if (isset($this['urlParams'])) {
733
+                $urlParams = $this['urlParams'];
734
+            } else {
735
+                $urlParams = [];
736
+            }
737
+
738
+            if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
739
+                && in_array('fakeinput', stream_get_wrappers())
740
+            ) {
741
+                $stream = 'fakeinput://data';
742
+            } else {
743
+                $stream = 'php://input';
744
+            }
745
+
746
+            return new Request(
747
+                [
748
+                    'get' => $_GET,
749
+                    'post' => $_POST,
750
+                    'files' => $_FILES,
751
+                    'server' => $_SERVER,
752
+                    'env' => $_ENV,
753
+                    'cookies' => $_COOKIE,
754
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
755
+                        ? $_SERVER['REQUEST_METHOD']
756
+                        : null,
757
+                    'urlParams' => $urlParams,
758
+                ],
759
+                $this->getSecureRandom(),
760
+                $this->getConfig(),
761
+                $this->getCsrfTokenManager(),
762
+                $stream
763
+            );
764
+        });
765
+        $this->registerAlias('Request', \OCP\IRequest::class);
766
+
767
+        $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) {
768
+            return new Mailer(
769
+                $c->getConfig(),
770
+                $c->getLogger(),
771
+                $c->query(Defaults::class),
772
+                $c->getURLGenerator(),
773
+                $c->getL10N('lib')
774
+            );
775
+        });
776
+        $this->registerAlias('Mailer', \OCP\Mail\IMailer::class);
777
+
778
+        $this->registerService('LDAPProvider', function(Server $c) {
779
+            $config = $c->getConfig();
780
+            $factoryClass = $config->getSystemValue('ldapProviderFactory', null);
781
+            if(is_null($factoryClass)) {
782
+                throw new \Exception('ldapProviderFactory not set');
783
+            }
784
+            /** @var \OCP\LDAP\ILDAPProviderFactory $factory */
785
+            $factory = new $factoryClass($this);
786
+            return $factory->getLDAPProvider();
787
+        });
788
+        $this->registerService('LockingProvider', function (Server $c) {
789
+            $ini = $c->getIniWrapper();
790
+            $config = $c->getConfig();
791
+            $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
792
+            if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
793
+                /** @var \OC\Memcache\Factory $memcacheFactory */
794
+                $memcacheFactory = $c->getMemCacheFactory();
795
+                $memcache = $memcacheFactory->createLocking('lock');
796
+                if (!($memcache instanceof \OC\Memcache\NullCache)) {
797
+                    return new MemcacheLockingProvider($memcache, $ttl);
798
+                }
799
+                return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl);
800
+            }
801
+            return new NoopLockingProvider();
802
+        });
803
+
804
+        $this->registerService(\OCP\Files\Mount\IMountManager::class, function () {
805
+            return new \OC\Files\Mount\Manager();
806
+        });
807
+        $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class);
808
+
809
+        $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) {
810
+            return new \OC\Files\Type\Detection(
811
+                $c->getURLGenerator(),
812
+                \OC::$configDir,
813
+                \OC::$SERVERROOT . '/resources/config/'
814
+            );
815
+        });
816
+        $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class);
817
+
818
+        $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) {
819
+            return new \OC\Files\Type\Loader(
820
+                $c->getDatabaseConnection()
821
+            );
822
+        });
823
+        $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class);
824
+        $this->registerService(BundleFetcher::class, function () {
825
+            return new BundleFetcher($this->getL10N('lib'));
826
+        });
827
+        $this->registerService(\OCP\Notification\IManager::class, function (Server $c) {
828
+            return new Manager(
829
+                $c->query(IValidator::class)
830
+            );
831
+        });
832
+        $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class);
833
+
834
+        $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) {
835
+            $manager = new \OC\CapabilitiesManager($c->getLogger());
836
+            $manager->registerCapability(function () use ($c) {
837
+                return new \OC\OCS\CoreCapabilities($c->getConfig());
838
+            });
839
+            return $manager;
840
+        });
841
+        $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class);
842
+
843
+        $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) {
844
+            $config = $c->getConfig();
845
+            $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
846
+            /** @var \OCP\Comments\ICommentsManagerFactory $factory */
847
+            $factory = new $factoryClass($this);
848
+            return $factory->getManager();
849
+        });
850
+        $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class);
851
+
852
+        $this->registerService('ThemingDefaults', function(Server $c) {
853
+            /*
854 854
 			 * Dark magic for autoloader.
855 855
 			 * If we do a class_exists it will try to load the class which will
856 856
 			 * make composer cache the result. Resulting in errors when enabling
857 857
 			 * the theming app.
858 858
 			 */
859
-			$prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
860
-			if (isset($prefixes['OCA\\Theming\\'])) {
861
-				$classExists = true;
862
-			} else {
863
-				$classExists = false;
864
-			}
865
-
866
-			if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) {
867
-				return new ThemingDefaults(
868
-					$c->getConfig(),
869
-					$c->getL10N('theming'),
870
-					$c->getURLGenerator(),
871
-					$c->getAppDataDir('theming'),
872
-					$c->getMemCacheFactory(),
873
-					new Util($c->getConfig(), $this->getAppManager(), $this->getAppDataDir('theming'))
874
-				);
875
-			}
876
-			return new \OC_Defaults();
877
-		});
878
-		$this->registerService(SCSSCacher::class, function(Server $c) {
879
-			/** @var Factory $cacheFactory */
880
-			$cacheFactory = $c->query(Factory::class);
881
-			return new SCSSCacher(
882
-				$c->getLogger(),
883
-				$c->query(\OC\Files\AppData\Factory::class),
884
-				$c->getURLGenerator(),
885
-				$c->getConfig(),
886
-				$c->getThemingDefaults(),
887
-				\OC::$SERVERROOT,
888
-				$cacheFactory->create('SCSS')
889
-			);
890
-		});
891
-		$this->registerService(EventDispatcher::class, function () {
892
-			return new EventDispatcher();
893
-		});
894
-		$this->registerAlias('EventDispatcher', EventDispatcher::class);
895
-		$this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class);
896
-
897
-		$this->registerService('CryptoWrapper', function (Server $c) {
898
-			// FIXME: Instantiiated here due to cyclic dependency
899
-			$request = new Request(
900
-				[
901
-					'get' => $_GET,
902
-					'post' => $_POST,
903
-					'files' => $_FILES,
904
-					'server' => $_SERVER,
905
-					'env' => $_ENV,
906
-					'cookies' => $_COOKIE,
907
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
908
-						? $_SERVER['REQUEST_METHOD']
909
-						: null,
910
-				],
911
-				$c->getSecureRandom(),
912
-				$c->getConfig()
913
-			);
914
-
915
-			return new CryptoWrapper(
916
-				$c->getConfig(),
917
-				$c->getCrypto(),
918
-				$c->getSecureRandom(),
919
-				$request
920
-			);
921
-		});
922
-		$this->registerService('CsrfTokenManager', function (Server $c) {
923
-			$tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
924
-
925
-			return new CsrfTokenManager(
926
-				$tokenGenerator,
927
-				$c->query(SessionStorage::class)
928
-			);
929
-		});
930
-		$this->registerService(SessionStorage::class, function (Server $c) {
931
-			return new SessionStorage($c->getSession());
932
-		});
933
-		$this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) {
934
-			return new ContentSecurityPolicyManager();
935
-		});
936
-		$this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class);
937
-
938
-		$this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) {
939
-			return new ContentSecurityPolicyNonceManager(
940
-				$c->getCsrfTokenManager(),
941
-				$c->getRequest()
942
-			);
943
-		});
944
-
945
-		$this->registerService(\OCP\Share\IManager::class, function(Server $c) {
946
-			$config = $c->getConfig();
947
-			$factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory');
948
-			/** @var \OCP\Share\IProviderFactory $factory */
949
-			$factory = new $factoryClass($this);
950
-
951
-			$manager = new \OC\Share20\Manager(
952
-				$c->getLogger(),
953
-				$c->getConfig(),
954
-				$c->getSecureRandom(),
955
-				$c->getHasher(),
956
-				$c->getMountManager(),
957
-				$c->getGroupManager(),
958
-				$c->getL10N('core'),
959
-				$factory,
960
-				$c->getUserManager(),
961
-				$c->getLazyRootFolder(),
962
-				$c->getEventDispatcher()
963
-			);
964
-
965
-			return $manager;
966
-		});
967
-		$this->registerAlias('ShareManager', \OCP\Share\IManager::class);
968
-
969
-		$this->registerService('SettingsManager', function(Server $c) {
970
-			$manager = new \OC\Settings\Manager(
971
-				$c->getLogger(),
972
-				$c->getDatabaseConnection(),
973
-				$c->getL10N('lib'),
974
-				$c->getConfig(),
975
-				$c->getEncryptionManager(),
976
-				$c->getUserManager(),
977
-				$c->getLockingProvider(),
978
-				$c->getRequest(),
979
-				new \OC\Settings\Mapper($c->getDatabaseConnection()),
980
-				$c->getURLGenerator(),
981
-				$c->query(AccountManager::class),
982
-				$c->getGroupManager(),
983
-				$c->getL10NFactory(),
984
-				$c->getThemingDefaults(),
985
-				$c->getAppManager()
986
-			);
987
-			return $manager;
988
-		});
989
-		$this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
990
-			return new \OC\Files\AppData\Factory(
991
-				$c->getRootFolder(),
992
-				$c->getSystemConfig()
993
-			);
994
-		});
995
-
996
-		$this->registerService('LockdownManager', function (Server $c) {
997
-			return new LockdownManager(function() use ($c) {
998
-				return $c->getSession();
999
-			});
1000
-		});
1001
-
1002
-		$this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) {
1003
-			return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService());
1004
-		});
1005
-
1006
-		$this->registerService(ICloudIdManager::class, function (Server $c) {
1007
-			return new CloudIdManager();
1008
-		});
1009
-
1010
-		/* To trick DI since we don't extend the DIContainer here */
1011
-		$this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) {
1012
-			return new CleanPreviewsBackgroundJob(
1013
-				$c->getRootFolder(),
1014
-				$c->getLogger(),
1015
-				$c->getJobList(),
1016
-				new TimeFactory()
1017
-			);
1018
-		});
1019
-
1020
-		$this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1021
-		$this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
1022
-
1023
-		$this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1024
-		$this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1025
-
1026
-		$this->registerService(Defaults::class, function (Server $c) {
1027
-			return new Defaults(
1028
-				$c->getThemingDefaults()
1029
-			);
1030
-		});
1031
-		$this->registerAlias('Defaults', \OCP\Defaults::class);
1032
-
1033
-		$this->registerService(\OCP\ISession::class, function(SimpleContainer $c) {
1034
-			return $c->query(\OCP\IUserSession::class)->getSession();
1035
-		});
1036
-
1037
-		$this->registerService(IShareHelper::class, function(Server $c) {
1038
-			return new ShareHelper(
1039
-				$c->query(\OCP\Share\IManager::class)
1040
-			);
1041
-		});
1042
-	}
1043
-
1044
-	/**
1045
-	 * @return \OCP\Contacts\IManager
1046
-	 */
1047
-	public function getContactsManager() {
1048
-		return $this->query('ContactsManager');
1049
-	}
1050
-
1051
-	/**
1052
-	 * @return \OC\Encryption\Manager
1053
-	 */
1054
-	public function getEncryptionManager() {
1055
-		return $this->query('EncryptionManager');
1056
-	}
1057
-
1058
-	/**
1059
-	 * @return \OC\Encryption\File
1060
-	 */
1061
-	public function getEncryptionFilesHelper() {
1062
-		return $this->query('EncryptionFileHelper');
1063
-	}
1064
-
1065
-	/**
1066
-	 * @return \OCP\Encryption\Keys\IStorage
1067
-	 */
1068
-	public function getEncryptionKeyStorage() {
1069
-		return $this->query('EncryptionKeyStorage');
1070
-	}
1071
-
1072
-	/**
1073
-	 * The current request object holding all information about the request
1074
-	 * currently being processed is returned from this method.
1075
-	 * In case the current execution was not initiated by a web request null is returned
1076
-	 *
1077
-	 * @return \OCP\IRequest
1078
-	 */
1079
-	public function getRequest() {
1080
-		return $this->query('Request');
1081
-	}
1082
-
1083
-	/**
1084
-	 * Returns the preview manager which can create preview images for a given file
1085
-	 *
1086
-	 * @return \OCP\IPreview
1087
-	 */
1088
-	public function getPreviewManager() {
1089
-		return $this->query('PreviewManager');
1090
-	}
1091
-
1092
-	/**
1093
-	 * Returns the tag manager which can get and set tags for different object types
1094
-	 *
1095
-	 * @see \OCP\ITagManager::load()
1096
-	 * @return \OCP\ITagManager
1097
-	 */
1098
-	public function getTagManager() {
1099
-		return $this->query('TagManager');
1100
-	}
1101
-
1102
-	/**
1103
-	 * Returns the system-tag manager
1104
-	 *
1105
-	 * @return \OCP\SystemTag\ISystemTagManager
1106
-	 *
1107
-	 * @since 9.0.0
1108
-	 */
1109
-	public function getSystemTagManager() {
1110
-		return $this->query('SystemTagManager');
1111
-	}
1112
-
1113
-	/**
1114
-	 * Returns the system-tag object mapper
1115
-	 *
1116
-	 * @return \OCP\SystemTag\ISystemTagObjectMapper
1117
-	 *
1118
-	 * @since 9.0.0
1119
-	 */
1120
-	public function getSystemTagObjectMapper() {
1121
-		return $this->query('SystemTagObjectMapper');
1122
-	}
1123
-
1124
-	/**
1125
-	 * Returns the avatar manager, used for avatar functionality
1126
-	 *
1127
-	 * @return \OCP\IAvatarManager
1128
-	 */
1129
-	public function getAvatarManager() {
1130
-		return $this->query('AvatarManager');
1131
-	}
1132
-
1133
-	/**
1134
-	 * Returns the root folder of ownCloud's data directory
1135
-	 *
1136
-	 * @return \OCP\Files\IRootFolder
1137
-	 */
1138
-	public function getRootFolder() {
1139
-		return $this->query('LazyRootFolder');
1140
-	}
1141
-
1142
-	/**
1143
-	 * Returns the root folder of ownCloud's data directory
1144
-	 * This is the lazy variant so this gets only initialized once it
1145
-	 * is actually used.
1146
-	 *
1147
-	 * @return \OCP\Files\IRootFolder
1148
-	 */
1149
-	public function getLazyRootFolder() {
1150
-		return $this->query('LazyRootFolder');
1151
-	}
1152
-
1153
-	/**
1154
-	 * Returns a view to ownCloud's files folder
1155
-	 *
1156
-	 * @param string $userId user ID
1157
-	 * @return \OCP\Files\Folder|null
1158
-	 */
1159
-	public function getUserFolder($userId = null) {
1160
-		if ($userId === null) {
1161
-			$user = $this->getUserSession()->getUser();
1162
-			if (!$user) {
1163
-				return null;
1164
-			}
1165
-			$userId = $user->getUID();
1166
-		}
1167
-		$root = $this->getRootFolder();
1168
-		return $root->getUserFolder($userId);
1169
-	}
1170
-
1171
-	/**
1172
-	 * Returns an app-specific view in ownClouds data directory
1173
-	 *
1174
-	 * @return \OCP\Files\Folder
1175
-	 * @deprecated since 9.2.0 use IAppData
1176
-	 */
1177
-	public function getAppFolder() {
1178
-		$dir = '/' . \OC_App::getCurrentApp();
1179
-		$root = $this->getRootFolder();
1180
-		if (!$root->nodeExists($dir)) {
1181
-			$folder = $root->newFolder($dir);
1182
-		} else {
1183
-			$folder = $root->get($dir);
1184
-		}
1185
-		return $folder;
1186
-	}
1187
-
1188
-	/**
1189
-	 * @return \OC\User\Manager
1190
-	 */
1191
-	public function getUserManager() {
1192
-		return $this->query('UserManager');
1193
-	}
1194
-
1195
-	/**
1196
-	 * @return \OC\Group\Manager
1197
-	 */
1198
-	public function getGroupManager() {
1199
-		return $this->query('GroupManager');
1200
-	}
1201
-
1202
-	/**
1203
-	 * @return \OC\User\Session
1204
-	 */
1205
-	public function getUserSession() {
1206
-		return $this->query('UserSession');
1207
-	}
1208
-
1209
-	/**
1210
-	 * @return \OCP\ISession
1211
-	 */
1212
-	public function getSession() {
1213
-		return $this->query('UserSession')->getSession();
1214
-	}
1215
-
1216
-	/**
1217
-	 * @param \OCP\ISession $session
1218
-	 */
1219
-	public function setSession(\OCP\ISession $session) {
1220
-		$this->query(SessionStorage::class)->setSession($session);
1221
-		$this->query('UserSession')->setSession($session);
1222
-		$this->query(Store::class)->setSession($session);
1223
-	}
1224
-
1225
-	/**
1226
-	 * @return \OC\Authentication\TwoFactorAuth\Manager
1227
-	 */
1228
-	public function getTwoFactorAuthManager() {
1229
-		return $this->query('\OC\Authentication\TwoFactorAuth\Manager');
1230
-	}
1231
-
1232
-	/**
1233
-	 * @return \OC\NavigationManager
1234
-	 */
1235
-	public function getNavigationManager() {
1236
-		return $this->query('NavigationManager');
1237
-	}
1238
-
1239
-	/**
1240
-	 * @return \OCP\IConfig
1241
-	 */
1242
-	public function getConfig() {
1243
-		return $this->query('AllConfig');
1244
-	}
1245
-
1246
-	/**
1247
-	 * @internal For internal use only
1248
-	 * @return \OC\SystemConfig
1249
-	 */
1250
-	public function getSystemConfig() {
1251
-		return $this->query('SystemConfig');
1252
-	}
1253
-
1254
-	/**
1255
-	 * Returns the app config manager
1256
-	 *
1257
-	 * @return \OCP\IAppConfig
1258
-	 */
1259
-	public function getAppConfig() {
1260
-		return $this->query('AppConfig');
1261
-	}
1262
-
1263
-	/**
1264
-	 * @return \OCP\L10N\IFactory
1265
-	 */
1266
-	public function getL10NFactory() {
1267
-		return $this->query('L10NFactory');
1268
-	}
1269
-
1270
-	/**
1271
-	 * get an L10N instance
1272
-	 *
1273
-	 * @param string $app appid
1274
-	 * @param string $lang
1275
-	 * @return IL10N
1276
-	 */
1277
-	public function getL10N($app, $lang = null) {
1278
-		return $this->getL10NFactory()->get($app, $lang);
1279
-	}
1280
-
1281
-	/**
1282
-	 * @return \OCP\IURLGenerator
1283
-	 */
1284
-	public function getURLGenerator() {
1285
-		return $this->query('URLGenerator');
1286
-	}
1287
-
1288
-	/**
1289
-	 * @return \OCP\IHelper
1290
-	 */
1291
-	public function getHelper() {
1292
-		return $this->query('AppHelper');
1293
-	}
1294
-
1295
-	/**
1296
-	 * @return AppFetcher
1297
-	 */
1298
-	public function getAppFetcher() {
1299
-		return $this->query(AppFetcher::class);
1300
-	}
1301
-
1302
-	/**
1303
-	 * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1304
-	 * getMemCacheFactory() instead.
1305
-	 *
1306
-	 * @return \OCP\ICache
1307
-	 * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1308
-	 */
1309
-	public function getCache() {
1310
-		return $this->query('UserCache');
1311
-	}
1312
-
1313
-	/**
1314
-	 * Returns an \OCP\CacheFactory instance
1315
-	 *
1316
-	 * @return \OCP\ICacheFactory
1317
-	 */
1318
-	public function getMemCacheFactory() {
1319
-		return $this->query('MemCacheFactory');
1320
-	}
1321
-
1322
-	/**
1323
-	 * Returns an \OC\RedisFactory instance
1324
-	 *
1325
-	 * @return \OC\RedisFactory
1326
-	 */
1327
-	public function getGetRedisFactory() {
1328
-		return $this->query('RedisFactory');
1329
-	}
1330
-
1331
-
1332
-	/**
1333
-	 * Returns the current session
1334
-	 *
1335
-	 * @return \OCP\IDBConnection
1336
-	 */
1337
-	public function getDatabaseConnection() {
1338
-		return $this->query('DatabaseConnection');
1339
-	}
1340
-
1341
-	/**
1342
-	 * Returns the activity manager
1343
-	 *
1344
-	 * @return \OCP\Activity\IManager
1345
-	 */
1346
-	public function getActivityManager() {
1347
-		return $this->query('ActivityManager');
1348
-	}
1349
-
1350
-	/**
1351
-	 * Returns an job list for controlling background jobs
1352
-	 *
1353
-	 * @return \OCP\BackgroundJob\IJobList
1354
-	 */
1355
-	public function getJobList() {
1356
-		return $this->query('JobList');
1357
-	}
1358
-
1359
-	/**
1360
-	 * Returns a logger instance
1361
-	 *
1362
-	 * @return \OCP\ILogger
1363
-	 */
1364
-	public function getLogger() {
1365
-		return $this->query('Logger');
1366
-	}
1367
-
1368
-	/**
1369
-	 * Returns a router for generating and matching urls
1370
-	 *
1371
-	 * @return \OCP\Route\IRouter
1372
-	 */
1373
-	public function getRouter() {
1374
-		return $this->query('Router');
1375
-	}
1376
-
1377
-	/**
1378
-	 * Returns a search instance
1379
-	 *
1380
-	 * @return \OCP\ISearch
1381
-	 */
1382
-	public function getSearch() {
1383
-		return $this->query('Search');
1384
-	}
1385
-
1386
-	/**
1387
-	 * Returns a SecureRandom instance
1388
-	 *
1389
-	 * @return \OCP\Security\ISecureRandom
1390
-	 */
1391
-	public function getSecureRandom() {
1392
-		return $this->query('SecureRandom');
1393
-	}
1394
-
1395
-	/**
1396
-	 * Returns a Crypto instance
1397
-	 *
1398
-	 * @return \OCP\Security\ICrypto
1399
-	 */
1400
-	public function getCrypto() {
1401
-		return $this->query('Crypto');
1402
-	}
1403
-
1404
-	/**
1405
-	 * Returns a Hasher instance
1406
-	 *
1407
-	 * @return \OCP\Security\IHasher
1408
-	 */
1409
-	public function getHasher() {
1410
-		return $this->query('Hasher');
1411
-	}
1412
-
1413
-	/**
1414
-	 * Returns a CredentialsManager instance
1415
-	 *
1416
-	 * @return \OCP\Security\ICredentialsManager
1417
-	 */
1418
-	public function getCredentialsManager() {
1419
-		return $this->query('CredentialsManager');
1420
-	}
1421
-
1422
-	/**
1423
-	 * Returns an instance of the HTTP helper class
1424
-	 *
1425
-	 * @deprecated Use getHTTPClientService()
1426
-	 * @return \OC\HTTPHelper
1427
-	 */
1428
-	public function getHTTPHelper() {
1429
-		return $this->query('HTTPHelper');
1430
-	}
1431
-
1432
-	/**
1433
-	 * Get the certificate manager for the user
1434
-	 *
1435
-	 * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
1436
-	 * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in
1437
-	 */
1438
-	public function getCertificateManager($userId = '') {
1439
-		if ($userId === '') {
1440
-			$userSession = $this->getUserSession();
1441
-			$user = $userSession->getUser();
1442
-			if (is_null($user)) {
1443
-				return null;
1444
-			}
1445
-			$userId = $user->getUID();
1446
-		}
1447
-		return new CertificateManager(
1448
-			$userId,
1449
-			new View(),
1450
-			$this->getConfig(),
1451
-			$this->getLogger(),
1452
-			$this->getSecureRandom()
1453
-		);
1454
-	}
1455
-
1456
-	/**
1457
-	 * Returns an instance of the HTTP client service
1458
-	 *
1459
-	 * @return \OCP\Http\Client\IClientService
1460
-	 */
1461
-	public function getHTTPClientService() {
1462
-		return $this->query('HttpClientService');
1463
-	}
1464
-
1465
-	/**
1466
-	 * Create a new event source
1467
-	 *
1468
-	 * @return \OCP\IEventSource
1469
-	 */
1470
-	public function createEventSource() {
1471
-		return new \OC_EventSource();
1472
-	}
1473
-
1474
-	/**
1475
-	 * Get the active event logger
1476
-	 *
1477
-	 * The returned logger only logs data when debug mode is enabled
1478
-	 *
1479
-	 * @return \OCP\Diagnostics\IEventLogger
1480
-	 */
1481
-	public function getEventLogger() {
1482
-		return $this->query('EventLogger');
1483
-	}
1484
-
1485
-	/**
1486
-	 * Get the active query logger
1487
-	 *
1488
-	 * The returned logger only logs data when debug mode is enabled
1489
-	 *
1490
-	 * @return \OCP\Diagnostics\IQueryLogger
1491
-	 */
1492
-	public function getQueryLogger() {
1493
-		return $this->query('QueryLogger');
1494
-	}
1495
-
1496
-	/**
1497
-	 * Get the manager for temporary files and folders
1498
-	 *
1499
-	 * @return \OCP\ITempManager
1500
-	 */
1501
-	public function getTempManager() {
1502
-		return $this->query('TempManager');
1503
-	}
1504
-
1505
-	/**
1506
-	 * Get the app manager
1507
-	 *
1508
-	 * @return \OCP\App\IAppManager
1509
-	 */
1510
-	public function getAppManager() {
1511
-		return $this->query('AppManager');
1512
-	}
1513
-
1514
-	/**
1515
-	 * Creates a new mailer
1516
-	 *
1517
-	 * @return \OCP\Mail\IMailer
1518
-	 */
1519
-	public function getMailer() {
1520
-		return $this->query('Mailer');
1521
-	}
1522
-
1523
-	/**
1524
-	 * Get the webroot
1525
-	 *
1526
-	 * @return string
1527
-	 */
1528
-	public function getWebRoot() {
1529
-		return $this->webRoot;
1530
-	}
1531
-
1532
-	/**
1533
-	 * @return \OC\OCSClient
1534
-	 */
1535
-	public function getOcsClient() {
1536
-		return $this->query('OcsClient');
1537
-	}
1538
-
1539
-	/**
1540
-	 * @return \OCP\IDateTimeZone
1541
-	 */
1542
-	public function getDateTimeZone() {
1543
-		return $this->query('DateTimeZone');
1544
-	}
1545
-
1546
-	/**
1547
-	 * @return \OCP\IDateTimeFormatter
1548
-	 */
1549
-	public function getDateTimeFormatter() {
1550
-		return $this->query('DateTimeFormatter');
1551
-	}
1552
-
1553
-	/**
1554
-	 * @return \OCP\Files\Config\IMountProviderCollection
1555
-	 */
1556
-	public function getMountProviderCollection() {
1557
-		return $this->query('MountConfigManager');
1558
-	}
1559
-
1560
-	/**
1561
-	 * Get the IniWrapper
1562
-	 *
1563
-	 * @return IniGetWrapper
1564
-	 */
1565
-	public function getIniWrapper() {
1566
-		return $this->query('IniWrapper');
1567
-	}
1568
-
1569
-	/**
1570
-	 * @return \OCP\Command\IBus
1571
-	 */
1572
-	public function getCommandBus() {
1573
-		return $this->query('AsyncCommandBus');
1574
-	}
1575
-
1576
-	/**
1577
-	 * Get the trusted domain helper
1578
-	 *
1579
-	 * @return TrustedDomainHelper
1580
-	 */
1581
-	public function getTrustedDomainHelper() {
1582
-		return $this->query('TrustedDomainHelper');
1583
-	}
1584
-
1585
-	/**
1586
-	 * Get the locking provider
1587
-	 *
1588
-	 * @return \OCP\Lock\ILockingProvider
1589
-	 * @since 8.1.0
1590
-	 */
1591
-	public function getLockingProvider() {
1592
-		return $this->query('LockingProvider');
1593
-	}
1594
-
1595
-	/**
1596
-	 * @return \OCP\Files\Mount\IMountManager
1597
-	 **/
1598
-	function getMountManager() {
1599
-		return $this->query('MountManager');
1600
-	}
1601
-
1602
-	/** @return \OCP\Files\Config\IUserMountCache */
1603
-	function getUserMountCache() {
1604
-		return $this->query('UserMountCache');
1605
-	}
1606
-
1607
-	/**
1608
-	 * Get the MimeTypeDetector
1609
-	 *
1610
-	 * @return \OCP\Files\IMimeTypeDetector
1611
-	 */
1612
-	public function getMimeTypeDetector() {
1613
-		return $this->query('MimeTypeDetector');
1614
-	}
1615
-
1616
-	/**
1617
-	 * Get the MimeTypeLoader
1618
-	 *
1619
-	 * @return \OCP\Files\IMimeTypeLoader
1620
-	 */
1621
-	public function getMimeTypeLoader() {
1622
-		return $this->query('MimeTypeLoader');
1623
-	}
1624
-
1625
-	/**
1626
-	 * Get the manager of all the capabilities
1627
-	 *
1628
-	 * @return \OC\CapabilitiesManager
1629
-	 */
1630
-	public function getCapabilitiesManager() {
1631
-		return $this->query('CapabilitiesManager');
1632
-	}
1633
-
1634
-	/**
1635
-	 * Get the EventDispatcher
1636
-	 *
1637
-	 * @return EventDispatcherInterface
1638
-	 * @since 8.2.0
1639
-	 */
1640
-	public function getEventDispatcher() {
1641
-		return $this->query('EventDispatcher');
1642
-	}
1643
-
1644
-	/**
1645
-	 * Get the Notification Manager
1646
-	 *
1647
-	 * @return \OCP\Notification\IManager
1648
-	 * @since 8.2.0
1649
-	 */
1650
-	public function getNotificationManager() {
1651
-		return $this->query('NotificationManager');
1652
-	}
1653
-
1654
-	/**
1655
-	 * @return \OCP\Comments\ICommentsManager
1656
-	 */
1657
-	public function getCommentsManager() {
1658
-		return $this->query('CommentsManager');
1659
-	}
1660
-
1661
-	/**
1662
-	 * @return \OCA\Theming\ThemingDefaults
1663
-	 */
1664
-	public function getThemingDefaults() {
1665
-		return $this->query('ThemingDefaults');
1666
-	}
1667
-
1668
-	/**
1669
-	 * @return \OC\IntegrityCheck\Checker
1670
-	 */
1671
-	public function getIntegrityCodeChecker() {
1672
-		return $this->query('IntegrityCodeChecker');
1673
-	}
1674
-
1675
-	/**
1676
-	 * @return \OC\Session\CryptoWrapper
1677
-	 */
1678
-	public function getSessionCryptoWrapper() {
1679
-		return $this->query('CryptoWrapper');
1680
-	}
1681
-
1682
-	/**
1683
-	 * @return CsrfTokenManager
1684
-	 */
1685
-	public function getCsrfTokenManager() {
1686
-		return $this->query('CsrfTokenManager');
1687
-	}
1688
-
1689
-	/**
1690
-	 * @return Throttler
1691
-	 */
1692
-	public function getBruteForceThrottler() {
1693
-		return $this->query('Throttler');
1694
-	}
1695
-
1696
-	/**
1697
-	 * @return IContentSecurityPolicyManager
1698
-	 */
1699
-	public function getContentSecurityPolicyManager() {
1700
-		return $this->query('ContentSecurityPolicyManager');
1701
-	}
1702
-
1703
-	/**
1704
-	 * @return ContentSecurityPolicyNonceManager
1705
-	 */
1706
-	public function getContentSecurityPolicyNonceManager() {
1707
-		return $this->query('ContentSecurityPolicyNonceManager');
1708
-	}
1709
-
1710
-	/**
1711
-	 * Not a public API as of 8.2, wait for 9.0
1712
-	 *
1713
-	 * @return \OCA\Files_External\Service\BackendService
1714
-	 */
1715
-	public function getStoragesBackendService() {
1716
-		return $this->query('OCA\\Files_External\\Service\\BackendService');
1717
-	}
1718
-
1719
-	/**
1720
-	 * Not a public API as of 8.2, wait for 9.0
1721
-	 *
1722
-	 * @return \OCA\Files_External\Service\GlobalStoragesService
1723
-	 */
1724
-	public function getGlobalStoragesService() {
1725
-		return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService');
1726
-	}
1727
-
1728
-	/**
1729
-	 * Not a public API as of 8.2, wait for 9.0
1730
-	 *
1731
-	 * @return \OCA\Files_External\Service\UserGlobalStoragesService
1732
-	 */
1733
-	public function getUserGlobalStoragesService() {
1734
-		return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService');
1735
-	}
1736
-
1737
-	/**
1738
-	 * Not a public API as of 8.2, wait for 9.0
1739
-	 *
1740
-	 * @return \OCA\Files_External\Service\UserStoragesService
1741
-	 */
1742
-	public function getUserStoragesService() {
1743
-		return $this->query('OCA\\Files_External\\Service\\UserStoragesService');
1744
-	}
1745
-
1746
-	/**
1747
-	 * @return \OCP\Share\IManager
1748
-	 */
1749
-	public function getShareManager() {
1750
-		return $this->query('ShareManager');
1751
-	}
1752
-
1753
-	/**
1754
-	 * Returns the LDAP Provider
1755
-	 *
1756
-	 * @return \OCP\LDAP\ILDAPProvider
1757
-	 */
1758
-	public function getLDAPProvider() {
1759
-		return $this->query('LDAPProvider');
1760
-	}
1761
-
1762
-	/**
1763
-	 * @return \OCP\Settings\IManager
1764
-	 */
1765
-	public function getSettingsManager() {
1766
-		return $this->query('SettingsManager');
1767
-	}
1768
-
1769
-	/**
1770
-	 * @return \OCP\Files\IAppData
1771
-	 */
1772
-	public function getAppDataDir($app) {
1773
-		/** @var \OC\Files\AppData\Factory $factory */
1774
-		$factory = $this->query(\OC\Files\AppData\Factory::class);
1775
-		return $factory->get($app);
1776
-	}
1777
-
1778
-	/**
1779
-	 * @return \OCP\Lockdown\ILockdownManager
1780
-	 */
1781
-	public function getLockdownManager() {
1782
-		return $this->query('LockdownManager');
1783
-	}
1784
-
1785
-	/**
1786
-	 * @return \OCP\Federation\ICloudIdManager
1787
-	 */
1788
-	public function getCloudIdManager() {
1789
-		return $this->query(ICloudIdManager::class);
1790
-	}
859
+            $prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
860
+            if (isset($prefixes['OCA\\Theming\\'])) {
861
+                $classExists = true;
862
+            } else {
863
+                $classExists = false;
864
+            }
865
+
866
+            if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) {
867
+                return new ThemingDefaults(
868
+                    $c->getConfig(),
869
+                    $c->getL10N('theming'),
870
+                    $c->getURLGenerator(),
871
+                    $c->getAppDataDir('theming'),
872
+                    $c->getMemCacheFactory(),
873
+                    new Util($c->getConfig(), $this->getAppManager(), $this->getAppDataDir('theming'))
874
+                );
875
+            }
876
+            return new \OC_Defaults();
877
+        });
878
+        $this->registerService(SCSSCacher::class, function(Server $c) {
879
+            /** @var Factory $cacheFactory */
880
+            $cacheFactory = $c->query(Factory::class);
881
+            return new SCSSCacher(
882
+                $c->getLogger(),
883
+                $c->query(\OC\Files\AppData\Factory::class),
884
+                $c->getURLGenerator(),
885
+                $c->getConfig(),
886
+                $c->getThemingDefaults(),
887
+                \OC::$SERVERROOT,
888
+                $cacheFactory->create('SCSS')
889
+            );
890
+        });
891
+        $this->registerService(EventDispatcher::class, function () {
892
+            return new EventDispatcher();
893
+        });
894
+        $this->registerAlias('EventDispatcher', EventDispatcher::class);
895
+        $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class);
896
+
897
+        $this->registerService('CryptoWrapper', function (Server $c) {
898
+            // FIXME: Instantiiated here due to cyclic dependency
899
+            $request = new Request(
900
+                [
901
+                    'get' => $_GET,
902
+                    'post' => $_POST,
903
+                    'files' => $_FILES,
904
+                    'server' => $_SERVER,
905
+                    'env' => $_ENV,
906
+                    'cookies' => $_COOKIE,
907
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
908
+                        ? $_SERVER['REQUEST_METHOD']
909
+                        : null,
910
+                ],
911
+                $c->getSecureRandom(),
912
+                $c->getConfig()
913
+            );
914
+
915
+            return new CryptoWrapper(
916
+                $c->getConfig(),
917
+                $c->getCrypto(),
918
+                $c->getSecureRandom(),
919
+                $request
920
+            );
921
+        });
922
+        $this->registerService('CsrfTokenManager', function (Server $c) {
923
+            $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
924
+
925
+            return new CsrfTokenManager(
926
+                $tokenGenerator,
927
+                $c->query(SessionStorage::class)
928
+            );
929
+        });
930
+        $this->registerService(SessionStorage::class, function (Server $c) {
931
+            return new SessionStorage($c->getSession());
932
+        });
933
+        $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) {
934
+            return new ContentSecurityPolicyManager();
935
+        });
936
+        $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class);
937
+
938
+        $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) {
939
+            return new ContentSecurityPolicyNonceManager(
940
+                $c->getCsrfTokenManager(),
941
+                $c->getRequest()
942
+            );
943
+        });
944
+
945
+        $this->registerService(\OCP\Share\IManager::class, function(Server $c) {
946
+            $config = $c->getConfig();
947
+            $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory');
948
+            /** @var \OCP\Share\IProviderFactory $factory */
949
+            $factory = new $factoryClass($this);
950
+
951
+            $manager = new \OC\Share20\Manager(
952
+                $c->getLogger(),
953
+                $c->getConfig(),
954
+                $c->getSecureRandom(),
955
+                $c->getHasher(),
956
+                $c->getMountManager(),
957
+                $c->getGroupManager(),
958
+                $c->getL10N('core'),
959
+                $factory,
960
+                $c->getUserManager(),
961
+                $c->getLazyRootFolder(),
962
+                $c->getEventDispatcher()
963
+            );
964
+
965
+            return $manager;
966
+        });
967
+        $this->registerAlias('ShareManager', \OCP\Share\IManager::class);
968
+
969
+        $this->registerService('SettingsManager', function(Server $c) {
970
+            $manager = new \OC\Settings\Manager(
971
+                $c->getLogger(),
972
+                $c->getDatabaseConnection(),
973
+                $c->getL10N('lib'),
974
+                $c->getConfig(),
975
+                $c->getEncryptionManager(),
976
+                $c->getUserManager(),
977
+                $c->getLockingProvider(),
978
+                $c->getRequest(),
979
+                new \OC\Settings\Mapper($c->getDatabaseConnection()),
980
+                $c->getURLGenerator(),
981
+                $c->query(AccountManager::class),
982
+                $c->getGroupManager(),
983
+                $c->getL10NFactory(),
984
+                $c->getThemingDefaults(),
985
+                $c->getAppManager()
986
+            );
987
+            return $manager;
988
+        });
989
+        $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
990
+            return new \OC\Files\AppData\Factory(
991
+                $c->getRootFolder(),
992
+                $c->getSystemConfig()
993
+            );
994
+        });
995
+
996
+        $this->registerService('LockdownManager', function (Server $c) {
997
+            return new LockdownManager(function() use ($c) {
998
+                return $c->getSession();
999
+            });
1000
+        });
1001
+
1002
+        $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) {
1003
+            return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService());
1004
+        });
1005
+
1006
+        $this->registerService(ICloudIdManager::class, function (Server $c) {
1007
+            return new CloudIdManager();
1008
+        });
1009
+
1010
+        /* To trick DI since we don't extend the DIContainer here */
1011
+        $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) {
1012
+            return new CleanPreviewsBackgroundJob(
1013
+                $c->getRootFolder(),
1014
+                $c->getLogger(),
1015
+                $c->getJobList(),
1016
+                new TimeFactory()
1017
+            );
1018
+        });
1019
+
1020
+        $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1021
+        $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
1022
+
1023
+        $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1024
+        $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1025
+
1026
+        $this->registerService(Defaults::class, function (Server $c) {
1027
+            return new Defaults(
1028
+                $c->getThemingDefaults()
1029
+            );
1030
+        });
1031
+        $this->registerAlias('Defaults', \OCP\Defaults::class);
1032
+
1033
+        $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) {
1034
+            return $c->query(\OCP\IUserSession::class)->getSession();
1035
+        });
1036
+
1037
+        $this->registerService(IShareHelper::class, function(Server $c) {
1038
+            return new ShareHelper(
1039
+                $c->query(\OCP\Share\IManager::class)
1040
+            );
1041
+        });
1042
+    }
1043
+
1044
+    /**
1045
+     * @return \OCP\Contacts\IManager
1046
+     */
1047
+    public function getContactsManager() {
1048
+        return $this->query('ContactsManager');
1049
+    }
1050
+
1051
+    /**
1052
+     * @return \OC\Encryption\Manager
1053
+     */
1054
+    public function getEncryptionManager() {
1055
+        return $this->query('EncryptionManager');
1056
+    }
1057
+
1058
+    /**
1059
+     * @return \OC\Encryption\File
1060
+     */
1061
+    public function getEncryptionFilesHelper() {
1062
+        return $this->query('EncryptionFileHelper');
1063
+    }
1064
+
1065
+    /**
1066
+     * @return \OCP\Encryption\Keys\IStorage
1067
+     */
1068
+    public function getEncryptionKeyStorage() {
1069
+        return $this->query('EncryptionKeyStorage');
1070
+    }
1071
+
1072
+    /**
1073
+     * The current request object holding all information about the request
1074
+     * currently being processed is returned from this method.
1075
+     * In case the current execution was not initiated by a web request null is returned
1076
+     *
1077
+     * @return \OCP\IRequest
1078
+     */
1079
+    public function getRequest() {
1080
+        return $this->query('Request');
1081
+    }
1082
+
1083
+    /**
1084
+     * Returns the preview manager which can create preview images for a given file
1085
+     *
1086
+     * @return \OCP\IPreview
1087
+     */
1088
+    public function getPreviewManager() {
1089
+        return $this->query('PreviewManager');
1090
+    }
1091
+
1092
+    /**
1093
+     * Returns the tag manager which can get and set tags for different object types
1094
+     *
1095
+     * @see \OCP\ITagManager::load()
1096
+     * @return \OCP\ITagManager
1097
+     */
1098
+    public function getTagManager() {
1099
+        return $this->query('TagManager');
1100
+    }
1101
+
1102
+    /**
1103
+     * Returns the system-tag manager
1104
+     *
1105
+     * @return \OCP\SystemTag\ISystemTagManager
1106
+     *
1107
+     * @since 9.0.0
1108
+     */
1109
+    public function getSystemTagManager() {
1110
+        return $this->query('SystemTagManager');
1111
+    }
1112
+
1113
+    /**
1114
+     * Returns the system-tag object mapper
1115
+     *
1116
+     * @return \OCP\SystemTag\ISystemTagObjectMapper
1117
+     *
1118
+     * @since 9.0.0
1119
+     */
1120
+    public function getSystemTagObjectMapper() {
1121
+        return $this->query('SystemTagObjectMapper');
1122
+    }
1123
+
1124
+    /**
1125
+     * Returns the avatar manager, used for avatar functionality
1126
+     *
1127
+     * @return \OCP\IAvatarManager
1128
+     */
1129
+    public function getAvatarManager() {
1130
+        return $this->query('AvatarManager');
1131
+    }
1132
+
1133
+    /**
1134
+     * Returns the root folder of ownCloud's data directory
1135
+     *
1136
+     * @return \OCP\Files\IRootFolder
1137
+     */
1138
+    public function getRootFolder() {
1139
+        return $this->query('LazyRootFolder');
1140
+    }
1141
+
1142
+    /**
1143
+     * Returns the root folder of ownCloud's data directory
1144
+     * This is the lazy variant so this gets only initialized once it
1145
+     * is actually used.
1146
+     *
1147
+     * @return \OCP\Files\IRootFolder
1148
+     */
1149
+    public function getLazyRootFolder() {
1150
+        return $this->query('LazyRootFolder');
1151
+    }
1152
+
1153
+    /**
1154
+     * Returns a view to ownCloud's files folder
1155
+     *
1156
+     * @param string $userId user ID
1157
+     * @return \OCP\Files\Folder|null
1158
+     */
1159
+    public function getUserFolder($userId = null) {
1160
+        if ($userId === null) {
1161
+            $user = $this->getUserSession()->getUser();
1162
+            if (!$user) {
1163
+                return null;
1164
+            }
1165
+            $userId = $user->getUID();
1166
+        }
1167
+        $root = $this->getRootFolder();
1168
+        return $root->getUserFolder($userId);
1169
+    }
1170
+
1171
+    /**
1172
+     * Returns an app-specific view in ownClouds data directory
1173
+     *
1174
+     * @return \OCP\Files\Folder
1175
+     * @deprecated since 9.2.0 use IAppData
1176
+     */
1177
+    public function getAppFolder() {
1178
+        $dir = '/' . \OC_App::getCurrentApp();
1179
+        $root = $this->getRootFolder();
1180
+        if (!$root->nodeExists($dir)) {
1181
+            $folder = $root->newFolder($dir);
1182
+        } else {
1183
+            $folder = $root->get($dir);
1184
+        }
1185
+        return $folder;
1186
+    }
1187
+
1188
+    /**
1189
+     * @return \OC\User\Manager
1190
+     */
1191
+    public function getUserManager() {
1192
+        return $this->query('UserManager');
1193
+    }
1194
+
1195
+    /**
1196
+     * @return \OC\Group\Manager
1197
+     */
1198
+    public function getGroupManager() {
1199
+        return $this->query('GroupManager');
1200
+    }
1201
+
1202
+    /**
1203
+     * @return \OC\User\Session
1204
+     */
1205
+    public function getUserSession() {
1206
+        return $this->query('UserSession');
1207
+    }
1208
+
1209
+    /**
1210
+     * @return \OCP\ISession
1211
+     */
1212
+    public function getSession() {
1213
+        return $this->query('UserSession')->getSession();
1214
+    }
1215
+
1216
+    /**
1217
+     * @param \OCP\ISession $session
1218
+     */
1219
+    public function setSession(\OCP\ISession $session) {
1220
+        $this->query(SessionStorage::class)->setSession($session);
1221
+        $this->query('UserSession')->setSession($session);
1222
+        $this->query(Store::class)->setSession($session);
1223
+    }
1224
+
1225
+    /**
1226
+     * @return \OC\Authentication\TwoFactorAuth\Manager
1227
+     */
1228
+    public function getTwoFactorAuthManager() {
1229
+        return $this->query('\OC\Authentication\TwoFactorAuth\Manager');
1230
+    }
1231
+
1232
+    /**
1233
+     * @return \OC\NavigationManager
1234
+     */
1235
+    public function getNavigationManager() {
1236
+        return $this->query('NavigationManager');
1237
+    }
1238
+
1239
+    /**
1240
+     * @return \OCP\IConfig
1241
+     */
1242
+    public function getConfig() {
1243
+        return $this->query('AllConfig');
1244
+    }
1245
+
1246
+    /**
1247
+     * @internal For internal use only
1248
+     * @return \OC\SystemConfig
1249
+     */
1250
+    public function getSystemConfig() {
1251
+        return $this->query('SystemConfig');
1252
+    }
1253
+
1254
+    /**
1255
+     * Returns the app config manager
1256
+     *
1257
+     * @return \OCP\IAppConfig
1258
+     */
1259
+    public function getAppConfig() {
1260
+        return $this->query('AppConfig');
1261
+    }
1262
+
1263
+    /**
1264
+     * @return \OCP\L10N\IFactory
1265
+     */
1266
+    public function getL10NFactory() {
1267
+        return $this->query('L10NFactory');
1268
+    }
1269
+
1270
+    /**
1271
+     * get an L10N instance
1272
+     *
1273
+     * @param string $app appid
1274
+     * @param string $lang
1275
+     * @return IL10N
1276
+     */
1277
+    public function getL10N($app, $lang = null) {
1278
+        return $this->getL10NFactory()->get($app, $lang);
1279
+    }
1280
+
1281
+    /**
1282
+     * @return \OCP\IURLGenerator
1283
+     */
1284
+    public function getURLGenerator() {
1285
+        return $this->query('URLGenerator');
1286
+    }
1287
+
1288
+    /**
1289
+     * @return \OCP\IHelper
1290
+     */
1291
+    public function getHelper() {
1292
+        return $this->query('AppHelper');
1293
+    }
1294
+
1295
+    /**
1296
+     * @return AppFetcher
1297
+     */
1298
+    public function getAppFetcher() {
1299
+        return $this->query(AppFetcher::class);
1300
+    }
1301
+
1302
+    /**
1303
+     * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1304
+     * getMemCacheFactory() instead.
1305
+     *
1306
+     * @return \OCP\ICache
1307
+     * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1308
+     */
1309
+    public function getCache() {
1310
+        return $this->query('UserCache');
1311
+    }
1312
+
1313
+    /**
1314
+     * Returns an \OCP\CacheFactory instance
1315
+     *
1316
+     * @return \OCP\ICacheFactory
1317
+     */
1318
+    public function getMemCacheFactory() {
1319
+        return $this->query('MemCacheFactory');
1320
+    }
1321
+
1322
+    /**
1323
+     * Returns an \OC\RedisFactory instance
1324
+     *
1325
+     * @return \OC\RedisFactory
1326
+     */
1327
+    public function getGetRedisFactory() {
1328
+        return $this->query('RedisFactory');
1329
+    }
1330
+
1331
+
1332
+    /**
1333
+     * Returns the current session
1334
+     *
1335
+     * @return \OCP\IDBConnection
1336
+     */
1337
+    public function getDatabaseConnection() {
1338
+        return $this->query('DatabaseConnection');
1339
+    }
1340
+
1341
+    /**
1342
+     * Returns the activity manager
1343
+     *
1344
+     * @return \OCP\Activity\IManager
1345
+     */
1346
+    public function getActivityManager() {
1347
+        return $this->query('ActivityManager');
1348
+    }
1349
+
1350
+    /**
1351
+     * Returns an job list for controlling background jobs
1352
+     *
1353
+     * @return \OCP\BackgroundJob\IJobList
1354
+     */
1355
+    public function getJobList() {
1356
+        return $this->query('JobList');
1357
+    }
1358
+
1359
+    /**
1360
+     * Returns a logger instance
1361
+     *
1362
+     * @return \OCP\ILogger
1363
+     */
1364
+    public function getLogger() {
1365
+        return $this->query('Logger');
1366
+    }
1367
+
1368
+    /**
1369
+     * Returns a router for generating and matching urls
1370
+     *
1371
+     * @return \OCP\Route\IRouter
1372
+     */
1373
+    public function getRouter() {
1374
+        return $this->query('Router');
1375
+    }
1376
+
1377
+    /**
1378
+     * Returns a search instance
1379
+     *
1380
+     * @return \OCP\ISearch
1381
+     */
1382
+    public function getSearch() {
1383
+        return $this->query('Search');
1384
+    }
1385
+
1386
+    /**
1387
+     * Returns a SecureRandom instance
1388
+     *
1389
+     * @return \OCP\Security\ISecureRandom
1390
+     */
1391
+    public function getSecureRandom() {
1392
+        return $this->query('SecureRandom');
1393
+    }
1394
+
1395
+    /**
1396
+     * Returns a Crypto instance
1397
+     *
1398
+     * @return \OCP\Security\ICrypto
1399
+     */
1400
+    public function getCrypto() {
1401
+        return $this->query('Crypto');
1402
+    }
1403
+
1404
+    /**
1405
+     * Returns a Hasher instance
1406
+     *
1407
+     * @return \OCP\Security\IHasher
1408
+     */
1409
+    public function getHasher() {
1410
+        return $this->query('Hasher');
1411
+    }
1412
+
1413
+    /**
1414
+     * Returns a CredentialsManager instance
1415
+     *
1416
+     * @return \OCP\Security\ICredentialsManager
1417
+     */
1418
+    public function getCredentialsManager() {
1419
+        return $this->query('CredentialsManager');
1420
+    }
1421
+
1422
+    /**
1423
+     * Returns an instance of the HTTP helper class
1424
+     *
1425
+     * @deprecated Use getHTTPClientService()
1426
+     * @return \OC\HTTPHelper
1427
+     */
1428
+    public function getHTTPHelper() {
1429
+        return $this->query('HTTPHelper');
1430
+    }
1431
+
1432
+    /**
1433
+     * Get the certificate manager for the user
1434
+     *
1435
+     * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
1436
+     * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in
1437
+     */
1438
+    public function getCertificateManager($userId = '') {
1439
+        if ($userId === '') {
1440
+            $userSession = $this->getUserSession();
1441
+            $user = $userSession->getUser();
1442
+            if (is_null($user)) {
1443
+                return null;
1444
+            }
1445
+            $userId = $user->getUID();
1446
+        }
1447
+        return new CertificateManager(
1448
+            $userId,
1449
+            new View(),
1450
+            $this->getConfig(),
1451
+            $this->getLogger(),
1452
+            $this->getSecureRandom()
1453
+        );
1454
+    }
1455
+
1456
+    /**
1457
+     * Returns an instance of the HTTP client service
1458
+     *
1459
+     * @return \OCP\Http\Client\IClientService
1460
+     */
1461
+    public function getHTTPClientService() {
1462
+        return $this->query('HttpClientService');
1463
+    }
1464
+
1465
+    /**
1466
+     * Create a new event source
1467
+     *
1468
+     * @return \OCP\IEventSource
1469
+     */
1470
+    public function createEventSource() {
1471
+        return new \OC_EventSource();
1472
+    }
1473
+
1474
+    /**
1475
+     * Get the active event logger
1476
+     *
1477
+     * The returned logger only logs data when debug mode is enabled
1478
+     *
1479
+     * @return \OCP\Diagnostics\IEventLogger
1480
+     */
1481
+    public function getEventLogger() {
1482
+        return $this->query('EventLogger');
1483
+    }
1484
+
1485
+    /**
1486
+     * Get the active query logger
1487
+     *
1488
+     * The returned logger only logs data when debug mode is enabled
1489
+     *
1490
+     * @return \OCP\Diagnostics\IQueryLogger
1491
+     */
1492
+    public function getQueryLogger() {
1493
+        return $this->query('QueryLogger');
1494
+    }
1495
+
1496
+    /**
1497
+     * Get the manager for temporary files and folders
1498
+     *
1499
+     * @return \OCP\ITempManager
1500
+     */
1501
+    public function getTempManager() {
1502
+        return $this->query('TempManager');
1503
+    }
1504
+
1505
+    /**
1506
+     * Get the app manager
1507
+     *
1508
+     * @return \OCP\App\IAppManager
1509
+     */
1510
+    public function getAppManager() {
1511
+        return $this->query('AppManager');
1512
+    }
1513
+
1514
+    /**
1515
+     * Creates a new mailer
1516
+     *
1517
+     * @return \OCP\Mail\IMailer
1518
+     */
1519
+    public function getMailer() {
1520
+        return $this->query('Mailer');
1521
+    }
1522
+
1523
+    /**
1524
+     * Get the webroot
1525
+     *
1526
+     * @return string
1527
+     */
1528
+    public function getWebRoot() {
1529
+        return $this->webRoot;
1530
+    }
1531
+
1532
+    /**
1533
+     * @return \OC\OCSClient
1534
+     */
1535
+    public function getOcsClient() {
1536
+        return $this->query('OcsClient');
1537
+    }
1538
+
1539
+    /**
1540
+     * @return \OCP\IDateTimeZone
1541
+     */
1542
+    public function getDateTimeZone() {
1543
+        return $this->query('DateTimeZone');
1544
+    }
1545
+
1546
+    /**
1547
+     * @return \OCP\IDateTimeFormatter
1548
+     */
1549
+    public function getDateTimeFormatter() {
1550
+        return $this->query('DateTimeFormatter');
1551
+    }
1552
+
1553
+    /**
1554
+     * @return \OCP\Files\Config\IMountProviderCollection
1555
+     */
1556
+    public function getMountProviderCollection() {
1557
+        return $this->query('MountConfigManager');
1558
+    }
1559
+
1560
+    /**
1561
+     * Get the IniWrapper
1562
+     *
1563
+     * @return IniGetWrapper
1564
+     */
1565
+    public function getIniWrapper() {
1566
+        return $this->query('IniWrapper');
1567
+    }
1568
+
1569
+    /**
1570
+     * @return \OCP\Command\IBus
1571
+     */
1572
+    public function getCommandBus() {
1573
+        return $this->query('AsyncCommandBus');
1574
+    }
1575
+
1576
+    /**
1577
+     * Get the trusted domain helper
1578
+     *
1579
+     * @return TrustedDomainHelper
1580
+     */
1581
+    public function getTrustedDomainHelper() {
1582
+        return $this->query('TrustedDomainHelper');
1583
+    }
1584
+
1585
+    /**
1586
+     * Get the locking provider
1587
+     *
1588
+     * @return \OCP\Lock\ILockingProvider
1589
+     * @since 8.1.0
1590
+     */
1591
+    public function getLockingProvider() {
1592
+        return $this->query('LockingProvider');
1593
+    }
1594
+
1595
+    /**
1596
+     * @return \OCP\Files\Mount\IMountManager
1597
+     **/
1598
+    function getMountManager() {
1599
+        return $this->query('MountManager');
1600
+    }
1601
+
1602
+    /** @return \OCP\Files\Config\IUserMountCache */
1603
+    function getUserMountCache() {
1604
+        return $this->query('UserMountCache');
1605
+    }
1606
+
1607
+    /**
1608
+     * Get the MimeTypeDetector
1609
+     *
1610
+     * @return \OCP\Files\IMimeTypeDetector
1611
+     */
1612
+    public function getMimeTypeDetector() {
1613
+        return $this->query('MimeTypeDetector');
1614
+    }
1615
+
1616
+    /**
1617
+     * Get the MimeTypeLoader
1618
+     *
1619
+     * @return \OCP\Files\IMimeTypeLoader
1620
+     */
1621
+    public function getMimeTypeLoader() {
1622
+        return $this->query('MimeTypeLoader');
1623
+    }
1624
+
1625
+    /**
1626
+     * Get the manager of all the capabilities
1627
+     *
1628
+     * @return \OC\CapabilitiesManager
1629
+     */
1630
+    public function getCapabilitiesManager() {
1631
+        return $this->query('CapabilitiesManager');
1632
+    }
1633
+
1634
+    /**
1635
+     * Get the EventDispatcher
1636
+     *
1637
+     * @return EventDispatcherInterface
1638
+     * @since 8.2.0
1639
+     */
1640
+    public function getEventDispatcher() {
1641
+        return $this->query('EventDispatcher');
1642
+    }
1643
+
1644
+    /**
1645
+     * Get the Notification Manager
1646
+     *
1647
+     * @return \OCP\Notification\IManager
1648
+     * @since 8.2.0
1649
+     */
1650
+    public function getNotificationManager() {
1651
+        return $this->query('NotificationManager');
1652
+    }
1653
+
1654
+    /**
1655
+     * @return \OCP\Comments\ICommentsManager
1656
+     */
1657
+    public function getCommentsManager() {
1658
+        return $this->query('CommentsManager');
1659
+    }
1660
+
1661
+    /**
1662
+     * @return \OCA\Theming\ThemingDefaults
1663
+     */
1664
+    public function getThemingDefaults() {
1665
+        return $this->query('ThemingDefaults');
1666
+    }
1667
+
1668
+    /**
1669
+     * @return \OC\IntegrityCheck\Checker
1670
+     */
1671
+    public function getIntegrityCodeChecker() {
1672
+        return $this->query('IntegrityCodeChecker');
1673
+    }
1674
+
1675
+    /**
1676
+     * @return \OC\Session\CryptoWrapper
1677
+     */
1678
+    public function getSessionCryptoWrapper() {
1679
+        return $this->query('CryptoWrapper');
1680
+    }
1681
+
1682
+    /**
1683
+     * @return CsrfTokenManager
1684
+     */
1685
+    public function getCsrfTokenManager() {
1686
+        return $this->query('CsrfTokenManager');
1687
+    }
1688
+
1689
+    /**
1690
+     * @return Throttler
1691
+     */
1692
+    public function getBruteForceThrottler() {
1693
+        return $this->query('Throttler');
1694
+    }
1695
+
1696
+    /**
1697
+     * @return IContentSecurityPolicyManager
1698
+     */
1699
+    public function getContentSecurityPolicyManager() {
1700
+        return $this->query('ContentSecurityPolicyManager');
1701
+    }
1702
+
1703
+    /**
1704
+     * @return ContentSecurityPolicyNonceManager
1705
+     */
1706
+    public function getContentSecurityPolicyNonceManager() {
1707
+        return $this->query('ContentSecurityPolicyNonceManager');
1708
+    }
1709
+
1710
+    /**
1711
+     * Not a public API as of 8.2, wait for 9.0
1712
+     *
1713
+     * @return \OCA\Files_External\Service\BackendService
1714
+     */
1715
+    public function getStoragesBackendService() {
1716
+        return $this->query('OCA\\Files_External\\Service\\BackendService');
1717
+    }
1718
+
1719
+    /**
1720
+     * Not a public API as of 8.2, wait for 9.0
1721
+     *
1722
+     * @return \OCA\Files_External\Service\GlobalStoragesService
1723
+     */
1724
+    public function getGlobalStoragesService() {
1725
+        return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService');
1726
+    }
1727
+
1728
+    /**
1729
+     * Not a public API as of 8.2, wait for 9.0
1730
+     *
1731
+     * @return \OCA\Files_External\Service\UserGlobalStoragesService
1732
+     */
1733
+    public function getUserGlobalStoragesService() {
1734
+        return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService');
1735
+    }
1736
+
1737
+    /**
1738
+     * Not a public API as of 8.2, wait for 9.0
1739
+     *
1740
+     * @return \OCA\Files_External\Service\UserStoragesService
1741
+     */
1742
+    public function getUserStoragesService() {
1743
+        return $this->query('OCA\\Files_External\\Service\\UserStoragesService');
1744
+    }
1745
+
1746
+    /**
1747
+     * @return \OCP\Share\IManager
1748
+     */
1749
+    public function getShareManager() {
1750
+        return $this->query('ShareManager');
1751
+    }
1752
+
1753
+    /**
1754
+     * Returns the LDAP Provider
1755
+     *
1756
+     * @return \OCP\LDAP\ILDAPProvider
1757
+     */
1758
+    public function getLDAPProvider() {
1759
+        return $this->query('LDAPProvider');
1760
+    }
1761
+
1762
+    /**
1763
+     * @return \OCP\Settings\IManager
1764
+     */
1765
+    public function getSettingsManager() {
1766
+        return $this->query('SettingsManager');
1767
+    }
1768
+
1769
+    /**
1770
+     * @return \OCP\Files\IAppData
1771
+     */
1772
+    public function getAppDataDir($app) {
1773
+        /** @var \OC\Files\AppData\Factory $factory */
1774
+        $factory = $this->query(\OC\Files\AppData\Factory::class);
1775
+        return $factory->get($app);
1776
+    }
1777
+
1778
+    /**
1779
+     * @return \OCP\Lockdown\ILockdownManager
1780
+     */
1781
+    public function getLockdownManager() {
1782
+        return $this->query('LockdownManager');
1783
+    }
1784
+
1785
+    /**
1786
+     * @return \OCP\Federation\ICloudIdManager
1787
+     */
1788
+    public function getCloudIdManager() {
1789
+        return $this->query(ICloudIdManager::class);
1790
+    }
1791 1791
 }
Please login to merge, or discard this patch.