Skip to content

Commit 5efc448

Browse files
committed
event on webfinger request
Signed-off-by: Maxence Lange <[email protected]>
1 parent 4824e5e commit 5efc448

File tree

9 files changed

+567
-8
lines changed

9 files changed

+567
-8
lines changed

lib/composer/composer/autoload_classmap.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,8 @@
522522
'OCP\\User\\Events\\UserLoggedInWithCookieEvent' => $baseDir . '/lib/public/User/Events/UserLoggedInWithCookieEvent.php',
523523
'OCP\\User\\Events\\UserLoggedOutEvent' => $baseDir . '/lib/public/User/Events/UserLoggedOutEvent.php',
524524
'OCP\\Util' => $baseDir . '/lib/public/Util.php',
525+
'OCP\\Webfinger\\IWebfingerManager' => $baseDir . '/lib/public/Webfinger/IWebfingerManager.php',
526+
'OCP\\Webfinger\\Model\\IWebfinger' => $baseDir . '/lib/public/Webfinger/Model/IWebfinger.php',
525527
'OCP\\WorkflowEngine\\EntityContext\\IDisplayName' => $baseDir . '/lib/public/WorkflowEngine/EntityContext/IDisplayName.php',
526528
'OCP\\WorkflowEngine\\EntityContext\\IDisplayText' => $baseDir . '/lib/public/WorkflowEngine/EntityContext/IDisplayText.php',
527529
'OCP\\WorkflowEngine\\EntityContext\\IIcon' => $baseDir . '/lib/public/WorkflowEngine/EntityContext/IIcon.php',
@@ -1347,6 +1349,10 @@
13471349
'OC\\User\\NoUserException' => $baseDir . '/lib/private/User/NoUserException.php',
13481350
'OC\\User\\Session' => $baseDir . '/lib/private/User/Session.php',
13491351
'OC\\User\\User' => $baseDir . '/lib/private/User/User.php',
1352+
'OC\\Webfinger\\Event\\WebfingerEvent' => $baseDir . '/lib/private/Webfinger/Event/WebfingerEvent.php',
1353+
'OC\\Webfinger\\Exceptions\\WebfingerRequestException' => $baseDir . '/lib/private/Webfinger/Exceptions/WebfingerRequestException.php',
1354+
'OC\\Webfinger\\Model\\Webfinger' => $baseDir . '/lib/private/Webfinger/Model/Webfinger.php',
1355+
'OC\\Webfinger\\WebfingerManager' => $baseDir . '/lib/private/Webfinger/WebfingerManager.php',
13501356
'OC_API' => $baseDir . '/lib/private/legacy/OC_API.php',
13511357
'OC_App' => $baseDir . '/lib/private/legacy/OC_App.php',
13521358
'OC_DB' => $baseDir . '/lib/private/legacy/OC_DB.php',

lib/composer/composer/autoload_static.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
88
{
99
public static $prefixLengthsPsr4 = array (
10-
'O' =>
10+
'O' =>
1111
array (
1212
'OC\\Core\\' => 8,
1313
'OC\\' => 3,
@@ -16,15 +16,15 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
1616
);
1717

1818
public static $prefixDirsPsr4 = array (
19-
'OC\\Core\\' =>
19+
'OC\\Core\\' =>
2020
array (
2121
0 => __DIR__ . '/../../..' . '/core',
2222
),
23-
'OC\\' =>
23+
'OC\\' =>
2424
array (
2525
0 => __DIR__ . '/../../..' . '/lib/private',
2626
),
27-
'OCP\\' =>
27+
'OCP\\' =>
2828
array (
2929
0 => __DIR__ . '/../../..' . '/lib/public',
3030
),
@@ -551,6 +551,8 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
551551
'OCP\\User\\Events\\UserLoggedInWithCookieEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserLoggedInWithCookieEvent.php',
552552
'OCP\\User\\Events\\UserLoggedOutEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserLoggedOutEvent.php',
553553
'OCP\\Util' => __DIR__ . '/../../..' . '/lib/public/Util.php',
554+
'OCP\\Webfinger\\IWebfingerManager' => __DIR__ . '/../../..' . '/lib/public/Webfinger/IWebfingerManager.php',
555+
'OCP\\Webfinger\\Model\\IWebfinger' => __DIR__ . '/../../..' . '/lib/public/Webfinger/Model/IWebfinger.php',
554556
'OCP\\WorkflowEngine\\EntityContext\\IDisplayName' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/EntityContext/IDisplayName.php',
555557
'OCP\\WorkflowEngine\\EntityContext\\IDisplayText' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/EntityContext/IDisplayText.php',
556558
'OCP\\WorkflowEngine\\EntityContext\\IIcon' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/EntityContext/IIcon.php',
@@ -1376,6 +1378,10 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
13761378
'OC\\User\\NoUserException' => __DIR__ . '/../../..' . '/lib/private/User/NoUserException.php',
13771379
'OC\\User\\Session' => __DIR__ . '/../../..' . '/lib/private/User/Session.php',
13781380
'OC\\User\\User' => __DIR__ . '/../../..' . '/lib/private/User/User.php',
1381+
'OC\\Webfinger\\Event\\WebfingerEvent' => __DIR__ . '/../../..' . '/lib/private/Webfinger/Event/WebfingerEvent.php',
1382+
'OC\\Webfinger\\Exceptions\\WebfingerRequestException' => __DIR__ . '/../../..' . '/lib/private/Webfinger/Exceptions/WebfingerRequestException.php',
1383+
'OC\\Webfinger\\Model\\Webfinger' => __DIR__ . '/../../..' . '/lib/private/Webfinger/Model/Webfinger.php',
1384+
'OC\\Webfinger\\WebfingerManager' => __DIR__ . '/../../..' . '/lib/private/Webfinger/WebfingerManager.php',
13791385
'OC_API' => __DIR__ . '/../../..' . '/lib/private/legacy/OC_API.php',
13801386
'OC_App' => __DIR__ . '/../../..' . '/lib/private/legacy/OC_App.php',
13811387
'OC_DB' => __DIR__ . '/../../..' . '/lib/private/legacy/OC_DB.php',
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* @copyright 2020, Maxence Lange <[email protected]>
7+
*
8+
* @author Maxence Lange <[email protected]>
9+
*
10+
* @license GNU AGPL version 3 or any later version
11+
*
12+
* This program is free software: you can redistribute it and/or modify
13+
* it under the terms of the GNU Affero General Public License as
14+
* published by the Free Software Foundation, either version 3 of the
15+
* License, or (at your option) any later version.
16+
*
17+
* This program is distributed in the hope that it will be useful,
18+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
* GNU Affero General Public License for more details.
21+
*
22+
* You should have received a copy of the GNU Affero General Public License
23+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
24+
*
25+
*/
26+
27+
namespace OC\Webfinger\Event;
28+
29+
30+
use OCP\EventDispatcher\Event;
31+
use OCP\Webfinger\Model\IWebfinger;
32+
33+
34+
/**
35+
* Class WebfingerEvent
36+
*
37+
* @package OC\Webfinger\Events
38+
*/
39+
class WebfingerEvent extends Event {
40+
41+
42+
/** @var IWebfinger */
43+
private $webfinger;
44+
45+
46+
public function __construct(IWebfinger $webfinger) {
47+
parent::__construct();
48+
49+
$this->webfinger = $webfinger;
50+
}
51+
52+
53+
public function getWebfinger(): IWebfinger {
54+
return $this->webfinger;
55+
}
56+
57+
}
58+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* @copyright 2020, Maxence Lange <[email protected]>
7+
*
8+
* @author Maxence Lange <[email protected]>
9+
*
10+
* @license GNU AGPL version 3 or any later version
11+
*
12+
* This program is free software: you can redistribute it and/or modify
13+
* it under the terms of the GNU Affero General Public License as
14+
* published by the Free Software Foundation, either version 3 of the
15+
* License, or (at your option) any later version.
16+
*
17+
* This program is distributed in the hope that it will be useful,
18+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
* GNU Affero General Public License for more details.
21+
*
22+
* You should have received a copy of the GNU Affero General Public License
23+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
24+
*
25+
*/
26+
27+
28+
namespace OC\Webfinger\Exceptions;
29+
30+
31+
use Exception;
32+
33+
34+
class WebfingerRequestException extends Exception {
35+
36+
}
37+
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* @copyright 2020, Maxence Lange <[email protected]>
7+
*
8+
* @author Maxence Lange <[email protected]>
9+
*
10+
* @license GNU AGPL version 3 or any later version
11+
*
12+
* This program is free software: you can redistribute it and/or modify
13+
* it under the terms of the GNU Affero General Public License as
14+
* published by the Free Software Foundation, either version 3 of the
15+
* License, or (at your option) any later version.
16+
*
17+
* This program is distributed in the hope that it will be useful,
18+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
* GNU Affero General Public License for more details.
21+
*
22+
* You should have received a copy of the GNU Affero General Public License
23+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
24+
*
25+
*/
26+
27+
28+
namespace OC\Webfinger\Model;
29+
30+
use JsonSerializable;
31+
use OCP\Webfinger\Model\IWebfinger;
32+
33+
34+
/**
35+
* @since 20.0.0
36+
*
37+
* @package OC\Webfinger\Model
38+
*/
39+
final class Webfinger implements IWebfinger, JsonSerializable {
40+
41+
42+
/** @var string */
43+
private $subject;
44+
45+
/** @var array */
46+
private $aliases = [];
47+
48+
/** @var array */
49+
private $properties = [];
50+
51+
/** @var array */
52+
private $rels = [];
53+
54+
/** @var array */
55+
private $links = [];
56+
57+
58+
public function __construct(string $subject) {
59+
$this->subject = $subject;
60+
}
61+
62+
63+
/**
64+
* @return string
65+
* @since 20.0.0
66+
*/
67+
public function getSubject(): string {
68+
return $this->subject;
69+
}
70+
71+
72+
/**
73+
* @return array
74+
*/
75+
public function getRels(): array {
76+
return $this->rels;
77+
}
78+
79+
80+
/**
81+
* @param string $alias
82+
*
83+
* @return $this
84+
*/
85+
public function addAlias(string $alias): IWebfinger {
86+
if (!in_array($alias, $this->aliases)) {
87+
$this->aliases[] = $alias;
88+
}
89+
90+
return $this;
91+
}
92+
93+
/**
94+
* @return array
95+
*/
96+
public function getAliases(): array {
97+
return $this->aliases;
98+
}
99+
100+
101+
/**
102+
* @param string $property
103+
* @param $value
104+
*
105+
* @return IWebfinger
106+
*/
107+
public function addProperty(string $property, $value): IWebfinger {
108+
$this->properties[$property] = $value;
109+
110+
return $this;
111+
}
112+
113+
/**
114+
* @return array
115+
*/
116+
public function getProperties(): array {
117+
return $this->properties;
118+
}
119+
120+
121+
/**
122+
* @param array $arr
123+
*
124+
* @return IWebfinger
125+
* @since 20.0.0
126+
*/
127+
public function addLink(array $arr): IWebfinger {
128+
$this->links[] = $arr;
129+
130+
return $this;
131+
}
132+
133+
/**
134+
* @param JsonSerializable $object
135+
*
136+
* @return IWebfinger
137+
* @since 20.0.0
138+
*/
139+
public function addLinkSerialized(JsonSerializable $object): IWebfinger {
140+
$this->links[] = $object;
141+
142+
return $this;
143+
}
144+
145+
/**
146+
* @return array
147+
* @since 20.0.0
148+
*/
149+
public function getLinks(): array {
150+
return $this->links;
151+
}
152+
153+
154+
/**
155+
* @return array
156+
* @since 20.0.0
157+
*/
158+
public function jsonSerialize(): array {
159+
$data = [
160+
'subject' => $this->getSubject(),
161+
'properties' => $this->getProperties(),
162+
'aliases' => $this->getAliases(),
163+
'links' => $this->getLinks()
164+
];
165+
166+
return array_filter($data);
167+
}
168+
169+
}
170+

0 commit comments

Comments
 (0)