|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Björn Schießle <[email protected]> |
|
6
|
|
|
* @author Robin Appelman <[email protected]> |
|
7
|
|
|
* @author Thomas Müller <[email protected]> |
|
8
|
|
|
* |
|
9
|
|
|
* @license AGPL-3.0 |
|
10
|
|
|
* |
|
11
|
|
|
* This code is free software: you can redistribute it and/or modify |
|
12
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
|
13
|
|
|
* as published by the Free Software Foundation. |
|
14
|
|
|
* |
|
15
|
|
|
* This program is distributed in the hope that it will be useful, |
|
16
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18
|
|
|
* GNU Affero General Public License for more details. |
|
19
|
|
|
* |
|
20
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
|
21
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
|
22
|
|
|
* |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
namespace OCA\Federation\AppInfo; |
|
26
|
|
|
|
|
27
|
|
|
use OCA\Federation\DAV\FedAuth; |
|
28
|
|
|
use OCA\Federation\Hooks; |
|
29
|
|
|
use OCA\Federation\Middleware\AddServerMiddleware; |
|
30
|
|
|
use OCP\AppFramework\App; |
|
31
|
|
|
use OCP\SabrePluginEvent; |
|
32
|
|
|
use OCP\Util; |
|
33
|
|
|
use Sabre\DAV\Auth\Plugin; |
|
34
|
|
|
use Sabre\DAV\Server; |
|
35
|
|
|
|
|
36
|
|
|
class Application extends App { |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @param array $urlParams |
|
40
|
|
|
*/ |
|
41
|
|
|
public function __construct($urlParams = []) { |
|
42
|
|
|
parent::__construct('federation', $urlParams); |
|
43
|
|
|
$this->registerMiddleware(); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
private function registerMiddleware() { |
|
47
|
|
|
$container = $this->getContainer(); |
|
48
|
|
|
$container->registerAlias('AddServerMiddleware', AddServerMiddleware::class); |
|
49
|
|
|
$container->registerMiddleWare('AddServerMiddleware'); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* listen to federated_share_added hooks to auto-add new servers to the |
|
54
|
|
|
* list of trusted servers. |
|
55
|
|
|
*/ |
|
56
|
|
|
public function registerHooks() { |
|
57
|
|
|
|
|
58
|
|
|
$container = $this->getContainer(); |
|
59
|
|
|
$hooksManager = $container->query(Hooks::class); |
|
60
|
|
|
|
|
61
|
|
|
Util::connectHook( |
|
62
|
|
|
'OCP\Share', |
|
63
|
|
|
'federated_share_added', |
|
64
|
|
|
$hooksManager, |
|
65
|
|
|
'addServerHook' |
|
66
|
|
|
); |
|
67
|
|
|
|
|
68
|
|
|
$dispatcher = $container->getServer()->getEventDispatcher(); |
|
69
|
|
|
$dispatcher->addListener('OCA\DAV\Connector\Sabre::authInit', function($event) use($container) { |
|
70
|
|
|
if ($event instanceof SabrePluginEvent) { |
|
71
|
|
|
$server = $event->getServer(); |
|
72
|
|
|
if ($server instanceof Server) { |
|
|
|
|
|
|
73
|
|
|
$authPlugin = $server->getPlugin('auth'); |
|
74
|
|
|
if ($authPlugin instanceof Plugin) { |
|
|
|
|
|
|
75
|
|
|
$authPlugin->addBackend($container->query(FedAuth::class)); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
}); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
} |
|
83
|
|
|
|
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.jsonfile (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.jsonto be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
requireorrequire-devsection?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceofchecks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.