@@ -60,510 +60,510 @@ |
||
| 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 | } |
@@ -32,17 +32,17 @@ |
||
| 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 | } |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | // for backward compatibility make sure that the remote url stored in the |
| 165 | 165 | // database ends with a trailing slash |
| 166 | 166 | if (substr($remote, -1) !== '/') { |
| 167 | - $remote = $remote . '/'; |
|
| 167 | + $remote = $remote.'/'; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | $token = $share->getShareSecret(); |
@@ -190,16 +190,16 @@ discard block |
||
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | // FIXME this should be a method in the user management instead |
| 193 | - $this->logger->debug('shareWith before, ' . $shareWith, ['app' => 'files_sharing']); |
|
| 193 | + $this->logger->debug('shareWith before, '.$shareWith, ['app' => 'files_sharing']); |
|
| 194 | 194 | Util::emitHook( |
| 195 | 195 | '\OCA\Files_Sharing\API\Server2Server', |
| 196 | 196 | 'preLoginNameUsedAsUserName', |
| 197 | 197 | array('uid' => &$shareWith) |
| 198 | 198 | ); |
| 199 | - $this->logger->debug('shareWith after, ' . $shareWith, ['app' => 'files_sharing']); |
|
| 199 | + $this->logger->debug('shareWith after, '.$shareWith, ['app' => 'files_sharing']); |
|
| 200 | 200 | |
| 201 | 201 | if (!$this->userManager->userExists($shareWith)) { |
| 202 | - throw new ProviderCouldNotAddShareException('User does not exists', '',Http::STATUS_BAD_REQUEST); |
|
| 202 | + throw new ProviderCouldNotAddShareException('User does not exists', '', Http::STATUS_BAD_REQUEST); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | \OC_Util::setupFS($shareWith); |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | ->setType('remote_share') |
| 226 | 226 | ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_RECEIVED, [$ownerFederatedId, trim($name, '/')]) |
| 227 | 227 | ->setAffectedUser($shareWith) |
| 228 | - ->setObject('remote_share', (int)$shareId, $name); |
|
| 228 | + ->setObject('remote_share', (int) $shareId, $name); |
|
| 229 | 229 | \OC::$server->getActivityManager()->publish($event); |
| 230 | 230 | |
| 231 | 231 | $notification = $this->notificationManager->createNotification(); |
@@ -237,12 +237,12 @@ discard block |
||
| 237 | 237 | |
| 238 | 238 | $declineAction = $notification->createAction(); |
| 239 | 239 | $declineAction->setLabel('decline') |
| 240 | - ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'DELETE'); |
|
| 240 | + ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/'.$shareId)), 'DELETE'); |
|
| 241 | 241 | $notification->addAction($declineAction); |
| 242 | 242 | |
| 243 | 243 | $acceptAction = $notification->createAction(); |
| 244 | 244 | $acceptAction->setLabel('accept') |
| 245 | - ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'POST'); |
|
| 245 | + ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/'.$shareId)), 'POST'); |
|
| 246 | 246 | $notification->addAction($acceptAction); |
| 247 | 247 | |
| 248 | 248 | $this->notificationManager->notify($notification); |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | 'level' => ILogger::ERROR, |
| 255 | 255 | 'app' => 'files_sharing' |
| 256 | 256 | ]); |
| 257 | - throw new ProviderCouldNotAddShareException('internal server error, was not able to add share from ' . $remote, '', HTTP::STATUS_INTERNAL_SERVER_ERROR); |
|
| 257 | + throw new ProviderCouldNotAddShareException('internal server error, was not able to add share from '.$remote, '', HTTP::STATUS_INTERNAL_SERVER_ERROR); |
|
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | 260 | |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | */ |
| 352 | 352 | protected function executeAcceptShare(IShare $share) { |
| 353 | 353 | try { |
| 354 | - $fileId = (int)$share->getNode()->getId(); |
|
| 354 | + $fileId = (int) $share->getNode()->getId(); |
|
| 355 | 355 | list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId); |
| 356 | 356 | } catch (\Exception $e) { |
| 357 | 357 | throw new ShareNotFound(); |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | $this->federatedShareProvider->removeShareFromTable($share); |
| 430 | 430 | |
| 431 | 431 | try { |
| 432 | - $fileId = (int)$share->getNode()->getId(); |
|
| 432 | + $fileId = (int) $share->getNode()->getId(); |
|
| 433 | 433 | list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId); |
| 434 | 434 | } catch (\Exception $e) { |
| 435 | 435 | throw new ShareNotFound(); |
@@ -530,7 +530,7 @@ discard block |
||
| 530 | 530 | $notification = $this->notificationManager->createNotification(); |
| 531 | 531 | $notification->setApp('files_sharing') |
| 532 | 532 | ->setUser($share['user']) |
| 533 | - ->setObject('remote_share', (int)$share['id']); |
|
| 533 | + ->setObject('remote_share', (int) $share['id']); |
|
| 534 | 534 | $this->notificationManager->markProcessed($notification); |
| 535 | 535 | |
| 536 | 536 | $event = $this->activityManager->generateEvent(); |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | ->setType('remote_share') |
| 539 | 539 | ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_UNSHARED, [$owner->getId(), $path]) |
| 540 | 540 | ->setAffectedUser($user) |
| 541 | - ->setObject('remote_share', (int)$share['id'], $path); |
|
| 541 | + ->setObject('remote_share', (int) $share['id'], $path); |
|
| 542 | 542 | \OC::$server->getActivityManager()->publish($event); |
| 543 | 543 | } |
| 544 | 544 | |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | $owner = $share->getShareOwner(); |
| 587 | 587 | $currentServer = $this->addressHandler->generateRemoteURL(); |
| 588 | 588 | if ($this->addressHandler->compareAddresses($user, $remote, $owner, $currentServer)) { |
| 589 | - throw new ProviderCouldNotAddShareException('Resharing back to the owner is not allowed: ' . $id); |
|
| 589 | + throw new ProviderCouldNotAddShareException('Resharing back to the owner is not allowed: '.$id); |
|
| 590 | 590 | } |
| 591 | 591 | } catch (\Exception $e) { |
| 592 | 592 | throw new ProviderCouldNotAddShareException($e->getMessage()); |
@@ -600,10 +600,10 @@ discard block |
||
| 600 | 600 | $share->setSharedBy($share->getSharedWith()); |
| 601 | 601 | $share->setSharedWith($shareWith); |
| 602 | 602 | $result = $this->federatedShareProvider->create($share); |
| 603 | - $this->federatedShareProvider->storeRemoteId((int)$result->getId(), $senderId); |
|
| 603 | + $this->federatedShareProvider->storeRemoteId((int) $result->getId(), $senderId); |
|
| 604 | 604 | return ['token' => $result->getToken(), 'providerId' => $result->getId()]; |
| 605 | 605 | } else { |
| 606 | - throw new ProviderCouldNotAddShareException('resharing not allowed for share: ' . $id); |
|
| 606 | + throw new ProviderCouldNotAddShareException('resharing not allowed for share: '.$id); |
|
| 607 | 607 | } |
| 608 | 608 | |
| 609 | 609 | } |
@@ -649,7 +649,7 @@ discard block |
||
| 649 | 649 | */ |
| 650 | 650 | protected function ocmPermissions2ncPermissions(array $ocmPermissions) { |
| 651 | 651 | $ncPermissions = 0; |
| 652 | - foreach($ocmPermissions as $permission) { |
|
| 652 | + foreach ($ocmPermissions as $permission) { |
|
| 653 | 653 | switch (strtolower($permission)) { |
| 654 | 654 | case 'read': |
| 655 | 655 | $ncPermissions += Constants::PERMISSION_READ; |
@@ -664,7 +664,7 @@ discard block |
||
| 664 | 664 | throw new BadRequestException(['permission']); |
| 665 | 665 | } |
| 666 | 666 | |
| 667 | - error_log("new permissions: " . $ncPermissions); |
|
| 667 | + error_log("new permissions: ".$ncPermissions); |
|
| 668 | 668 | } |
| 669 | 669 | |
| 670 | 670 | return $ncPermissions; |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * share received from another server |
| 143 | 143 | * |
| 144 | 144 | * @param ICloudFederationShare $share |
| 145 | - * @return string provider specific unique ID of the share |
|
| 145 | + * @return integer provider specific unique ID of the share |
|
| 146 | 146 | * |
| 147 | 147 | * @throws ProviderCouldNotAddShareException |
| 148 | 148 | * @throws \OCP\AppFramework\QueryException |
@@ -767,7 +767,7 @@ discard block |
||
| 767 | 767 | /** |
| 768 | 768 | * get the supported share types, e.g. "user", "group", etc. |
| 769 | 769 | * |
| 770 | - * @return array |
|
| 770 | + * @return string[] |
|
| 771 | 771 | */ |
| 772 | 772 | public function getSupportedShareTypes() { |
| 773 | 773 | return ['user']; |
@@ -50,726 +50,726 @@ |
||
| 50 | 50 | |
| 51 | 51 | class CloudFederationProviderFiles implements ICloudFederationProvider { |
| 52 | 52 | |
| 53 | - /** @var IAppManager */ |
|
| 54 | - private $appManager; |
|
| 55 | - |
|
| 56 | - /** @var FederatedShareProvider */ |
|
| 57 | - private $federatedShareProvider; |
|
| 58 | - |
|
| 59 | - /** @var AddressHandler */ |
|
| 60 | - private $addressHandler; |
|
| 61 | - |
|
| 62 | - /** @var ILogger */ |
|
| 63 | - private $logger; |
|
| 64 | - |
|
| 65 | - /** @var IUserManager */ |
|
| 66 | - private $userManager; |
|
| 67 | - |
|
| 68 | - /** @var ICloudIdManager */ |
|
| 69 | - private $cloudIdManager; |
|
| 70 | - |
|
| 71 | - /** @var IActivityManager */ |
|
| 72 | - private $activityManager; |
|
| 73 | - |
|
| 74 | - /** @var INotificationManager */ |
|
| 75 | - private $notificationManager; |
|
| 76 | - |
|
| 77 | - /** @var IURLGenerator */ |
|
| 78 | - private $urlGenerator; |
|
| 79 | - |
|
| 80 | - /** @var ICloudFederationFactory */ |
|
| 81 | - private $cloudFederationFactory; |
|
| 82 | - |
|
| 83 | - /** @var ICloudFederationProviderManager */ |
|
| 84 | - private $cloudFederationProviderManager; |
|
| 85 | - |
|
| 86 | - /** @var IDBConnection */ |
|
| 87 | - private $connection; |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * CloudFederationProvider constructor. |
|
| 91 | - * |
|
| 92 | - * @param IAppManager $appManager |
|
| 93 | - * @param FederatedShareProvider $federatedShareProvider |
|
| 94 | - * @param AddressHandler $addressHandler |
|
| 95 | - * @param ILogger $logger |
|
| 96 | - * @param IUserManager $userManager |
|
| 97 | - * @param ICloudIdManager $cloudIdManager |
|
| 98 | - * @param IActivityManager $activityManager |
|
| 99 | - * @param INotificationManager $notificationManager |
|
| 100 | - * @param IURLGenerator $urlGenerator |
|
| 101 | - * @param ICloudFederationFactory $cloudFederationFactory |
|
| 102 | - * @param ICloudFederationProviderManager $cloudFederationProviderManager |
|
| 103 | - * @param IDBConnection $connection |
|
| 104 | - */ |
|
| 105 | - public function __construct(IAppManager $appManager, |
|
| 106 | - FederatedShareProvider $federatedShareProvider, |
|
| 107 | - AddressHandler $addressHandler, |
|
| 108 | - ILogger $logger, |
|
| 109 | - IUserManager $userManager, |
|
| 110 | - ICloudIdManager $cloudIdManager, |
|
| 111 | - IActivityManager $activityManager, |
|
| 112 | - INotificationManager $notificationManager, |
|
| 113 | - IURLGenerator $urlGenerator, |
|
| 114 | - ICloudFederationFactory $cloudFederationFactory, |
|
| 115 | - ICloudFederationProviderManager $cloudFederationProviderManager, |
|
| 116 | - IDBConnection $connection |
|
| 117 | - ) { |
|
| 118 | - $this->appManager = $appManager; |
|
| 119 | - $this->federatedShareProvider = $federatedShareProvider; |
|
| 120 | - $this->addressHandler = $addressHandler; |
|
| 121 | - $this->logger = $logger; |
|
| 122 | - $this->userManager = $userManager; |
|
| 123 | - $this->cloudIdManager = $cloudIdManager; |
|
| 124 | - $this->activityManager = $activityManager; |
|
| 125 | - $this->notificationManager = $notificationManager; |
|
| 126 | - $this->urlGenerator = $urlGenerator; |
|
| 127 | - $this->cloudFederationFactory = $cloudFederationFactory; |
|
| 128 | - $this->cloudFederationProviderManager = $cloudFederationProviderManager; |
|
| 129 | - $this->connection = $connection; |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - |
|
| 133 | - |
|
| 134 | - /** |
|
| 135 | - * @return string |
|
| 136 | - */ |
|
| 137 | - public function getShareType() { |
|
| 138 | - return 'file'; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * share received from another server |
|
| 143 | - * |
|
| 144 | - * @param ICloudFederationShare $share |
|
| 145 | - * @return string provider specific unique ID of the share |
|
| 146 | - * |
|
| 147 | - * @throws ProviderCouldNotAddShareException |
|
| 148 | - * @throws \OCP\AppFramework\QueryException |
|
| 149 | - * @throws \OC\HintException |
|
| 150 | - * @since 14.0.0 |
|
| 151 | - */ |
|
| 152 | - public function shareReceived(ICloudFederationShare $share) { |
|
| 153 | - |
|
| 154 | - if (!$this->isS2SEnabled(true)) { |
|
| 155 | - throw new ProviderCouldNotAddShareException('Server does not support federated cloud sharing', '', Http::STATUS_SERVICE_UNAVAILABLE); |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - $protocol = $share->getProtocol(); |
|
| 159 | - if ($protocol['name'] !== 'webdav') { |
|
| 160 | - throw new ProviderCouldNotAddShareException('Unsupported protocol for data exchange.', '', Http::STATUS_NOT_IMPLEMENTED); |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - list($ownerUid, $remote) = $this->addressHandler->splitUserRemote($share->getOwner()); |
|
| 164 | - // for backward compatibility make sure that the remote url stored in the |
|
| 165 | - // database ends with a trailing slash |
|
| 166 | - if (substr($remote, -1) !== '/') { |
|
| 167 | - $remote = $remote . '/'; |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - $token = $share->getShareSecret(); |
|
| 171 | - $name = $share->getResourceName(); |
|
| 172 | - $owner = $share->getOwnerDisplayName(); |
|
| 173 | - $sharedBy = $share->getSharedByDisplayName(); |
|
| 174 | - $shareWith = $share->getShareWith(); |
|
| 175 | - $remoteId = $share->getProviderId(); |
|
| 176 | - $sharedByFederatedId = $share->getSharedBy(); |
|
| 177 | - $ownerFederatedId = $share->getOwner(); |
|
| 178 | - |
|
| 179 | - // if no explicit information about the person who created the share was send |
|
| 180 | - // we assume that the share comes from the owner |
|
| 181 | - if ($sharedByFederatedId === null) { |
|
| 182 | - $sharedBy = $owner; |
|
| 183 | - $sharedByFederatedId = $ownerFederatedId; |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - if ($remote && $token && $name && $owner && $remoteId && $shareWith) { |
|
| 187 | - |
|
| 188 | - if (!Util::isValidFileName($name)) { |
|
| 189 | - throw new ProviderCouldNotAddShareException('The mountpoint name contains invalid characters.', '', Http::STATUS_BAD_REQUEST); |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - // FIXME this should be a method in the user management instead |
|
| 193 | - $this->logger->debug('shareWith before, ' . $shareWith, ['app' => 'files_sharing']); |
|
| 194 | - Util::emitHook( |
|
| 195 | - '\OCA\Files_Sharing\API\Server2Server', |
|
| 196 | - 'preLoginNameUsedAsUserName', |
|
| 197 | - array('uid' => &$shareWith) |
|
| 198 | - ); |
|
| 199 | - $this->logger->debug('shareWith after, ' . $shareWith, ['app' => 'files_sharing']); |
|
| 200 | - |
|
| 201 | - if (!$this->userManager->userExists($shareWith)) { |
|
| 202 | - throw new ProviderCouldNotAddShareException('User does not exists', '',Http::STATUS_BAD_REQUEST); |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - \OC_Util::setupFS($shareWith); |
|
| 206 | - |
|
| 207 | - $externalManager = new \OCA\Files_Sharing\External\Manager( |
|
| 208 | - \OC::$server->getDatabaseConnection(), |
|
| 209 | - Filesystem::getMountManager(), |
|
| 210 | - Filesystem::getLoader(), |
|
| 211 | - \OC::$server->getHTTPClientService(), |
|
| 212 | - \OC::$server->getNotificationManager(), |
|
| 213 | - \OC::$server->query(\OCP\OCS\IDiscoveryService::class), |
|
| 214 | - \OC::$server->getCloudFederationProviderManager(), |
|
| 215 | - \OC::$server->getCloudFederationFactory(), |
|
| 216 | - $shareWith |
|
| 217 | - ); |
|
| 218 | - |
|
| 219 | - try { |
|
| 220 | - $externalManager->addShare($remote, $token, '', $name, $owner, false, $shareWith, $remoteId); |
|
| 221 | - $shareId = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share_external'); |
|
| 222 | - |
|
| 223 | - $event = $this->activityManager->generateEvent(); |
|
| 224 | - $event->setApp('files_sharing') |
|
| 225 | - ->setType('remote_share') |
|
| 226 | - ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_RECEIVED, [$ownerFederatedId, trim($name, '/')]) |
|
| 227 | - ->setAffectedUser($shareWith) |
|
| 228 | - ->setObject('remote_share', (int)$shareId, $name); |
|
| 229 | - \OC::$server->getActivityManager()->publish($event); |
|
| 230 | - |
|
| 231 | - $notification = $this->notificationManager->createNotification(); |
|
| 232 | - $notification->setApp('files_sharing') |
|
| 233 | - ->setUser($shareWith) |
|
| 234 | - ->setDateTime(new \DateTime()) |
|
| 235 | - ->setObject('remote_share', $shareId) |
|
| 236 | - ->setSubject('remote_share', [$ownerFederatedId, $sharedByFederatedId, trim($name, '/')]); |
|
| 237 | - |
|
| 238 | - $declineAction = $notification->createAction(); |
|
| 239 | - $declineAction->setLabel('decline') |
|
| 240 | - ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'DELETE'); |
|
| 241 | - $notification->addAction($declineAction); |
|
| 242 | - |
|
| 243 | - $acceptAction = $notification->createAction(); |
|
| 244 | - $acceptAction->setLabel('accept') |
|
| 245 | - ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'POST'); |
|
| 246 | - $notification->addAction($acceptAction); |
|
| 247 | - |
|
| 248 | - $this->notificationManager->notify($notification); |
|
| 249 | - |
|
| 250 | - return $shareId; |
|
| 251 | - } catch (\Exception $e) { |
|
| 252 | - $this->logger->logException($e, [ |
|
| 253 | - 'message' => 'Server can not add remote share.', |
|
| 254 | - 'level' => ILogger::ERROR, |
|
| 255 | - 'app' => 'files_sharing' |
|
| 256 | - ]); |
|
| 257 | - throw new ProviderCouldNotAddShareException('internal server error, was not able to add share from ' . $remote, '', HTTP::STATUS_INTERNAL_SERVER_ERROR); |
|
| 258 | - } |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - throw new ProviderCouldNotAddShareException('server can not add remote share, missing parameter', '', HTTP::STATUS_BAD_REQUEST); |
|
| 262 | - |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - /** |
|
| 266 | - * notification received from another server |
|
| 267 | - * |
|
| 268 | - * @param string $notificationType (e.g. SHARE_ACCEPTED) |
|
| 269 | - * @param string $providerId id of the share |
|
| 270 | - * @param array $notification payload of the notification |
|
| 271 | - * @return array data send back to the sender |
|
| 272 | - * |
|
| 273 | - * @throws ActionNotSupportedException |
|
| 274 | - * @throws AuthenticationFailedException |
|
| 275 | - * @throws BadRequestException |
|
| 276 | - * @throws \OC\HintException |
|
| 277 | - * @since 14.0.0 |
|
| 278 | - */ |
|
| 279 | - public function notificationReceived($notificationType, $providerId, array $notification) { |
|
| 280 | - |
|
| 281 | - switch ($notificationType) { |
|
| 282 | - case 'SHARE_ACCEPTED': |
|
| 283 | - return $this->shareAccepted($providerId, $notification); |
|
| 284 | - case 'SHARE_DECLINED': |
|
| 285 | - return $this->shareDeclined($providerId, $notification); |
|
| 286 | - case 'SHARE_UNSHARED': |
|
| 287 | - return $this->unshare($providerId, $notification); |
|
| 288 | - case 'REQUEST_RESHARE': |
|
| 289 | - return $this->reshareRequested($providerId, $notification); |
|
| 290 | - case 'RESHARE_UNDO': |
|
| 291 | - return $this->undoReshare($providerId, $notification); |
|
| 292 | - case 'RESHARE_CHANGE_PERMISSION': |
|
| 293 | - return $this->updateResharePermissions($providerId, $notification); |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - |
|
| 297 | - throw new BadRequestException([$notificationType]); |
|
| 298 | - } |
|
| 299 | - |
|
| 300 | - /** |
|
| 301 | - * process notification that the recipient accepted a share |
|
| 302 | - * |
|
| 303 | - * @param string $id |
|
| 304 | - * @param array $notification |
|
| 305 | - * @return array |
|
| 306 | - * @throws ActionNotSupportedException |
|
| 307 | - * @throws AuthenticationFailedException |
|
| 308 | - * @throws BadRequestException |
|
| 309 | - * @throws \OC\HintException |
|
| 310 | - */ |
|
| 311 | - private function shareAccepted($id, array $notification) { |
|
| 312 | - |
|
| 313 | - if (!$this->isS2SEnabled()) { |
|
| 314 | - throw new ActionNotSupportedException('Server does not support federated cloud sharing'); |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - if (!isset($notification['sharedSecret'])) { |
|
| 318 | - throw new BadRequestException(['sharedSecret']); |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - $token = $notification['sharedSecret']; |
|
| 322 | - |
|
| 323 | - $share = $this->federatedShareProvider->getShareById($id); |
|
| 324 | - |
|
| 325 | - $this->verifyShare($share, $token); |
|
| 326 | - $this->executeAcceptShare($share); |
|
| 327 | - if ($share->getShareOwner() !== $share->getSharedBy()) { |
|
| 328 | - list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedBy()); |
|
| 329 | - $remoteId = $this->federatedShareProvider->getRemoteId($share); |
|
| 330 | - $notification = $this->cloudFederationFactory->getCloudFederationNotification(); |
|
| 331 | - $notification->setMessage( |
|
| 332 | - 'SHARE_ACCEPTED', |
|
| 333 | - 'file', |
|
| 334 | - $remoteId, |
|
| 335 | - [ |
|
| 336 | - 'sharedSecret' => $token, |
|
| 337 | - 'message' => 'Recipient accepted the re-share' |
|
| 338 | - ] |
|
| 339 | - |
|
| 340 | - ); |
|
| 341 | - $this->cloudFederationProviderManager->sendNotification($remote, $notification); |
|
| 342 | - |
|
| 343 | - } |
|
| 344 | - |
|
| 345 | - return []; |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - /** |
|
| 349 | - * @param IShare $share |
|
| 350 | - * @throws ShareNotFound |
|
| 351 | - */ |
|
| 352 | - protected function executeAcceptShare(IShare $share) { |
|
| 353 | - try { |
|
| 354 | - $fileId = (int)$share->getNode()->getId(); |
|
| 355 | - list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId); |
|
| 356 | - } catch (\Exception $e) { |
|
| 357 | - throw new ShareNotFound(); |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - $event = $this->activityManager->generateEvent(); |
|
| 361 | - $event->setApp('files_sharing') |
|
| 362 | - ->setType('remote_share') |
|
| 363 | - ->setAffectedUser($this->getCorrectUid($share)) |
|
| 364 | - ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_ACCEPTED, [$share->getSharedWith(), [$fileId => $file]]) |
|
| 365 | - ->setObject('files', $fileId, $file) |
|
| 366 | - ->setLink($link); |
|
| 367 | - $this->activityManager->publish($event); |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - /** |
|
| 371 | - * process notification that the recipient declined a share |
|
| 372 | - * |
|
| 373 | - * @param string $id |
|
| 374 | - * @param array $notification |
|
| 375 | - * @return array |
|
| 376 | - * @throws ActionNotSupportedException |
|
| 377 | - * @throws AuthenticationFailedException |
|
| 378 | - * @throws BadRequestException |
|
| 379 | - * @throws ShareNotFound |
|
| 380 | - * @throws \OC\HintException |
|
| 381 | - * |
|
| 382 | - */ |
|
| 383 | - protected function shareDeclined($id, array $notification) { |
|
| 384 | - |
|
| 385 | - if (!$this->isS2SEnabled()) { |
|
| 386 | - throw new ActionNotSupportedException('Server does not support federated cloud sharing'); |
|
| 387 | - } |
|
| 388 | - |
|
| 389 | - if (!isset($notification['sharedSecret'])) { |
|
| 390 | - throw new BadRequestException(['sharedSecret']); |
|
| 391 | - } |
|
| 392 | - |
|
| 393 | - $token = $notification['sharedSecret']; |
|
| 394 | - |
|
| 395 | - $share = $this->federatedShareProvider->getShareById($id); |
|
| 396 | - |
|
| 397 | - $this->verifyShare($share, $token); |
|
| 398 | - |
|
| 399 | - if ($share->getShareOwner() !== $share->getSharedBy()) { |
|
| 400 | - list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedBy()); |
|
| 401 | - $remoteId = $this->federatedShareProvider->getRemoteId($share); |
|
| 402 | - $notification = $this->cloudFederationFactory->getCloudFederationNotification(); |
|
| 403 | - $notification->setMessage( |
|
| 404 | - 'SHARE_DECLINED', |
|
| 405 | - 'file', |
|
| 406 | - $remoteId, |
|
| 407 | - [ |
|
| 408 | - 'sharedSecret' => $token, |
|
| 409 | - 'message' => 'Recipient declined the re-share' |
|
| 410 | - ] |
|
| 411 | - |
|
| 412 | - ); |
|
| 413 | - $this->cloudFederationProviderManager->sendNotification($remote, $notification); |
|
| 414 | - } |
|
| 415 | - |
|
| 416 | - $this->executeDeclineShare($share); |
|
| 417 | - |
|
| 418 | - return []; |
|
| 419 | - |
|
| 420 | - } |
|
| 421 | - |
|
| 422 | - /** |
|
| 423 | - * delete declined share and create a activity |
|
| 424 | - * |
|
| 425 | - * @param IShare $share |
|
| 426 | - * @throws ShareNotFound |
|
| 427 | - */ |
|
| 428 | - protected function executeDeclineShare(IShare $share) { |
|
| 429 | - $this->federatedShareProvider->removeShareFromTable($share); |
|
| 430 | - |
|
| 431 | - try { |
|
| 432 | - $fileId = (int)$share->getNode()->getId(); |
|
| 433 | - list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId); |
|
| 434 | - } catch (\Exception $e) { |
|
| 435 | - throw new ShareNotFound(); |
|
| 436 | - } |
|
| 437 | - |
|
| 438 | - $event = $this->activityManager->generateEvent(); |
|
| 439 | - $event->setApp('files_sharing') |
|
| 440 | - ->setType('remote_share') |
|
| 441 | - ->setAffectedUser($this->getCorrectUid($share)) |
|
| 442 | - ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_DECLINED, [$share->getSharedWith(), [$fileId => $file]]) |
|
| 443 | - ->setObject('files', $fileId, $file) |
|
| 444 | - ->setLink($link); |
|
| 445 | - $this->activityManager->publish($event); |
|
| 446 | - |
|
| 447 | - } |
|
| 448 | - |
|
| 449 | - /** |
|
| 450 | - * received the notification that the owner unshared a file from you |
|
| 451 | - * |
|
| 452 | - * @param string $id |
|
| 453 | - * @param array $notification |
|
| 454 | - * @return array |
|
| 455 | - * @throws AuthenticationFailedException |
|
| 456 | - * @throws BadRequestException |
|
| 457 | - */ |
|
| 458 | - private function undoReshare($id, array $notification) { |
|
| 459 | - if (!isset($notification['sharedSecret'])) { |
|
| 460 | - throw new BadRequestException(['sharedSecret']); |
|
| 461 | - } |
|
| 462 | - $token = $notification['sharedSecret']; |
|
| 463 | - |
|
| 464 | - $share = $this->federatedShareProvider->getShareById($id); |
|
| 465 | - |
|
| 466 | - $this->verifyShare($share, $token); |
|
| 467 | - $this->federatedShareProvider->removeShareFromTable($share); |
|
| 468 | - return []; |
|
| 469 | - } |
|
| 470 | - |
|
| 471 | - /** |
|
| 472 | - * unshare file from self |
|
| 473 | - * |
|
| 474 | - * @param string $id |
|
| 475 | - * @param array $notification |
|
| 476 | - * @return array |
|
| 477 | - * @throws ActionNotSupportedException |
|
| 478 | - * @throws BadRequestException |
|
| 479 | - */ |
|
| 480 | - private function unshare($id, array $notification) { |
|
| 481 | - |
|
| 482 | - if (!$this->isS2SEnabled(true)) { |
|
| 483 | - throw new ActionNotSupportedException("incoming shares disabled!"); |
|
| 484 | - } |
|
| 485 | - |
|
| 486 | - if (!isset($notification['sharedSecret'])) { |
|
| 487 | - throw new BadRequestException(['sharedSecret']); |
|
| 488 | - } |
|
| 489 | - $token = $notification['sharedSecret']; |
|
| 490 | - |
|
| 491 | - $qb = $this->connection->getQueryBuilder(); |
|
| 492 | - $qb->select('*') |
|
| 493 | - ->from('share_external') |
|
| 494 | - ->where( |
|
| 495 | - $qb->expr()->andX( |
|
| 496 | - $qb->expr()->eq('remote_id', $qb->createNamedParameter($id)), |
|
| 497 | - $qb->expr()->eq('share_token', $qb->createNamedParameter($token)) |
|
| 498 | - ) |
|
| 499 | - ); |
|
| 500 | - |
|
| 501 | - $result = $qb->execute(); |
|
| 502 | - $share = $result->fetch(); |
|
| 503 | - $result->closeCursor(); |
|
| 504 | - |
|
| 505 | - if ($token && $id && !empty($share)) { |
|
| 506 | - |
|
| 507 | - $remote = $this->cleanupRemote($share['remote']); |
|
| 508 | - |
|
| 509 | - $owner = $this->cloudIdManager->getCloudId($share['owner'], $remote); |
|
| 510 | - $mountpoint = $share['mountpoint']; |
|
| 511 | - $user = $share['user']; |
|
| 512 | - |
|
| 513 | - $qb = $this->connection->getQueryBuilder(); |
|
| 514 | - $qb->delete('share_external') |
|
| 515 | - ->where( |
|
| 516 | - $qb->expr()->andX( |
|
| 517 | - $qb->expr()->eq('remote_id', $qb->createNamedParameter($id)), |
|
| 518 | - $qb->expr()->eq('share_token', $qb->createNamedParameter($token)) |
|
| 519 | - ) |
|
| 520 | - ); |
|
| 521 | - |
|
| 522 | - $qb->execute(); |
|
| 523 | - |
|
| 524 | - if ($share['accepted']) { |
|
| 525 | - $path = trim($mountpoint, '/'); |
|
| 526 | - } else { |
|
| 527 | - $path = trim($share['name'], '/'); |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - $notification = $this->notificationManager->createNotification(); |
|
| 531 | - $notification->setApp('files_sharing') |
|
| 532 | - ->setUser($share['user']) |
|
| 533 | - ->setObject('remote_share', (int)$share['id']); |
|
| 534 | - $this->notificationManager->markProcessed($notification); |
|
| 535 | - |
|
| 536 | - $event = $this->activityManager->generateEvent(); |
|
| 537 | - $event->setApp('files_sharing') |
|
| 538 | - ->setType('remote_share') |
|
| 539 | - ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_UNSHARED, [$owner->getId(), $path]) |
|
| 540 | - ->setAffectedUser($user) |
|
| 541 | - ->setObject('remote_share', (int)$share['id'], $path); |
|
| 542 | - \OC::$server->getActivityManager()->publish($event); |
|
| 543 | - } |
|
| 544 | - |
|
| 545 | - return []; |
|
| 546 | - } |
|
| 547 | - |
|
| 548 | - private function cleanupRemote($remote) { |
|
| 549 | - $remote = substr($remote, strpos($remote, '://') + 3); |
|
| 550 | - |
|
| 551 | - return rtrim($remote, '/'); |
|
| 552 | - } |
|
| 553 | - |
|
| 554 | - /** |
|
| 555 | - * recipient of a share request to re-share the file with another user |
|
| 556 | - * |
|
| 557 | - * @param string $id |
|
| 558 | - * @param array $notification |
|
| 559 | - * @return array |
|
| 560 | - * @throws AuthenticationFailedException |
|
| 561 | - * @throws BadRequestException |
|
| 562 | - * @throws ProviderCouldNotAddShareException |
|
| 563 | - * @throws ShareNotFound |
|
| 564 | - */ |
|
| 565 | - protected function reshareRequested($id, array $notification) { |
|
| 566 | - |
|
| 567 | - if (!isset($notification['sharedSecret'])) { |
|
| 568 | - throw new BadRequestException(['sharedSecret']); |
|
| 569 | - } |
|
| 570 | - $token = $notification['sharedSecret']; |
|
| 571 | - |
|
| 572 | - if (!isset($notification['shareWith'])) { |
|
| 573 | - throw new BadRequestException(['shareWith']); |
|
| 574 | - } |
|
| 575 | - $shareWith = $notification['shareWith']; |
|
| 576 | - |
|
| 577 | - if (!isset($notification['senderId'])) { |
|
| 578 | - throw new BadRequestException(['senderId']); |
|
| 579 | - } |
|
| 580 | - $senderId = $notification['senderId']; |
|
| 581 | - |
|
| 582 | - $share = $this->federatedShareProvider->getShareById($id); |
|
| 583 | - // don't allow to share a file back to the owner |
|
| 584 | - try { |
|
| 585 | - list($user, $remote) = $this->addressHandler->splitUserRemote($shareWith); |
|
| 586 | - $owner = $share->getShareOwner(); |
|
| 587 | - $currentServer = $this->addressHandler->generateRemoteURL(); |
|
| 588 | - if ($this->addressHandler->compareAddresses($user, $remote, $owner, $currentServer)) { |
|
| 589 | - throw new ProviderCouldNotAddShareException('Resharing back to the owner is not allowed: ' . $id); |
|
| 590 | - } |
|
| 591 | - } catch (\Exception $e) { |
|
| 592 | - throw new ProviderCouldNotAddShareException($e->getMessage()); |
|
| 593 | - } |
|
| 594 | - |
|
| 595 | - $this->verifyShare($share, $token); |
|
| 596 | - |
|
| 597 | - // check if re-sharing is allowed |
|
| 598 | - if ($share->getPermissions() & Constants::PERMISSION_SHARE) { |
|
| 599 | - // the recipient of the initial share is now the initiator for the re-share |
|
| 600 | - $share->setSharedBy($share->getSharedWith()); |
|
| 601 | - $share->setSharedWith($shareWith); |
|
| 602 | - $result = $this->federatedShareProvider->create($share); |
|
| 603 | - $this->federatedShareProvider->storeRemoteId((int)$result->getId(), $senderId); |
|
| 604 | - return ['token' => $result->getToken(), 'providerId' => $result->getId()]; |
|
| 605 | - } else { |
|
| 606 | - throw new ProviderCouldNotAddShareException('resharing not allowed for share: ' . $id); |
|
| 607 | - } |
|
| 608 | - |
|
| 609 | - } |
|
| 610 | - |
|
| 611 | - /** |
|
| 612 | - * update permission of a re-share so that the share dialog shows the right |
|
| 613 | - * permission if the owner or the sender changes the permission |
|
| 614 | - * |
|
| 615 | - * @param string $id |
|
| 616 | - * @param array $notification |
|
| 617 | - * @return array |
|
| 618 | - * @throws AuthenticationFailedException |
|
| 619 | - * @throws BadRequestException |
|
| 620 | - */ |
|
| 621 | - protected function updateResharePermissions($id, array $notification) { |
|
| 622 | - |
|
| 623 | - if (!isset($notification['sharedSecret'])) { |
|
| 624 | - throw new BadRequestException(['sharedSecret']); |
|
| 625 | - } |
|
| 626 | - $token = $notification['sharedSecret']; |
|
| 627 | - |
|
| 628 | - if (!isset($notification['permission'])) { |
|
| 629 | - throw new BadRequestException(['permission']); |
|
| 630 | - } |
|
| 631 | - $ocmPermissions = $notification['permission']; |
|
| 632 | - |
|
| 633 | - $share = $this->federatedShareProvider->getShareById($id); |
|
| 634 | - |
|
| 635 | - $ncPermission = $this->ocmPermissions2ncPermissions($ocmPermissions); |
|
| 636 | - |
|
| 637 | - $this->verifyShare($share, $token); |
|
| 638 | - $this->updatePermissionsInDatabase($share, $ncPermission); |
|
| 639 | - |
|
| 640 | - return []; |
|
| 641 | - } |
|
| 642 | - |
|
| 643 | - /** |
|
| 644 | - * translate OCM Permissions to Nextcloud permissions |
|
| 645 | - * |
|
| 646 | - * @param array $ocmPermissions |
|
| 647 | - * @return int |
|
| 648 | - * @throws BadRequestException |
|
| 649 | - */ |
|
| 650 | - protected function ocmPermissions2ncPermissions(array $ocmPermissions) { |
|
| 651 | - $ncPermissions = 0; |
|
| 652 | - foreach($ocmPermissions as $permission) { |
|
| 653 | - switch (strtolower($permission)) { |
|
| 654 | - case 'read': |
|
| 655 | - $ncPermissions += Constants::PERMISSION_READ; |
|
| 656 | - break; |
|
| 657 | - case 'write': |
|
| 658 | - $ncPermissions += Constants::PERMISSION_CREATE + Constants::PERMISSION_UPDATE; |
|
| 659 | - break; |
|
| 660 | - case 'share': |
|
| 661 | - $ncPermissions += Constants::PERMISSION_SHARE; |
|
| 662 | - break; |
|
| 663 | - default: |
|
| 664 | - throw new BadRequestException(['permission']); |
|
| 665 | - } |
|
| 666 | - |
|
| 667 | - error_log("new permissions: " . $ncPermissions); |
|
| 668 | - } |
|
| 669 | - |
|
| 670 | - return $ncPermissions; |
|
| 671 | - } |
|
| 672 | - |
|
| 673 | - /** |
|
| 674 | - * update permissions in database |
|
| 675 | - * |
|
| 676 | - * @param IShare $share |
|
| 677 | - * @param int $permissions |
|
| 678 | - */ |
|
| 679 | - protected function updatePermissionsInDatabase(IShare $share, $permissions) { |
|
| 680 | - $query = $this->connection->getQueryBuilder(); |
|
| 681 | - $query->update('share') |
|
| 682 | - ->where($query->expr()->eq('id', $query->createNamedParameter($share->getId()))) |
|
| 683 | - ->set('permissions', $query->createNamedParameter($permissions)) |
|
| 684 | - ->execute(); |
|
| 685 | - } |
|
| 686 | - |
|
| 687 | - |
|
| 688 | - /** |
|
| 689 | - * get file |
|
| 690 | - * |
|
| 691 | - * @param string $user |
|
| 692 | - * @param int $fileSource |
|
| 693 | - * @return array with internal path of the file and a absolute link to it |
|
| 694 | - */ |
|
| 695 | - private function getFile($user, $fileSource) { |
|
| 696 | - \OC_Util::setupFS($user); |
|
| 697 | - |
|
| 698 | - try { |
|
| 699 | - $file = Filesystem::getPath($fileSource); |
|
| 700 | - } catch (NotFoundException $e) { |
|
| 701 | - $file = null; |
|
| 702 | - } |
|
| 703 | - $args = Filesystem::is_dir($file) ? array('dir' => $file) : array('dir' => dirname($file), 'scrollto' => $file); |
|
| 704 | - $link = Util::linkToAbsolute('files', 'index.php', $args); |
|
| 705 | - |
|
| 706 | - return [$file, $link]; |
|
| 707 | - |
|
| 708 | - } |
|
| 709 | - |
|
| 710 | - /** |
|
| 711 | - * check if we are the initiator or the owner of a re-share and return the correct UID |
|
| 712 | - * |
|
| 713 | - * @param IShare $share |
|
| 714 | - * @return string |
|
| 715 | - */ |
|
| 716 | - protected function getCorrectUid(IShare $share) { |
|
| 717 | - if ($this->userManager->userExists($share->getShareOwner())) { |
|
| 718 | - return $share->getShareOwner(); |
|
| 719 | - } |
|
| 720 | - |
|
| 721 | - return $share->getSharedBy(); |
|
| 722 | - } |
|
| 723 | - |
|
| 724 | - |
|
| 725 | - |
|
| 726 | - /** |
|
| 727 | - * check if we got the right share |
|
| 728 | - * |
|
| 729 | - * @param IShare $share |
|
| 730 | - * @param string $token |
|
| 731 | - * @return bool |
|
| 732 | - * @throws AuthenticationFailedException |
|
| 733 | - */ |
|
| 734 | - protected function verifyShare(IShare $share, $token) { |
|
| 735 | - if ( |
|
| 736 | - $share->getShareType() === FederatedShareProvider::SHARE_TYPE_REMOTE && |
|
| 737 | - $share->getToken() === $token |
|
| 738 | - ) { |
|
| 739 | - return true; |
|
| 740 | - } |
|
| 741 | - |
|
| 742 | - throw new AuthenticationFailedException(); |
|
| 743 | - } |
|
| 744 | - |
|
| 745 | - |
|
| 746 | - |
|
| 747 | - /** |
|
| 748 | - * check if server-to-server sharing is enabled |
|
| 749 | - * |
|
| 750 | - * @param bool $incoming |
|
| 751 | - * @return bool |
|
| 752 | - */ |
|
| 753 | - private function isS2SEnabled($incoming = false) { |
|
| 754 | - |
|
| 755 | - $result = $this->appManager->isEnabledForUser('files_sharing'); |
|
| 756 | - |
|
| 757 | - if ($incoming) { |
|
| 758 | - $result = $result && $this->federatedShareProvider->isIncomingServer2serverShareEnabled(); |
|
| 759 | - } else { |
|
| 760 | - $result = $result && $this->federatedShareProvider->isOutgoingServer2serverShareEnabled(); |
|
| 761 | - } |
|
| 762 | - |
|
| 763 | - return $result; |
|
| 764 | - } |
|
| 765 | - |
|
| 766 | - |
|
| 767 | - /** |
|
| 768 | - * get the supported share types, e.g. "user", "group", etc. |
|
| 769 | - * |
|
| 770 | - * @return array |
|
| 771 | - */ |
|
| 772 | - public function getSupportedShareTypes() { |
|
| 773 | - return ['user']; |
|
| 774 | - } |
|
| 53 | + /** @var IAppManager */ |
|
| 54 | + private $appManager; |
|
| 55 | + |
|
| 56 | + /** @var FederatedShareProvider */ |
|
| 57 | + private $federatedShareProvider; |
|
| 58 | + |
|
| 59 | + /** @var AddressHandler */ |
|
| 60 | + private $addressHandler; |
|
| 61 | + |
|
| 62 | + /** @var ILogger */ |
|
| 63 | + private $logger; |
|
| 64 | + |
|
| 65 | + /** @var IUserManager */ |
|
| 66 | + private $userManager; |
|
| 67 | + |
|
| 68 | + /** @var ICloudIdManager */ |
|
| 69 | + private $cloudIdManager; |
|
| 70 | + |
|
| 71 | + /** @var IActivityManager */ |
|
| 72 | + private $activityManager; |
|
| 73 | + |
|
| 74 | + /** @var INotificationManager */ |
|
| 75 | + private $notificationManager; |
|
| 76 | + |
|
| 77 | + /** @var IURLGenerator */ |
|
| 78 | + private $urlGenerator; |
|
| 79 | + |
|
| 80 | + /** @var ICloudFederationFactory */ |
|
| 81 | + private $cloudFederationFactory; |
|
| 82 | + |
|
| 83 | + /** @var ICloudFederationProviderManager */ |
|
| 84 | + private $cloudFederationProviderManager; |
|
| 85 | + |
|
| 86 | + /** @var IDBConnection */ |
|
| 87 | + private $connection; |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * CloudFederationProvider constructor. |
|
| 91 | + * |
|
| 92 | + * @param IAppManager $appManager |
|
| 93 | + * @param FederatedShareProvider $federatedShareProvider |
|
| 94 | + * @param AddressHandler $addressHandler |
|
| 95 | + * @param ILogger $logger |
|
| 96 | + * @param IUserManager $userManager |
|
| 97 | + * @param ICloudIdManager $cloudIdManager |
|
| 98 | + * @param IActivityManager $activityManager |
|
| 99 | + * @param INotificationManager $notificationManager |
|
| 100 | + * @param IURLGenerator $urlGenerator |
|
| 101 | + * @param ICloudFederationFactory $cloudFederationFactory |
|
| 102 | + * @param ICloudFederationProviderManager $cloudFederationProviderManager |
|
| 103 | + * @param IDBConnection $connection |
|
| 104 | + */ |
|
| 105 | + public function __construct(IAppManager $appManager, |
|
| 106 | + FederatedShareProvider $federatedShareProvider, |
|
| 107 | + AddressHandler $addressHandler, |
|
| 108 | + ILogger $logger, |
|
| 109 | + IUserManager $userManager, |
|
| 110 | + ICloudIdManager $cloudIdManager, |
|
| 111 | + IActivityManager $activityManager, |
|
| 112 | + INotificationManager $notificationManager, |
|
| 113 | + IURLGenerator $urlGenerator, |
|
| 114 | + ICloudFederationFactory $cloudFederationFactory, |
|
| 115 | + ICloudFederationProviderManager $cloudFederationProviderManager, |
|
| 116 | + IDBConnection $connection |
|
| 117 | + ) { |
|
| 118 | + $this->appManager = $appManager; |
|
| 119 | + $this->federatedShareProvider = $federatedShareProvider; |
|
| 120 | + $this->addressHandler = $addressHandler; |
|
| 121 | + $this->logger = $logger; |
|
| 122 | + $this->userManager = $userManager; |
|
| 123 | + $this->cloudIdManager = $cloudIdManager; |
|
| 124 | + $this->activityManager = $activityManager; |
|
| 125 | + $this->notificationManager = $notificationManager; |
|
| 126 | + $this->urlGenerator = $urlGenerator; |
|
| 127 | + $this->cloudFederationFactory = $cloudFederationFactory; |
|
| 128 | + $this->cloudFederationProviderManager = $cloudFederationProviderManager; |
|
| 129 | + $this->connection = $connection; |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + |
|
| 133 | + |
|
| 134 | + /** |
|
| 135 | + * @return string |
|
| 136 | + */ |
|
| 137 | + public function getShareType() { |
|
| 138 | + return 'file'; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * share received from another server |
|
| 143 | + * |
|
| 144 | + * @param ICloudFederationShare $share |
|
| 145 | + * @return string provider specific unique ID of the share |
|
| 146 | + * |
|
| 147 | + * @throws ProviderCouldNotAddShareException |
|
| 148 | + * @throws \OCP\AppFramework\QueryException |
|
| 149 | + * @throws \OC\HintException |
|
| 150 | + * @since 14.0.0 |
|
| 151 | + */ |
|
| 152 | + public function shareReceived(ICloudFederationShare $share) { |
|
| 153 | + |
|
| 154 | + if (!$this->isS2SEnabled(true)) { |
|
| 155 | + throw new ProviderCouldNotAddShareException('Server does not support federated cloud sharing', '', Http::STATUS_SERVICE_UNAVAILABLE); |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + $protocol = $share->getProtocol(); |
|
| 159 | + if ($protocol['name'] !== 'webdav') { |
|
| 160 | + throw new ProviderCouldNotAddShareException('Unsupported protocol for data exchange.', '', Http::STATUS_NOT_IMPLEMENTED); |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + list($ownerUid, $remote) = $this->addressHandler->splitUserRemote($share->getOwner()); |
|
| 164 | + // for backward compatibility make sure that the remote url stored in the |
|
| 165 | + // database ends with a trailing slash |
|
| 166 | + if (substr($remote, -1) !== '/') { |
|
| 167 | + $remote = $remote . '/'; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + $token = $share->getShareSecret(); |
|
| 171 | + $name = $share->getResourceName(); |
|
| 172 | + $owner = $share->getOwnerDisplayName(); |
|
| 173 | + $sharedBy = $share->getSharedByDisplayName(); |
|
| 174 | + $shareWith = $share->getShareWith(); |
|
| 175 | + $remoteId = $share->getProviderId(); |
|
| 176 | + $sharedByFederatedId = $share->getSharedBy(); |
|
| 177 | + $ownerFederatedId = $share->getOwner(); |
|
| 178 | + |
|
| 179 | + // if no explicit information about the person who created the share was send |
|
| 180 | + // we assume that the share comes from the owner |
|
| 181 | + if ($sharedByFederatedId === null) { |
|
| 182 | + $sharedBy = $owner; |
|
| 183 | + $sharedByFederatedId = $ownerFederatedId; |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + if ($remote && $token && $name && $owner && $remoteId && $shareWith) { |
|
| 187 | + |
|
| 188 | + if (!Util::isValidFileName($name)) { |
|
| 189 | + throw new ProviderCouldNotAddShareException('The mountpoint name contains invalid characters.', '', Http::STATUS_BAD_REQUEST); |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + // FIXME this should be a method in the user management instead |
|
| 193 | + $this->logger->debug('shareWith before, ' . $shareWith, ['app' => 'files_sharing']); |
|
| 194 | + Util::emitHook( |
|
| 195 | + '\OCA\Files_Sharing\API\Server2Server', |
|
| 196 | + 'preLoginNameUsedAsUserName', |
|
| 197 | + array('uid' => &$shareWith) |
|
| 198 | + ); |
|
| 199 | + $this->logger->debug('shareWith after, ' . $shareWith, ['app' => 'files_sharing']); |
|
| 200 | + |
|
| 201 | + if (!$this->userManager->userExists($shareWith)) { |
|
| 202 | + throw new ProviderCouldNotAddShareException('User does not exists', '',Http::STATUS_BAD_REQUEST); |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + \OC_Util::setupFS($shareWith); |
|
| 206 | + |
|
| 207 | + $externalManager = new \OCA\Files_Sharing\External\Manager( |
|
| 208 | + \OC::$server->getDatabaseConnection(), |
|
| 209 | + Filesystem::getMountManager(), |
|
| 210 | + Filesystem::getLoader(), |
|
| 211 | + \OC::$server->getHTTPClientService(), |
|
| 212 | + \OC::$server->getNotificationManager(), |
|
| 213 | + \OC::$server->query(\OCP\OCS\IDiscoveryService::class), |
|
| 214 | + \OC::$server->getCloudFederationProviderManager(), |
|
| 215 | + \OC::$server->getCloudFederationFactory(), |
|
| 216 | + $shareWith |
|
| 217 | + ); |
|
| 218 | + |
|
| 219 | + try { |
|
| 220 | + $externalManager->addShare($remote, $token, '', $name, $owner, false, $shareWith, $remoteId); |
|
| 221 | + $shareId = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share_external'); |
|
| 222 | + |
|
| 223 | + $event = $this->activityManager->generateEvent(); |
|
| 224 | + $event->setApp('files_sharing') |
|
| 225 | + ->setType('remote_share') |
|
| 226 | + ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_RECEIVED, [$ownerFederatedId, trim($name, '/')]) |
|
| 227 | + ->setAffectedUser($shareWith) |
|
| 228 | + ->setObject('remote_share', (int)$shareId, $name); |
|
| 229 | + \OC::$server->getActivityManager()->publish($event); |
|
| 230 | + |
|
| 231 | + $notification = $this->notificationManager->createNotification(); |
|
| 232 | + $notification->setApp('files_sharing') |
|
| 233 | + ->setUser($shareWith) |
|
| 234 | + ->setDateTime(new \DateTime()) |
|
| 235 | + ->setObject('remote_share', $shareId) |
|
| 236 | + ->setSubject('remote_share', [$ownerFederatedId, $sharedByFederatedId, trim($name, '/')]); |
|
| 237 | + |
|
| 238 | + $declineAction = $notification->createAction(); |
|
| 239 | + $declineAction->setLabel('decline') |
|
| 240 | + ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'DELETE'); |
|
| 241 | + $notification->addAction($declineAction); |
|
| 242 | + |
|
| 243 | + $acceptAction = $notification->createAction(); |
|
| 244 | + $acceptAction->setLabel('accept') |
|
| 245 | + ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'POST'); |
|
| 246 | + $notification->addAction($acceptAction); |
|
| 247 | + |
|
| 248 | + $this->notificationManager->notify($notification); |
|
| 249 | + |
|
| 250 | + return $shareId; |
|
| 251 | + } catch (\Exception $e) { |
|
| 252 | + $this->logger->logException($e, [ |
|
| 253 | + 'message' => 'Server can not add remote share.', |
|
| 254 | + 'level' => ILogger::ERROR, |
|
| 255 | + 'app' => 'files_sharing' |
|
| 256 | + ]); |
|
| 257 | + throw new ProviderCouldNotAddShareException('internal server error, was not able to add share from ' . $remote, '', HTTP::STATUS_INTERNAL_SERVER_ERROR); |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + throw new ProviderCouldNotAddShareException('server can not add remote share, missing parameter', '', HTTP::STATUS_BAD_REQUEST); |
|
| 262 | + |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + /** |
|
| 266 | + * notification received from another server |
|
| 267 | + * |
|
| 268 | + * @param string $notificationType (e.g. SHARE_ACCEPTED) |
|
| 269 | + * @param string $providerId id of the share |
|
| 270 | + * @param array $notification payload of the notification |
|
| 271 | + * @return array data send back to the sender |
|
| 272 | + * |
|
| 273 | + * @throws ActionNotSupportedException |
|
| 274 | + * @throws AuthenticationFailedException |
|
| 275 | + * @throws BadRequestException |
|
| 276 | + * @throws \OC\HintException |
|
| 277 | + * @since 14.0.0 |
|
| 278 | + */ |
|
| 279 | + public function notificationReceived($notificationType, $providerId, array $notification) { |
|
| 280 | + |
|
| 281 | + switch ($notificationType) { |
|
| 282 | + case 'SHARE_ACCEPTED': |
|
| 283 | + return $this->shareAccepted($providerId, $notification); |
|
| 284 | + case 'SHARE_DECLINED': |
|
| 285 | + return $this->shareDeclined($providerId, $notification); |
|
| 286 | + case 'SHARE_UNSHARED': |
|
| 287 | + return $this->unshare($providerId, $notification); |
|
| 288 | + case 'REQUEST_RESHARE': |
|
| 289 | + return $this->reshareRequested($providerId, $notification); |
|
| 290 | + case 'RESHARE_UNDO': |
|
| 291 | + return $this->undoReshare($providerId, $notification); |
|
| 292 | + case 'RESHARE_CHANGE_PERMISSION': |
|
| 293 | + return $this->updateResharePermissions($providerId, $notification); |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + |
|
| 297 | + throw new BadRequestException([$notificationType]); |
|
| 298 | + } |
|
| 299 | + |
|
| 300 | + /** |
|
| 301 | + * process notification that the recipient accepted a share |
|
| 302 | + * |
|
| 303 | + * @param string $id |
|
| 304 | + * @param array $notification |
|
| 305 | + * @return array |
|
| 306 | + * @throws ActionNotSupportedException |
|
| 307 | + * @throws AuthenticationFailedException |
|
| 308 | + * @throws BadRequestException |
|
| 309 | + * @throws \OC\HintException |
|
| 310 | + */ |
|
| 311 | + private function shareAccepted($id, array $notification) { |
|
| 312 | + |
|
| 313 | + if (!$this->isS2SEnabled()) { |
|
| 314 | + throw new ActionNotSupportedException('Server does not support federated cloud sharing'); |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + if (!isset($notification['sharedSecret'])) { |
|
| 318 | + throw new BadRequestException(['sharedSecret']); |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + $token = $notification['sharedSecret']; |
|
| 322 | + |
|
| 323 | + $share = $this->federatedShareProvider->getShareById($id); |
|
| 324 | + |
|
| 325 | + $this->verifyShare($share, $token); |
|
| 326 | + $this->executeAcceptShare($share); |
|
| 327 | + if ($share->getShareOwner() !== $share->getSharedBy()) { |
|
| 328 | + list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedBy()); |
|
| 329 | + $remoteId = $this->federatedShareProvider->getRemoteId($share); |
|
| 330 | + $notification = $this->cloudFederationFactory->getCloudFederationNotification(); |
|
| 331 | + $notification->setMessage( |
|
| 332 | + 'SHARE_ACCEPTED', |
|
| 333 | + 'file', |
|
| 334 | + $remoteId, |
|
| 335 | + [ |
|
| 336 | + 'sharedSecret' => $token, |
|
| 337 | + 'message' => 'Recipient accepted the re-share' |
|
| 338 | + ] |
|
| 339 | + |
|
| 340 | + ); |
|
| 341 | + $this->cloudFederationProviderManager->sendNotification($remote, $notification); |
|
| 342 | + |
|
| 343 | + } |
|
| 344 | + |
|
| 345 | + return []; |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + /** |
|
| 349 | + * @param IShare $share |
|
| 350 | + * @throws ShareNotFound |
|
| 351 | + */ |
|
| 352 | + protected function executeAcceptShare(IShare $share) { |
|
| 353 | + try { |
|
| 354 | + $fileId = (int)$share->getNode()->getId(); |
|
| 355 | + list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId); |
|
| 356 | + } catch (\Exception $e) { |
|
| 357 | + throw new ShareNotFound(); |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + $event = $this->activityManager->generateEvent(); |
|
| 361 | + $event->setApp('files_sharing') |
|
| 362 | + ->setType('remote_share') |
|
| 363 | + ->setAffectedUser($this->getCorrectUid($share)) |
|
| 364 | + ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_ACCEPTED, [$share->getSharedWith(), [$fileId => $file]]) |
|
| 365 | + ->setObject('files', $fileId, $file) |
|
| 366 | + ->setLink($link); |
|
| 367 | + $this->activityManager->publish($event); |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + /** |
|
| 371 | + * process notification that the recipient declined a share |
|
| 372 | + * |
|
| 373 | + * @param string $id |
|
| 374 | + * @param array $notification |
|
| 375 | + * @return array |
|
| 376 | + * @throws ActionNotSupportedException |
|
| 377 | + * @throws AuthenticationFailedException |
|
| 378 | + * @throws BadRequestException |
|
| 379 | + * @throws ShareNotFound |
|
| 380 | + * @throws \OC\HintException |
|
| 381 | + * |
|
| 382 | + */ |
|
| 383 | + protected function shareDeclined($id, array $notification) { |
|
| 384 | + |
|
| 385 | + if (!$this->isS2SEnabled()) { |
|
| 386 | + throw new ActionNotSupportedException('Server does not support federated cloud sharing'); |
|
| 387 | + } |
|
| 388 | + |
|
| 389 | + if (!isset($notification['sharedSecret'])) { |
|
| 390 | + throw new BadRequestException(['sharedSecret']); |
|
| 391 | + } |
|
| 392 | + |
|
| 393 | + $token = $notification['sharedSecret']; |
|
| 394 | + |
|
| 395 | + $share = $this->federatedShareProvider->getShareById($id); |
|
| 396 | + |
|
| 397 | + $this->verifyShare($share, $token); |
|
| 398 | + |
|
| 399 | + if ($share->getShareOwner() !== $share->getSharedBy()) { |
|
| 400 | + list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedBy()); |
|
| 401 | + $remoteId = $this->federatedShareProvider->getRemoteId($share); |
|
| 402 | + $notification = $this->cloudFederationFactory->getCloudFederationNotification(); |
|
| 403 | + $notification->setMessage( |
|
| 404 | + 'SHARE_DECLINED', |
|
| 405 | + 'file', |
|
| 406 | + $remoteId, |
|
| 407 | + [ |
|
| 408 | + 'sharedSecret' => $token, |
|
| 409 | + 'message' => 'Recipient declined the re-share' |
|
| 410 | + ] |
|
| 411 | + |
|
| 412 | + ); |
|
| 413 | + $this->cloudFederationProviderManager->sendNotification($remote, $notification); |
|
| 414 | + } |
|
| 415 | + |
|
| 416 | + $this->executeDeclineShare($share); |
|
| 417 | + |
|
| 418 | + return []; |
|
| 419 | + |
|
| 420 | + } |
|
| 421 | + |
|
| 422 | + /** |
|
| 423 | + * delete declined share and create a activity |
|
| 424 | + * |
|
| 425 | + * @param IShare $share |
|
| 426 | + * @throws ShareNotFound |
|
| 427 | + */ |
|
| 428 | + protected function executeDeclineShare(IShare $share) { |
|
| 429 | + $this->federatedShareProvider->removeShareFromTable($share); |
|
| 430 | + |
|
| 431 | + try { |
|
| 432 | + $fileId = (int)$share->getNode()->getId(); |
|
| 433 | + list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId); |
|
| 434 | + } catch (\Exception $e) { |
|
| 435 | + throw new ShareNotFound(); |
|
| 436 | + } |
|
| 437 | + |
|
| 438 | + $event = $this->activityManager->generateEvent(); |
|
| 439 | + $event->setApp('files_sharing') |
|
| 440 | + ->setType('remote_share') |
|
| 441 | + ->setAffectedUser($this->getCorrectUid($share)) |
|
| 442 | + ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_DECLINED, [$share->getSharedWith(), [$fileId => $file]]) |
|
| 443 | + ->setObject('files', $fileId, $file) |
|
| 444 | + ->setLink($link); |
|
| 445 | + $this->activityManager->publish($event); |
|
| 446 | + |
|
| 447 | + } |
|
| 448 | + |
|
| 449 | + /** |
|
| 450 | + * received the notification that the owner unshared a file from you |
|
| 451 | + * |
|
| 452 | + * @param string $id |
|
| 453 | + * @param array $notification |
|
| 454 | + * @return array |
|
| 455 | + * @throws AuthenticationFailedException |
|
| 456 | + * @throws BadRequestException |
|
| 457 | + */ |
|
| 458 | + private function undoReshare($id, array $notification) { |
|
| 459 | + if (!isset($notification['sharedSecret'])) { |
|
| 460 | + throw new BadRequestException(['sharedSecret']); |
|
| 461 | + } |
|
| 462 | + $token = $notification['sharedSecret']; |
|
| 463 | + |
|
| 464 | + $share = $this->federatedShareProvider->getShareById($id); |
|
| 465 | + |
|
| 466 | + $this->verifyShare($share, $token); |
|
| 467 | + $this->federatedShareProvider->removeShareFromTable($share); |
|
| 468 | + return []; |
|
| 469 | + } |
|
| 470 | + |
|
| 471 | + /** |
|
| 472 | + * unshare file from self |
|
| 473 | + * |
|
| 474 | + * @param string $id |
|
| 475 | + * @param array $notification |
|
| 476 | + * @return array |
|
| 477 | + * @throws ActionNotSupportedException |
|
| 478 | + * @throws BadRequestException |
|
| 479 | + */ |
|
| 480 | + private function unshare($id, array $notification) { |
|
| 481 | + |
|
| 482 | + if (!$this->isS2SEnabled(true)) { |
|
| 483 | + throw new ActionNotSupportedException("incoming shares disabled!"); |
|
| 484 | + } |
|
| 485 | + |
|
| 486 | + if (!isset($notification['sharedSecret'])) { |
|
| 487 | + throw new BadRequestException(['sharedSecret']); |
|
| 488 | + } |
|
| 489 | + $token = $notification['sharedSecret']; |
|
| 490 | + |
|
| 491 | + $qb = $this->connection->getQueryBuilder(); |
|
| 492 | + $qb->select('*') |
|
| 493 | + ->from('share_external') |
|
| 494 | + ->where( |
|
| 495 | + $qb->expr()->andX( |
|
| 496 | + $qb->expr()->eq('remote_id', $qb->createNamedParameter($id)), |
|
| 497 | + $qb->expr()->eq('share_token', $qb->createNamedParameter($token)) |
|
| 498 | + ) |
|
| 499 | + ); |
|
| 500 | + |
|
| 501 | + $result = $qb->execute(); |
|
| 502 | + $share = $result->fetch(); |
|
| 503 | + $result->closeCursor(); |
|
| 504 | + |
|
| 505 | + if ($token && $id && !empty($share)) { |
|
| 506 | + |
|
| 507 | + $remote = $this->cleanupRemote($share['remote']); |
|
| 508 | + |
|
| 509 | + $owner = $this->cloudIdManager->getCloudId($share['owner'], $remote); |
|
| 510 | + $mountpoint = $share['mountpoint']; |
|
| 511 | + $user = $share['user']; |
|
| 512 | + |
|
| 513 | + $qb = $this->connection->getQueryBuilder(); |
|
| 514 | + $qb->delete('share_external') |
|
| 515 | + ->where( |
|
| 516 | + $qb->expr()->andX( |
|
| 517 | + $qb->expr()->eq('remote_id', $qb->createNamedParameter($id)), |
|
| 518 | + $qb->expr()->eq('share_token', $qb->createNamedParameter($token)) |
|
| 519 | + ) |
|
| 520 | + ); |
|
| 521 | + |
|
| 522 | + $qb->execute(); |
|
| 523 | + |
|
| 524 | + if ($share['accepted']) { |
|
| 525 | + $path = trim($mountpoint, '/'); |
|
| 526 | + } else { |
|
| 527 | + $path = trim($share['name'], '/'); |
|
| 528 | + } |
|
| 529 | + |
|
| 530 | + $notification = $this->notificationManager->createNotification(); |
|
| 531 | + $notification->setApp('files_sharing') |
|
| 532 | + ->setUser($share['user']) |
|
| 533 | + ->setObject('remote_share', (int)$share['id']); |
|
| 534 | + $this->notificationManager->markProcessed($notification); |
|
| 535 | + |
|
| 536 | + $event = $this->activityManager->generateEvent(); |
|
| 537 | + $event->setApp('files_sharing') |
|
| 538 | + ->setType('remote_share') |
|
| 539 | + ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_UNSHARED, [$owner->getId(), $path]) |
|
| 540 | + ->setAffectedUser($user) |
|
| 541 | + ->setObject('remote_share', (int)$share['id'], $path); |
|
| 542 | + \OC::$server->getActivityManager()->publish($event); |
|
| 543 | + } |
|
| 544 | + |
|
| 545 | + return []; |
|
| 546 | + } |
|
| 547 | + |
|
| 548 | + private function cleanupRemote($remote) { |
|
| 549 | + $remote = substr($remote, strpos($remote, '://') + 3); |
|
| 550 | + |
|
| 551 | + return rtrim($remote, '/'); |
|
| 552 | + } |
|
| 553 | + |
|
| 554 | + /** |
|
| 555 | + * recipient of a share request to re-share the file with another user |
|
| 556 | + * |
|
| 557 | + * @param string $id |
|
| 558 | + * @param array $notification |
|
| 559 | + * @return array |
|
| 560 | + * @throws AuthenticationFailedException |
|
| 561 | + * @throws BadRequestException |
|
| 562 | + * @throws ProviderCouldNotAddShareException |
|
| 563 | + * @throws ShareNotFound |
|
| 564 | + */ |
|
| 565 | + protected function reshareRequested($id, array $notification) { |
|
| 566 | + |
|
| 567 | + if (!isset($notification['sharedSecret'])) { |
|
| 568 | + throw new BadRequestException(['sharedSecret']); |
|
| 569 | + } |
|
| 570 | + $token = $notification['sharedSecret']; |
|
| 571 | + |
|
| 572 | + if (!isset($notification['shareWith'])) { |
|
| 573 | + throw new BadRequestException(['shareWith']); |
|
| 574 | + } |
|
| 575 | + $shareWith = $notification['shareWith']; |
|
| 576 | + |
|
| 577 | + if (!isset($notification['senderId'])) { |
|
| 578 | + throw new BadRequestException(['senderId']); |
|
| 579 | + } |
|
| 580 | + $senderId = $notification['senderId']; |
|
| 581 | + |
|
| 582 | + $share = $this->federatedShareProvider->getShareById($id); |
|
| 583 | + // don't allow to share a file back to the owner |
|
| 584 | + try { |
|
| 585 | + list($user, $remote) = $this->addressHandler->splitUserRemote($shareWith); |
|
| 586 | + $owner = $share->getShareOwner(); |
|
| 587 | + $currentServer = $this->addressHandler->generateRemoteURL(); |
|
| 588 | + if ($this->addressHandler->compareAddresses($user, $remote, $owner, $currentServer)) { |
|
| 589 | + throw new ProviderCouldNotAddShareException('Resharing back to the owner is not allowed: ' . $id); |
|
| 590 | + } |
|
| 591 | + } catch (\Exception $e) { |
|
| 592 | + throw new ProviderCouldNotAddShareException($e->getMessage()); |
|
| 593 | + } |
|
| 594 | + |
|
| 595 | + $this->verifyShare($share, $token); |
|
| 596 | + |
|
| 597 | + // check if re-sharing is allowed |
|
| 598 | + if ($share->getPermissions() & Constants::PERMISSION_SHARE) { |
|
| 599 | + // the recipient of the initial share is now the initiator for the re-share |
|
| 600 | + $share->setSharedBy($share->getSharedWith()); |
|
| 601 | + $share->setSharedWith($shareWith); |
|
| 602 | + $result = $this->federatedShareProvider->create($share); |
|
| 603 | + $this->federatedShareProvider->storeRemoteId((int)$result->getId(), $senderId); |
|
| 604 | + return ['token' => $result->getToken(), 'providerId' => $result->getId()]; |
|
| 605 | + } else { |
|
| 606 | + throw new ProviderCouldNotAddShareException('resharing not allowed for share: ' . $id); |
|
| 607 | + } |
|
| 608 | + |
|
| 609 | + } |
|
| 610 | + |
|
| 611 | + /** |
|
| 612 | + * update permission of a re-share so that the share dialog shows the right |
|
| 613 | + * permission if the owner or the sender changes the permission |
|
| 614 | + * |
|
| 615 | + * @param string $id |
|
| 616 | + * @param array $notification |
|
| 617 | + * @return array |
|
| 618 | + * @throws AuthenticationFailedException |
|
| 619 | + * @throws BadRequestException |
|
| 620 | + */ |
|
| 621 | + protected function updateResharePermissions($id, array $notification) { |
|
| 622 | + |
|
| 623 | + if (!isset($notification['sharedSecret'])) { |
|
| 624 | + throw new BadRequestException(['sharedSecret']); |
|
| 625 | + } |
|
| 626 | + $token = $notification['sharedSecret']; |
|
| 627 | + |
|
| 628 | + if (!isset($notification['permission'])) { |
|
| 629 | + throw new BadRequestException(['permission']); |
|
| 630 | + } |
|
| 631 | + $ocmPermissions = $notification['permission']; |
|
| 632 | + |
|
| 633 | + $share = $this->federatedShareProvider->getShareById($id); |
|
| 634 | + |
|
| 635 | + $ncPermission = $this->ocmPermissions2ncPermissions($ocmPermissions); |
|
| 636 | + |
|
| 637 | + $this->verifyShare($share, $token); |
|
| 638 | + $this->updatePermissionsInDatabase($share, $ncPermission); |
|
| 639 | + |
|
| 640 | + return []; |
|
| 641 | + } |
|
| 642 | + |
|
| 643 | + /** |
|
| 644 | + * translate OCM Permissions to Nextcloud permissions |
|
| 645 | + * |
|
| 646 | + * @param array $ocmPermissions |
|
| 647 | + * @return int |
|
| 648 | + * @throws BadRequestException |
|
| 649 | + */ |
|
| 650 | + protected function ocmPermissions2ncPermissions(array $ocmPermissions) { |
|
| 651 | + $ncPermissions = 0; |
|
| 652 | + foreach($ocmPermissions as $permission) { |
|
| 653 | + switch (strtolower($permission)) { |
|
| 654 | + case 'read': |
|
| 655 | + $ncPermissions += Constants::PERMISSION_READ; |
|
| 656 | + break; |
|
| 657 | + case 'write': |
|
| 658 | + $ncPermissions += Constants::PERMISSION_CREATE + Constants::PERMISSION_UPDATE; |
|
| 659 | + break; |
|
| 660 | + case 'share': |
|
| 661 | + $ncPermissions += Constants::PERMISSION_SHARE; |
|
| 662 | + break; |
|
| 663 | + default: |
|
| 664 | + throw new BadRequestException(['permission']); |
|
| 665 | + } |
|
| 666 | + |
|
| 667 | + error_log("new permissions: " . $ncPermissions); |
|
| 668 | + } |
|
| 669 | + |
|
| 670 | + return $ncPermissions; |
|
| 671 | + } |
|
| 672 | + |
|
| 673 | + /** |
|
| 674 | + * update permissions in database |
|
| 675 | + * |
|
| 676 | + * @param IShare $share |
|
| 677 | + * @param int $permissions |
|
| 678 | + */ |
|
| 679 | + protected function updatePermissionsInDatabase(IShare $share, $permissions) { |
|
| 680 | + $query = $this->connection->getQueryBuilder(); |
|
| 681 | + $query->update('share') |
|
| 682 | + ->where($query->expr()->eq('id', $query->createNamedParameter($share->getId()))) |
|
| 683 | + ->set('permissions', $query->createNamedParameter($permissions)) |
|
| 684 | + ->execute(); |
|
| 685 | + } |
|
| 686 | + |
|
| 687 | + |
|
| 688 | + /** |
|
| 689 | + * get file |
|
| 690 | + * |
|
| 691 | + * @param string $user |
|
| 692 | + * @param int $fileSource |
|
| 693 | + * @return array with internal path of the file and a absolute link to it |
|
| 694 | + */ |
|
| 695 | + private function getFile($user, $fileSource) { |
|
| 696 | + \OC_Util::setupFS($user); |
|
| 697 | + |
|
| 698 | + try { |
|
| 699 | + $file = Filesystem::getPath($fileSource); |
|
| 700 | + } catch (NotFoundException $e) { |
|
| 701 | + $file = null; |
|
| 702 | + } |
|
| 703 | + $args = Filesystem::is_dir($file) ? array('dir' => $file) : array('dir' => dirname($file), 'scrollto' => $file); |
|
| 704 | + $link = Util::linkToAbsolute('files', 'index.php', $args); |
|
| 705 | + |
|
| 706 | + return [$file, $link]; |
|
| 707 | + |
|
| 708 | + } |
|
| 709 | + |
|
| 710 | + /** |
|
| 711 | + * check if we are the initiator or the owner of a re-share and return the correct UID |
|
| 712 | + * |
|
| 713 | + * @param IShare $share |
|
| 714 | + * @return string |
|
| 715 | + */ |
|
| 716 | + protected function getCorrectUid(IShare $share) { |
|
| 717 | + if ($this->userManager->userExists($share->getShareOwner())) { |
|
| 718 | + return $share->getShareOwner(); |
|
| 719 | + } |
|
| 720 | + |
|
| 721 | + return $share->getSharedBy(); |
|
| 722 | + } |
|
| 723 | + |
|
| 724 | + |
|
| 725 | + |
|
| 726 | + /** |
|
| 727 | + * check if we got the right share |
|
| 728 | + * |
|
| 729 | + * @param IShare $share |
|
| 730 | + * @param string $token |
|
| 731 | + * @return bool |
|
| 732 | + * @throws AuthenticationFailedException |
|
| 733 | + */ |
|
| 734 | + protected function verifyShare(IShare $share, $token) { |
|
| 735 | + if ( |
|
| 736 | + $share->getShareType() === FederatedShareProvider::SHARE_TYPE_REMOTE && |
|
| 737 | + $share->getToken() === $token |
|
| 738 | + ) { |
|
| 739 | + return true; |
|
| 740 | + } |
|
| 741 | + |
|
| 742 | + throw new AuthenticationFailedException(); |
|
| 743 | + } |
|
| 744 | + |
|
| 745 | + |
|
| 746 | + |
|
| 747 | + /** |
|
| 748 | + * check if server-to-server sharing is enabled |
|
| 749 | + * |
|
| 750 | + * @param bool $incoming |
|
| 751 | + * @return bool |
|
| 752 | + */ |
|
| 753 | + private function isS2SEnabled($incoming = false) { |
|
| 754 | + |
|
| 755 | + $result = $this->appManager->isEnabledForUser('files_sharing'); |
|
| 756 | + |
|
| 757 | + if ($incoming) { |
|
| 758 | + $result = $result && $this->federatedShareProvider->isIncomingServer2serverShareEnabled(); |
|
| 759 | + } else { |
|
| 760 | + $result = $result && $this->federatedShareProvider->isOutgoingServer2serverShareEnabled(); |
|
| 761 | + } |
|
| 762 | + |
|
| 763 | + return $result; |
|
| 764 | + } |
|
| 765 | + |
|
| 766 | + |
|
| 767 | + /** |
|
| 768 | + * get the supported share types, e.g. "user", "group", etc. |
|
| 769 | + * |
|
| 770 | + * @return array |
|
| 771 | + */ |
|
| 772 | + public function getSupportedShareTypes() { |
|
| 773 | + return ['user']; |
|
| 774 | + } |
|
| 775 | 775 | } |
@@ -39,49 +39,49 @@ |
||
| 39 | 39 | |
| 40 | 40 | interface ICloudFederationProvider { |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * get the name of the share type, handled by this provider |
|
| 44 | - * |
|
| 45 | - * @return string |
|
| 46 | - * |
|
| 47 | - * @since 14.0.0 |
|
| 48 | - */ |
|
| 49 | - public function getShareType(); |
|
| 42 | + /** |
|
| 43 | + * get the name of the share type, handled by this provider |
|
| 44 | + * |
|
| 45 | + * @return string |
|
| 46 | + * |
|
| 47 | + * @since 14.0.0 |
|
| 48 | + */ |
|
| 49 | + public function getShareType(); |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * share received from another server |
|
| 53 | - * |
|
| 54 | - * @param ICloudFederationShare $share |
|
| 55 | - * @return string provider specific unique ID of the share |
|
| 56 | - * |
|
| 57 | - * @throws ProviderCouldNotAddShareException |
|
| 58 | - * |
|
| 59 | - * @since 14.0.0 |
|
| 60 | - */ |
|
| 61 | - public function shareReceived(ICloudFederationShare $share); |
|
| 51 | + /** |
|
| 52 | + * share received from another server |
|
| 53 | + * |
|
| 54 | + * @param ICloudFederationShare $share |
|
| 55 | + * @return string provider specific unique ID of the share |
|
| 56 | + * |
|
| 57 | + * @throws ProviderCouldNotAddShareException |
|
| 58 | + * |
|
| 59 | + * @since 14.0.0 |
|
| 60 | + */ |
|
| 61 | + public function shareReceived(ICloudFederationShare $share); |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * notification received from another server |
|
| 65 | - * |
|
| 66 | - * @param string $notificationType (e.g SHARE_ACCEPTED) |
|
| 67 | - * @param string $providerId share ID |
|
| 68 | - * @param array $notification provider specific notification |
|
| 69 | - * @return array $data send back to sender |
|
| 70 | - * |
|
| 71 | - * @throws ShareNotFound |
|
| 72 | - * @throws ActionNotSupportedException |
|
| 73 | - * @throws BadRequestException |
|
| 74 | - * @throws AuthenticationFailedException |
|
| 75 | - * |
|
| 76 | - * @since 14.0.0 |
|
| 77 | - */ |
|
| 78 | - public function notificationReceived($notificationType, $providerId, array $notification); |
|
| 63 | + /** |
|
| 64 | + * notification received from another server |
|
| 65 | + * |
|
| 66 | + * @param string $notificationType (e.g SHARE_ACCEPTED) |
|
| 67 | + * @param string $providerId share ID |
|
| 68 | + * @param array $notification provider specific notification |
|
| 69 | + * @return array $data send back to sender |
|
| 70 | + * |
|
| 71 | + * @throws ShareNotFound |
|
| 72 | + * @throws ActionNotSupportedException |
|
| 73 | + * @throws BadRequestException |
|
| 74 | + * @throws AuthenticationFailedException |
|
| 75 | + * |
|
| 76 | + * @since 14.0.0 |
|
| 77 | + */ |
|
| 78 | + public function notificationReceived($notificationType, $providerId, array $notification); |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * get the supported share types, e.g. "user", "group", etc. |
|
| 82 | - * |
|
| 83 | - * @return array |
|
| 84 | - */ |
|
| 85 | - public function getSupportedShareTypes(); |
|
| 80 | + /** |
|
| 81 | + * get the supported share types, e.g. "user", "group", etc. |
|
| 82 | + * |
|
| 83 | + * @return array |
|
| 84 | + */ |
|
| 85 | + public function getSupportedShareTypes(); |
|
| 86 | 86 | |
| 87 | 87 | } |
@@ -32,76 +32,76 @@ |
||
| 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 | } |
@@ -35,23 +35,23 @@ |
||
| 35 | 35 | */ |
| 36 | 36 | class Config { |
| 37 | 37 | |
| 38 | - /** @var ICloudFederationProviderManager */ |
|
| 39 | - private $cloudFederationProviderManager; |
|
| 40 | - |
|
| 41 | - public function __construct(ICloudFederationProviderManager $cloudFederationProviderManager) { |
|
| 42 | - $this->cloudFederationProviderManager = $cloudFederationProviderManager; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * get a list of supported share types |
|
| 47 | - * |
|
| 48 | - * @param string $resourceType |
|
| 49 | - * @return array |
|
| 50 | - * @throws \OCP\Federation\Exceptions\ProviderDoesNotExistsException |
|
| 51 | - */ |
|
| 52 | - public function getSupportedShareTypes($resourceType) { |
|
| 53 | - $provider = $this->cloudFederationProviderManager->getCloudFederationProvider($resourceType); |
|
| 54 | - return $provider->getSupportedShareTypes(); |
|
| 55 | - } |
|
| 38 | + /** @var ICloudFederationProviderManager */ |
|
| 39 | + private $cloudFederationProviderManager; |
|
| 40 | + |
|
| 41 | + public function __construct(ICloudFederationProviderManager $cloudFederationProviderManager) { |
|
| 42 | + $this->cloudFederationProviderManager = $cloudFederationProviderManager; |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * get a list of supported share types |
|
| 47 | + * |
|
| 48 | + * @param string $resourceType |
|
| 49 | + * @return array |
|
| 50 | + * @throws \OCP\Federation\Exceptions\ProviderDoesNotExistsException |
|
| 51 | + */ |
|
| 52 | + public function getSupportedShareTypes($resourceType) { |
|
| 53 | + $provider = $this->cloudFederationProviderManager->getCloudFederationProvider($resourceType); |
|
| 54 | + return $provider->getSupportedShareTypes(); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | 57 | } |