Completed
Pull Request — master (#9345)
by Björn
23:58
created
lib/public/Federation/Exceptions/ProviderDoesNotExistsException.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -32,18 +32,18 @@
 block discarded – undo
32 32
  */
33 33
 class ProviderDoesNotExistsException extends HintException {
34 34
 
35
-	/**
36
-	 * ProviderDoesNotExistsException constructor.
37
-	 *
38
-	 * @since 14.0.0
39
-	 *
40
-	 * @param string $providerId cloud federation provider ID
41
-	 */
42
-	public function __construct($providerId) {
43
-		$l = \OC::$server->getL10N('federation');
44
-		$message = 'Cloud Federation Provider with ID: "' . $providerId . '" does not exist.';
45
-		$hint = $l->t('Cloud Federation Provider with ID: "%s" does not exist.', [$providerId]);
46
-		parent::__construct($message, $hint);
47
-	}
35
+    /**
36
+     * ProviderDoesNotExistsException constructor.
37
+     *
38
+     * @since 14.0.0
39
+     *
40
+     * @param string $providerId cloud federation provider ID
41
+     */
42
+    public function __construct($providerId) {
43
+        $l = \OC::$server->getL10N('federation');
44
+        $message = 'Cloud Federation Provider with ID: "' . $providerId . '" does not exist.';
45
+        $hint = $l->t('Cloud Federation Provider with ID: "%s" does not exist.', [$providerId]);
46
+        parent::__construct($message, $hint);
47
+    }
48 48
 
49 49
 }
Please login to merge, or discard this patch.
lib/public/Federation/Exceptions/ActionNotSupportedException.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -32,17 +32,17 @@
 block discarded – undo
32 32
  */
33 33
 class ActionNotSupportedException extends HintException {
34 34
 
35
-	/**
36
-	 * ActionNotSupportedException constructor.
37
-	 *
38
-	 * @since 14.0.0
39
-	 *
40
-	 */
41
-	public function __construct($action) {
42
-		$l = \OC::$server->getL10N('federation');
43
-		$message = 'Action "' . $action . '" not supported or implemented.';
44
-		$hint = $l->t('Action "%s" not supported or implemented.', [$action]);
45
-		parent::__construct($message, $hint);
46
-	}
35
+    /**
36
+     * ActionNotSupportedException constructor.
37
+     *
38
+     * @since 14.0.0
39
+     *
40
+     */
41
+    public function __construct($action) {
42
+        $l = \OC::$server->getL10N('federation');
43
+        $message = 'Action "' . $action . '" not supported or implemented.';
44
+        $hint = $l->t('Action "%s" not supported or implemented.', [$action]);
45
+        parent::__construct($message, $hint);
46
+    }
47 47
 
48 48
 }
Please login to merge, or discard this patch.
lib/public/Federation/ICloudFederationFactory.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -30,33 +30,33 @@
 block discarded – undo
30 30
  */
31 31
 interface ICloudFederationFactory {
32 32
 
33
-	/**
34
-	 * get a CloudFederationShare Object to prepare a share you want to send
35
-	 *
36
-	 * @param string $shareWith
37
-	 * @param string $name resource name (e.g. document.odt)
38
-	 * @param string $description share description (optional)
39
-	 * @param string $providerId resource UID on the provider side
40
-	 * @param string $owner provider specific UID of the user who owns the resource
41
-	 * @param string $ownerDisplayName display name of the user who shared the item
42
-	 * @param string $sharedBy provider specific UID of the user who shared the resource
43
-	 * @param string $sharedByDisplayName display name of the user who shared the resource
44
-	 * @param string $sharedSecret used to authenticate requests across servers
45
-	 * @param string $shareType ('group' or 'user' share)
46
-	 * @param $resourceType ('file', 'calendar',...)
47
-	 * @return ICloudFederationShare
48
-	 *
49
-	 * @since 14.0.0
50
-	 */
51
-	public function getCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $sharedSecret, $shareType, $resourceType);
33
+    /**
34
+     * get a CloudFederationShare Object to prepare a share you want to send
35
+     *
36
+     * @param string $shareWith
37
+     * @param string $name resource name (e.g. document.odt)
38
+     * @param string $description share description (optional)
39
+     * @param string $providerId resource UID on the provider side
40
+     * @param string $owner provider specific UID of the user who owns the resource
41
+     * @param string $ownerDisplayName display name of the user who shared the item
42
+     * @param string $sharedBy provider specific UID of the user who shared the resource
43
+     * @param string $sharedByDisplayName display name of the user who shared the resource
44
+     * @param string $sharedSecret used to authenticate requests across servers
45
+     * @param string $shareType ('group' or 'user' share)
46
+     * @param $resourceType ('file', 'calendar',...)
47
+     * @return ICloudFederationShare
48
+     *
49
+     * @since 14.0.0
50
+     */
51
+    public function getCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $sharedSecret, $shareType, $resourceType);
52 52
 
53
-	/**
54
-	 * get a Cloud FederationNotification object to prepare a notification you
55
-	 * want to send
56
-	 *
57
-	 * @return ICloudFederationNotification
58
-	 *
59
-	 * @since 14.0.0
60
-	 */
61
-	public function getCloudFederationNotification();
53
+    /**
54
+     * get a Cloud FederationNotification object to prepare a notification you
55
+     * want to send
56
+     *
57
+     * @return ICloudFederationNotification
58
+     *
59
+     * @since 14.0.0
60
+     */
61
+    public function getCloudFederationNotification();
62 62
 }
Please login to merge, or discard this patch.
lib/public/IServerContainer.php 1 patch
Indentation   +506 added lines, -506 removed lines patch added patch discarded remove patch
@@ -60,510 +60,510 @@
 block discarded – undo
60 60
  */
61 61
 interface IServerContainer extends IContainer {
62 62
 
63
-	/**
64
-	 * The calendar manager will act as a broker between consumers for calendar information and
65
-	 * providers which actual deliver the calendar information.
66
-	 *
67
-	 * @return \OCP\Calendar\IManager
68
-	 * @since 13.0.0
69
-	 */
70
-	public function getCalendarManager();
71
-
72
-	/**
73
-	 * The contacts manager will act as a broker between consumers for contacts information and
74
-	 * providers which actual deliver the contact information.
75
-	 *
76
-	 * @return \OCP\Contacts\IManager
77
-	 * @since 6.0.0
78
-	 */
79
-	public function getContactsManager();
80
-
81
-	/**
82
-	 * The current request object holding all information about the request currently being processed
83
-	 * is returned from this method.
84
-	 * In case the current execution was not initiated by a web request null is returned
85
-	 *
86
-	 * @return \OCP\IRequest
87
-	 * @since 6.0.0
88
-	 */
89
-	public function getRequest();
90
-
91
-	/**
92
-	 * Returns the preview manager which can create preview images for a given file
93
-	 *
94
-	 * @return \OCP\IPreview
95
-	 * @since 6.0.0
96
-	 */
97
-	public function getPreviewManager();
98
-
99
-	/**
100
-	 * Returns the tag manager which can get and set tags for different object types
101
-	 *
102
-	 * @see \OCP\ITagManager::load()
103
-	 * @return \OCP\ITagManager
104
-	 * @since 6.0.0
105
-	 */
106
-	public function getTagManager();
107
-
108
-	/**
109
-	 * Returns the root folder of ownCloud's data directory
110
-	 *
111
-	 * @return \OCP\Files\IRootFolder
112
-	 * @since 6.0.0 - between 6.0.0 and 8.0.0 this returned \OCP\Files\Folder
113
-	 */
114
-	public function getRootFolder();
115
-
116
-	/**
117
-	 * Returns a view to ownCloud's files folder
118
-	 *
119
-	 * @param string $userId user ID
120
-	 * @return \OCP\Files\Folder
121
-	 * @since 6.0.0 - parameter $userId was added in 8.0.0
122
-	 * @see getUserFolder in \OCP\Files\IRootFolder
123
-	 */
124
-	public function getUserFolder($userId = null);
125
-
126
-	/**
127
-	 * Returns an app-specific view in ownClouds data directory
128
-	 *
129
-	 * @return \OCP\Files\Folder
130
-	 * @since 6.0.0
131
-	 * @deprecated 9.2.0 use IAppData
132
-	 */
133
-	public function getAppFolder();
134
-
135
-	/**
136
-	 * Returns a user manager
137
-	 *
138
-	 * @return \OCP\IUserManager
139
-	 * @since 8.0.0
140
-	 */
141
-	public function getUserManager();
142
-
143
-	/**
144
-	 * Returns a group manager
145
-	 *
146
-	 * @return \OCP\IGroupManager
147
-	 * @since 8.0.0
148
-	 */
149
-	public function getGroupManager();
150
-
151
-	/**
152
-	 * Returns the user session
153
-	 *
154
-	 * @return \OCP\IUserSession
155
-	 * @since 6.0.0
156
-	 */
157
-	public function getUserSession();
158
-
159
-	/**
160
-	 * Returns the navigation manager
161
-	 *
162
-	 * @return \OCP\INavigationManager
163
-	 * @since 6.0.0
164
-	 */
165
-	public function getNavigationManager();
166
-
167
-	/**
168
-	 * Returns the config manager
169
-	 *
170
-	 * @return \OCP\IConfig
171
-	 * @since 6.0.0
172
-	 */
173
-	public function getConfig();
174
-
175
-	/**
176
-	 * Returns a Crypto instance
177
-	 *
178
-	 * @return \OCP\Security\ICrypto
179
-	 * @since 8.0.0
180
-	 */
181
-	public function getCrypto();
182
-
183
-	/**
184
-	 * Returns a Hasher instance
185
-	 *
186
-	 * @return \OCP\Security\IHasher
187
-	 * @since 8.0.0
188
-	 */
189
-	public function getHasher();
190
-
191
-	/**
192
-	 * Returns a SecureRandom instance
193
-	 *
194
-	 * @return \OCP\Security\ISecureRandom
195
-	 * @since 8.1.0
196
-	 */
197
-	public function getSecureRandom();
198
-
199
-	/**
200
-	 * Returns a CredentialsManager instance
201
-	 *
202
-	 * @return \OCP\Security\ICredentialsManager
203
-	 * @since 9.0.0
204
-	 */
205
-	public function getCredentialsManager();
206
-
207
-	/**
208
-	 * Returns the app config manager
209
-	 *
210
-	 * @return \OCP\IAppConfig
211
-	 * @since 7.0.0
212
-	 */
213
-	public function getAppConfig();
214
-
215
-	/**
216
-	 * @return \OCP\L10N\IFactory
217
-	 * @since 8.2.0
218
-	 */
219
-	public function getL10NFactory();
220
-
221
-	/**
222
-	 * get an L10N instance
223
-	 * @param string $app appid
224
-	 * @param string $lang
225
-	 * @return \OCP\IL10N
226
-	 * @since 6.0.0 - parameter $lang was added in 8.0.0
227
-	 */
228
-	public function getL10N($app, $lang = null);
229
-
230
-	/**
231
-	 * @return \OC\Encryption\Manager
232
-	 * @since 8.1.0
233
-	 */
234
-	public function getEncryptionManager();
235
-
236
-	/**
237
-	 * @return \OC\Encryption\File
238
-	 * @since 8.1.0
239
-	 */
240
-	public function getEncryptionFilesHelper();
241
-
242
-	/**
243
-	 * @return \OCP\Encryption\Keys\IStorage
244
-	 * @since 8.1.0
245
-	 */
246
-	public function getEncryptionKeyStorage();
247
-
248
-	/**
249
-	 * Returns the URL generator
250
-	 *
251
-	 * @return \OCP\IURLGenerator
252
-	 * @since 6.0.0
253
-	 */
254
-	public function getURLGenerator();
255
-
256
-	/**
257
-	 * Returns an ICache instance
258
-	 *
259
-	 * @return \OCP\ICache
260
-	 * @since 6.0.0
261
-	 */
262
-	public function getCache();
263
-
264
-	/**
265
-	 * Returns an \OCP\CacheFactory instance
266
-	 *
267
-	 * @return \OCP\ICacheFactory
268
-	 * @since 7.0.0
269
-	 */
270
-	public function getMemCacheFactory();
271
-
272
-	/**
273
-	 * Returns the current session
274
-	 *
275
-	 * @return \OCP\ISession
276
-	 * @since 6.0.0
277
-	 */
278
-	public function getSession();
279
-
280
-	/**
281
-	 * Returns the activity manager
282
-	 *
283
-	 * @return \OCP\Activity\IManager
284
-	 * @since 6.0.0
285
-	 */
286
-	public function getActivityManager();
287
-
288
-	/**
289
-	 * Returns the current session
290
-	 *
291
-	 * @return \OCP\IDBConnection
292
-	 * @since 6.0.0
293
-	 */
294
-	public function getDatabaseConnection();
295
-
296
-	/**
297
-	 * Returns an avatar manager, used for avatar functionality
298
-	 *
299
-	 * @return \OCP\IAvatarManager
300
-	 * @since 6.0.0
301
-	 */
302
-	public function getAvatarManager();
303
-
304
-	/**
305
-	 * Returns an job list for controlling background jobs
306
-	 *
307
-	 * @return \OCP\BackgroundJob\IJobList
308
-	 * @since 7.0.0
309
-	 */
310
-	public function getJobList();
311
-
312
-	/**
313
-	 * Returns a logger instance
314
-	 *
315
-	 * @return \OCP\ILogger
316
-	 * @since 8.0.0
317
-	 */
318
-	public function getLogger();
319
-
320
-	/**
321
-	 * returns a log factory instance
322
-	 *
323
-	 * @return ILogFactory
324
-	 * @since 14.0.0
325
-	 */
326
-	public function getLogFactory();
327
-
328
-	/**
329
-	 * Returns a router for generating and matching urls
330
-	 *
331
-	 * @return \OCP\Route\IRouter
332
-	 * @since 7.0.0
333
-	 */
334
-	public function getRouter();
335
-
336
-	/**
337
-	 * Returns a search instance
338
-	 *
339
-	 * @return \OCP\ISearch
340
-	 * @since 7.0.0
341
-	 */
342
-	public function getSearch();
343
-
344
-	/**
345
-	 * Get the certificate manager for the user
346
-	 *
347
-	 * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
348
-	 * @return \OCP\ICertificateManager | null if $userId is null and no user is logged in
349
-	 * @since 8.0.0
350
-	 */
351
-	public function getCertificateManager($userId = null);
352
-
353
-	/**
354
-	 * Create a new event source
355
-	 *
356
-	 * @return \OCP\IEventSource
357
-	 * @since 8.0.0
358
-	 */
359
-	public function createEventSource();
360
-
361
-	/**
362
-	 * Returns an instance of the HTTP client service
363
-	 *
364
-	 * @return \OCP\Http\Client\IClientService
365
-	 * @since 8.1.0
366
-	 */
367
-	public function getHTTPClientService();
368
-
369
-	/**
370
-	 * Get the active event logger
371
-	 *
372
-	 * @return \OCP\Diagnostics\IEventLogger
373
-	 * @since 8.0.0
374
-	 */
375
-	public function getEventLogger();
376
-
377
-	/**
378
-	 * Get the active query logger
379
-	 *
380
-	 * The returned logger only logs data when debug mode is enabled
381
-	 *
382
-	 * @return \OCP\Diagnostics\IQueryLogger
383
-	 * @since 8.0.0
384
-	 */
385
-	public function getQueryLogger();
386
-
387
-	/**
388
-	 * Get the manager for temporary files and folders
389
-	 *
390
-	 * @return \OCP\ITempManager
391
-	 * @since 8.0.0
392
-	 */
393
-	public function getTempManager();
394
-
395
-	/**
396
-	 * Get the app manager
397
-	 *
398
-	 * @return \OCP\App\IAppManager
399
-	 * @since 8.0.0
400
-	 */
401
-	public function getAppManager();
402
-
403
-	/**
404
-	 * Get the webroot
405
-	 *
406
-	 * @return string
407
-	 * @since 8.0.0
408
-	 */
409
-	public function getWebRoot();
410
-
411
-	/**
412
-	 * @return \OCP\Files\Config\IMountProviderCollection
413
-	 * @since 8.0.0
414
-	 */
415
-	public function getMountProviderCollection();
416
-
417
-	/**
418
-	 * Get the IniWrapper
419
-	 *
420
-	 * @return \bantu\IniGetWrapper\IniGetWrapper
421
-	 * @since 8.0.0
422
-	 */
423
-	public function getIniWrapper();
424
-	/**
425
-	 * @return \OCP\Command\IBus
426
-	 * @since 8.1.0
427
-	 */
428
-	public function getCommandBus();
429
-
430
-	/**
431
-	 * Creates a new mailer
432
-	 *
433
-	 * @return \OCP\Mail\IMailer
434
-	 * @since 8.1.0
435
-	 */
436
-	public function getMailer();
437
-
438
-	/**
439
-	 * Get the locking provider
440
-	 *
441
-	 * @return \OCP\Lock\ILockingProvider
442
-	 * @since 8.1.0
443
-	 */
444
-	public function getLockingProvider();
445
-
446
-	/**
447
-	 * @return \OCP\Files\Mount\IMountManager
448
-	 * @since 8.2.0
449
-	 */
450
-	public function getMountManager();
451
-
452
-	/**
453
-	 * Get the MimeTypeDetector
454
-	 *
455
-	 * @return \OCP\Files\IMimeTypeDetector
456
-	 * @since 8.2.0
457
-	 */
458
-	public function getMimeTypeDetector();
459
-
460
-	/**
461
-	 * Get the MimeTypeLoader
462
-	 *
463
-	 * @return \OCP\Files\IMimeTypeLoader
464
-	 * @since 8.2.0
465
-	 */
466
-	public function getMimeTypeLoader();
467
-
468
-	/**
469
-	 * Get the EventDispatcher
470
-	 *
471
-	 * @return EventDispatcherInterface
472
-	 * @since 8.2.0
473
-	 */
474
-	public function getEventDispatcher();
475
-
476
-	/**
477
-	 * Get the Notification Manager
478
-	 *
479
-	 * @return \OCP\Notification\IManager
480
-	 * @since 9.0.0
481
-	 */
482
-	public function getNotificationManager();
483
-
484
-	/**
485
-	 * @return \OCP\Comments\ICommentsManager
486
-	 * @since 9.0.0
487
-	 */
488
-	public function getCommentsManager();
489
-
490
-	/**
491
-	 * Returns the system-tag manager
492
-	 *
493
-	 * @return \OCP\SystemTag\ISystemTagManager
494
-	 *
495
-	 * @since 9.0.0
496
-	 */
497
-	public function getSystemTagManager();
498
-
499
-	/**
500
-	 * Returns the system-tag object mapper
501
-	 *
502
-	 * @return \OCP\SystemTag\ISystemTagObjectMapper
503
-	 *
504
-	 * @since 9.0.0
505
-	 */
506
-	public function getSystemTagObjectMapper();
507
-
508
-	/**
509
-	 * Returns the share manager
510
-	 *
511
-	 * @return \OCP\Share\IManager
512
-	 * @since 9.0.0
513
-	 */
514
-	public function getShareManager();
515
-
516
-	/**
517
-	 * @return IContentSecurityPolicyManager
518
-	 * @since 9.0.0
519
-	 */
520
-	public function getContentSecurityPolicyManager();
521
-
522
-	/**
523
-	 * @return \OCP\IDateTimeZone
524
-	 * @since 8.0.0
525
-	 */
526
-	public function getDateTimeZone();
527
-
528
-	/**
529
-	 * @return \OCP\IDateTimeFormatter
530
-	 * @since 8.0.0
531
-	 */
532
-	public function getDateTimeFormatter();
533
-
534
-	/**
535
-	 * @return \OCP\Federation\ICloudIdManager
536
-	 * @since 12.0.0
537
-	 */
538
-	public function getCloudIdManager();
539
-
540
-	/**
541
-	 * @return \OCP\GlobalScale\IConfig
542
-	 * @since 14.0.0
543
-	 */
544
-	public function getGlobalScaleConfig();
545
-
546
-	/**
547
-	 * @return ICloudFederationFactory
548
-	 * @since 14.0.0
549
-	 */
550
-	public function getCloudFederationFactory();
551
-
552
-	/**
553
-	 * @return ICloudFederationProviderManager
554
-	 * @since 14.0.0
555
-	 */
556
-	public function getCloudFederationProviderManager();
557
-
558
-	/**
559
-	 * @return \OCP\Remote\Api\IApiFactory
560
-	 * @since 13.0.0
561
-	 */
562
-	public function getRemoteApiFactory();
563
-
564
-	/**
565
-	 * @return \OCP\Remote\IInstanceFactory
566
-	 * @since 13.0.0
567
-	 */
568
-	public function getRemoteInstanceFactory();
63
+    /**
64
+     * The calendar manager will act as a broker between consumers for calendar information and
65
+     * providers which actual deliver the calendar information.
66
+     *
67
+     * @return \OCP\Calendar\IManager
68
+     * @since 13.0.0
69
+     */
70
+    public function getCalendarManager();
71
+
72
+    /**
73
+     * The contacts manager will act as a broker between consumers for contacts information and
74
+     * providers which actual deliver the contact information.
75
+     *
76
+     * @return \OCP\Contacts\IManager
77
+     * @since 6.0.0
78
+     */
79
+    public function getContactsManager();
80
+
81
+    /**
82
+     * The current request object holding all information about the request currently being processed
83
+     * is returned from this method.
84
+     * In case the current execution was not initiated by a web request null is returned
85
+     *
86
+     * @return \OCP\IRequest
87
+     * @since 6.0.0
88
+     */
89
+    public function getRequest();
90
+
91
+    /**
92
+     * Returns the preview manager which can create preview images for a given file
93
+     *
94
+     * @return \OCP\IPreview
95
+     * @since 6.0.0
96
+     */
97
+    public function getPreviewManager();
98
+
99
+    /**
100
+     * Returns the tag manager which can get and set tags for different object types
101
+     *
102
+     * @see \OCP\ITagManager::load()
103
+     * @return \OCP\ITagManager
104
+     * @since 6.0.0
105
+     */
106
+    public function getTagManager();
107
+
108
+    /**
109
+     * Returns the root folder of ownCloud's data directory
110
+     *
111
+     * @return \OCP\Files\IRootFolder
112
+     * @since 6.0.0 - between 6.0.0 and 8.0.0 this returned \OCP\Files\Folder
113
+     */
114
+    public function getRootFolder();
115
+
116
+    /**
117
+     * Returns a view to ownCloud's files folder
118
+     *
119
+     * @param string $userId user ID
120
+     * @return \OCP\Files\Folder
121
+     * @since 6.0.0 - parameter $userId was added in 8.0.0
122
+     * @see getUserFolder in \OCP\Files\IRootFolder
123
+     */
124
+    public function getUserFolder($userId = null);
125
+
126
+    /**
127
+     * Returns an app-specific view in ownClouds data directory
128
+     *
129
+     * @return \OCP\Files\Folder
130
+     * @since 6.0.0
131
+     * @deprecated 9.2.0 use IAppData
132
+     */
133
+    public function getAppFolder();
134
+
135
+    /**
136
+     * Returns a user manager
137
+     *
138
+     * @return \OCP\IUserManager
139
+     * @since 8.0.0
140
+     */
141
+    public function getUserManager();
142
+
143
+    /**
144
+     * Returns a group manager
145
+     *
146
+     * @return \OCP\IGroupManager
147
+     * @since 8.0.0
148
+     */
149
+    public function getGroupManager();
150
+
151
+    /**
152
+     * Returns the user session
153
+     *
154
+     * @return \OCP\IUserSession
155
+     * @since 6.0.0
156
+     */
157
+    public function getUserSession();
158
+
159
+    /**
160
+     * Returns the navigation manager
161
+     *
162
+     * @return \OCP\INavigationManager
163
+     * @since 6.0.0
164
+     */
165
+    public function getNavigationManager();
166
+
167
+    /**
168
+     * Returns the config manager
169
+     *
170
+     * @return \OCP\IConfig
171
+     * @since 6.0.0
172
+     */
173
+    public function getConfig();
174
+
175
+    /**
176
+     * Returns a Crypto instance
177
+     *
178
+     * @return \OCP\Security\ICrypto
179
+     * @since 8.0.0
180
+     */
181
+    public function getCrypto();
182
+
183
+    /**
184
+     * Returns a Hasher instance
185
+     *
186
+     * @return \OCP\Security\IHasher
187
+     * @since 8.0.0
188
+     */
189
+    public function getHasher();
190
+
191
+    /**
192
+     * Returns a SecureRandom instance
193
+     *
194
+     * @return \OCP\Security\ISecureRandom
195
+     * @since 8.1.0
196
+     */
197
+    public function getSecureRandom();
198
+
199
+    /**
200
+     * Returns a CredentialsManager instance
201
+     *
202
+     * @return \OCP\Security\ICredentialsManager
203
+     * @since 9.0.0
204
+     */
205
+    public function getCredentialsManager();
206
+
207
+    /**
208
+     * Returns the app config manager
209
+     *
210
+     * @return \OCP\IAppConfig
211
+     * @since 7.0.0
212
+     */
213
+    public function getAppConfig();
214
+
215
+    /**
216
+     * @return \OCP\L10N\IFactory
217
+     * @since 8.2.0
218
+     */
219
+    public function getL10NFactory();
220
+
221
+    /**
222
+     * get an L10N instance
223
+     * @param string $app appid
224
+     * @param string $lang
225
+     * @return \OCP\IL10N
226
+     * @since 6.0.0 - parameter $lang was added in 8.0.0
227
+     */
228
+    public function getL10N($app, $lang = null);
229
+
230
+    /**
231
+     * @return \OC\Encryption\Manager
232
+     * @since 8.1.0
233
+     */
234
+    public function getEncryptionManager();
235
+
236
+    /**
237
+     * @return \OC\Encryption\File
238
+     * @since 8.1.0
239
+     */
240
+    public function getEncryptionFilesHelper();
241
+
242
+    /**
243
+     * @return \OCP\Encryption\Keys\IStorage
244
+     * @since 8.1.0
245
+     */
246
+    public function getEncryptionKeyStorage();
247
+
248
+    /**
249
+     * Returns the URL generator
250
+     *
251
+     * @return \OCP\IURLGenerator
252
+     * @since 6.0.0
253
+     */
254
+    public function getURLGenerator();
255
+
256
+    /**
257
+     * Returns an ICache instance
258
+     *
259
+     * @return \OCP\ICache
260
+     * @since 6.0.0
261
+     */
262
+    public function getCache();
263
+
264
+    /**
265
+     * Returns an \OCP\CacheFactory instance
266
+     *
267
+     * @return \OCP\ICacheFactory
268
+     * @since 7.0.0
269
+     */
270
+    public function getMemCacheFactory();
271
+
272
+    /**
273
+     * Returns the current session
274
+     *
275
+     * @return \OCP\ISession
276
+     * @since 6.0.0
277
+     */
278
+    public function getSession();
279
+
280
+    /**
281
+     * Returns the activity manager
282
+     *
283
+     * @return \OCP\Activity\IManager
284
+     * @since 6.0.0
285
+     */
286
+    public function getActivityManager();
287
+
288
+    /**
289
+     * Returns the current session
290
+     *
291
+     * @return \OCP\IDBConnection
292
+     * @since 6.0.0
293
+     */
294
+    public function getDatabaseConnection();
295
+
296
+    /**
297
+     * Returns an avatar manager, used for avatar functionality
298
+     *
299
+     * @return \OCP\IAvatarManager
300
+     * @since 6.0.0
301
+     */
302
+    public function getAvatarManager();
303
+
304
+    /**
305
+     * Returns an job list for controlling background jobs
306
+     *
307
+     * @return \OCP\BackgroundJob\IJobList
308
+     * @since 7.0.0
309
+     */
310
+    public function getJobList();
311
+
312
+    /**
313
+     * Returns a logger instance
314
+     *
315
+     * @return \OCP\ILogger
316
+     * @since 8.0.0
317
+     */
318
+    public function getLogger();
319
+
320
+    /**
321
+     * returns a log factory instance
322
+     *
323
+     * @return ILogFactory
324
+     * @since 14.0.0
325
+     */
326
+    public function getLogFactory();
327
+
328
+    /**
329
+     * Returns a router for generating and matching urls
330
+     *
331
+     * @return \OCP\Route\IRouter
332
+     * @since 7.0.0
333
+     */
334
+    public function getRouter();
335
+
336
+    /**
337
+     * Returns a search instance
338
+     *
339
+     * @return \OCP\ISearch
340
+     * @since 7.0.0
341
+     */
342
+    public function getSearch();
343
+
344
+    /**
345
+     * Get the certificate manager for the user
346
+     *
347
+     * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
348
+     * @return \OCP\ICertificateManager | null if $userId is null and no user is logged in
349
+     * @since 8.0.0
350
+     */
351
+    public function getCertificateManager($userId = null);
352
+
353
+    /**
354
+     * Create a new event source
355
+     *
356
+     * @return \OCP\IEventSource
357
+     * @since 8.0.0
358
+     */
359
+    public function createEventSource();
360
+
361
+    /**
362
+     * Returns an instance of the HTTP client service
363
+     *
364
+     * @return \OCP\Http\Client\IClientService
365
+     * @since 8.1.0
366
+     */
367
+    public function getHTTPClientService();
368
+
369
+    /**
370
+     * Get the active event logger
371
+     *
372
+     * @return \OCP\Diagnostics\IEventLogger
373
+     * @since 8.0.0
374
+     */
375
+    public function getEventLogger();
376
+
377
+    /**
378
+     * Get the active query logger
379
+     *
380
+     * The returned logger only logs data when debug mode is enabled
381
+     *
382
+     * @return \OCP\Diagnostics\IQueryLogger
383
+     * @since 8.0.0
384
+     */
385
+    public function getQueryLogger();
386
+
387
+    /**
388
+     * Get the manager for temporary files and folders
389
+     *
390
+     * @return \OCP\ITempManager
391
+     * @since 8.0.0
392
+     */
393
+    public function getTempManager();
394
+
395
+    /**
396
+     * Get the app manager
397
+     *
398
+     * @return \OCP\App\IAppManager
399
+     * @since 8.0.0
400
+     */
401
+    public function getAppManager();
402
+
403
+    /**
404
+     * Get the webroot
405
+     *
406
+     * @return string
407
+     * @since 8.0.0
408
+     */
409
+    public function getWebRoot();
410
+
411
+    /**
412
+     * @return \OCP\Files\Config\IMountProviderCollection
413
+     * @since 8.0.0
414
+     */
415
+    public function getMountProviderCollection();
416
+
417
+    /**
418
+     * Get the IniWrapper
419
+     *
420
+     * @return \bantu\IniGetWrapper\IniGetWrapper
421
+     * @since 8.0.0
422
+     */
423
+    public function getIniWrapper();
424
+    /**
425
+     * @return \OCP\Command\IBus
426
+     * @since 8.1.0
427
+     */
428
+    public function getCommandBus();
429
+
430
+    /**
431
+     * Creates a new mailer
432
+     *
433
+     * @return \OCP\Mail\IMailer
434
+     * @since 8.1.0
435
+     */
436
+    public function getMailer();
437
+
438
+    /**
439
+     * Get the locking provider
440
+     *
441
+     * @return \OCP\Lock\ILockingProvider
442
+     * @since 8.1.0
443
+     */
444
+    public function getLockingProvider();
445
+
446
+    /**
447
+     * @return \OCP\Files\Mount\IMountManager
448
+     * @since 8.2.0
449
+     */
450
+    public function getMountManager();
451
+
452
+    /**
453
+     * Get the MimeTypeDetector
454
+     *
455
+     * @return \OCP\Files\IMimeTypeDetector
456
+     * @since 8.2.0
457
+     */
458
+    public function getMimeTypeDetector();
459
+
460
+    /**
461
+     * Get the MimeTypeLoader
462
+     *
463
+     * @return \OCP\Files\IMimeTypeLoader
464
+     * @since 8.2.0
465
+     */
466
+    public function getMimeTypeLoader();
467
+
468
+    /**
469
+     * Get the EventDispatcher
470
+     *
471
+     * @return EventDispatcherInterface
472
+     * @since 8.2.0
473
+     */
474
+    public function getEventDispatcher();
475
+
476
+    /**
477
+     * Get the Notification Manager
478
+     *
479
+     * @return \OCP\Notification\IManager
480
+     * @since 9.0.0
481
+     */
482
+    public function getNotificationManager();
483
+
484
+    /**
485
+     * @return \OCP\Comments\ICommentsManager
486
+     * @since 9.0.0
487
+     */
488
+    public function getCommentsManager();
489
+
490
+    /**
491
+     * Returns the system-tag manager
492
+     *
493
+     * @return \OCP\SystemTag\ISystemTagManager
494
+     *
495
+     * @since 9.0.0
496
+     */
497
+    public function getSystemTagManager();
498
+
499
+    /**
500
+     * Returns the system-tag object mapper
501
+     *
502
+     * @return \OCP\SystemTag\ISystemTagObjectMapper
503
+     *
504
+     * @since 9.0.0
505
+     */
506
+    public function getSystemTagObjectMapper();
507
+
508
+    /**
509
+     * Returns the share manager
510
+     *
511
+     * @return \OCP\Share\IManager
512
+     * @since 9.0.0
513
+     */
514
+    public function getShareManager();
515
+
516
+    /**
517
+     * @return IContentSecurityPolicyManager
518
+     * @since 9.0.0
519
+     */
520
+    public function getContentSecurityPolicyManager();
521
+
522
+    /**
523
+     * @return \OCP\IDateTimeZone
524
+     * @since 8.0.0
525
+     */
526
+    public function getDateTimeZone();
527
+
528
+    /**
529
+     * @return \OCP\IDateTimeFormatter
530
+     * @since 8.0.0
531
+     */
532
+    public function getDateTimeFormatter();
533
+
534
+    /**
535
+     * @return \OCP\Federation\ICloudIdManager
536
+     * @since 12.0.0
537
+     */
538
+    public function getCloudIdManager();
539
+
540
+    /**
541
+     * @return \OCP\GlobalScale\IConfig
542
+     * @since 14.0.0
543
+     */
544
+    public function getGlobalScaleConfig();
545
+
546
+    /**
547
+     * @return ICloudFederationFactory
548
+     * @since 14.0.0
549
+     */
550
+    public function getCloudFederationFactory();
551
+
552
+    /**
553
+     * @return ICloudFederationProviderManager
554
+     * @since 14.0.0
555
+     */
556
+    public function getCloudFederationProviderManager();
557
+
558
+    /**
559
+     * @return \OCP\Remote\Api\IApiFactory
560
+     * @since 13.0.0
561
+     */
562
+    public function getRemoteApiFactory();
563
+
564
+    /**
565
+     * @return \OCP\Remote\IInstanceFactory
566
+     * @since 13.0.0
567
+     */
568
+    public function getRemoteInstanceFactory();
569 569
 }
Please login to merge, or discard this patch.
lib/public/Federation/Exceptions/AuthenticationFailedException.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -32,17 +32,17 @@
 block discarded – undo
32 32
  */
33 33
 class AuthenticationFailedException extends HintException {
34 34
 
35
-	/**
36
-	 * BadRequestException constructor.
37
-	 *
38
-	 * @since 14.0.0
39
-	 *
40
-	 */
41
-	public function __construct() {
42
-		$l = \OC::$server->getL10N('federation');
43
-		$message = 'Authentication failed, wrong token or provider ID given';
44
-		$hint = $l->t('Authentication failed, wrong token or provider ID given');
45
-		parent::__construct($message, $hint);
46
-	}
35
+    /**
36
+     * BadRequestException constructor.
37
+     *
38
+     * @since 14.0.0
39
+     *
40
+     */
41
+    public function __construct() {
42
+        $l = \OC::$server->getL10N('federation');
43
+        $message = 'Authentication failed, wrong token or provider ID given';
44
+        $hint = $l->t('Authentication failed, wrong token or provider ID given');
45
+        parent::__construct($message, $hint);
46
+    }
47 47
 
48 48
 }
Please login to merge, or discard this patch.
apps/federatedfilesharing/lib/Controller/RequestHandlerController.php 1 patch
Indentation   +427 added lines, -427 removed lines patch added patch discarded remove patch
@@ -52,431 +52,431 @@
 block discarded – undo
52 52
 
53 53
 class RequestHandlerController extends OCSController {
54 54
 
55
-	/** @var FederatedShareProvider */
56
-	private $federatedShareProvider;
57
-
58
-	/** @var IDBConnection */
59
-	private $connection;
60
-
61
-	/** @var Share\IManager */
62
-	private $shareManager;
63
-
64
-	/** @var Notifications */
65
-	private $notifications;
66
-
67
-	/** @var AddressHandler */
68
-	private $addressHandler;
69
-
70
-	/** @var  IUserManager */
71
-	private $userManager;
72
-
73
-	/** @var string */
74
-	private $shareTable = 'share';
75
-
76
-	/** @var ICloudIdManager */
77
-	private $cloudIdManager;
78
-
79
-	/** @var ILogger */
80
-	private $logger;
81
-
82
-	/** @var ICloudFederationFactory */
83
-	private $cloudFederationFactory;
84
-
85
-	/** @var ICloudFederationProviderManager */
86
-	private $cloudFederationProviderManager;
87
-
88
-	/**
89
-	 * Server2Server constructor.
90
-	 *
91
-	 * @param string $appName
92
-	 * @param IRequest $request
93
-	 * @param FederatedShareProvider $federatedShareProvider
94
-	 * @param IDBConnection $connection
95
-	 * @param Share\IManager $shareManager
96
-	 * @param Notifications $notifications
97
-	 * @param AddressHandler $addressHandler
98
-	 * @param IUserManager $userManager
99
-	 * @param ICloudIdManager $cloudIdManager
100
-	 * @param ILogger $logger
101
-	 * @param ICloudFederationFactory $cloudFederationFactory
102
-	 * @param ICloudFederationProviderManager $cloudFederationProviderManager
103
-	 */
104
-	public function __construct($appName,
105
-								IRequest $request,
106
-								FederatedShareProvider $federatedShareProvider,
107
-								IDBConnection $connection,
108
-								Share\IManager $shareManager,
109
-								Notifications $notifications,
110
-								AddressHandler $addressHandler,
111
-								IUserManager $userManager,
112
-								ICloudIdManager $cloudIdManager,
113
-								ILogger $logger,
114
-								ICloudFederationFactory $cloudFederationFactory,
115
-								ICloudFederationProviderManager $cloudFederationProviderManager
116
-	) {
117
-		parent::__construct($appName, $request);
118
-
119
-		$this->federatedShareProvider = $federatedShareProvider;
120
-		$this->connection = $connection;
121
-		$this->shareManager = $shareManager;
122
-		$this->notifications = $notifications;
123
-		$this->addressHandler = $addressHandler;
124
-		$this->userManager = $userManager;
125
-		$this->cloudIdManager = $cloudIdManager;
126
-		$this->logger = $logger;
127
-		$this->cloudFederationFactory = $cloudFederationFactory;
128
-		$this->cloudFederationProviderManager = $cloudFederationProviderManager;
129
-	}
130
-
131
-	/**
132
-	 * @NoCSRFRequired
133
-	 * @PublicPage
134
-	 *
135
-	 * create a new share
136
-	 *
137
-	 * @return Http\DataResponse
138
-	 * @throws OCSException
139
-	 */
140
-	public function createShare() {
141
-
142
-		$remote = isset($_POST['remote']) ? $_POST['remote'] : null;
143
-		$token = isset($_POST['token']) ? $_POST['token'] : null;
144
-		$name = isset($_POST['name']) ? $_POST['name'] : null;
145
-		$owner = isset($_POST['owner']) ? $_POST['owner'] : null;
146
-		$sharedBy = isset($_POST['sharedBy']) ? $_POST['sharedBy'] : null;
147
-		$shareWith = isset($_POST['shareWith']) ? $_POST['shareWith'] : null;
148
-		$remoteId = isset($_POST['remoteId']) ? (int)$_POST['remoteId'] : null;
149
-		$sharedByFederatedId = isset($_POST['sharedByFederatedId']) ? $_POST['sharedByFederatedId'] : null;
150
-		$ownerFederatedId = isset($_POST['ownerFederatedId']) ? $_POST['ownerFederatedId'] : null;
151
-
152
-		if ($ownerFederatedId === null) {
153
-			$ownerFederatedId = $this->cloudIdManager->getCloudId($owner, $this->cleanupRemote($remote))->getId();
154
-		}
155
-		// if the owner of the share and the initiator are the same user
156
-		// we also complete the federated share ID for the initiator
157
-		if ($sharedByFederatedId === null && $owner === $sharedBy) {
158
-			$sharedByFederatedId = $ownerFederatedId;
159
-		}
160
-
161
-		$share = $this->cloudFederationFactory->getCloudFederationShare(
162
-			$shareWith,
163
-			$name,
164
-			'',
165
-			$remoteId,
166
-			$ownerFederatedId,
167
-			$owner,
168
-			$sharedByFederatedId,
169
-			$sharedBy,
170
-			$token,
171
-			'user',
172
-			'file'
173
-		);
174
-
175
-		try {
176
-			$provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file');
177
-			$provider->shareReceived($share);
178
-		} catch (ProviderDoesNotExistsException $e) {
179
-			throw new OCSException('Server does not support federated cloud sharing', 503);
180
-		} catch (ProviderCouldNotAddShareException $e) {
181
-			throw new OCSException($e->getMessage(), 400);
182
-		} catch (\Exception $e) {
183
-			throw new OCSException('internal server error, was not able to add share from ' . $remote, 500);
184
-		}
185
-
186
-		return new Http\DataResponse();
187
-	}
188
-
189
-	/**
190
-	 * @NoCSRFRequired
191
-	 * @PublicPage
192
-	 *
193
-	 * create re-share on behalf of another user
194
-	 *
195
-	 * @param int $id
196
-	 * @return Http\DataResponse
197
-	 * @throws OCSBadRequestException
198
-	 * @throws OCSException
199
-	 * @throws OCSForbiddenException
200
-	 */
201
-	public function reShare($id) {
202
-
203
-		$token = $this->request->getParam('token', null);
204
-		$shareWith = $this->request->getParam('shareWith', null);
205
-		$permission = (int)$this->request->getParam('permission', null);
206
-		$remoteId = (int)$this->request->getParam('remoteId', null);
207
-
208
-		if ($id === null ||
209
-			$token === null ||
210
-			$shareWith === null ||
211
-			$permission === null ||
212
-			$remoteId === null
213
-		) {
214
-			throw new OCSBadRequestException();
215
-		}
216
-
217
-		$notification = [
218
-			'sharedSecret' => $token,
219
-			'shareWith' => $shareWith,
220
-			'senderId' => $remoteId,
221
-			'message' => 'Recipient of a share ask the owner to reshare the file'
222
-		];
223
-
224
-		try {
225
-			$provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file');
226
-			list($newToken, $localId) = $provider->notificationReceived('REQUEST_RESHARE', $id, $notification);
227
-			return new Http\DataResponse([
228
-				'token' => $newToken,
229
-				'remoteId' => $localId
230
-			]);
231
-		} catch (ProviderDoesNotExistsException $e) {
232
-			throw new OCSException('Server does not support federated cloud sharing', 503);
233
-		} catch (ShareNotFound $e) {
234
-			$this->logger->debug('Share not found: ' . $e->getMessage());
235
-		} catch (\Exception $e) {
236
-			$this->logger->debug('internal server error, can not process notification: ' . $e->getMessage());
237
-		}
238
-
239
-		throw new OCSBadRequestException();
240
-	}
241
-
242
-
243
-	/**
244
-	 * @NoCSRFRequired
245
-	 * @PublicPage
246
-	 *
247
-	 * accept server-to-server share
248
-	 *
249
-	 * @param int $id
250
-	 * @return Http\DataResponse
251
-	 * @throws OCSException
252
-	 * @throws ShareNotFound
253
-	 * @throws \OC\HintException
254
-	 */
255
-	public function acceptShare($id) {
256
-
257
-		$token = isset($_POST['token']) ? $_POST['token'] : null;
258
-
259
-		$notification = [
260
-			'sharedSecret' => $token,
261
-			'message' => 'Recipient accept the share'
262
-		];
263
-
264
-		try {
265
-			$provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file');
266
-			$provider->notificationReceived('SHARE_ACCEPTED', $id, $notification);
267
-		} catch (ProviderDoesNotExistsException $e) {
268
-			throw new OCSException('Server does not support federated cloud sharing', 503);
269
-		} catch (ShareNotFound $e) {
270
-			$this->logger->debug('Share not found: ' . $e->getMessage());
271
-		} catch (\Exception $e) {
272
-			$this->logger->debug('internal server error, can not process notification: ' . $e->getMessage());
273
-		}
274
-
275
-		return new Http\DataResponse();
276
-	}
277
-
278
-	/**
279
-	 * @NoCSRFRequired
280
-	 * @PublicPage
281
-	 *
282
-	 * decline server-to-server share
283
-	 *
284
-	 * @param int $id
285
-	 * @return Http\DataResponse
286
-	 * @throws OCSException
287
-	 */
288
-	public function declineShare($id) {
289
-
290
-		$token = isset($_POST['token']) ? $_POST['token'] : null;
291
-
292
-		$notification = [
293
-			'sharedSecret' => $token,
294
-			'message' => 'Recipient declined the share'
295
-		];
296
-
297
-		try {
298
-			$provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file');
299
-			$provider->notificationReceived('SHARE_DECLINED', $id, $notification);
300
-		} catch (ProviderDoesNotExistsException $e) {
301
-			throw new OCSException('Server does not support federated cloud sharing', 503);
302
-		} catch (ShareNotFound $e) {
303
-			$this->logger->debug('Share not found: ' . $e->getMessage());
304
-		} catch (\Exception $e) {
305
-			$this->logger->debug('internal server error, can not process notification: ' . $e->getMessage());
306
-		}
307
-
308
-		return new Http\DataResponse();
309
-	}
310
-
311
-	/**
312
-	 * @NoCSRFRequired
313
-	 * @PublicPage
314
-	 *
315
-	 * remove server-to-server share if it was unshared by the owner
316
-	 *
317
-	 * @param int $id
318
-	 * @return Http\DataResponse
319
-	 * @throws OCSException
320
-	 */
321
-	public function unshare($id) {
322
-
323
-		if (!$this->isS2SEnabled()) {
324
-			throw new OCSException('Server does not support federated cloud sharing', 503);
325
-		}
326
-
327
-		$token = isset($_POST['token']) ? $_POST['token'] : null;
328
-
329
-		try {
330
-			$provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file');
331
-			$notification = ['sharedSecret' => $token];
332
-			$provider->notificationReceived('SHARE_UNSHARED', $id, $notification);
333
-		} catch (\Exception $e) {
334
-			$this->logger->debug('processing unshare notification failed: ' . $e->getMessage());
335
-		}
336
-
337
-		return new Http\DataResponse();
338
-	}
339
-
340
-	private function cleanupRemote($remote) {
341
-		$remote = substr($remote, strpos($remote, '://') + 3);
342
-
343
-		return rtrim($remote, '/');
344
-	}
345
-
346
-
347
-	/**
348
-	 * @NoCSRFRequired
349
-	 * @PublicPage
350
-	 *
351
-	 * federated share was revoked, either by the owner or the re-sharer
352
-	 *
353
-	 * @param int $id
354
-	 * @return Http\DataResponse
355
-	 * @throws OCSBadRequestException
356
-	 */
357
-	public function revoke($id) {
358
-
359
-		$token = $this->request->getParam('token');
360
-
361
-		try {
362
-			$provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file');
363
-			$notification = ['sharedSecret' => $token];
364
-			$provider->notificationReceived('RESHARE_UNDO', $id, $notification);
365
-			return new Http\DataResponse();
366
-		} catch (\Exception $e) {
367
-			throw new OCSBadRequestException();
368
-		}
369
-
370
-	}
371
-
372
-	/**
373
-	 * check if server-to-server sharing is enabled
374
-	 *
375
-	 * @param bool $incoming
376
-	 * @return bool
377
-	 */
378
-	private function isS2SEnabled($incoming = false) {
379
-
380
-		$result = \OCP\App::isEnabled('files_sharing');
381
-
382
-		if ($incoming) {
383
-			$result = $result && $this->federatedShareProvider->isIncomingServer2serverShareEnabled();
384
-		} else {
385
-			$result = $result && $this->federatedShareProvider->isOutgoingServer2serverShareEnabled();
386
-		}
387
-
388
-		return $result;
389
-	}
390
-
391
-	/**
392
-	 * @NoCSRFRequired
393
-	 * @PublicPage
394
-	 *
395
-	 * update share information to keep federated re-shares in sync
396
-	 *
397
-	 * @param int $id
398
-	 * @return Http\DataResponse
399
-	 * @throws OCSBadRequestException
400
-	 */
401
-	public function updatePermissions($id) {
402
-		$token = $this->request->getParam('token', null);
403
-		$ncPermissions = $this->request->getParam('permissions', null);
404
-
405
-		try {
406
-			$provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file');
407
-			$ocmPermissions = $this->ncPermissions2ocmPermissions((int)$ncPermissions);
408
-			$notification = ['sharedSecret' => $token, 'permission' => $ocmPermissions];
409
-			$provider->notificationReceived('RESHARE_CHANGE_PERMISSION', $id, $notification);
410
-		} catch (\Exception $e) {
411
-			$this->logger->debug($e->getMessage());
412
-			throw new OCSBadRequestException();
413
-		}
414
-
415
-		return new Http\DataResponse();
416
-	}
417
-
418
-	/**
419
-	 * translate Nextcloud permissions to OCM Permissions
420
-	 *
421
-	 * @param $ncPermissions
422
-	 * @return array
423
-	 */
424
-	protected function ncPermissions2ocmPermissions($ncPermissions) {
425
-
426
-		$ocmPermissions = [];
427
-
428
-		if ($ncPermissions & Constants::PERMISSION_SHARE) {
429
-			$ocmPermissions[] = 'share';
430
-		}
431
-
432
-		if ($ncPermissions & Constants::PERMISSION_READ) {
433
-			$ocmPermissions[] = 'read';
434
-		}
435
-
436
-		if (($ncPermissions & Constants::PERMISSION_CREATE) ||
437
-			($ncPermissions & Constants::PERMISSION_UPDATE)) {
438
-			$ocmPermissions[] = 'write';
439
-		}
440
-
441
-		return $ocmPermissions;
442
-
443
-	}
444
-
445
-	/**
446
-	 * @NoCSRFRequired
447
-	 * @PublicPage
448
-	 *
449
-	 * change the owner of a server-to-server share
450
-	 *
451
-	 * @param int $id
452
-	 * @return Http\DataResponse
453
-	 * @throws \InvalidArgumentException
454
-	 * @throws OCSException
455
-	 */
456
-	public function move($id) {
457
-
458
-		if (!$this->isS2SEnabled()) {
459
-			throw new OCSException('Server does not support federated cloud sharing', 503);
460
-		}
461
-
462
-		$token = $this->request->getParam('token');
463
-		$remote = $this->request->getParam('remote');
464
-		$newRemoteId = $this->request->getParam('remote_id', $id);
465
-		$cloudId = $this->cloudIdManager->resolveCloudId($remote);
466
-
467
-		$qb = $this->connection->getQueryBuilder();
468
-		$query = $qb->update('share_external')
469
-			->set('remote', $qb->createNamedParameter($cloudId->getRemote()))
470
-			->set('owner', $qb->createNamedParameter($cloudId->getUser()))
471
-			->set('remote_id', $qb->createNamedParameter($newRemoteId))
472
-			->where($qb->expr()->eq('remote_id', $qb->createNamedParameter($id)))
473
-			->andWhere($qb->expr()->eq('share_token', $qb->createNamedParameter($token)));
474
-		$affected = $query->execute();
475
-
476
-		if ($affected > 0) {
477
-			return new Http\DataResponse(['remote' => $cloudId->getRemote(), 'owner' => $cloudId->getUser()]);
478
-		} else {
479
-			throw new OCSBadRequestException('Share not found or token invalid');
480
-		}
481
-	}
55
+    /** @var FederatedShareProvider */
56
+    private $federatedShareProvider;
57
+
58
+    /** @var IDBConnection */
59
+    private $connection;
60
+
61
+    /** @var Share\IManager */
62
+    private $shareManager;
63
+
64
+    /** @var Notifications */
65
+    private $notifications;
66
+
67
+    /** @var AddressHandler */
68
+    private $addressHandler;
69
+
70
+    /** @var  IUserManager */
71
+    private $userManager;
72
+
73
+    /** @var string */
74
+    private $shareTable = 'share';
75
+
76
+    /** @var ICloudIdManager */
77
+    private $cloudIdManager;
78
+
79
+    /** @var ILogger */
80
+    private $logger;
81
+
82
+    /** @var ICloudFederationFactory */
83
+    private $cloudFederationFactory;
84
+
85
+    /** @var ICloudFederationProviderManager */
86
+    private $cloudFederationProviderManager;
87
+
88
+    /**
89
+     * Server2Server constructor.
90
+     *
91
+     * @param string $appName
92
+     * @param IRequest $request
93
+     * @param FederatedShareProvider $federatedShareProvider
94
+     * @param IDBConnection $connection
95
+     * @param Share\IManager $shareManager
96
+     * @param Notifications $notifications
97
+     * @param AddressHandler $addressHandler
98
+     * @param IUserManager $userManager
99
+     * @param ICloudIdManager $cloudIdManager
100
+     * @param ILogger $logger
101
+     * @param ICloudFederationFactory $cloudFederationFactory
102
+     * @param ICloudFederationProviderManager $cloudFederationProviderManager
103
+     */
104
+    public function __construct($appName,
105
+                                IRequest $request,
106
+                                FederatedShareProvider $federatedShareProvider,
107
+                                IDBConnection $connection,
108
+                                Share\IManager $shareManager,
109
+                                Notifications $notifications,
110
+                                AddressHandler $addressHandler,
111
+                                IUserManager $userManager,
112
+                                ICloudIdManager $cloudIdManager,
113
+                                ILogger $logger,
114
+                                ICloudFederationFactory $cloudFederationFactory,
115
+                                ICloudFederationProviderManager $cloudFederationProviderManager
116
+    ) {
117
+        parent::__construct($appName, $request);
118
+
119
+        $this->federatedShareProvider = $federatedShareProvider;
120
+        $this->connection = $connection;
121
+        $this->shareManager = $shareManager;
122
+        $this->notifications = $notifications;
123
+        $this->addressHandler = $addressHandler;
124
+        $this->userManager = $userManager;
125
+        $this->cloudIdManager = $cloudIdManager;
126
+        $this->logger = $logger;
127
+        $this->cloudFederationFactory = $cloudFederationFactory;
128
+        $this->cloudFederationProviderManager = $cloudFederationProviderManager;
129
+    }
130
+
131
+    /**
132
+     * @NoCSRFRequired
133
+     * @PublicPage
134
+     *
135
+     * create a new share
136
+     *
137
+     * @return Http\DataResponse
138
+     * @throws OCSException
139
+     */
140
+    public function createShare() {
141
+
142
+        $remote = isset($_POST['remote']) ? $_POST['remote'] : null;
143
+        $token = isset($_POST['token']) ? $_POST['token'] : null;
144
+        $name = isset($_POST['name']) ? $_POST['name'] : null;
145
+        $owner = isset($_POST['owner']) ? $_POST['owner'] : null;
146
+        $sharedBy = isset($_POST['sharedBy']) ? $_POST['sharedBy'] : null;
147
+        $shareWith = isset($_POST['shareWith']) ? $_POST['shareWith'] : null;
148
+        $remoteId = isset($_POST['remoteId']) ? (int)$_POST['remoteId'] : null;
149
+        $sharedByFederatedId = isset($_POST['sharedByFederatedId']) ? $_POST['sharedByFederatedId'] : null;
150
+        $ownerFederatedId = isset($_POST['ownerFederatedId']) ? $_POST['ownerFederatedId'] : null;
151
+
152
+        if ($ownerFederatedId === null) {
153
+            $ownerFederatedId = $this->cloudIdManager->getCloudId($owner, $this->cleanupRemote($remote))->getId();
154
+        }
155
+        // if the owner of the share and the initiator are the same user
156
+        // we also complete the federated share ID for the initiator
157
+        if ($sharedByFederatedId === null && $owner === $sharedBy) {
158
+            $sharedByFederatedId = $ownerFederatedId;
159
+        }
160
+
161
+        $share = $this->cloudFederationFactory->getCloudFederationShare(
162
+            $shareWith,
163
+            $name,
164
+            '',
165
+            $remoteId,
166
+            $ownerFederatedId,
167
+            $owner,
168
+            $sharedByFederatedId,
169
+            $sharedBy,
170
+            $token,
171
+            'user',
172
+            'file'
173
+        );
174
+
175
+        try {
176
+            $provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file');
177
+            $provider->shareReceived($share);
178
+        } catch (ProviderDoesNotExistsException $e) {
179
+            throw new OCSException('Server does not support federated cloud sharing', 503);
180
+        } catch (ProviderCouldNotAddShareException $e) {
181
+            throw new OCSException($e->getMessage(), 400);
182
+        } catch (\Exception $e) {
183
+            throw new OCSException('internal server error, was not able to add share from ' . $remote, 500);
184
+        }
185
+
186
+        return new Http\DataResponse();
187
+    }
188
+
189
+    /**
190
+     * @NoCSRFRequired
191
+     * @PublicPage
192
+     *
193
+     * create re-share on behalf of another user
194
+     *
195
+     * @param int $id
196
+     * @return Http\DataResponse
197
+     * @throws OCSBadRequestException
198
+     * @throws OCSException
199
+     * @throws OCSForbiddenException
200
+     */
201
+    public function reShare($id) {
202
+
203
+        $token = $this->request->getParam('token', null);
204
+        $shareWith = $this->request->getParam('shareWith', null);
205
+        $permission = (int)$this->request->getParam('permission', null);
206
+        $remoteId = (int)$this->request->getParam('remoteId', null);
207
+
208
+        if ($id === null ||
209
+            $token === null ||
210
+            $shareWith === null ||
211
+            $permission === null ||
212
+            $remoteId === null
213
+        ) {
214
+            throw new OCSBadRequestException();
215
+        }
216
+
217
+        $notification = [
218
+            'sharedSecret' => $token,
219
+            'shareWith' => $shareWith,
220
+            'senderId' => $remoteId,
221
+            'message' => 'Recipient of a share ask the owner to reshare the file'
222
+        ];
223
+
224
+        try {
225
+            $provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file');
226
+            list($newToken, $localId) = $provider->notificationReceived('REQUEST_RESHARE', $id, $notification);
227
+            return new Http\DataResponse([
228
+                'token' => $newToken,
229
+                'remoteId' => $localId
230
+            ]);
231
+        } catch (ProviderDoesNotExistsException $e) {
232
+            throw new OCSException('Server does not support federated cloud sharing', 503);
233
+        } catch (ShareNotFound $e) {
234
+            $this->logger->debug('Share not found: ' . $e->getMessage());
235
+        } catch (\Exception $e) {
236
+            $this->logger->debug('internal server error, can not process notification: ' . $e->getMessage());
237
+        }
238
+
239
+        throw new OCSBadRequestException();
240
+    }
241
+
242
+
243
+    /**
244
+     * @NoCSRFRequired
245
+     * @PublicPage
246
+     *
247
+     * accept server-to-server share
248
+     *
249
+     * @param int $id
250
+     * @return Http\DataResponse
251
+     * @throws OCSException
252
+     * @throws ShareNotFound
253
+     * @throws \OC\HintException
254
+     */
255
+    public function acceptShare($id) {
256
+
257
+        $token = isset($_POST['token']) ? $_POST['token'] : null;
258
+
259
+        $notification = [
260
+            'sharedSecret' => $token,
261
+            'message' => 'Recipient accept the share'
262
+        ];
263
+
264
+        try {
265
+            $provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file');
266
+            $provider->notificationReceived('SHARE_ACCEPTED', $id, $notification);
267
+        } catch (ProviderDoesNotExistsException $e) {
268
+            throw new OCSException('Server does not support federated cloud sharing', 503);
269
+        } catch (ShareNotFound $e) {
270
+            $this->logger->debug('Share not found: ' . $e->getMessage());
271
+        } catch (\Exception $e) {
272
+            $this->logger->debug('internal server error, can not process notification: ' . $e->getMessage());
273
+        }
274
+
275
+        return new Http\DataResponse();
276
+    }
277
+
278
+    /**
279
+     * @NoCSRFRequired
280
+     * @PublicPage
281
+     *
282
+     * decline server-to-server share
283
+     *
284
+     * @param int $id
285
+     * @return Http\DataResponse
286
+     * @throws OCSException
287
+     */
288
+    public function declineShare($id) {
289
+
290
+        $token = isset($_POST['token']) ? $_POST['token'] : null;
291
+
292
+        $notification = [
293
+            'sharedSecret' => $token,
294
+            'message' => 'Recipient declined the share'
295
+        ];
296
+
297
+        try {
298
+            $provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file');
299
+            $provider->notificationReceived('SHARE_DECLINED', $id, $notification);
300
+        } catch (ProviderDoesNotExistsException $e) {
301
+            throw new OCSException('Server does not support federated cloud sharing', 503);
302
+        } catch (ShareNotFound $e) {
303
+            $this->logger->debug('Share not found: ' . $e->getMessage());
304
+        } catch (\Exception $e) {
305
+            $this->logger->debug('internal server error, can not process notification: ' . $e->getMessage());
306
+        }
307
+
308
+        return new Http\DataResponse();
309
+    }
310
+
311
+    /**
312
+     * @NoCSRFRequired
313
+     * @PublicPage
314
+     *
315
+     * remove server-to-server share if it was unshared by the owner
316
+     *
317
+     * @param int $id
318
+     * @return Http\DataResponse
319
+     * @throws OCSException
320
+     */
321
+    public function unshare($id) {
322
+
323
+        if (!$this->isS2SEnabled()) {
324
+            throw new OCSException('Server does not support federated cloud sharing', 503);
325
+        }
326
+
327
+        $token = isset($_POST['token']) ? $_POST['token'] : null;
328
+
329
+        try {
330
+            $provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file');
331
+            $notification = ['sharedSecret' => $token];
332
+            $provider->notificationReceived('SHARE_UNSHARED', $id, $notification);
333
+        } catch (\Exception $e) {
334
+            $this->logger->debug('processing unshare notification failed: ' . $e->getMessage());
335
+        }
336
+
337
+        return new Http\DataResponse();
338
+    }
339
+
340
+    private function cleanupRemote($remote) {
341
+        $remote = substr($remote, strpos($remote, '://') + 3);
342
+
343
+        return rtrim($remote, '/');
344
+    }
345
+
346
+
347
+    /**
348
+     * @NoCSRFRequired
349
+     * @PublicPage
350
+     *
351
+     * federated share was revoked, either by the owner or the re-sharer
352
+     *
353
+     * @param int $id
354
+     * @return Http\DataResponse
355
+     * @throws OCSBadRequestException
356
+     */
357
+    public function revoke($id) {
358
+
359
+        $token = $this->request->getParam('token');
360
+
361
+        try {
362
+            $provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file');
363
+            $notification = ['sharedSecret' => $token];
364
+            $provider->notificationReceived('RESHARE_UNDO', $id, $notification);
365
+            return new Http\DataResponse();
366
+        } catch (\Exception $e) {
367
+            throw new OCSBadRequestException();
368
+        }
369
+
370
+    }
371
+
372
+    /**
373
+     * check if server-to-server sharing is enabled
374
+     *
375
+     * @param bool $incoming
376
+     * @return bool
377
+     */
378
+    private function isS2SEnabled($incoming = false) {
379
+
380
+        $result = \OCP\App::isEnabled('files_sharing');
381
+
382
+        if ($incoming) {
383
+            $result = $result && $this->federatedShareProvider->isIncomingServer2serverShareEnabled();
384
+        } else {
385
+            $result = $result && $this->federatedShareProvider->isOutgoingServer2serverShareEnabled();
386
+        }
387
+
388
+        return $result;
389
+    }
390
+
391
+    /**
392
+     * @NoCSRFRequired
393
+     * @PublicPage
394
+     *
395
+     * update share information to keep federated re-shares in sync
396
+     *
397
+     * @param int $id
398
+     * @return Http\DataResponse
399
+     * @throws OCSBadRequestException
400
+     */
401
+    public function updatePermissions($id) {
402
+        $token = $this->request->getParam('token', null);
403
+        $ncPermissions = $this->request->getParam('permissions', null);
404
+
405
+        try {
406
+            $provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file');
407
+            $ocmPermissions = $this->ncPermissions2ocmPermissions((int)$ncPermissions);
408
+            $notification = ['sharedSecret' => $token, 'permission' => $ocmPermissions];
409
+            $provider->notificationReceived('RESHARE_CHANGE_PERMISSION', $id, $notification);
410
+        } catch (\Exception $e) {
411
+            $this->logger->debug($e->getMessage());
412
+            throw new OCSBadRequestException();
413
+        }
414
+
415
+        return new Http\DataResponse();
416
+    }
417
+
418
+    /**
419
+     * translate Nextcloud permissions to OCM Permissions
420
+     *
421
+     * @param $ncPermissions
422
+     * @return array
423
+     */
424
+    protected function ncPermissions2ocmPermissions($ncPermissions) {
425
+
426
+        $ocmPermissions = [];
427
+
428
+        if ($ncPermissions & Constants::PERMISSION_SHARE) {
429
+            $ocmPermissions[] = 'share';
430
+        }
431
+
432
+        if ($ncPermissions & Constants::PERMISSION_READ) {
433
+            $ocmPermissions[] = 'read';
434
+        }
435
+
436
+        if (($ncPermissions & Constants::PERMISSION_CREATE) ||
437
+            ($ncPermissions & Constants::PERMISSION_UPDATE)) {
438
+            $ocmPermissions[] = 'write';
439
+        }
440
+
441
+        return $ocmPermissions;
442
+
443
+    }
444
+
445
+    /**
446
+     * @NoCSRFRequired
447
+     * @PublicPage
448
+     *
449
+     * change the owner of a server-to-server share
450
+     *
451
+     * @param int $id
452
+     * @return Http\DataResponse
453
+     * @throws \InvalidArgumentException
454
+     * @throws OCSException
455
+     */
456
+    public function move($id) {
457
+
458
+        if (!$this->isS2SEnabled()) {
459
+            throw new OCSException('Server does not support federated cloud sharing', 503);
460
+        }
461
+
462
+        $token = $this->request->getParam('token');
463
+        $remote = $this->request->getParam('remote');
464
+        $newRemoteId = $this->request->getParam('remote_id', $id);
465
+        $cloudId = $this->cloudIdManager->resolveCloudId($remote);
466
+
467
+        $qb = $this->connection->getQueryBuilder();
468
+        $query = $qb->update('share_external')
469
+            ->set('remote', $qb->createNamedParameter($cloudId->getRemote()))
470
+            ->set('owner', $qb->createNamedParameter($cloudId->getUser()))
471
+            ->set('remote_id', $qb->createNamedParameter($newRemoteId))
472
+            ->where($qb->expr()->eq('remote_id', $qb->createNamedParameter($id)))
473
+            ->andWhere($qb->expr()->eq('share_token', $qb->createNamedParameter($token)));
474
+        $affected = $query->execute();
475
+
476
+        if ($affected > 0) {
477
+            return new Http\DataResponse(['remote' => $cloudId->getRemote(), 'owner' => $cloudId->getUser()]);
478
+        } else {
479
+            throw new OCSBadRequestException('Share not found or token invalid');
480
+        }
481
+    }
482 482
 }
Please login to merge, or discard this patch.
lib/public/Federation/ICloudFederationProviderManager.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -32,76 +32,76 @@
 block discarded – undo
32 32
  */
33 33
 interface ICloudFederationProviderManager {
34 34
 
35
-	/**
36
-	 * Registers an callback function which must return an cloud federation provider
37
-	 *
38
-	 * @param string $resourceType which resource type does the provider handles
39
-	 * @param string $displayName user facing name of the federated share provider
40
-	 * @param callable $callback
41
-	 * @throws Exceptions\ProviderAlreadyExistsException
42
-	 *
43
-	 * @since 14.0.0
44
-	 */
45
-	public function addCloudFederationProvider($resourceType, $displayName, callable $callback);
35
+    /**
36
+     * Registers an callback function which must return an cloud federation provider
37
+     *
38
+     * @param string $resourceType which resource type does the provider handles
39
+     * @param string $displayName user facing name of the federated share provider
40
+     * @param callable $callback
41
+     * @throws Exceptions\ProviderAlreadyExistsException
42
+     *
43
+     * @since 14.0.0
44
+     */
45
+    public function addCloudFederationProvider($resourceType, $displayName, callable $callback);
46 46
 
47
-	/**
48
-	 * remove cloud federation provider
49
-	 *
50
-	 * @param string $resourceType
51
-	 *
52
-	 * @since 14.0.0
53
-	 */
54
-	public function removeCloudFederationProvider($resourceType);
47
+    /**
48
+     * remove cloud federation provider
49
+     *
50
+     * @param string $resourceType
51
+     *
52
+     * @since 14.0.0
53
+     */
54
+    public function removeCloudFederationProvider($resourceType);
55 55
 
56
-	/**
57
-	 * get a list of all cloudFederationProviders
58
-	 *
59
-	 * @return array [resourceType => ['resourceType' => $resourceType, 'displayName' => $displayName, 'callback' => callback]]
60
-	 *
61
-	 * @since 14.0.0
62
-	 */
63
-	public function getAllCloudFederationProviders();
56
+    /**
57
+     * get a list of all cloudFederationProviders
58
+     *
59
+     * @return array [resourceType => ['resourceType' => $resourceType, 'displayName' => $displayName, 'callback' => callback]]
60
+     *
61
+     * @since 14.0.0
62
+     */
63
+    public function getAllCloudFederationProviders();
64 64
 
65
-	/**
66
-	 * get a specific cloud federation provider
67
-	 *
68
-	 * @param string $resourceType
69
-	 * @return ICloudFederationProvider
70
-	 * @throws Exceptions\ProviderDoesNotExistsException;
71
-	 *
72
-	 * @since 14.0.0
73
-	 */
74
-	public function getCloudFederationProvider($resourceType);
65
+    /**
66
+     * get a specific cloud federation provider
67
+     *
68
+     * @param string $resourceType
69
+     * @return ICloudFederationProvider
70
+     * @throws Exceptions\ProviderDoesNotExistsException;
71
+     *
72
+     * @since 14.0.0
73
+     */
74
+    public function getCloudFederationProvider($resourceType);
75 75
 
76
-	/**
77
-	 * send federated share
78
-	 *
79
-	 * @param ICloudFederationShare $share
80
-	 * @return bool
81
-	 *
82
-	 * @since 14.0.0
83
-	 */
84
-	public function sendShare(ICloudFederationShare $share);
76
+    /**
77
+     * send federated share
78
+     *
79
+     * @param ICloudFederationShare $share
80
+     * @return bool
81
+     *
82
+     * @since 14.0.0
83
+     */
84
+    public function sendShare(ICloudFederationShare $share);
85 85
 
86
-	/**
87
-	 * send notification about existing share
88
-	 *
89
-	 * @param string $url
90
-	 * @param ICloudFederationNotification $notification
91
-	 * @return mixed
92
-	 *
93
-	 * @since 14.0.0
94
-	 */
95
-	public function sendNotification($url, ICloudFederationNotification $notification);
86
+    /**
87
+     * send notification about existing share
88
+     *
89
+     * @param string $url
90
+     * @param ICloudFederationNotification $notification
91
+     * @return mixed
92
+     *
93
+     * @since 14.0.0
94
+     */
95
+    public function sendNotification($url, ICloudFederationNotification $notification);
96 96
 
97
-	/**
98
-	 * check if the new cloud federation API is ready to be used
99
-	 *
100
-	 * @return bool
101
-	 *
102
-	 * @since 14.0.0
103
-	 */
104
-	public function isReady();
97
+    /**
98
+     * check if the new cloud federation API is ready to be used
99
+     *
100
+     * @return bool
101
+     *
102
+     * @since 14.0.0
103
+     */
104
+    public function isReady();
105 105
 
106 106
 
107 107
 }
Please login to merge, or discard this patch.
lib/private/Federation/CloudFederationProviderManager.php 1 patch
Indentation   +183 added lines, -183 removed lines patch added patch discarded remove patch
@@ -42,189 +42,189 @@
 block discarded – undo
42 42
  */
43 43
 class CloudFederationProviderManager implements ICloudFederationProviderManager {
44 44
 
45
-	/** @var array list of available cloud federation providers */
46
-	private $cloudFederationProvider;
47
-
48
-	/** @var IAppManager */
49
-	private $appManager;
50
-
51
-	/** @var IClientService */
52
-	private $httpClientService;
53
-
54
-	/** @var ICloudIdManager */
55
-	private $cloudIdManager;
56
-
57
-	/** @var ILogger */
58
-	private $logger;
59
-
60
-	private $supportedAPIVersion = '1.0-proposal1';
61
-
62
-	/**
63
-	 * CloudFederationProviderManager constructor.
64
-	 *
65
-	 * @param IAppManager $appManager
66
-	 * @param IClientService $httpClientService
67
-	 * @param ICloudIdManager $cloudIdManager
68
-	 * @param ILogger $logger
69
-	 */
70
-	public function __construct(IAppManager $appManager,
71
-								IClientService $httpClientService,
72
-								ICloudIdManager $cloudIdManager,
73
-								ILogger $logger) {
74
-		$this->cloudFederationProvider= [];
75
-		$this->appManager = $appManager;
76
-		$this->httpClientService = $httpClientService;
77
-		$this->cloudIdManager = $cloudIdManager;
78
-		$this->logger = $logger;
79
-	}
80
-
81
-
82
-	/**
83
-	 * Registers an callback function which must return an cloud federation provider
84
-	 *
85
-	 * @param string $resourceType which resource type does the provider handles
86
-	 * @param string $displayName user facing name of the federated share provider
87
-	 * @param callable $callback
88
-	 */
89
-	public function addCloudFederationProvider($resourceType, $displayName, callable $callback) {
90
-		$this->cloudFederationProvider[$resourceType] = [
91
-			'resourceType' => $resourceType,
92
-			'displayName' => $displayName,
93
-			'callback' => $callback,
94
-		];
95
-
96
-	}
97
-
98
-	/**
99
-	 * remove cloud federation provider
100
-	 *
101
-	 * @param string $providerId
102
-	 */
103
-	public function removeCloudFederationProvider($providerId) {
104
-		unset($this->cloudFederationProvider[$providerId]);
105
-	}
106
-
107
-	/**
108
-	 * get a list of all cloudFederationProviders
109
-	 *
110
-	 * @return array [resourceType => ['resourceType' => $resourceType, 'displayName' => $displayName, 'callback' => callback]]
111
-	 */
112
-	public function getAllCloudFederationProviders() {
113
-		return $this->cloudFederationProvider;
114
-	}
115
-
116
-	/**
117
-	 * get a specific cloud federation provider
118
-	 *
119
-	 * @param string $resourceType
120
-	 * @return ICloudFederationProvider
121
-	 * @throws ProviderDoesNotExistsException
122
-	 */
123
-	public function getCloudFederationProvider($resourceType) {
124
-		if (isset($this->cloudFederationProvider[$resourceType])) {
125
-			return call_user_func($this->cloudFederationProvider[$resourceType]['callback']);
126
-		} else {
127
-			throw new ProviderDoesNotExistsException($resourceType);
128
-		}
129
-	}
130
-
131
-	public function sendShare(ICloudFederationShare $share) {
132
-		$cloudID = $this->cloudIdManager->resolveCloudId($share->getShareWith());
133
-		$ocmEndPoint = $this->getOCMEndPoint($cloudID->getRemote());
134
-
135
-		if (empty($ocmEndPoint)) {
136
-			return false;
137
-		}
138
-
139
-		$client = $this->httpClientService->newClient();
140
-		try {
141
-			$response = $client->post($ocmEndPoint . '/shares', [
142
-				'body' => $share->getShare(),
143
-				'timeout' => 10,
144
-				'connect_timeout' => 10,
145
-			]);
146
-
147
-			if ($response->getStatusCode() === Http::STATUS_CREATED) {
148
-				return true;
149
-			}
150
-
151
-		} catch (\Exception $e) {
152
-			// if flat re-sharing is not supported by the remote server
153
-			// we re-throw the exception and fall back to the old behaviour.
154
-			// (flat re-shares has been introduced in Nextcloud 9.1)
155
-			if ($e->getCode() === Http::STATUS_INTERNAL_SERVER_ERROR) {
156
-				throw $e;
157
-			}
158
-		}
159
-
160
-		return false;
161
-
162
-	}
163
-
164
-	/**
165
-	 * @param string $url
166
-	 * @param ICloudFederationNotification $notification
167
-	 * @return mixed
168
-	 */
169
-	public function sendNotification($url, ICloudFederationNotification $notification) {
170
-		$ocmEndPoint = $this->getOCMEndPoint($url);
171
-
172
-		if (empty($ocmEndPoint)) {
173
-			return false;
174
-		}
175
-
176
-		$client = $this->httpClientService->newClient();
177
-		try {
178
-			$response = $client->post($ocmEndPoint . '/notifications', [
179
-				'body' => $notification->getMessage(),
180
-				'timeout' => 10,
181
-				'connect_timeout' => 10,
182
-			]);
183
-			if ($response->getStatusCode() === Http::STATUS_CREATED) {
184
-				$result = json_decode($response->getBody(), true);
185
-				return (is_array($result)) ? $result : [];
186
-			}
187
-		} catch (\Exception $e) {
188
-			// log the error and return false
189
-			$this->logger->error('error while sending notification for federated share: ' . $e->getMessage());
190
-		}
191
-
192
-		return false;
193
-	}
194
-
195
-	/**
196
-	 * check if the new cloud federation API is ready to be used
197
-	 *
198
-	 * @return bool
199
-	 */
200
-	public function isReady() {
201
-		return $this->appManager->isEnabledForUser('cloud_federation_api');
202
-	}
203
-	/**
204
-	 * check if server supports the new OCM api and ask for the correct end-point
205
-	 *
206
-	 * @param string $url full base URL of the cloud server
207
-	 * @return string
208
-	 */
209
-	protected function getOCMEndPoint($url) {
210
-		$client = $this->httpClientService->newClient();
211
-		try {
212
-			$response = $client->get($url . '/ocm-provider/', ['timeout' => 10, 'connect_timeout' => 10]);
213
-		} catch (\Exception $e) {
214
-			return '';
215
-		}
216
-
217
-		$result = $response->getBody();
218
-		$result = json_decode($result, true);
219
-
220
-		$supportedVersion = isset($result['apiVersion']) && $result['apiVersion'] === $this->supportedAPIVersion;
221
-
222
-		if (isset($result['endPoint']) && $supportedVersion) {
223
-			return $result['endPoint'];
224
-		}
225
-
226
-		return '';
227
-	}
45
+    /** @var array list of available cloud federation providers */
46
+    private $cloudFederationProvider;
47
+
48
+    /** @var IAppManager */
49
+    private $appManager;
50
+
51
+    /** @var IClientService */
52
+    private $httpClientService;
53
+
54
+    /** @var ICloudIdManager */
55
+    private $cloudIdManager;
56
+
57
+    /** @var ILogger */
58
+    private $logger;
59
+
60
+    private $supportedAPIVersion = '1.0-proposal1';
61
+
62
+    /**
63
+     * CloudFederationProviderManager constructor.
64
+     *
65
+     * @param IAppManager $appManager
66
+     * @param IClientService $httpClientService
67
+     * @param ICloudIdManager $cloudIdManager
68
+     * @param ILogger $logger
69
+     */
70
+    public function __construct(IAppManager $appManager,
71
+                                IClientService $httpClientService,
72
+                                ICloudIdManager $cloudIdManager,
73
+                                ILogger $logger) {
74
+        $this->cloudFederationProvider= [];
75
+        $this->appManager = $appManager;
76
+        $this->httpClientService = $httpClientService;
77
+        $this->cloudIdManager = $cloudIdManager;
78
+        $this->logger = $logger;
79
+    }
80
+
81
+
82
+    /**
83
+     * Registers an callback function which must return an cloud federation provider
84
+     *
85
+     * @param string $resourceType which resource type does the provider handles
86
+     * @param string $displayName user facing name of the federated share provider
87
+     * @param callable $callback
88
+     */
89
+    public function addCloudFederationProvider($resourceType, $displayName, callable $callback) {
90
+        $this->cloudFederationProvider[$resourceType] = [
91
+            'resourceType' => $resourceType,
92
+            'displayName' => $displayName,
93
+            'callback' => $callback,
94
+        ];
95
+
96
+    }
97
+
98
+    /**
99
+     * remove cloud federation provider
100
+     *
101
+     * @param string $providerId
102
+     */
103
+    public function removeCloudFederationProvider($providerId) {
104
+        unset($this->cloudFederationProvider[$providerId]);
105
+    }
106
+
107
+    /**
108
+     * get a list of all cloudFederationProviders
109
+     *
110
+     * @return array [resourceType => ['resourceType' => $resourceType, 'displayName' => $displayName, 'callback' => callback]]
111
+     */
112
+    public function getAllCloudFederationProviders() {
113
+        return $this->cloudFederationProvider;
114
+    }
115
+
116
+    /**
117
+     * get a specific cloud federation provider
118
+     *
119
+     * @param string $resourceType
120
+     * @return ICloudFederationProvider
121
+     * @throws ProviderDoesNotExistsException
122
+     */
123
+    public function getCloudFederationProvider($resourceType) {
124
+        if (isset($this->cloudFederationProvider[$resourceType])) {
125
+            return call_user_func($this->cloudFederationProvider[$resourceType]['callback']);
126
+        } else {
127
+            throw new ProviderDoesNotExistsException($resourceType);
128
+        }
129
+    }
130
+
131
+    public function sendShare(ICloudFederationShare $share) {
132
+        $cloudID = $this->cloudIdManager->resolveCloudId($share->getShareWith());
133
+        $ocmEndPoint = $this->getOCMEndPoint($cloudID->getRemote());
134
+
135
+        if (empty($ocmEndPoint)) {
136
+            return false;
137
+        }
138
+
139
+        $client = $this->httpClientService->newClient();
140
+        try {
141
+            $response = $client->post($ocmEndPoint . '/shares', [
142
+                'body' => $share->getShare(),
143
+                'timeout' => 10,
144
+                'connect_timeout' => 10,
145
+            ]);
146
+
147
+            if ($response->getStatusCode() === Http::STATUS_CREATED) {
148
+                return true;
149
+            }
150
+
151
+        } catch (\Exception $e) {
152
+            // if flat re-sharing is not supported by the remote server
153
+            // we re-throw the exception and fall back to the old behaviour.
154
+            // (flat re-shares has been introduced in Nextcloud 9.1)
155
+            if ($e->getCode() === Http::STATUS_INTERNAL_SERVER_ERROR) {
156
+                throw $e;
157
+            }
158
+        }
159
+
160
+        return false;
161
+
162
+    }
163
+
164
+    /**
165
+     * @param string $url
166
+     * @param ICloudFederationNotification $notification
167
+     * @return mixed
168
+     */
169
+    public function sendNotification($url, ICloudFederationNotification $notification) {
170
+        $ocmEndPoint = $this->getOCMEndPoint($url);
171
+
172
+        if (empty($ocmEndPoint)) {
173
+            return false;
174
+        }
175
+
176
+        $client = $this->httpClientService->newClient();
177
+        try {
178
+            $response = $client->post($ocmEndPoint . '/notifications', [
179
+                'body' => $notification->getMessage(),
180
+                'timeout' => 10,
181
+                'connect_timeout' => 10,
182
+            ]);
183
+            if ($response->getStatusCode() === Http::STATUS_CREATED) {
184
+                $result = json_decode($response->getBody(), true);
185
+                return (is_array($result)) ? $result : [];
186
+            }
187
+        } catch (\Exception $e) {
188
+            // log the error and return false
189
+            $this->logger->error('error while sending notification for federated share: ' . $e->getMessage());
190
+        }
191
+
192
+        return false;
193
+    }
194
+
195
+    /**
196
+     * check if the new cloud federation API is ready to be used
197
+     *
198
+     * @return bool
199
+     */
200
+    public function isReady() {
201
+        return $this->appManager->isEnabledForUser('cloud_federation_api');
202
+    }
203
+    /**
204
+     * check if server supports the new OCM api and ask for the correct end-point
205
+     *
206
+     * @param string $url full base URL of the cloud server
207
+     * @return string
208
+     */
209
+    protected function getOCMEndPoint($url) {
210
+        $client = $this->httpClientService->newClient();
211
+        try {
212
+            $response = $client->get($url . '/ocm-provider/', ['timeout' => 10, 'connect_timeout' => 10]);
213
+        } catch (\Exception $e) {
214
+            return '';
215
+        }
216
+
217
+        $result = $response->getBody();
218
+        $result = json_decode($result, true);
219
+
220
+        $supportedVersion = isset($result['apiVersion']) && $result['apiVersion'] === $this->supportedAPIVersion;
221
+
222
+        if (isset($result['endPoint']) && $supportedVersion) {
223
+            return $result['endPoint'];
224
+        }
225
+
226
+        return '';
227
+    }
228 228
 
229 229
 
230 230
 }
Please login to merge, or discard this patch.
apps/cloud_federation_api/lib/Controller/RequestHandlerController.php 1 patch
Indentation   +195 added lines, -195 removed lines patch added patch discarded remove patch
@@ -51,225 +51,225 @@
 block discarded – undo
51 51
  */
52 52
 class RequestHandlerController extends Controller {
53 53
 
54
-	/** @var ILogger */
55
-	private $logger;
54
+    /** @var ILogger */
55
+    private $logger;
56 56
 
57
-	/** @var IUserManager */
58
-	private $userManager;
57
+    /** @var IUserManager */
58
+    private $userManager;
59 59
 
60
-	/** @var IURLGenerator */
61
-	private $urlGenerator;
60
+    /** @var IURLGenerator */
61
+    private $urlGenerator;
62 62
 
63
-	/** @var ICloudFederationProviderManager */
64
-	private $cloudFederationProviderManager;
63
+    /** @var ICloudFederationProviderManager */
64
+    private $cloudFederationProviderManager;
65 65
 
66
-	/** @var Config */
67
-	private $config;
66
+    /** @var Config */
67
+    private $config;
68 68
 
69
-	/** @var ICloudFederationFactory */
70
-	private $factory;
69
+    /** @var ICloudFederationFactory */
70
+    private $factory;
71 71
 
72
-	/** @var ICloudIdManager */
73
-	private $cloudIdManager;
72
+    /** @var ICloudIdManager */
73
+    private $cloudIdManager;
74 74
 
75
-	public function __construct($appName,
76
-								IRequest $request,
77
-								ILogger $logger,
78
-								IUserManager $userManager,
79
-								IURLGenerator $urlGenerator,
80
-								ICloudFederationProviderManager $cloudFederationProviderManager,
81
-								Config $config,
82
-								ICloudFederationFactory $factory,
83
-								ICloudIdManager $cloudIdManager
84
-	) {
85
-		parent::__construct($appName, $request);
75
+    public function __construct($appName,
76
+                                IRequest $request,
77
+                                ILogger $logger,
78
+                                IUserManager $userManager,
79
+                                IURLGenerator $urlGenerator,
80
+                                ICloudFederationProviderManager $cloudFederationProviderManager,
81
+                                Config $config,
82
+                                ICloudFederationFactory $factory,
83
+                                ICloudIdManager $cloudIdManager
84
+    ) {
85
+        parent::__construct($appName, $request);
86 86
 
87
-		$this->logger = $logger;
88
-		$this->userManager = $userManager;
89
-		$this->urlGenerator = $urlGenerator;
90
-		$this->cloudFederationProviderManager = $cloudFederationProviderManager;
91
-		$this->config = $config;
92
-		$this->factory = $factory;
93
-		$this->cloudIdManager = $cloudIdManager;
94
-	}
87
+        $this->logger = $logger;
88
+        $this->userManager = $userManager;
89
+        $this->urlGenerator = $urlGenerator;
90
+        $this->cloudFederationProviderManager = $cloudFederationProviderManager;
91
+        $this->config = $config;
92
+        $this->factory = $factory;
93
+        $this->cloudIdManager = $cloudIdManager;
94
+    }
95 95
 
96
-	/**
97
-	 * add share
98
-	 *
99
-	 * @NoCSRFRequired
100
-	 * @PublicPage
101
-	 * @BruteForceProtection(action=receiveFederatedShare)
102
-	 *
103
-	 * @param string $shareWith
104
-	 * @param string $name resource name (e.g. document.odt)
105
-	 * @param string $description share description (optional)
106
-	 * @param string $providerId resource UID on the provider side
107
-	 * @param string $owner provider specific UID of the user who owns the resource
108
-	 * @param string $ownerDisplayName display name of the user who shared the item
109
-	 * @param string $sharedBy provider specific UID of the user who shared the resource
110
-	 * @param string $sharedByDisplayName display name of the user who shared the resource
111
-	 * @param array $protocol (e,.g. ['name' => 'webdav', 'options' => ['username' => 'john', 'permissions' => 31]])
112
-	 * @param string $shareType ('group' or 'user' share)
113
-	 * @param $resourceType ('file', 'calendar',...)
114
-	 * @return Http\DataResponse|JSONResponse
115
-	 *
116
-	 * Example: curl -H "Content-Type: application/json" -X POST -d '{"shareWith":"admin1@serve1","name":"welcome server2.txt","description":"desc","providerId":"2","owner":"admin2@http://localhost/server2","ownerDisplayName":"admin2 display","shareType":"user","resourceType":"file","protocol":{"name":"webdav","options":{"sharedSecret":"secret","permissions":"webdav-property"}}}' http://localhost/server/index.php/ocm/shares
117
-	 */
118
-	public function addShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $protocol, $shareType, $resourceType) {
96
+    /**
97
+     * add share
98
+     *
99
+     * @NoCSRFRequired
100
+     * @PublicPage
101
+     * @BruteForceProtection(action=receiveFederatedShare)
102
+     *
103
+     * @param string $shareWith
104
+     * @param string $name resource name (e.g. document.odt)
105
+     * @param string $description share description (optional)
106
+     * @param string $providerId resource UID on the provider side
107
+     * @param string $owner provider specific UID of the user who owns the resource
108
+     * @param string $ownerDisplayName display name of the user who shared the item
109
+     * @param string $sharedBy provider specific UID of the user who shared the resource
110
+     * @param string $sharedByDisplayName display name of the user who shared the resource
111
+     * @param array $protocol (e,.g. ['name' => 'webdav', 'options' => ['username' => 'john', 'permissions' => 31]])
112
+     * @param string $shareType ('group' or 'user' share)
113
+     * @param $resourceType ('file', 'calendar',...)
114
+     * @return Http\DataResponse|JSONResponse
115
+     *
116
+     * Example: curl -H "Content-Type: application/json" -X POST -d '{"shareWith":"admin1@serve1","name":"welcome server2.txt","description":"desc","providerId":"2","owner":"admin2@http://localhost/server2","ownerDisplayName":"admin2 display","shareType":"user","resourceType":"file","protocol":{"name":"webdav","options":{"sharedSecret":"secret","permissions":"webdav-property"}}}' http://localhost/server/index.php/ocm/shares
117
+     */
118
+    public function addShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $protocol, $shareType, $resourceType) {
119 119
 
120
-		// check if all required parameters are set
121
-		if ($shareWith === null ||
122
-			$name === null ||
123
-			$providerId === null ||
124
-			$owner === null ||
125
-			$resourceType === null ||
126
-			$shareType === null ||
127
-			!is_array($protocol) ||
128
-			!isset($protocol['name']) ||
129
-			!isset ($protocol['options']) ||
130
-			!is_array($protocol['options']) ||
131
-			!isset($protocol['options']['sharedSecret'])
132
-		) {
133
-			return new JSONResponse(
134
-				['message' => 'Missing arguments'],
135
-				Http::STATUS_BAD_REQUEST
136
-			);
137
-		}
120
+        // check if all required parameters are set
121
+        if ($shareWith === null ||
122
+            $name === null ||
123
+            $providerId === null ||
124
+            $owner === null ||
125
+            $resourceType === null ||
126
+            $shareType === null ||
127
+            !is_array($protocol) ||
128
+            !isset($protocol['name']) ||
129
+            !isset ($protocol['options']) ||
130
+            !is_array($protocol['options']) ||
131
+            !isset($protocol['options']['sharedSecret'])
132
+        ) {
133
+            return new JSONResponse(
134
+                ['message' => 'Missing arguments'],
135
+                Http::STATUS_BAD_REQUEST
136
+            );
137
+        }
138 138
 
139
-		$cloudId = $this->cloudIdManager->resolveCloudId($shareWith);
140
-		$shareWithLocalId = $cloudId->getUser();
141
-		$shareWith = $this->mapUid($shareWithLocalId);
139
+        $cloudId = $this->cloudIdManager->resolveCloudId($shareWith);
140
+        $shareWithLocalId = $cloudId->getUser();
141
+        $shareWith = $this->mapUid($shareWithLocalId);
142 142
 
143
-		if (!$this->userManager->userExists($shareWith)) {
144
-			return new JSONResponse(
145
-				['message' => 'User "' . $shareWith . '" does not exists at ' . $this->urlGenerator->getBaseUrl()],
146
-				Http::STATUS_BAD_REQUEST
147
-			);
148
-		}
143
+        if (!$this->userManager->userExists($shareWith)) {
144
+            return new JSONResponse(
145
+                ['message' => 'User "' . $shareWith . '" does not exists at ' . $this->urlGenerator->getBaseUrl()],
146
+                Http::STATUS_BAD_REQUEST
147
+            );
148
+        }
149 149
 
150
-		// if no explicit display name is given, we use the uid as display name
151
-		$ownerDisplayName = $ownerDisplayName === null ? $owner : $ownerDisplayName;
152
-		$sharedByDisplayName = $sharedByDisplayName === null ? $sharedBy : $sharedByDisplayName;
150
+        // if no explicit display name is given, we use the uid as display name
151
+        $ownerDisplayName = $ownerDisplayName === null ? $owner : $ownerDisplayName;
152
+        $sharedByDisplayName = $sharedByDisplayName === null ? $sharedBy : $sharedByDisplayName;
153 153
 
154
-		// sharedBy* parameter is optional, if nothing is set we assume that it is the same user as the owner
155
-		if ($sharedBy === null) {
156
-			$sharedBy = $owner;
157
-			$sharedByDisplayName = $ownerDisplayName;
158
-		}
154
+        // sharedBy* parameter is optional, if nothing is set we assume that it is the same user as the owner
155
+        if ($sharedBy === null) {
156
+            $sharedBy = $owner;
157
+            $sharedByDisplayName = $ownerDisplayName;
158
+        }
159 159
 
160
-		try {
161
-			$provider = $this->cloudFederationProviderManager->getCloudFederationProvider($resourceType);
162
-			$share = $this->factory->getCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, '', $shareType, $resourceType);
163
-			$share->setProtocol($protocol);
164
-			$id = $provider->shareReceived($share);
165
-		} catch (ProviderDoesNotExistsException $e) {
166
-			return new JSONResponse(
167
-				['message' => $e->getMessage()],
168
-				Http::STATUS_NOT_IMPLEMENTED
169
-			);
170
-		} catch (ProviderCouldNotAddShareException $e) {
171
-			return new JSONResponse(
172
-				['message' => $e->getMessage()],
173
-				$e->getCode()
174
-			);
175
-		} catch (\Exception $e) {
176
-			return new JSONResponse(
177
-				['message' => 'Internal error at ' . $this->urlGenerator->getBaseUrl()],
178
-				Http::STATUS_BAD_REQUEST
179
-			);
180
-		}
160
+        try {
161
+            $provider = $this->cloudFederationProviderManager->getCloudFederationProvider($resourceType);
162
+            $share = $this->factory->getCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, '', $shareType, $resourceType);
163
+            $share->setProtocol($protocol);
164
+            $id = $provider->shareReceived($share);
165
+        } catch (ProviderDoesNotExistsException $e) {
166
+            return new JSONResponse(
167
+                ['message' => $e->getMessage()],
168
+                Http::STATUS_NOT_IMPLEMENTED
169
+            );
170
+        } catch (ProviderCouldNotAddShareException $e) {
171
+            return new JSONResponse(
172
+                ['message' => $e->getMessage()],
173
+                $e->getCode()
174
+            );
175
+        } catch (\Exception $e) {
176
+            return new JSONResponse(
177
+                ['message' => 'Internal error at ' . $this->urlGenerator->getBaseUrl()],
178
+                Http::STATUS_BAD_REQUEST
179
+            );
180
+        }
181 181
 
182
-		$user = $this->userManager->get($shareWithLocalId);
183
-		$recipientDisplayName = '';
184
-		if($user) {
185
-			$recipientDisplayName = $user->getDisplayName();
186
-		}
182
+        $user = $this->userManager->get($shareWithLocalId);
183
+        $recipientDisplayName = '';
184
+        if($user) {
185
+            $recipientDisplayName = $user->getDisplayName();
186
+        }
187 187
 
188
-		return new JSONResponse(
189
-			['recipientDisplayName' => $recipientDisplayName],
190
-			Http::STATUS_CREATED);
188
+        return new JSONResponse(
189
+            ['recipientDisplayName' => $recipientDisplayName],
190
+            Http::STATUS_CREATED);
191 191
 
192
-	}
192
+    }
193 193
 
194
-	/**
195
-	 * receive notification about existing share
196
-	 *
197
-	 * @NoCSRFRequired
198
-	 * @PublicPage
199
-	 * @BruteForceProtection(action=receiveFederatedShareNotification)
200
-	 *
201
-	 * @param string $notificationType (notification type, e.g. SHARE_ACCEPTED)
202
-	 * @param string $resourceType (calendar, file, contact,...)
203
-	 * @param string $providerId id of the share
204
-	 * @param array $notification the actual payload of the notification
205
-	 * @return JSONResponse
206
-	 */
207
-	public function receiveNotification($notificationType, $resourceType, $providerId, array $notification) {
194
+    /**
195
+     * receive notification about existing share
196
+     *
197
+     * @NoCSRFRequired
198
+     * @PublicPage
199
+     * @BruteForceProtection(action=receiveFederatedShareNotification)
200
+     *
201
+     * @param string $notificationType (notification type, e.g. SHARE_ACCEPTED)
202
+     * @param string $resourceType (calendar, file, contact,...)
203
+     * @param string $providerId id of the share
204
+     * @param array $notification the actual payload of the notification
205
+     * @return JSONResponse
206
+     */
207
+    public function receiveNotification($notificationType, $resourceType, $providerId, array $notification) {
208 208
 
209
-		// check if all required parameters are set
210
-		if ($notificationType === null ||
211
-			$resourceType === null ||
212
-			$providerId === null ||
213
-			!is_array($notification)
214
-		) {
215
-			return new JSONResponse(
216
-				['message' => 'Missing arguments'],
217
-				Http::STATUS_BAD_REQUEST
218
-			);
219
-		}
209
+        // check if all required parameters are set
210
+        if ($notificationType === null ||
211
+            $resourceType === null ||
212
+            $providerId === null ||
213
+            !is_array($notification)
214
+        ) {
215
+            return new JSONResponse(
216
+                ['message' => 'Missing arguments'],
217
+                Http::STATUS_BAD_REQUEST
218
+            );
219
+        }
220 220
 
221
-		try {
222
-			$provider = $this->cloudFederationProviderManager->getCloudFederationProvider($resourceType);
223
-			$result = $provider->notificationReceived($notificationType, $providerId, $notification);
224
-		} catch (ProviderDoesNotExistsException $e) {
225
-			return new JSONResponse(
226
-				['message' => $e->getMessage()],
227
-				Http::STATUS_BAD_REQUEST
228
-			);
229
-		} catch (ShareNotFound $e) {
230
-			return new JSONResponse(
231
-				['message' => $e->getMessage()],
232
-				Http::STATUS_BAD_REQUEST
233
-			);
234
-		} catch (ActionNotSupportedException $e) {
235
-			return new JSONResponse(
236
-				['message' => $e->getMessage()],
237
-				Http::STATUS_NOT_IMPLEMENTED
238
-			);
239
-		} catch (BadRequestException $e) {
240
-			return new JSONResponse($e->getReturnMessage(), Http::STATUS_BAD_REQUEST);
241
-		} catch (AuthenticationFailedException $e) {
242
-			return new JSONResponse(["message" => "RESOURCE_NOT_FOUND"], Http::STATUS_FORBIDDEN);
243
-		}
244
-		catch (\Exception $e) {
245
-			return new JSONResponse(
246
-				['message' => 'Internal error at ' . $this->urlGenerator->getBaseUrl()],
247
-				Http::STATUS_BAD_REQUEST
248
-			);
249
-		}
221
+        try {
222
+            $provider = $this->cloudFederationProviderManager->getCloudFederationProvider($resourceType);
223
+            $result = $provider->notificationReceived($notificationType, $providerId, $notification);
224
+        } catch (ProviderDoesNotExistsException $e) {
225
+            return new JSONResponse(
226
+                ['message' => $e->getMessage()],
227
+                Http::STATUS_BAD_REQUEST
228
+            );
229
+        } catch (ShareNotFound $e) {
230
+            return new JSONResponse(
231
+                ['message' => $e->getMessage()],
232
+                Http::STATUS_BAD_REQUEST
233
+            );
234
+        } catch (ActionNotSupportedException $e) {
235
+            return new JSONResponse(
236
+                ['message' => $e->getMessage()],
237
+                Http::STATUS_NOT_IMPLEMENTED
238
+            );
239
+        } catch (BadRequestException $e) {
240
+            return new JSONResponse($e->getReturnMessage(), Http::STATUS_BAD_REQUEST);
241
+        } catch (AuthenticationFailedException $e) {
242
+            return new JSONResponse(["message" => "RESOURCE_NOT_FOUND"], Http::STATUS_FORBIDDEN);
243
+        }
244
+        catch (\Exception $e) {
245
+            return new JSONResponse(
246
+                ['message' => 'Internal error at ' . $this->urlGenerator->getBaseUrl()],
247
+                Http::STATUS_BAD_REQUEST
248
+            );
249
+        }
250 250
 
251
-		return new JSONResponse($result,Http::STATUS_CREATED);
251
+        return new JSONResponse($result,Http::STATUS_CREATED);
252 252
 
253
-	}
253
+    }
254 254
 
255
-	/**
256
-	 * map login name to internal LDAP UID if a LDAP backend is in use
257
-	 *
258
-	 * @param string $uid
259
-	 * @return string mixed
260
-	 */
261
-	private function mapUid($uid) {
262
-		\OC::$server->getURLGenerator()->linkToDocs('key');
263
-		// FIXME this should be a method in the user management instead
264
-		$this->logger->debug('shareWith before, ' . $uid, ['app' => $this->appName]);
265
-		\OCP\Util::emitHook(
266
-			'\OCA\Files_Sharing\API\Server2Server',
267
-			'preLoginNameUsedAsUserName',
268
-			array('uid' => &$uid)
269
-		);
270
-		$this->logger->debug('shareWith after, ' . $uid, ['app' => $this->appName]);
255
+    /**
256
+     * map login name to internal LDAP UID if a LDAP backend is in use
257
+     *
258
+     * @param string $uid
259
+     * @return string mixed
260
+     */
261
+    private function mapUid($uid) {
262
+        \OC::$server->getURLGenerator()->linkToDocs('key');
263
+        // FIXME this should be a method in the user management instead
264
+        $this->logger->debug('shareWith before, ' . $uid, ['app' => $this->appName]);
265
+        \OCP\Util::emitHook(
266
+            '\OCA\Files_Sharing\API\Server2Server',
267
+            'preLoginNameUsedAsUserName',
268
+            array('uid' => &$uid)
269
+        );
270
+        $this->logger->debug('shareWith after, ' . $uid, ['app' => $this->appName]);
271 271
 
272
-		return $uid;
273
-	}
272
+        return $uid;
273
+    }
274 274
 
275 275
 }
Please login to merge, or discard this patch.