@@ -121,7 +121,7 @@ |
||
121 | 121 | * share received from another server |
122 | 122 | * |
123 | 123 | * @param ICloudFederationShare $share |
124 | - * @return string provider specific unique ID of the share |
|
124 | + * @return integer provider specific unique ID of the share |
|
125 | 125 | * |
126 | 126 | * @throws ProviderCouldNotAddShareException |
127 | 127 | * @throws \OCP\AppFramework\QueryException |
@@ -27,7 +27,6 @@ |
||
27 | 27 | use OCA\FederatedFileSharing\AddressHandler; |
28 | 28 | use OCA\FederatedFileSharing\FederatedShareProvider; |
29 | 29 | use OCP\Activity\IManager as IActivityManager; |
30 | -use OCP\Activity\IManager; |
|
31 | 30 | use OCP\App\IAppManager; |
32 | 31 | use OCP\Federation\Exceptions\ActionNotSupportedException; |
33 | 32 | use OCP\Federation\Exceptions\AuthenticationFailedException; |
@@ -50,458 +50,458 @@ |
||
50 | 50 | |
51 | 51 | class CloudFederationProviderFiles implements ICloudFederationProvider { |
52 | 52 | |
53 | - /** @var IAppManager */ |
|
54 | - private $appManager; |
|
55 | - |
|
56 | - /** @var FederatedShareProvider */ |
|
57 | - private $federatedShareProvider; |
|
58 | - |
|
59 | - /** @var AddressHandler */ |
|
60 | - private $addressHandler; |
|
61 | - |
|
62 | - /** @var ILogger */ |
|
63 | - private $logger; |
|
64 | - |
|
65 | - /** @var IUserManager */ |
|
66 | - private $userManager; |
|
67 | - |
|
68 | - /** @var ICloudIdManager */ |
|
69 | - private $cloudIdManager; |
|
70 | - |
|
71 | - /** @var IActivityManager */ |
|
72 | - private $activityManager; |
|
73 | - |
|
74 | - /** @var INotificationManager */ |
|
75 | - private $notificationManager; |
|
76 | - |
|
77 | - /** @var IURLGenerator */ |
|
78 | - private $urlGenerator; |
|
79 | - |
|
80 | - /** @var ICloudFederationFactory */ |
|
81 | - private $cloudFederationFactory; |
|
82 | - |
|
83 | - /** @var ICloudFederationProviderManager */ |
|
84 | - private $cloudFederationProviderManager; |
|
85 | - |
|
86 | - /** |
|
87 | - * CloudFederationProvider constructor. |
|
88 | - * |
|
89 | - * @param IAppManager $appManager |
|
90 | - * @param FederatedShareProvider $federatedShareProvider |
|
91 | - * @param AddressHandler $addressHandler |
|
92 | - * @param ILogger $logger |
|
93 | - * @param IUserManager $userManager |
|
94 | - * @param ICloudIdManager $cloudIdManager |
|
95 | - * @param IActivityManager $activityManager |
|
96 | - * @param INotificationManager $notificationManager |
|
97 | - * @param IURLGenerator $urlGenerator |
|
98 | - * @param ICloudFederationFactory $cloudFederationFactory |
|
99 | - * @param ICloudFederationProviderManager $cloudFederationProviderManager |
|
100 | - */ |
|
101 | - public function __construct(IAppManager $appManager, |
|
102 | - FederatedShareProvider $federatedShareProvider, |
|
103 | - AddressHandler $addressHandler, |
|
104 | - ILogger $logger, |
|
105 | - IUserManager $userManager, |
|
106 | - ICloudIdManager $cloudIdManager, |
|
107 | - IActivityManager $activityManager, |
|
108 | - INotificationManager $notificationManager, |
|
109 | - IURLGenerator $urlGenerator, |
|
110 | - ICloudFederationFactory $cloudFederationFactory, |
|
111 | - ICloudFederationProviderManager $cloudFederationProviderManager |
|
112 | - ) { |
|
113 | - $this->appManager = $appManager; |
|
114 | - $this->federatedShareProvider = $federatedShareProvider; |
|
115 | - $this->addressHandler = $addressHandler; |
|
116 | - $this->logger = $logger; |
|
117 | - $this->userManager = $userManager; |
|
118 | - $this->cloudIdManager = $cloudIdManager; |
|
119 | - $this->activityManager = $activityManager; |
|
120 | - $this->notificationManager = $notificationManager; |
|
121 | - $this->urlGenerator = $urlGenerator; |
|
122 | - $this->cloudFederationFactory = $cloudFederationFactory; |
|
123 | - $this->cloudFederationProviderManager = $cloudFederationProviderManager; |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * @return string |
|
130 | - */ |
|
131 | - public function getShareType() { |
|
132 | - return 'file'; |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * share received from another server |
|
137 | - * |
|
138 | - * @param ICloudFederationShare $share |
|
139 | - * @return string provider specific unique ID of the share |
|
140 | - * |
|
141 | - * @throws ProviderCouldNotAddShareException |
|
142 | - * @throws \OCP\AppFramework\QueryException |
|
143 | - * @throws \OC\HintException |
|
144 | - * @since 14.0.0 |
|
145 | - */ |
|
146 | - public function shareReceived(ICloudFederationShare $share) { |
|
147 | - |
|
148 | - if (!$this->isS2SEnabled(true)) { |
|
149 | - throw new ProviderCouldNotAddShareException('Server does not support federated cloud sharing', '', Http::STATUS_SERVICE_UNAVAILABLE); |
|
150 | - } |
|
151 | - |
|
152 | - $protocol = $share->getProtocol(); |
|
153 | - if ($protocol['name'] !== 'webdav') { |
|
154 | - throw new ProviderCouldNotAddShareException('Unsupported protocol for data exchange.', '', Http::STATUS_NOT_IMPLEMENTED); |
|
155 | - } |
|
156 | - |
|
157 | - list($ownerUid, $remote) = $this->addressHandler->splitUserRemote($share->getOwner()); |
|
158 | - |
|
159 | - $remote = $remote; |
|
160 | - $token = $share->getShareSecret(); |
|
161 | - $name = $share->getResourceName(); |
|
162 | - $owner = $share->getOwnerDisplayName(); |
|
163 | - $sharedBy = $share->getSharedByDisplayName(); |
|
164 | - $shareWith = $share->getShareWith(); |
|
165 | - $remoteId = $share->getProviderId(); |
|
166 | - $sharedByFederatedId = $share->getSharedBy(); |
|
167 | - $ownerFederatedId = $share->getOwner(); |
|
168 | - |
|
169 | - // if no explicit information about the person who created the share was send |
|
170 | - // we assume that the share comes from the owner |
|
171 | - if ($sharedByFederatedId === null) { |
|
172 | - $sharedBy = $owner; |
|
173 | - $sharedByFederatedId = $ownerFederatedId; |
|
174 | - } |
|
175 | - |
|
176 | - if ($remote && $token && $name && $owner && $remoteId && $shareWith) { |
|
177 | - |
|
178 | - if (!Util::isValidFileName($name)) { |
|
179 | - throw new ProviderCouldNotAddShareException('The mountpoint name contains invalid characters.', '', Http::STATUS_BAD_REQUEST); |
|
180 | - } |
|
181 | - |
|
182 | - // FIXME this should be a method in the user management instead |
|
183 | - $this->logger->debug('shareWith before, ' . $shareWith, ['app' => 'files_sharing']); |
|
184 | - Util::emitHook( |
|
185 | - '\OCA\Files_Sharing\API\Server2Server', |
|
186 | - 'preLoginNameUsedAsUserName', |
|
187 | - array('uid' => &$shareWith) |
|
188 | - ); |
|
189 | - $this->logger->debug('shareWith after, ' . $shareWith, ['app' => 'files_sharing']); |
|
190 | - |
|
191 | - if (!$this->userManager->userExists($shareWith)) { |
|
192 | - throw new ProviderCouldNotAddShareException('User does not exists', '',Http::STATUS_BAD_REQUEST); |
|
193 | - } |
|
194 | - |
|
195 | - \OC_Util::setupFS($shareWith); |
|
196 | - |
|
197 | - $externalManager = new \OCA\Files_Sharing\External\Manager( |
|
198 | - \OC::$server->getDatabaseConnection(), |
|
199 | - Filesystem::getMountManager(), |
|
200 | - Filesystem::getLoader(), |
|
201 | - \OC::$server->getHTTPClientService(), |
|
202 | - \OC::$server->getNotificationManager(), |
|
203 | - \OC::$server->query(\OCP\OCS\IDiscoveryService::class), |
|
204 | - \OC::$server->getCloudFederationProviderManager(), |
|
205 | - \OC::$server->getCloudFederationFactory(), |
|
206 | - $shareWith |
|
207 | - ); |
|
208 | - |
|
209 | - try { |
|
210 | - $externalManager->addShare($remote, $token, '', $name, $owner, false, $shareWith, $remoteId); |
|
211 | - $shareId = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share_external'); |
|
212 | - |
|
213 | - $event = $this->activityManager->generateEvent(); |
|
214 | - $event->setApp('files_sharing') |
|
215 | - ->setType('remote_share') |
|
216 | - ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_RECEIVED, [$ownerFederatedId, trim($name, '/')]) |
|
217 | - ->setAffectedUser($shareWith) |
|
218 | - ->setObject('remote_share', (int)$shareId, $name); |
|
219 | - \OC::$server->getActivityManager()->publish($event); |
|
220 | - |
|
221 | - $notification = $this->notificationManager->createNotification(); |
|
222 | - $notification->setApp('files_sharing') |
|
223 | - ->setUser($shareWith) |
|
224 | - ->setDateTime(new \DateTime()) |
|
225 | - ->setObject('remote_share', $shareId) |
|
226 | - ->setSubject('remote_share', [$ownerFederatedId, $sharedByFederatedId, trim($name, '/')]); |
|
227 | - |
|
228 | - $declineAction = $notification->createAction(); |
|
229 | - $declineAction->setLabel('decline') |
|
230 | - ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'DELETE'); |
|
231 | - $notification->addAction($declineAction); |
|
232 | - |
|
233 | - $acceptAction = $notification->createAction(); |
|
234 | - $acceptAction->setLabel('accept') |
|
235 | - ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'POST'); |
|
236 | - $notification->addAction($acceptAction); |
|
237 | - |
|
238 | - $this->notificationManager->notify($notification); |
|
239 | - |
|
240 | - return $shareId; |
|
241 | - } catch (\Exception $e) { |
|
242 | - $this->logger->logException($e, [ |
|
243 | - 'message' => 'Server can not add remote share.', |
|
244 | - 'level' => Util::ERROR, |
|
245 | - 'app' => 'files_sharing' |
|
246 | - ]); |
|
247 | - throw new ProviderCouldNotAddShareException('internal server error, was not able to add share from ' . $remote, '', HTTP::STATUS_INTERNAL_SERVER_ERROR); |
|
248 | - } |
|
249 | - } |
|
250 | - |
|
251 | - throw new ProviderCouldNotAddShareException('server can not add remote share, missing parameter', '', HTTP::STATUS_BAD_REQUEST); |
|
252 | - |
|
253 | - } |
|
254 | - |
|
255 | - /** |
|
256 | - * notification received from another server |
|
257 | - * |
|
258 | - * @param string $notificationType (e.g. SHARE_ACCEPTED) |
|
259 | - * @param string $providerId id of the share |
|
260 | - * @param array $notification payload of the notification |
|
261 | - * |
|
262 | - * @throws ActionNotSupportedException |
|
263 | - * @throws AuthenticationFailedException |
|
264 | - * @throws BadRequestException |
|
265 | - * @throws ShareNotFoundException |
|
266 | - * @throws \OC\HintException |
|
267 | - * @since 14.0.0 |
|
268 | - */ |
|
269 | - public function notificationReceived($notificationType, $providerId, array $notification) { |
|
270 | - |
|
271 | - switch ($notificationType) { |
|
272 | - case 'SHARE_ACCEPTED': |
|
273 | - $this->shareAccepted($providerId, $notification); |
|
274 | - return; |
|
275 | - case 'SHARE_DECLINED': |
|
276 | - $this->shareDeclined($providerId, $notification); |
|
277 | - return; |
|
278 | - } |
|
279 | - |
|
280 | - |
|
281 | - throw new BadRequestException([$notificationType]); |
|
282 | - } |
|
283 | - |
|
284 | - /** |
|
285 | - * @param string $id |
|
286 | - * @param array $notification |
|
287 | - * @return bool |
|
288 | - * @throws ActionNotSupportedException |
|
289 | - * @throws AuthenticationFailedException |
|
290 | - * @throws BadRequestException |
|
291 | - * @throws ShareNotFoundException |
|
292 | - * @throws \OC\HintException |
|
293 | - */ |
|
294 | - private function shareAccepted($id, $notification) { |
|
295 | - |
|
296 | - if (!$this->isS2SEnabled()) { |
|
297 | - throw new ActionNotSupportedException('Server does not support federated cloud sharing'); |
|
298 | - } |
|
299 | - |
|
300 | - if (!isset($notification['sharedSecret'])) { |
|
301 | - throw new BadRequestException(['sharedSecret']); |
|
302 | - } |
|
303 | - |
|
304 | - $token = $notification['sharedSecret']; |
|
305 | - |
|
306 | - $share = $this->federatedShareProvider->getShareById($id); |
|
307 | - |
|
308 | - $this->verifyShare($share, $token); |
|
309 | - $this->executeAcceptShare($share); |
|
310 | - if ($share->getShareOwner() !== $share->getSharedBy()) { |
|
311 | - list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedBy()); |
|
312 | - $remoteId = $this->federatedShareProvider->getRemoteId($share); |
|
313 | - $notification = $this->cloudFederationFactory->getCloudFederationNotification(); |
|
314 | - $notification->setMessage( |
|
315 | - 'SHARE_ACCEPTED', |
|
316 | - 'file', |
|
317 | - $remoteId, |
|
318 | - [ |
|
319 | - 'sharedSecret' => $token, |
|
320 | - 'message' => 'Recipient accepted the re-share' |
|
321 | - ] |
|
322 | - |
|
323 | - ); |
|
324 | - $this->cloudFederationProviderManager->sendNotification($remote, $notification); |
|
325 | - |
|
326 | - } |
|
327 | - |
|
328 | - return true; |
|
329 | - } |
|
330 | - |
|
331 | - /** |
|
332 | - * @param IShare $share |
|
333 | - * @throws ShareNotFoundException |
|
334 | - */ |
|
335 | - protected function executeAcceptShare(IShare $share) { |
|
336 | - try { |
|
337 | - $fileId = (int)$share->getNode()->getId(); |
|
338 | - list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId); |
|
339 | - } catch (\Exception $e) { |
|
340 | - throw new ShareNotFoundException(); |
|
341 | - } |
|
342 | - |
|
343 | - $event = $this->activityManager->generateEvent(); |
|
344 | - $event->setApp('files_sharing') |
|
345 | - ->setType('remote_share') |
|
346 | - ->setAffectedUser($this->getCorrectUid($share)) |
|
347 | - ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_ACCEPTED, [$share->getSharedWith(), [$fileId => $file]]) |
|
348 | - ->setObject('files', $fileId, $file) |
|
349 | - ->setLink($link); |
|
350 | - $this->activityManager->publish($event); |
|
351 | - } |
|
352 | - |
|
353 | - /** |
|
354 | - * @param string $id |
|
355 | - * @param array $notification |
|
356 | - * @throws ActionNotSupportedException |
|
357 | - * @throws AuthenticationFailedException |
|
358 | - * @throws BadRequestException |
|
359 | - * @throws ShareNotFound |
|
360 | - * @throws ShareNotFoundException |
|
361 | - * @throws \OC\HintException |
|
362 | - */ |
|
363 | - protected function shareDeclined($id, $notification) { |
|
364 | - |
|
365 | - if (!$this->isS2SEnabled()) { |
|
366 | - throw new ActionNotSupportedException('Server does not support federated cloud sharing'); |
|
367 | - } |
|
368 | - |
|
369 | - if (!isset($notification['sharedSecret'])) { |
|
370 | - throw new BadRequestException(['sharedSecret']); |
|
371 | - } |
|
372 | - |
|
373 | - $token = $notification['sharedSecret']; |
|
374 | - |
|
375 | - $share = $this->federatedShareProvider->getShareById($id); |
|
376 | - |
|
377 | - $this->verifyShare($share, $token); |
|
378 | - |
|
379 | - if ($share->getShareOwner() !== $share->getSharedBy()) { |
|
380 | - list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedBy()); |
|
381 | - $remoteId = $this->federatedShareProvider->getRemoteId($share); |
|
382 | - $notification = $this->cloudFederationFactory->getCloudFederationNotification(); |
|
383 | - $notification->setMessage( |
|
384 | - 'SHARE_DECLINED', |
|
385 | - 'file', |
|
386 | - $remoteId, |
|
387 | - [ |
|
388 | - 'sharedSecret' => $token, |
|
389 | - 'message' => 'Recipient declined the re-share' |
|
390 | - ] |
|
391 | - |
|
392 | - ); |
|
393 | - $this->cloudFederationProviderManager->sendNotification($remote, $notification); |
|
394 | - } |
|
395 | - |
|
396 | - $this->executeDeclineShare($share); |
|
397 | - |
|
398 | - } |
|
399 | - |
|
400 | - /** |
|
401 | - * delete declined share and create a activity |
|
402 | - * |
|
403 | - * @param IShare $share |
|
404 | - * @throws ShareNotFoundException |
|
405 | - */ |
|
406 | - protected function executeDeclineShare(IShare $share) { |
|
407 | - $this->federatedShareProvider->removeShareFromTable($share); |
|
408 | - |
|
409 | - try { |
|
410 | - $fileId = (int)$share->getNode()->getId(); |
|
411 | - list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId); |
|
412 | - } catch (\Exception $e) { |
|
413 | - throw new ShareNotFoundException(); |
|
414 | - } |
|
415 | - |
|
416 | - $event = $this->activityManager->generateEvent(); |
|
417 | - $event->setApp('files_sharing') |
|
418 | - ->setType('remote_share') |
|
419 | - ->setAffectedUser($this->getCorrectUid($share)) |
|
420 | - ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_DECLINED, [$share->getSharedWith(), [$fileId => $file]]) |
|
421 | - ->setObject('files', $fileId, $file) |
|
422 | - ->setLink($link); |
|
423 | - $this->activityManager->publish($event); |
|
424 | - |
|
425 | - } |
|
426 | - |
|
427 | - |
|
428 | - /** |
|
429 | - * get file |
|
430 | - * |
|
431 | - * @param string $user |
|
432 | - * @param int $fileSource |
|
433 | - * @return array with internal path of the file and a absolute link to it |
|
434 | - */ |
|
435 | - private function getFile($user, $fileSource) { |
|
436 | - \OC_Util::setupFS($user); |
|
437 | - |
|
438 | - try { |
|
439 | - $file = Filesystem::getPath($fileSource); |
|
440 | - } catch (NotFoundException $e) { |
|
441 | - $file = null; |
|
442 | - } |
|
443 | - $args = Filesystem::is_dir($file) ? array('dir' => $file) : array('dir' => dirname($file), 'scrollto' => $file); |
|
444 | - $link = Util::linkToAbsolute('files', 'index.php', $args); |
|
445 | - |
|
446 | - return array($file, $link); |
|
447 | - |
|
448 | - } |
|
449 | - |
|
450 | - /** |
|
451 | - * check if we are the initiator or the owner of a re-share and return the correct UID |
|
452 | - * |
|
453 | - * @param IShare $share |
|
454 | - * @return string |
|
455 | - */ |
|
456 | - protected function getCorrectUid(IShare $share) { |
|
457 | - if ($this->userManager->userExists($share->getShareOwner())) { |
|
458 | - return $share->getShareOwner(); |
|
459 | - } |
|
460 | - |
|
461 | - return $share->getSharedBy(); |
|
462 | - } |
|
463 | - |
|
464 | - |
|
465 | - |
|
466 | - /** |
|
467 | - * check if we got the right share |
|
468 | - * |
|
469 | - * @param IShare $share |
|
470 | - * @param string $token |
|
471 | - * @return bool |
|
472 | - * @throws AuthenticationFailedException |
|
473 | - */ |
|
474 | - protected function verifyShare(IShare $share, $token) { |
|
475 | - if ( |
|
476 | - $share->getShareType() === FederatedShareProvider::SHARE_TYPE_REMOTE && |
|
477 | - $share->getToken() === $token |
|
478 | - ) { |
|
479 | - return true; |
|
480 | - } |
|
481 | - |
|
482 | - throw new AuthenticationFailedException(); |
|
483 | - } |
|
484 | - |
|
485 | - |
|
486 | - |
|
487 | - /** |
|
488 | - * check if server-to-server sharing is enabled |
|
489 | - * |
|
490 | - * @param bool $incoming |
|
491 | - * @return bool |
|
492 | - */ |
|
493 | - private function isS2SEnabled($incoming = false) { |
|
494 | - |
|
495 | - $result = $this->appManager->isEnabledForUser('files_sharing'); |
|
496 | - |
|
497 | - if ($incoming) { |
|
498 | - $result = $result && $this->federatedShareProvider->isIncomingServer2serverShareEnabled(); |
|
499 | - } else { |
|
500 | - $result = $result && $this->federatedShareProvider->isOutgoingServer2serverShareEnabled(); |
|
501 | - } |
|
502 | - |
|
503 | - return $result; |
|
504 | - } |
|
53 | + /** @var IAppManager */ |
|
54 | + private $appManager; |
|
55 | + |
|
56 | + /** @var FederatedShareProvider */ |
|
57 | + private $federatedShareProvider; |
|
58 | + |
|
59 | + /** @var AddressHandler */ |
|
60 | + private $addressHandler; |
|
61 | + |
|
62 | + /** @var ILogger */ |
|
63 | + private $logger; |
|
64 | + |
|
65 | + /** @var IUserManager */ |
|
66 | + private $userManager; |
|
67 | + |
|
68 | + /** @var ICloudIdManager */ |
|
69 | + private $cloudIdManager; |
|
70 | + |
|
71 | + /** @var IActivityManager */ |
|
72 | + private $activityManager; |
|
73 | + |
|
74 | + /** @var INotificationManager */ |
|
75 | + private $notificationManager; |
|
76 | + |
|
77 | + /** @var IURLGenerator */ |
|
78 | + private $urlGenerator; |
|
79 | + |
|
80 | + /** @var ICloudFederationFactory */ |
|
81 | + private $cloudFederationFactory; |
|
82 | + |
|
83 | + /** @var ICloudFederationProviderManager */ |
|
84 | + private $cloudFederationProviderManager; |
|
85 | + |
|
86 | + /** |
|
87 | + * CloudFederationProvider constructor. |
|
88 | + * |
|
89 | + * @param IAppManager $appManager |
|
90 | + * @param FederatedShareProvider $federatedShareProvider |
|
91 | + * @param AddressHandler $addressHandler |
|
92 | + * @param ILogger $logger |
|
93 | + * @param IUserManager $userManager |
|
94 | + * @param ICloudIdManager $cloudIdManager |
|
95 | + * @param IActivityManager $activityManager |
|
96 | + * @param INotificationManager $notificationManager |
|
97 | + * @param IURLGenerator $urlGenerator |
|
98 | + * @param ICloudFederationFactory $cloudFederationFactory |
|
99 | + * @param ICloudFederationProviderManager $cloudFederationProviderManager |
|
100 | + */ |
|
101 | + public function __construct(IAppManager $appManager, |
|
102 | + FederatedShareProvider $federatedShareProvider, |
|
103 | + AddressHandler $addressHandler, |
|
104 | + ILogger $logger, |
|
105 | + IUserManager $userManager, |
|
106 | + ICloudIdManager $cloudIdManager, |
|
107 | + IActivityManager $activityManager, |
|
108 | + INotificationManager $notificationManager, |
|
109 | + IURLGenerator $urlGenerator, |
|
110 | + ICloudFederationFactory $cloudFederationFactory, |
|
111 | + ICloudFederationProviderManager $cloudFederationProviderManager |
|
112 | + ) { |
|
113 | + $this->appManager = $appManager; |
|
114 | + $this->federatedShareProvider = $federatedShareProvider; |
|
115 | + $this->addressHandler = $addressHandler; |
|
116 | + $this->logger = $logger; |
|
117 | + $this->userManager = $userManager; |
|
118 | + $this->cloudIdManager = $cloudIdManager; |
|
119 | + $this->activityManager = $activityManager; |
|
120 | + $this->notificationManager = $notificationManager; |
|
121 | + $this->urlGenerator = $urlGenerator; |
|
122 | + $this->cloudFederationFactory = $cloudFederationFactory; |
|
123 | + $this->cloudFederationProviderManager = $cloudFederationProviderManager; |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * @return string |
|
130 | + */ |
|
131 | + public function getShareType() { |
|
132 | + return 'file'; |
|
133 | + } |
|
134 | + |
|
135 | + /** |
|
136 | + * share received from another server |
|
137 | + * |
|
138 | + * @param ICloudFederationShare $share |
|
139 | + * @return string provider specific unique ID of the share |
|
140 | + * |
|
141 | + * @throws ProviderCouldNotAddShareException |
|
142 | + * @throws \OCP\AppFramework\QueryException |
|
143 | + * @throws \OC\HintException |
|
144 | + * @since 14.0.0 |
|
145 | + */ |
|
146 | + public function shareReceived(ICloudFederationShare $share) { |
|
147 | + |
|
148 | + if (!$this->isS2SEnabled(true)) { |
|
149 | + throw new ProviderCouldNotAddShareException('Server does not support federated cloud sharing', '', Http::STATUS_SERVICE_UNAVAILABLE); |
|
150 | + } |
|
151 | + |
|
152 | + $protocol = $share->getProtocol(); |
|
153 | + if ($protocol['name'] !== 'webdav') { |
|
154 | + throw new ProviderCouldNotAddShareException('Unsupported protocol for data exchange.', '', Http::STATUS_NOT_IMPLEMENTED); |
|
155 | + } |
|
156 | + |
|
157 | + list($ownerUid, $remote) = $this->addressHandler->splitUserRemote($share->getOwner()); |
|
158 | + |
|
159 | + $remote = $remote; |
|
160 | + $token = $share->getShareSecret(); |
|
161 | + $name = $share->getResourceName(); |
|
162 | + $owner = $share->getOwnerDisplayName(); |
|
163 | + $sharedBy = $share->getSharedByDisplayName(); |
|
164 | + $shareWith = $share->getShareWith(); |
|
165 | + $remoteId = $share->getProviderId(); |
|
166 | + $sharedByFederatedId = $share->getSharedBy(); |
|
167 | + $ownerFederatedId = $share->getOwner(); |
|
168 | + |
|
169 | + // if no explicit information about the person who created the share was send |
|
170 | + // we assume that the share comes from the owner |
|
171 | + if ($sharedByFederatedId === null) { |
|
172 | + $sharedBy = $owner; |
|
173 | + $sharedByFederatedId = $ownerFederatedId; |
|
174 | + } |
|
175 | + |
|
176 | + if ($remote && $token && $name && $owner && $remoteId && $shareWith) { |
|
177 | + |
|
178 | + if (!Util::isValidFileName($name)) { |
|
179 | + throw new ProviderCouldNotAddShareException('The mountpoint name contains invalid characters.', '', Http::STATUS_BAD_REQUEST); |
|
180 | + } |
|
181 | + |
|
182 | + // FIXME this should be a method in the user management instead |
|
183 | + $this->logger->debug('shareWith before, ' . $shareWith, ['app' => 'files_sharing']); |
|
184 | + Util::emitHook( |
|
185 | + '\OCA\Files_Sharing\API\Server2Server', |
|
186 | + 'preLoginNameUsedAsUserName', |
|
187 | + array('uid' => &$shareWith) |
|
188 | + ); |
|
189 | + $this->logger->debug('shareWith after, ' . $shareWith, ['app' => 'files_sharing']); |
|
190 | + |
|
191 | + if (!$this->userManager->userExists($shareWith)) { |
|
192 | + throw new ProviderCouldNotAddShareException('User does not exists', '',Http::STATUS_BAD_REQUEST); |
|
193 | + } |
|
194 | + |
|
195 | + \OC_Util::setupFS($shareWith); |
|
196 | + |
|
197 | + $externalManager = new \OCA\Files_Sharing\External\Manager( |
|
198 | + \OC::$server->getDatabaseConnection(), |
|
199 | + Filesystem::getMountManager(), |
|
200 | + Filesystem::getLoader(), |
|
201 | + \OC::$server->getHTTPClientService(), |
|
202 | + \OC::$server->getNotificationManager(), |
|
203 | + \OC::$server->query(\OCP\OCS\IDiscoveryService::class), |
|
204 | + \OC::$server->getCloudFederationProviderManager(), |
|
205 | + \OC::$server->getCloudFederationFactory(), |
|
206 | + $shareWith |
|
207 | + ); |
|
208 | + |
|
209 | + try { |
|
210 | + $externalManager->addShare($remote, $token, '', $name, $owner, false, $shareWith, $remoteId); |
|
211 | + $shareId = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share_external'); |
|
212 | + |
|
213 | + $event = $this->activityManager->generateEvent(); |
|
214 | + $event->setApp('files_sharing') |
|
215 | + ->setType('remote_share') |
|
216 | + ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_RECEIVED, [$ownerFederatedId, trim($name, '/')]) |
|
217 | + ->setAffectedUser($shareWith) |
|
218 | + ->setObject('remote_share', (int)$shareId, $name); |
|
219 | + \OC::$server->getActivityManager()->publish($event); |
|
220 | + |
|
221 | + $notification = $this->notificationManager->createNotification(); |
|
222 | + $notification->setApp('files_sharing') |
|
223 | + ->setUser($shareWith) |
|
224 | + ->setDateTime(new \DateTime()) |
|
225 | + ->setObject('remote_share', $shareId) |
|
226 | + ->setSubject('remote_share', [$ownerFederatedId, $sharedByFederatedId, trim($name, '/')]); |
|
227 | + |
|
228 | + $declineAction = $notification->createAction(); |
|
229 | + $declineAction->setLabel('decline') |
|
230 | + ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'DELETE'); |
|
231 | + $notification->addAction($declineAction); |
|
232 | + |
|
233 | + $acceptAction = $notification->createAction(); |
|
234 | + $acceptAction->setLabel('accept') |
|
235 | + ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'POST'); |
|
236 | + $notification->addAction($acceptAction); |
|
237 | + |
|
238 | + $this->notificationManager->notify($notification); |
|
239 | + |
|
240 | + return $shareId; |
|
241 | + } catch (\Exception $e) { |
|
242 | + $this->logger->logException($e, [ |
|
243 | + 'message' => 'Server can not add remote share.', |
|
244 | + 'level' => Util::ERROR, |
|
245 | + 'app' => 'files_sharing' |
|
246 | + ]); |
|
247 | + throw new ProviderCouldNotAddShareException('internal server error, was not able to add share from ' . $remote, '', HTTP::STATUS_INTERNAL_SERVER_ERROR); |
|
248 | + } |
|
249 | + } |
|
250 | + |
|
251 | + throw new ProviderCouldNotAddShareException('server can not add remote share, missing parameter', '', HTTP::STATUS_BAD_REQUEST); |
|
252 | + |
|
253 | + } |
|
254 | + |
|
255 | + /** |
|
256 | + * notification received from another server |
|
257 | + * |
|
258 | + * @param string $notificationType (e.g. SHARE_ACCEPTED) |
|
259 | + * @param string $providerId id of the share |
|
260 | + * @param array $notification payload of the notification |
|
261 | + * |
|
262 | + * @throws ActionNotSupportedException |
|
263 | + * @throws AuthenticationFailedException |
|
264 | + * @throws BadRequestException |
|
265 | + * @throws ShareNotFoundException |
|
266 | + * @throws \OC\HintException |
|
267 | + * @since 14.0.0 |
|
268 | + */ |
|
269 | + public function notificationReceived($notificationType, $providerId, array $notification) { |
|
270 | + |
|
271 | + switch ($notificationType) { |
|
272 | + case 'SHARE_ACCEPTED': |
|
273 | + $this->shareAccepted($providerId, $notification); |
|
274 | + return; |
|
275 | + case 'SHARE_DECLINED': |
|
276 | + $this->shareDeclined($providerId, $notification); |
|
277 | + return; |
|
278 | + } |
|
279 | + |
|
280 | + |
|
281 | + throw new BadRequestException([$notificationType]); |
|
282 | + } |
|
283 | + |
|
284 | + /** |
|
285 | + * @param string $id |
|
286 | + * @param array $notification |
|
287 | + * @return bool |
|
288 | + * @throws ActionNotSupportedException |
|
289 | + * @throws AuthenticationFailedException |
|
290 | + * @throws BadRequestException |
|
291 | + * @throws ShareNotFoundException |
|
292 | + * @throws \OC\HintException |
|
293 | + */ |
|
294 | + private function shareAccepted($id, $notification) { |
|
295 | + |
|
296 | + if (!$this->isS2SEnabled()) { |
|
297 | + throw new ActionNotSupportedException('Server does not support federated cloud sharing'); |
|
298 | + } |
|
299 | + |
|
300 | + if (!isset($notification['sharedSecret'])) { |
|
301 | + throw new BadRequestException(['sharedSecret']); |
|
302 | + } |
|
303 | + |
|
304 | + $token = $notification['sharedSecret']; |
|
305 | + |
|
306 | + $share = $this->federatedShareProvider->getShareById($id); |
|
307 | + |
|
308 | + $this->verifyShare($share, $token); |
|
309 | + $this->executeAcceptShare($share); |
|
310 | + if ($share->getShareOwner() !== $share->getSharedBy()) { |
|
311 | + list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedBy()); |
|
312 | + $remoteId = $this->federatedShareProvider->getRemoteId($share); |
|
313 | + $notification = $this->cloudFederationFactory->getCloudFederationNotification(); |
|
314 | + $notification->setMessage( |
|
315 | + 'SHARE_ACCEPTED', |
|
316 | + 'file', |
|
317 | + $remoteId, |
|
318 | + [ |
|
319 | + 'sharedSecret' => $token, |
|
320 | + 'message' => 'Recipient accepted the re-share' |
|
321 | + ] |
|
322 | + |
|
323 | + ); |
|
324 | + $this->cloudFederationProviderManager->sendNotification($remote, $notification); |
|
325 | + |
|
326 | + } |
|
327 | + |
|
328 | + return true; |
|
329 | + } |
|
330 | + |
|
331 | + /** |
|
332 | + * @param IShare $share |
|
333 | + * @throws ShareNotFoundException |
|
334 | + */ |
|
335 | + protected function executeAcceptShare(IShare $share) { |
|
336 | + try { |
|
337 | + $fileId = (int)$share->getNode()->getId(); |
|
338 | + list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId); |
|
339 | + } catch (\Exception $e) { |
|
340 | + throw new ShareNotFoundException(); |
|
341 | + } |
|
342 | + |
|
343 | + $event = $this->activityManager->generateEvent(); |
|
344 | + $event->setApp('files_sharing') |
|
345 | + ->setType('remote_share') |
|
346 | + ->setAffectedUser($this->getCorrectUid($share)) |
|
347 | + ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_ACCEPTED, [$share->getSharedWith(), [$fileId => $file]]) |
|
348 | + ->setObject('files', $fileId, $file) |
|
349 | + ->setLink($link); |
|
350 | + $this->activityManager->publish($event); |
|
351 | + } |
|
352 | + |
|
353 | + /** |
|
354 | + * @param string $id |
|
355 | + * @param array $notification |
|
356 | + * @throws ActionNotSupportedException |
|
357 | + * @throws AuthenticationFailedException |
|
358 | + * @throws BadRequestException |
|
359 | + * @throws ShareNotFound |
|
360 | + * @throws ShareNotFoundException |
|
361 | + * @throws \OC\HintException |
|
362 | + */ |
|
363 | + protected function shareDeclined($id, $notification) { |
|
364 | + |
|
365 | + if (!$this->isS2SEnabled()) { |
|
366 | + throw new ActionNotSupportedException('Server does not support federated cloud sharing'); |
|
367 | + } |
|
368 | + |
|
369 | + if (!isset($notification['sharedSecret'])) { |
|
370 | + throw new BadRequestException(['sharedSecret']); |
|
371 | + } |
|
372 | + |
|
373 | + $token = $notification['sharedSecret']; |
|
374 | + |
|
375 | + $share = $this->federatedShareProvider->getShareById($id); |
|
376 | + |
|
377 | + $this->verifyShare($share, $token); |
|
378 | + |
|
379 | + if ($share->getShareOwner() !== $share->getSharedBy()) { |
|
380 | + list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedBy()); |
|
381 | + $remoteId = $this->federatedShareProvider->getRemoteId($share); |
|
382 | + $notification = $this->cloudFederationFactory->getCloudFederationNotification(); |
|
383 | + $notification->setMessage( |
|
384 | + 'SHARE_DECLINED', |
|
385 | + 'file', |
|
386 | + $remoteId, |
|
387 | + [ |
|
388 | + 'sharedSecret' => $token, |
|
389 | + 'message' => 'Recipient declined the re-share' |
|
390 | + ] |
|
391 | + |
|
392 | + ); |
|
393 | + $this->cloudFederationProviderManager->sendNotification($remote, $notification); |
|
394 | + } |
|
395 | + |
|
396 | + $this->executeDeclineShare($share); |
|
397 | + |
|
398 | + } |
|
399 | + |
|
400 | + /** |
|
401 | + * delete declined share and create a activity |
|
402 | + * |
|
403 | + * @param IShare $share |
|
404 | + * @throws ShareNotFoundException |
|
405 | + */ |
|
406 | + protected function executeDeclineShare(IShare $share) { |
|
407 | + $this->federatedShareProvider->removeShareFromTable($share); |
|
408 | + |
|
409 | + try { |
|
410 | + $fileId = (int)$share->getNode()->getId(); |
|
411 | + list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId); |
|
412 | + } catch (\Exception $e) { |
|
413 | + throw new ShareNotFoundException(); |
|
414 | + } |
|
415 | + |
|
416 | + $event = $this->activityManager->generateEvent(); |
|
417 | + $event->setApp('files_sharing') |
|
418 | + ->setType('remote_share') |
|
419 | + ->setAffectedUser($this->getCorrectUid($share)) |
|
420 | + ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_DECLINED, [$share->getSharedWith(), [$fileId => $file]]) |
|
421 | + ->setObject('files', $fileId, $file) |
|
422 | + ->setLink($link); |
|
423 | + $this->activityManager->publish($event); |
|
424 | + |
|
425 | + } |
|
426 | + |
|
427 | + |
|
428 | + /** |
|
429 | + * get file |
|
430 | + * |
|
431 | + * @param string $user |
|
432 | + * @param int $fileSource |
|
433 | + * @return array with internal path of the file and a absolute link to it |
|
434 | + */ |
|
435 | + private function getFile($user, $fileSource) { |
|
436 | + \OC_Util::setupFS($user); |
|
437 | + |
|
438 | + try { |
|
439 | + $file = Filesystem::getPath($fileSource); |
|
440 | + } catch (NotFoundException $e) { |
|
441 | + $file = null; |
|
442 | + } |
|
443 | + $args = Filesystem::is_dir($file) ? array('dir' => $file) : array('dir' => dirname($file), 'scrollto' => $file); |
|
444 | + $link = Util::linkToAbsolute('files', 'index.php', $args); |
|
445 | + |
|
446 | + return array($file, $link); |
|
447 | + |
|
448 | + } |
|
449 | + |
|
450 | + /** |
|
451 | + * check if we are the initiator or the owner of a re-share and return the correct UID |
|
452 | + * |
|
453 | + * @param IShare $share |
|
454 | + * @return string |
|
455 | + */ |
|
456 | + protected function getCorrectUid(IShare $share) { |
|
457 | + if ($this->userManager->userExists($share->getShareOwner())) { |
|
458 | + return $share->getShareOwner(); |
|
459 | + } |
|
460 | + |
|
461 | + return $share->getSharedBy(); |
|
462 | + } |
|
463 | + |
|
464 | + |
|
465 | + |
|
466 | + /** |
|
467 | + * check if we got the right share |
|
468 | + * |
|
469 | + * @param IShare $share |
|
470 | + * @param string $token |
|
471 | + * @return bool |
|
472 | + * @throws AuthenticationFailedException |
|
473 | + */ |
|
474 | + protected function verifyShare(IShare $share, $token) { |
|
475 | + if ( |
|
476 | + $share->getShareType() === FederatedShareProvider::SHARE_TYPE_REMOTE && |
|
477 | + $share->getToken() === $token |
|
478 | + ) { |
|
479 | + return true; |
|
480 | + } |
|
481 | + |
|
482 | + throw new AuthenticationFailedException(); |
|
483 | + } |
|
484 | + |
|
485 | + |
|
486 | + |
|
487 | + /** |
|
488 | + * check if server-to-server sharing is enabled |
|
489 | + * |
|
490 | + * @param bool $incoming |
|
491 | + * @return bool |
|
492 | + */ |
|
493 | + private function isS2SEnabled($incoming = false) { |
|
494 | + |
|
495 | + $result = $this->appManager->isEnabledForUser('files_sharing'); |
|
496 | + |
|
497 | + if ($incoming) { |
|
498 | + $result = $result && $this->federatedShareProvider->isIncomingServer2serverShareEnabled(); |
|
499 | + } else { |
|
500 | + $result = $result && $this->federatedShareProvider->isOutgoingServer2serverShareEnabled(); |
|
501 | + } |
|
502 | + |
|
503 | + return $result; |
|
504 | + } |
|
505 | 505 | |
506 | 506 | |
507 | 507 | } |
@@ -180,16 +180,16 @@ discard block |
||
180 | 180 | } |
181 | 181 | |
182 | 182 | // FIXME this should be a method in the user management instead |
183 | - $this->logger->debug('shareWith before, ' . $shareWith, ['app' => 'files_sharing']); |
|
183 | + $this->logger->debug('shareWith before, '.$shareWith, ['app' => 'files_sharing']); |
|
184 | 184 | Util::emitHook( |
185 | 185 | '\OCA\Files_Sharing\API\Server2Server', |
186 | 186 | 'preLoginNameUsedAsUserName', |
187 | 187 | array('uid' => &$shareWith) |
188 | 188 | ); |
189 | - $this->logger->debug('shareWith after, ' . $shareWith, ['app' => 'files_sharing']); |
|
189 | + $this->logger->debug('shareWith after, '.$shareWith, ['app' => 'files_sharing']); |
|
190 | 190 | |
191 | 191 | if (!$this->userManager->userExists($shareWith)) { |
192 | - throw new ProviderCouldNotAddShareException('User does not exists', '',Http::STATUS_BAD_REQUEST); |
|
192 | + throw new ProviderCouldNotAddShareException('User does not exists', '', Http::STATUS_BAD_REQUEST); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | \OC_Util::setupFS($shareWith); |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | ->setType('remote_share') |
216 | 216 | ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_RECEIVED, [$ownerFederatedId, trim($name, '/')]) |
217 | 217 | ->setAffectedUser($shareWith) |
218 | - ->setObject('remote_share', (int)$shareId, $name); |
|
218 | + ->setObject('remote_share', (int) $shareId, $name); |
|
219 | 219 | \OC::$server->getActivityManager()->publish($event); |
220 | 220 | |
221 | 221 | $notification = $this->notificationManager->createNotification(); |
@@ -227,12 +227,12 @@ discard block |
||
227 | 227 | |
228 | 228 | $declineAction = $notification->createAction(); |
229 | 229 | $declineAction->setLabel('decline') |
230 | - ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'DELETE'); |
|
230 | + ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/'.$shareId)), 'DELETE'); |
|
231 | 231 | $notification->addAction($declineAction); |
232 | 232 | |
233 | 233 | $acceptAction = $notification->createAction(); |
234 | 234 | $acceptAction->setLabel('accept') |
235 | - ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'POST'); |
|
235 | + ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/'.$shareId)), 'POST'); |
|
236 | 236 | $notification->addAction($acceptAction); |
237 | 237 | |
238 | 238 | $this->notificationManager->notify($notification); |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | 'level' => Util::ERROR, |
245 | 245 | 'app' => 'files_sharing' |
246 | 246 | ]); |
247 | - throw new ProviderCouldNotAddShareException('internal server error, was not able to add share from ' . $remote, '', HTTP::STATUS_INTERNAL_SERVER_ERROR); |
|
247 | + throw new ProviderCouldNotAddShareException('internal server error, was not able to add share from '.$remote, '', HTTP::STATUS_INTERNAL_SERVER_ERROR); |
|
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | */ |
335 | 335 | protected function executeAcceptShare(IShare $share) { |
336 | 336 | try { |
337 | - $fileId = (int)$share->getNode()->getId(); |
|
337 | + $fileId = (int) $share->getNode()->getId(); |
|
338 | 338 | list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId); |
339 | 339 | } catch (\Exception $e) { |
340 | 340 | throw new ShareNotFoundException(); |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | $this->federatedShareProvider->removeShareFromTable($share); |
408 | 408 | |
409 | 409 | try { |
410 | - $fileId = (int)$share->getNode()->getId(); |
|
410 | + $fileId = (int) $share->getNode()->getId(); |
|
411 | 411 | list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId); |
412 | 412 | } catch (\Exception $e) { |
413 | 413 | throw new ShareNotFoundException(); |
@@ -32,7 +32,6 @@ |
||
32 | 32 | use OCA\FederatedFileSharing\AddressHandler; |
33 | 33 | use OCA\FederatedFileSharing\FederatedShareProvider; |
34 | 34 | use OCA\FederatedFileSharing\Notifications; |
35 | -use OCA\FederatedFileSharing\OCM\CloudFederationProvider; |
|
36 | 35 | use OCA\FederatedFileSharing\TokenHandler; |
37 | 36 | use OCA\ShareByMail\Settings\SettingsManager; |
38 | 37 | use OCA\ShareByMail\ShareByMailProvider; |
@@ -48,235 +48,235 @@ |
||
48 | 48 | */ |
49 | 49 | class ProviderFactory implements IProviderFactory { |
50 | 50 | |
51 | - /** @var IServerContainer */ |
|
52 | - private $serverContainer; |
|
53 | - /** @var DefaultShareProvider */ |
|
54 | - private $defaultProvider = null; |
|
55 | - /** @var FederatedShareProvider */ |
|
56 | - private $federatedProvider = null; |
|
57 | - /** @var ShareByMailProvider */ |
|
58 | - private $shareByMailProvider; |
|
59 | - /** @var \OCA\Circles\ShareByCircleProvider */ |
|
60 | - private $shareByCircleProvider = null; |
|
61 | - /** @var bool */ |
|
62 | - private $circlesAreNotAvailable = false; |
|
63 | - |
|
64 | - /** |
|
65 | - * IProviderFactory constructor. |
|
66 | - * |
|
67 | - * @param IServerContainer $serverContainer |
|
68 | - */ |
|
69 | - public function __construct(IServerContainer $serverContainer) { |
|
70 | - $this->serverContainer = $serverContainer; |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * Create the default share provider. |
|
75 | - * |
|
76 | - * @return DefaultShareProvider |
|
77 | - */ |
|
78 | - protected function defaultShareProvider() { |
|
79 | - if ($this->defaultProvider === null) { |
|
80 | - $this->defaultProvider = new DefaultShareProvider( |
|
81 | - $this->serverContainer->getDatabaseConnection(), |
|
82 | - $this->serverContainer->getUserManager(), |
|
83 | - $this->serverContainer->getGroupManager(), |
|
84 | - $this->serverContainer->getLazyRootFolder() |
|
85 | - ); |
|
86 | - } |
|
87 | - |
|
88 | - return $this->defaultProvider; |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * Create the federated share provider |
|
93 | - * |
|
94 | - * @return FederatedShareProvider |
|
95 | - */ |
|
96 | - protected function federatedShareProvider() { |
|
97 | - if ($this->federatedProvider === null) { |
|
98 | - /* |
|
51 | + /** @var IServerContainer */ |
|
52 | + private $serverContainer; |
|
53 | + /** @var DefaultShareProvider */ |
|
54 | + private $defaultProvider = null; |
|
55 | + /** @var FederatedShareProvider */ |
|
56 | + private $federatedProvider = null; |
|
57 | + /** @var ShareByMailProvider */ |
|
58 | + private $shareByMailProvider; |
|
59 | + /** @var \OCA\Circles\ShareByCircleProvider */ |
|
60 | + private $shareByCircleProvider = null; |
|
61 | + /** @var bool */ |
|
62 | + private $circlesAreNotAvailable = false; |
|
63 | + |
|
64 | + /** |
|
65 | + * IProviderFactory constructor. |
|
66 | + * |
|
67 | + * @param IServerContainer $serverContainer |
|
68 | + */ |
|
69 | + public function __construct(IServerContainer $serverContainer) { |
|
70 | + $this->serverContainer = $serverContainer; |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * Create the default share provider. |
|
75 | + * |
|
76 | + * @return DefaultShareProvider |
|
77 | + */ |
|
78 | + protected function defaultShareProvider() { |
|
79 | + if ($this->defaultProvider === null) { |
|
80 | + $this->defaultProvider = new DefaultShareProvider( |
|
81 | + $this->serverContainer->getDatabaseConnection(), |
|
82 | + $this->serverContainer->getUserManager(), |
|
83 | + $this->serverContainer->getGroupManager(), |
|
84 | + $this->serverContainer->getLazyRootFolder() |
|
85 | + ); |
|
86 | + } |
|
87 | + |
|
88 | + return $this->defaultProvider; |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * Create the federated share provider |
|
93 | + * |
|
94 | + * @return FederatedShareProvider |
|
95 | + */ |
|
96 | + protected function federatedShareProvider() { |
|
97 | + if ($this->federatedProvider === null) { |
|
98 | + /* |
|
99 | 99 | * Check if the app is enabled |
100 | 100 | */ |
101 | - $appManager = $this->serverContainer->getAppManager(); |
|
102 | - if (!$appManager->isEnabledForUser('federatedfilesharing')) { |
|
103 | - return null; |
|
104 | - } |
|
101 | + $appManager = $this->serverContainer->getAppManager(); |
|
102 | + if (!$appManager->isEnabledForUser('federatedfilesharing')) { |
|
103 | + return null; |
|
104 | + } |
|
105 | 105 | |
106 | - /* |
|
106 | + /* |
|
107 | 107 | * TODO: add factory to federated sharing app |
108 | 108 | */ |
109 | - $l = $this->serverContainer->getL10N('federatedfilessharing'); |
|
110 | - $addressHandler = new AddressHandler( |
|
111 | - $this->serverContainer->getURLGenerator(), |
|
112 | - $l, |
|
113 | - $this->serverContainer->getCloudIdManager() |
|
114 | - ); |
|
115 | - $notifications = new Notifications( |
|
116 | - $addressHandler, |
|
117 | - $this->serverContainer->getHTTPClientService(), |
|
118 | - $this->serverContainer->query(\OCP\OCS\IDiscoveryService::class), |
|
119 | - $this->serverContainer->getJobList(), |
|
120 | - \OC::$server->getCloudFederationProviderManager(), |
|
121 | - \OC::$server->getCloudFederationFactory() |
|
122 | - ); |
|
123 | - $tokenHandler = new TokenHandler( |
|
124 | - $this->serverContainer->getSecureRandom() |
|
125 | - ); |
|
126 | - |
|
127 | - $this->federatedProvider = new FederatedShareProvider( |
|
128 | - $this->serverContainer->getDatabaseConnection(), |
|
129 | - $addressHandler, |
|
130 | - $notifications, |
|
131 | - $tokenHandler, |
|
132 | - $l, |
|
133 | - $this->serverContainer->getLogger(), |
|
134 | - $this->serverContainer->getLazyRootFolder(), |
|
135 | - $this->serverContainer->getConfig(), |
|
136 | - $this->serverContainer->getUserManager(), |
|
137 | - $this->serverContainer->getCloudIdManager(), |
|
138 | - $this->serverContainer->getGlobalScaleConfig() |
|
139 | - ); |
|
140 | - } |
|
141 | - |
|
142 | - return $this->federatedProvider; |
|
143 | - } |
|
144 | - |
|
145 | - /** |
|
146 | - * Create the federated share provider |
|
147 | - * |
|
148 | - * @return ShareByMailProvider |
|
149 | - */ |
|
150 | - protected function getShareByMailProvider() { |
|
151 | - if ($this->shareByMailProvider === null) { |
|
152 | - /* |
|
109 | + $l = $this->serverContainer->getL10N('federatedfilessharing'); |
|
110 | + $addressHandler = new AddressHandler( |
|
111 | + $this->serverContainer->getURLGenerator(), |
|
112 | + $l, |
|
113 | + $this->serverContainer->getCloudIdManager() |
|
114 | + ); |
|
115 | + $notifications = new Notifications( |
|
116 | + $addressHandler, |
|
117 | + $this->serverContainer->getHTTPClientService(), |
|
118 | + $this->serverContainer->query(\OCP\OCS\IDiscoveryService::class), |
|
119 | + $this->serverContainer->getJobList(), |
|
120 | + \OC::$server->getCloudFederationProviderManager(), |
|
121 | + \OC::$server->getCloudFederationFactory() |
|
122 | + ); |
|
123 | + $tokenHandler = new TokenHandler( |
|
124 | + $this->serverContainer->getSecureRandom() |
|
125 | + ); |
|
126 | + |
|
127 | + $this->federatedProvider = new FederatedShareProvider( |
|
128 | + $this->serverContainer->getDatabaseConnection(), |
|
129 | + $addressHandler, |
|
130 | + $notifications, |
|
131 | + $tokenHandler, |
|
132 | + $l, |
|
133 | + $this->serverContainer->getLogger(), |
|
134 | + $this->serverContainer->getLazyRootFolder(), |
|
135 | + $this->serverContainer->getConfig(), |
|
136 | + $this->serverContainer->getUserManager(), |
|
137 | + $this->serverContainer->getCloudIdManager(), |
|
138 | + $this->serverContainer->getGlobalScaleConfig() |
|
139 | + ); |
|
140 | + } |
|
141 | + |
|
142 | + return $this->federatedProvider; |
|
143 | + } |
|
144 | + |
|
145 | + /** |
|
146 | + * Create the federated share provider |
|
147 | + * |
|
148 | + * @return ShareByMailProvider |
|
149 | + */ |
|
150 | + protected function getShareByMailProvider() { |
|
151 | + if ($this->shareByMailProvider === null) { |
|
152 | + /* |
|
153 | 153 | * Check if the app is enabled |
154 | 154 | */ |
155 | - $appManager = $this->serverContainer->getAppManager(); |
|
156 | - if (!$appManager->isEnabledForUser('sharebymail')) { |
|
157 | - return null; |
|
158 | - } |
|
159 | - |
|
160 | - $settingsManager = new SettingsManager($this->serverContainer->getConfig()); |
|
161 | - |
|
162 | - $this->shareByMailProvider = new ShareByMailProvider( |
|
163 | - $this->serverContainer->getDatabaseConnection(), |
|
164 | - $this->serverContainer->getSecureRandom(), |
|
165 | - $this->serverContainer->getUserManager(), |
|
166 | - $this->serverContainer->getLazyRootFolder(), |
|
167 | - $this->serverContainer->getL10N('sharebymail'), |
|
168 | - $this->serverContainer->getLogger(), |
|
169 | - $this->serverContainer->getMailer(), |
|
170 | - $this->serverContainer->getURLGenerator(), |
|
171 | - $this->serverContainer->getActivityManager(), |
|
172 | - $settingsManager, |
|
173 | - $this->serverContainer->query(Defaults::class), |
|
174 | - $this->serverContainer->getHasher(), |
|
175 | - $this->serverContainer->query(CapabilitiesManager::class) |
|
176 | - ); |
|
177 | - } |
|
178 | - |
|
179 | - return $this->shareByMailProvider; |
|
180 | - } |
|
181 | - |
|
182 | - |
|
183 | - /** |
|
184 | - * Create the circle share provider |
|
185 | - * |
|
186 | - * @return FederatedShareProvider |
|
187 | - * |
|
188 | - * @suppress PhanUndeclaredClassMethod |
|
189 | - */ |
|
190 | - protected function getShareByCircleProvider() { |
|
191 | - |
|
192 | - if ($this->circlesAreNotAvailable) { |
|
193 | - return null; |
|
194 | - } |
|
195 | - |
|
196 | - if (!$this->serverContainer->getAppManager()->isEnabledForUser('circles') || |
|
197 | - !class_exists('\OCA\Circles\ShareByCircleProvider') |
|
198 | - ) { |
|
199 | - $this->circlesAreNotAvailable = true; |
|
200 | - return null; |
|
201 | - } |
|
202 | - |
|
203 | - if ($this->shareByCircleProvider === null) { |
|
204 | - |
|
205 | - $this->shareByCircleProvider = new \OCA\Circles\ShareByCircleProvider( |
|
206 | - $this->serverContainer->getDatabaseConnection(), |
|
207 | - $this->serverContainer->getSecureRandom(), |
|
208 | - $this->serverContainer->getUserManager(), |
|
209 | - $this->serverContainer->getLazyRootFolder(), |
|
210 | - $this->serverContainer->getL10N('circles'), |
|
211 | - $this->serverContainer->getLogger(), |
|
212 | - $this->serverContainer->getURLGenerator() |
|
213 | - ); |
|
214 | - } |
|
215 | - |
|
216 | - return $this->shareByCircleProvider; |
|
217 | - } |
|
218 | - |
|
219 | - |
|
220 | - /** |
|
221 | - * @inheritdoc |
|
222 | - */ |
|
223 | - public function getProvider($id) { |
|
224 | - $provider = null; |
|
225 | - if ($id === 'ocinternal') { |
|
226 | - $provider = $this->defaultShareProvider(); |
|
227 | - } else if ($id === 'ocFederatedSharing') { |
|
228 | - $provider = $this->federatedShareProvider(); |
|
229 | - } else if ($id === 'ocMailShare') { |
|
230 | - $provider = $this->getShareByMailProvider(); |
|
231 | - } else if ($id === 'ocCircleShare') { |
|
232 | - $provider = $this->getShareByCircleProvider(); |
|
233 | - } |
|
234 | - |
|
235 | - if ($provider === null) { |
|
236 | - throw new ProviderException('No provider with id .' . $id . ' found.'); |
|
237 | - } |
|
238 | - |
|
239 | - return $provider; |
|
240 | - } |
|
241 | - |
|
242 | - /** |
|
243 | - * @inheritdoc |
|
244 | - */ |
|
245 | - public function getProviderForType($shareType) { |
|
246 | - $provider = null; |
|
247 | - |
|
248 | - if ($shareType === \OCP\Share::SHARE_TYPE_USER || |
|
249 | - $shareType === \OCP\Share::SHARE_TYPE_GROUP || |
|
250 | - $shareType === \OCP\Share::SHARE_TYPE_LINK |
|
251 | - ) { |
|
252 | - $provider = $this->defaultShareProvider(); |
|
253 | - } else if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE) { |
|
254 | - $provider = $this->federatedShareProvider(); |
|
255 | - } else if ($shareType === \OCP\Share::SHARE_TYPE_EMAIL) { |
|
256 | - $provider = $this->getShareByMailProvider(); |
|
257 | - } else if ($shareType === \OCP\Share::SHARE_TYPE_CIRCLE) { |
|
258 | - $provider = $this->getShareByCircleProvider(); |
|
259 | - } |
|
260 | - |
|
261 | - |
|
262 | - if ($provider === null) { |
|
263 | - throw new ProviderException('No share provider for share type ' . $shareType); |
|
264 | - } |
|
265 | - |
|
266 | - return $provider; |
|
267 | - } |
|
268 | - |
|
269 | - public function getAllProviders() { |
|
270 | - $shares = [$this->defaultShareProvider(), $this->federatedShareProvider()]; |
|
271 | - $shareByMail = $this->getShareByMailProvider(); |
|
272 | - if ($shareByMail !== null) { |
|
273 | - $shares[] = $shareByMail; |
|
274 | - } |
|
275 | - $shareByCircle = $this->getShareByCircleProvider(); |
|
276 | - if ($shareByCircle !== null) { |
|
277 | - $shares[] = $shareByCircle; |
|
278 | - } |
|
279 | - |
|
280 | - return $shares; |
|
281 | - } |
|
155 | + $appManager = $this->serverContainer->getAppManager(); |
|
156 | + if (!$appManager->isEnabledForUser('sharebymail')) { |
|
157 | + return null; |
|
158 | + } |
|
159 | + |
|
160 | + $settingsManager = new SettingsManager($this->serverContainer->getConfig()); |
|
161 | + |
|
162 | + $this->shareByMailProvider = new ShareByMailProvider( |
|
163 | + $this->serverContainer->getDatabaseConnection(), |
|
164 | + $this->serverContainer->getSecureRandom(), |
|
165 | + $this->serverContainer->getUserManager(), |
|
166 | + $this->serverContainer->getLazyRootFolder(), |
|
167 | + $this->serverContainer->getL10N('sharebymail'), |
|
168 | + $this->serverContainer->getLogger(), |
|
169 | + $this->serverContainer->getMailer(), |
|
170 | + $this->serverContainer->getURLGenerator(), |
|
171 | + $this->serverContainer->getActivityManager(), |
|
172 | + $settingsManager, |
|
173 | + $this->serverContainer->query(Defaults::class), |
|
174 | + $this->serverContainer->getHasher(), |
|
175 | + $this->serverContainer->query(CapabilitiesManager::class) |
|
176 | + ); |
|
177 | + } |
|
178 | + |
|
179 | + return $this->shareByMailProvider; |
|
180 | + } |
|
181 | + |
|
182 | + |
|
183 | + /** |
|
184 | + * Create the circle share provider |
|
185 | + * |
|
186 | + * @return FederatedShareProvider |
|
187 | + * |
|
188 | + * @suppress PhanUndeclaredClassMethod |
|
189 | + */ |
|
190 | + protected function getShareByCircleProvider() { |
|
191 | + |
|
192 | + if ($this->circlesAreNotAvailable) { |
|
193 | + return null; |
|
194 | + } |
|
195 | + |
|
196 | + if (!$this->serverContainer->getAppManager()->isEnabledForUser('circles') || |
|
197 | + !class_exists('\OCA\Circles\ShareByCircleProvider') |
|
198 | + ) { |
|
199 | + $this->circlesAreNotAvailable = true; |
|
200 | + return null; |
|
201 | + } |
|
202 | + |
|
203 | + if ($this->shareByCircleProvider === null) { |
|
204 | + |
|
205 | + $this->shareByCircleProvider = new \OCA\Circles\ShareByCircleProvider( |
|
206 | + $this->serverContainer->getDatabaseConnection(), |
|
207 | + $this->serverContainer->getSecureRandom(), |
|
208 | + $this->serverContainer->getUserManager(), |
|
209 | + $this->serverContainer->getLazyRootFolder(), |
|
210 | + $this->serverContainer->getL10N('circles'), |
|
211 | + $this->serverContainer->getLogger(), |
|
212 | + $this->serverContainer->getURLGenerator() |
|
213 | + ); |
|
214 | + } |
|
215 | + |
|
216 | + return $this->shareByCircleProvider; |
|
217 | + } |
|
218 | + |
|
219 | + |
|
220 | + /** |
|
221 | + * @inheritdoc |
|
222 | + */ |
|
223 | + public function getProvider($id) { |
|
224 | + $provider = null; |
|
225 | + if ($id === 'ocinternal') { |
|
226 | + $provider = $this->defaultShareProvider(); |
|
227 | + } else if ($id === 'ocFederatedSharing') { |
|
228 | + $provider = $this->federatedShareProvider(); |
|
229 | + } else if ($id === 'ocMailShare') { |
|
230 | + $provider = $this->getShareByMailProvider(); |
|
231 | + } else if ($id === 'ocCircleShare') { |
|
232 | + $provider = $this->getShareByCircleProvider(); |
|
233 | + } |
|
234 | + |
|
235 | + if ($provider === null) { |
|
236 | + throw new ProviderException('No provider with id .' . $id . ' found.'); |
|
237 | + } |
|
238 | + |
|
239 | + return $provider; |
|
240 | + } |
|
241 | + |
|
242 | + /** |
|
243 | + * @inheritdoc |
|
244 | + */ |
|
245 | + public function getProviderForType($shareType) { |
|
246 | + $provider = null; |
|
247 | + |
|
248 | + if ($shareType === \OCP\Share::SHARE_TYPE_USER || |
|
249 | + $shareType === \OCP\Share::SHARE_TYPE_GROUP || |
|
250 | + $shareType === \OCP\Share::SHARE_TYPE_LINK |
|
251 | + ) { |
|
252 | + $provider = $this->defaultShareProvider(); |
|
253 | + } else if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE) { |
|
254 | + $provider = $this->federatedShareProvider(); |
|
255 | + } else if ($shareType === \OCP\Share::SHARE_TYPE_EMAIL) { |
|
256 | + $provider = $this->getShareByMailProvider(); |
|
257 | + } else if ($shareType === \OCP\Share::SHARE_TYPE_CIRCLE) { |
|
258 | + $provider = $this->getShareByCircleProvider(); |
|
259 | + } |
|
260 | + |
|
261 | + |
|
262 | + if ($provider === null) { |
|
263 | + throw new ProviderException('No share provider for share type ' . $shareType); |
|
264 | + } |
|
265 | + |
|
266 | + return $provider; |
|
267 | + } |
|
268 | + |
|
269 | + public function getAllProviders() { |
|
270 | + $shares = [$this->defaultShareProvider(), $this->federatedShareProvider()]; |
|
271 | + $shareByMail = $this->getShareByMailProvider(); |
|
272 | + if ($shareByMail !== null) { |
|
273 | + $shares[] = $shareByMail; |
|
274 | + } |
|
275 | + $shareByCircle = $this->getShareByCircleProvider(); |
|
276 | + if ($shareByCircle !== null) { |
|
277 | + $shares[] = $shareByCircle; |
|
278 | + } |
|
279 | + |
|
280 | + return $shares; |
|
281 | + } |
|
282 | 282 | } |
@@ -29,11 +29,11 @@ |
||
29 | 29 | $isEnabled = $server->getAppManager()->isEnabledForUser('cloud_federation_api'); |
30 | 30 | |
31 | 31 | if ($isEnabled) { |
32 | - $capabilities = new OCA\CloudFederationAPI\Capabilities($server->getURLGenerator()); |
|
33 | - header('Content-Type: application/json'); |
|
34 | - echo json_encode($capabilities->getCapabilities()['ocm']); |
|
32 | + $capabilities = new OCA\CloudFederationAPI\Capabilities($server->getURLGenerator()); |
|
33 | + header('Content-Type: application/json'); |
|
34 | + echo json_encode($capabilities->getCapabilities()['ocm']); |
|
35 | 35 | } else { |
36 | - header($_SERVER["SERVER_PROTOCOL"]." 501 Not Implemented", true, 501); |
|
37 | - exit("501 Not Implemented"); |
|
36 | + header($_SERVER["SERVER_PROTOCOL"]." 501 Not Implemented", true, 501); |
|
37 | + exit("501 Not Implemented"); |
|
38 | 38 | } |
39 | 39 |
@@ -20,7 +20,7 @@ |
||
20 | 20 | */ |
21 | 21 | |
22 | 22 | |
23 | -require_once __DIR__ . '/../lib/base.php'; |
|
23 | +require_once __DIR__.'/../lib/base.php'; |
|
24 | 24 | |
25 | 25 | header('Content-Type: application/json'); |
26 | 26 |
@@ -6,39 +6,39 @@ |
||
6 | 6 | |
7 | 7 | class ComposerStaticInitFederatedFileSharing |
8 | 8 | { |
9 | - public static $prefixLengthsPsr4 = array ( |
|
9 | + public static $prefixLengthsPsr4 = array( |
|
10 | 10 | 'O' => |
11 | - array ( |
|
11 | + array( |
|
12 | 12 | 'OCA\\FederatedFileSharing\\' => 25, |
13 | 13 | ), |
14 | 14 | ); |
15 | 15 | |
16 | - public static $prefixDirsPsr4 = array ( |
|
16 | + public static $prefixDirsPsr4 = array( |
|
17 | 17 | 'OCA\\FederatedFileSharing\\' => |
18 | - array ( |
|
19 | - 0 => __DIR__ . '/..' . '/../lib', |
|
18 | + array( |
|
19 | + 0 => __DIR__.'/..'.'/../lib', |
|
20 | 20 | ), |
21 | 21 | ); |
22 | 22 | |
23 | - public static $classMap = array ( |
|
24 | - 'OCA\\FederatedFileSharing\\AddressHandler' => __DIR__ . '/..' . '/../lib/AddressHandler.php', |
|
25 | - 'OCA\\FederatedFileSharing\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php', |
|
26 | - 'OCA\\FederatedFileSharing\\BackgroundJob\\RetryJob' => __DIR__ . '/..' . '/../lib/BackgroundJob/RetryJob.php', |
|
27 | - 'OCA\\FederatedFileSharing\\Controller\\MountPublicLinkController' => __DIR__ . '/..' . '/../lib/Controller/MountPublicLinkController.php', |
|
28 | - 'OCA\\FederatedFileSharing\\Controller\\RequestHandlerController' => __DIR__ . '/..' . '/../lib/Controller/RequestHandlerController.php', |
|
29 | - 'OCA\\FederatedFileSharing\\FederatedShareProvider' => __DIR__ . '/..' . '/../lib/FederatedShareProvider.php', |
|
30 | - 'OCA\\FederatedFileSharing\\Notifications' => __DIR__ . '/..' . '/../lib/Notifications.php', |
|
31 | - 'OCA\\FederatedFileSharing\\Notifier' => __DIR__ . '/..' . '/../lib/Notifier.php', |
|
32 | - 'OCA\\FederatedFileSharing\\OCM\\CloudFederationProviderFiles' => __DIR__ . '/..' . '/../lib/ocm/CloudFederationProviderFiles.php', |
|
33 | - 'OCA\\FederatedFileSharing\\Settings\\Admin' => __DIR__ . '/..' . '/../lib/Settings/Admin.php', |
|
34 | - 'OCA\\FederatedFileSharing\\Settings\\Personal' => __DIR__ . '/..' . '/../lib/Settings/Personal.php', |
|
35 | - 'OCA\\FederatedFileSharing\\Settings\\PersonalSection' => __DIR__ . '/..' . '/../lib/Settings/PersonalSection.php', |
|
36 | - 'OCA\\FederatedFileSharing\\TokenHandler' => __DIR__ . '/..' . '/../lib/TokenHandler.php', |
|
23 | + public static $classMap = array( |
|
24 | + 'OCA\\FederatedFileSharing\\AddressHandler' => __DIR__.'/..'.'/../lib/AddressHandler.php', |
|
25 | + 'OCA\\FederatedFileSharing\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php', |
|
26 | + 'OCA\\FederatedFileSharing\\BackgroundJob\\RetryJob' => __DIR__.'/..'.'/../lib/BackgroundJob/RetryJob.php', |
|
27 | + 'OCA\\FederatedFileSharing\\Controller\\MountPublicLinkController' => __DIR__.'/..'.'/../lib/Controller/MountPublicLinkController.php', |
|
28 | + 'OCA\\FederatedFileSharing\\Controller\\RequestHandlerController' => __DIR__.'/..'.'/../lib/Controller/RequestHandlerController.php', |
|
29 | + 'OCA\\FederatedFileSharing\\FederatedShareProvider' => __DIR__.'/..'.'/../lib/FederatedShareProvider.php', |
|
30 | + 'OCA\\FederatedFileSharing\\Notifications' => __DIR__.'/..'.'/../lib/Notifications.php', |
|
31 | + 'OCA\\FederatedFileSharing\\Notifier' => __DIR__.'/..'.'/../lib/Notifier.php', |
|
32 | + 'OCA\\FederatedFileSharing\\OCM\\CloudFederationProviderFiles' => __DIR__.'/..'.'/../lib/ocm/CloudFederationProviderFiles.php', |
|
33 | + 'OCA\\FederatedFileSharing\\Settings\\Admin' => __DIR__.'/..'.'/../lib/Settings/Admin.php', |
|
34 | + 'OCA\\FederatedFileSharing\\Settings\\Personal' => __DIR__.'/..'.'/../lib/Settings/Personal.php', |
|
35 | + 'OCA\\FederatedFileSharing\\Settings\\PersonalSection' => __DIR__.'/..'.'/../lib/Settings/PersonalSection.php', |
|
36 | + 'OCA\\FederatedFileSharing\\TokenHandler' => __DIR__.'/..'.'/../lib/TokenHandler.php', |
|
37 | 37 | ); |
38 | 38 | |
39 | 39 | public static function getInitializer(ClassLoader $loader) |
40 | 40 | { |
41 | - return \Closure::bind(function () use ($loader) { |
|
41 | + return \Closure::bind(function() use ($loader) { |
|
42 | 42 | $loader->prefixLengthsPsr4 = ComposerStaticInitFederatedFileSharing::$prefixLengthsPsr4; |
43 | 43 | $loader->prefixDirsPsr4 = ComposerStaticInitFederatedFileSharing::$prefixDirsPsr4; |
44 | 44 | $loader->classMap = ComposerStaticInitFederatedFileSharing::$classMap; |
@@ -6,17 +6,17 @@ |
||
6 | 6 | $baseDir = $vendorDir; |
7 | 7 | |
8 | 8 | return array( |
9 | - 'OCA\\FederatedFileSharing\\AddressHandler' => $baseDir . '/../lib/AddressHandler.php', |
|
10 | - 'OCA\\FederatedFileSharing\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php', |
|
11 | - 'OCA\\FederatedFileSharing\\BackgroundJob\\RetryJob' => $baseDir . '/../lib/BackgroundJob/RetryJob.php', |
|
12 | - 'OCA\\FederatedFileSharing\\Controller\\MountPublicLinkController' => $baseDir . '/../lib/Controller/MountPublicLinkController.php', |
|
13 | - 'OCA\\FederatedFileSharing\\Controller\\RequestHandlerController' => $baseDir . '/../lib/Controller/RequestHandlerController.php', |
|
14 | - 'OCA\\FederatedFileSharing\\FederatedShareProvider' => $baseDir . '/../lib/FederatedShareProvider.php', |
|
15 | - 'OCA\\FederatedFileSharing\\Notifications' => $baseDir . '/../lib/Notifications.php', |
|
16 | - 'OCA\\FederatedFileSharing\\Notifier' => $baseDir . '/../lib/Notifier.php', |
|
17 | - 'OCA\\FederatedFileSharing\\OCM\\CloudFederationProviderFiles' => $baseDir . '/../lib/ocm/CloudFederationProviderFiles.php', |
|
18 | - 'OCA\\FederatedFileSharing\\Settings\\Admin' => $baseDir . '/../lib/Settings/Admin.php', |
|
19 | - 'OCA\\FederatedFileSharing\\Settings\\Personal' => $baseDir . '/../lib/Settings/Personal.php', |
|
20 | - 'OCA\\FederatedFileSharing\\Settings\\PersonalSection' => $baseDir . '/../lib/Settings/PersonalSection.php', |
|
21 | - 'OCA\\FederatedFileSharing\\TokenHandler' => $baseDir . '/../lib/TokenHandler.php', |
|
9 | + 'OCA\\FederatedFileSharing\\AddressHandler' => $baseDir.'/../lib/AddressHandler.php', |
|
10 | + 'OCA\\FederatedFileSharing\\AppInfo\\Application' => $baseDir.'/../lib/AppInfo/Application.php', |
|
11 | + 'OCA\\FederatedFileSharing\\BackgroundJob\\RetryJob' => $baseDir.'/../lib/BackgroundJob/RetryJob.php', |
|
12 | + 'OCA\\FederatedFileSharing\\Controller\\MountPublicLinkController' => $baseDir.'/../lib/Controller/MountPublicLinkController.php', |
|
13 | + 'OCA\\FederatedFileSharing\\Controller\\RequestHandlerController' => $baseDir.'/../lib/Controller/RequestHandlerController.php', |
|
14 | + 'OCA\\FederatedFileSharing\\FederatedShareProvider' => $baseDir.'/../lib/FederatedShareProvider.php', |
|
15 | + 'OCA\\FederatedFileSharing\\Notifications' => $baseDir.'/../lib/Notifications.php', |
|
16 | + 'OCA\\FederatedFileSharing\\Notifier' => $baseDir.'/../lib/Notifier.php', |
|
17 | + 'OCA\\FederatedFileSharing\\OCM\\CloudFederationProviderFiles' => $baseDir.'/../lib/ocm/CloudFederationProviderFiles.php', |
|
18 | + 'OCA\\FederatedFileSharing\\Settings\\Admin' => $baseDir.'/../lib/Settings/Admin.php', |
|
19 | + 'OCA\\FederatedFileSharing\\Settings\\Personal' => $baseDir.'/../lib/Settings/Personal.php', |
|
20 | + 'OCA\\FederatedFileSharing\\Settings\\PersonalSection' => $baseDir.'/../lib/Settings/PersonalSection.php', |
|
21 | + 'OCA\\FederatedFileSharing\\TokenHandler' => $baseDir.'/../lib/TokenHandler.php', |
|
22 | 22 | ); |
@@ -32,15 +32,15 @@ |
||
32 | 32 | */ |
33 | 33 | class Config { |
34 | 34 | |
35 | - public function __construct() { |
|
36 | - } |
|
35 | + public function __construct() { |
|
36 | + } |
|
37 | 37 | |
38 | - public function incomingRequestsEnabled() { |
|
39 | - return true; |
|
40 | - } |
|
38 | + public function incomingRequestsEnabled() { |
|
39 | + return true; |
|
40 | + } |
|
41 | 41 | |
42 | - public function outgoingRequestsEnabled() { |
|
43 | - return true; |
|
44 | - } |
|
42 | + public function outgoingRequestsEnabled() { |
|
43 | + return true; |
|
44 | + } |
|
45 | 45 | |
46 | 46 | } |
@@ -28,10 +28,10 @@ |
||
28 | 28 | |
29 | 29 | class Application extends App { |
30 | 30 | |
31 | - public function __construct() { |
|
32 | - parent::__construct('cloud_federation_api'); |
|
31 | + public function __construct() { |
|
32 | + parent::__construct('cloud_federation_api'); |
|
33 | 33 | |
34 | - $container = $this->getContainer(); |
|
35 | - $container->registerCapability(Capabilities::class); |
|
36 | - } |
|
34 | + $container = $this->getContainer(); |
|
35 | + $container->registerCapability(Capabilities::class); |
|
36 | + } |
|
37 | 37 | } |
@@ -26,9 +26,9 @@ |
||
26 | 26 | |
27 | 27 | class ProviderCouldNotAddShareException extends HintException { |
28 | 28 | |
29 | - public function __construct($message, $hint = '', $code = Http::STATUS_BAD_REQUEST, \Exception $previous = null) { |
|
30 | - parent::__construct($message, $hint, $code, $previous); |
|
31 | - } |
|
29 | + public function __construct($message, $hint = '', $code = Http::STATUS_BAD_REQUEST, \Exception $previous = null) { |
|
30 | + parent::__construct($message, $hint, $code, $previous); |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | 34 | } |
@@ -25,16 +25,16 @@ |
||
25 | 25 | |
26 | 26 | class ProviderDoesNotExistsException extends HintException { |
27 | 27 | |
28 | - /** |
|
29 | - * ProviderDoesNotExistsException constructor. |
|
30 | - * |
|
31 | - * @param string $providerId cloud federation provider ID |
|
32 | - */ |
|
33 | - public function __construct($providerId) { |
|
34 | - $l = \OC::$server->getL10N('federation'); |
|
35 | - $message = 'Cloud Federation Provider with ID: "' . $providerId . '" does not exist.'; |
|
36 | - $hint = $l->t('Cloud Federation Provider with ID: "%s" does not exist.', [$providerId]); |
|
37 | - parent::__construct($message, $hint); |
|
38 | - } |
|
28 | + /** |
|
29 | + * ProviderDoesNotExistsException constructor. |
|
30 | + * |
|
31 | + * @param string $providerId cloud federation provider ID |
|
32 | + */ |
|
33 | + public function __construct($providerId) { |
|
34 | + $l = \OC::$server->getL10N('federation'); |
|
35 | + $message = 'Cloud Federation Provider with ID: "' . $providerId . '" does not exist.'; |
|
36 | + $hint = $l->t('Cloud Federation Provider with ID: "%s" does not exist.', [$providerId]); |
|
37 | + parent::__construct($message, $hint); |
|
38 | + } |
|
39 | 39 | |
40 | 40 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | */ |
33 | 33 | public function __construct($providerId) { |
34 | 34 | $l = \OC::$server->getL10N('federation'); |
35 | - $message = 'Cloud Federation Provider with ID: "' . $providerId . '" does not exist.'; |
|
35 | + $message = 'Cloud Federation Provider with ID: "'.$providerId.'" does not exist.'; |
|
36 | 36 | $hint = $l->t('Cloud Federation Provider with ID: "%s" does not exist.', [$providerId]); |
37 | 37 | parent::__construct($message, $hint); |
38 | 38 | } |