|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Circles - Bring cloud-users closer together. |
|
8
|
|
|
* |
|
9
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
|
10
|
|
|
* later. See the COPYING file. |
|
11
|
|
|
* |
|
12
|
|
|
* @author Maxence Lange <[email protected]> |
|
13
|
|
|
* @copyright 2020 |
|
14
|
|
|
* @license GNU AGPL version 3 or any later version |
|
15
|
|
|
* |
|
16
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
17
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
18
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
19
|
|
|
* License, or (at your option) any later version. |
|
20
|
|
|
* |
|
21
|
|
|
* This program is distributed in the hope that it will be useful, |
|
22
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
23
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
24
|
|
|
* GNU Affero General Public License for more details. |
|
25
|
|
|
* |
|
26
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
27
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
28
|
|
|
* |
|
29
|
|
|
*/ |
|
30
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
namespace OCA\Circles\Controller; |
|
33
|
|
|
|
|
34
|
|
|
use daita\MySmallPhpTools\Exceptions\InvalidOriginException; |
|
35
|
|
|
use daita\MySmallPhpTools\Exceptions\MalformedArrayException; |
|
36
|
|
|
use daita\MySmallPhpTools\Exceptions\SignatoryException; |
|
37
|
|
|
use daita\MySmallPhpTools\Exceptions\SignatureException; |
|
38
|
|
|
use daita\MySmallPhpTools\Traits\Nextcloud\nc21\TNC21Controller; |
|
39
|
|
|
use daita\MySmallPhpTools\Traits\Nextcloud\nc21\TNC21Signature; |
|
40
|
|
|
use Exception; |
|
41
|
|
|
use OCA\Circles\Service\RemoteService; |
|
42
|
|
|
use OCP\AppFramework\Controller; |
|
43
|
|
|
use OCP\AppFramework\Http\DataResponse; |
|
44
|
|
|
use OCP\IRequest; |
|
45
|
|
|
|
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Class RemoteController |
|
49
|
|
|
* |
|
50
|
|
|
* @package OCA\Circles\Controller |
|
51
|
|
|
*/ |
|
52
|
|
|
class RemoteController extends Controller { |
|
53
|
|
|
|
|
54
|
|
|
|
|
55
|
|
|
use TNC21Controller; |
|
56
|
|
|
|
|
57
|
|
|
|
|
58
|
|
|
/** @var RemoteService */ |
|
59
|
|
|
private $remoteService; |
|
60
|
|
|
|
|
61
|
|
|
|
|
62
|
|
|
public function __construct(string $appName, IRequest $request, RemoteService $remoteService) { |
|
63
|
|
|
parent::__construct($appName, $request); |
|
64
|
|
|
|
|
65
|
|
|
$this->remoteService = $remoteService; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @PublicPage |
|
71
|
|
|
* @NoCSRFRequired |
|
72
|
|
|
* |
|
73
|
|
|
* @return DataResponse |
|
74
|
|
|
* @throws InvalidOriginException |
|
75
|
|
|
* @throws MalformedArrayException |
|
76
|
|
|
* @throws SignatoryException |
|
77
|
|
|
* @throws SignatureException |
|
78
|
|
|
*/ |
|
79
|
|
|
public function test() { |
|
80
|
|
|
return $this->successObj($this->remoteService->incomingTest()); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @PublicPage |
|
86
|
|
|
* @NoCSRFRequired |
|
87
|
|
|
* @SignedRequest(signatory=toto) |
|
88
|
|
|
*/ |
|
89
|
|
|
public function incoming() { |
|
90
|
|
|
try { |
|
91
|
|
|
return $this->success([]); |
|
92
|
|
|
} catch (Exception $e) { |
|
93
|
|
|
return $this->fail($e); |
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* @PublicPage |
|
100
|
|
|
* @NoCSRFRequired |
|
101
|
|
|
*/ |
|
102
|
|
|
public function circles() { |
|
103
|
|
|
$body = file_get_contents('php://input'); |
|
|
|
|
|
|
104
|
|
|
|
|
105
|
|
|
$circles = []; |
|
106
|
|
|
|
|
107
|
|
|
return $this->success($circles); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
|
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.