Skip to content

Commit

Permalink
event on webfinger request
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
  • Loading branch information
ArtificialOwl committed Jul 28, 2020
1 parent 4824e5e commit 5efc448
Show file tree
Hide file tree
Showing 9 changed files with 567 additions and 8 deletions.
6 changes: 6 additions & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,8 @@
'OCP\\User\\Events\\UserLoggedInWithCookieEvent' => $baseDir . '/lib/public/User/Events/UserLoggedInWithCookieEvent.php',
'OCP\\User\\Events\\UserLoggedOutEvent' => $baseDir . '/lib/public/User/Events/UserLoggedOutEvent.php',
'OCP\\Util' => $baseDir . '/lib/public/Util.php',
'OCP\\Webfinger\\IWebfingerManager' => $baseDir . '/lib/public/Webfinger/IWebfingerManager.php',
'OCP\\Webfinger\\Model\\IWebfinger' => $baseDir . '/lib/public/Webfinger/Model/IWebfinger.php',
'OCP\\WorkflowEngine\\EntityContext\\IDisplayName' => $baseDir . '/lib/public/WorkflowEngine/EntityContext/IDisplayName.php',
'OCP\\WorkflowEngine\\EntityContext\\IDisplayText' => $baseDir . '/lib/public/WorkflowEngine/EntityContext/IDisplayText.php',
'OCP\\WorkflowEngine\\EntityContext\\IIcon' => $baseDir . '/lib/public/WorkflowEngine/EntityContext/IIcon.php',
Expand Down Expand Up @@ -1347,6 +1349,10 @@
'OC\\User\\NoUserException' => $baseDir . '/lib/private/User/NoUserException.php',
'OC\\User\\Session' => $baseDir . '/lib/private/User/Session.php',
'OC\\User\\User' => $baseDir . '/lib/private/User/User.php',
'OC\\Webfinger\\Event\\WebfingerEvent' => $baseDir . '/lib/private/Webfinger/Event/WebfingerEvent.php',
'OC\\Webfinger\\Exceptions\\WebfingerRequestException' => $baseDir . '/lib/private/Webfinger/Exceptions/WebfingerRequestException.php',
'OC\\Webfinger\\Model\\Webfinger' => $baseDir . '/lib/private/Webfinger/Model/Webfinger.php',
'OC\\Webfinger\\WebfingerManager' => $baseDir . '/lib/private/Webfinger/WebfingerManager.php',
'OC_API' => $baseDir . '/lib/private/legacy/OC_API.php',
'OC_App' => $baseDir . '/lib/private/legacy/OC_App.php',
'OC_DB' => $baseDir . '/lib/private/legacy/OC_DB.php',
Expand Down
14 changes: 10 additions & 4 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
{
public static $prefixLengthsPsr4 = array (
'O' =>
'O' =>
array (
'OC\\Core\\' => 8,
'OC\\' => 3,
Expand All @@ -16,15 +16,15 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
);

public static $prefixDirsPsr4 = array (
'OC\\Core\\' =>
'OC\\Core\\' =>
array (
0 => __DIR__ . '/../../..' . '/core',
),
'OC\\' =>
'OC\\' =>
array (
0 => __DIR__ . '/../../..' . '/lib/private',
),
'OCP\\' =>
'OCP\\' =>
array (
0 => __DIR__ . '/../../..' . '/lib/public',
),
Expand Down Expand Up @@ -551,6 +551,8 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OCP\\User\\Events\\UserLoggedInWithCookieEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserLoggedInWithCookieEvent.php',
'OCP\\User\\Events\\UserLoggedOutEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserLoggedOutEvent.php',
'OCP\\Util' => __DIR__ . '/../../..' . '/lib/public/Util.php',
'OCP\\Webfinger\\IWebfingerManager' => __DIR__ . '/../../..' . '/lib/public/Webfinger/IWebfingerManager.php',
'OCP\\Webfinger\\Model\\IWebfinger' => __DIR__ . '/../../..' . '/lib/public/Webfinger/Model/IWebfinger.php',
'OCP\\WorkflowEngine\\EntityContext\\IDisplayName' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/EntityContext/IDisplayName.php',
'OCP\\WorkflowEngine\\EntityContext\\IDisplayText' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/EntityContext/IDisplayText.php',
'OCP\\WorkflowEngine\\EntityContext\\IIcon' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/EntityContext/IIcon.php',
Expand Down Expand Up @@ -1376,6 +1378,10 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OC\\User\\NoUserException' => __DIR__ . '/../../..' . '/lib/private/User/NoUserException.php',
'OC\\User\\Session' => __DIR__ . '/../../..' . '/lib/private/User/Session.php',
'OC\\User\\User' => __DIR__ . '/../../..' . '/lib/private/User/User.php',
'OC\\Webfinger\\Event\\WebfingerEvent' => __DIR__ . '/../../..' . '/lib/private/Webfinger/Event/WebfingerEvent.php',
'OC\\Webfinger\\Exceptions\\WebfingerRequestException' => __DIR__ . '/../../..' . '/lib/private/Webfinger/Exceptions/WebfingerRequestException.php',
'OC\\Webfinger\\Model\\Webfinger' => __DIR__ . '/../../..' . '/lib/private/Webfinger/Model/Webfinger.php',
'OC\\Webfinger\\WebfingerManager' => __DIR__ . '/../../..' . '/lib/private/Webfinger/WebfingerManager.php',
'OC_API' => __DIR__ . '/../../..' . '/lib/private/legacy/OC_API.php',
'OC_App' => __DIR__ . '/../../..' . '/lib/private/legacy/OC_App.php',
'OC_DB' => __DIR__ . '/../../..' . '/lib/private/legacy/OC_DB.php',
Expand Down
58 changes: 58 additions & 0 deletions lib/private/Webfinger/Event/WebfingerEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

declare(strict_types=1);

/**
* @copyright 2020, Maxence Lange <maxence@artificial-owl.com>
*
* @author Maxence Lange <maxence@artificial-owl.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace OC\Webfinger\Event;


use OCP\EventDispatcher\Event;
use OCP\Webfinger\Model\IWebfinger;


/**
* Class WebfingerEvent
*
* @package OC\Webfinger\Events
*/
class WebfingerEvent extends Event {


/** @var IWebfinger */
private $webfinger;


public function __construct(IWebfinger $webfinger) {
parent::__construct();

$this->webfinger = $webfinger;
}


public function getWebfinger(): IWebfinger {
return $this->webfinger;
}

}

37 changes: 37 additions & 0 deletions lib/private/Webfinger/Exceptions/WebfingerRequestException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

/**
* @copyright 2020, Maxence Lange <maxence@artificial-owl.com>
*
* @author Maxence Lange <maxence@artificial-owl.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/


namespace OC\Webfinger\Exceptions;


use Exception;


class WebfingerRequestException extends Exception {

}

170 changes: 170 additions & 0 deletions lib/private/Webfinger/Model/Webfinger.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
<?php

declare(strict_types=1);

/**
* @copyright 2020, Maxence Lange <maxence@artificial-owl.com>
*
* @author Maxence Lange <maxence@artificial-owl.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/


namespace OC\Webfinger\Model;

use JsonSerializable;
use OCP\Webfinger\Model\IWebfinger;


/**
* @since 20.0.0
*
* @package OC\Webfinger\Model
*/
final class Webfinger implements IWebfinger, JsonSerializable {


/** @var string */
private $subject;

/** @var array */
private $aliases = [];

/** @var array */
private $properties = [];

/** @var array */
private $rels = [];

/** @var array */
private $links = [];


public function __construct(string $subject) {
$this->subject = $subject;
}


/**
* @return string
* @since 20.0.0
*/
public function getSubject(): string {
return $this->subject;
}


/**
* @return array
*/
public function getRels(): array {
return $this->rels;
}


/**
* @param string $alias
*
* @return $this
*/
public function addAlias(string $alias): IWebfinger {
if (!in_array($alias, $this->aliases)) {
$this->aliases[] = $alias;
}

return $this;
}

/**
* @return array
*/
public function getAliases(): array {
return $this->aliases;
}


/**
* @param string $property
* @param $value
*
* @return IWebfinger
*/
public function addProperty(string $property, $value): IWebfinger {
$this->properties[$property] = $value;

return $this;
}

/**
* @return array
*/
public function getProperties(): array {
return $this->properties;
}


/**
* @param array $arr
*
* @return IWebfinger
* @since 20.0.0
*/
public function addLink(array $arr): IWebfinger {
$this->links[] = $arr;

return $this;
}

/**
* @param JsonSerializable $object
*
* @return IWebfinger
* @since 20.0.0
*/
public function addLinkSerialized(JsonSerializable $object): IWebfinger {
$this->links[] = $object;

return $this;
}

/**
* @return array
* @since 20.0.0
*/
public function getLinks(): array {
return $this->links;
}


/**
* @return array
* @since 20.0.0
*/
public function jsonSerialize(): array {
$data = [
'subject' => $this->getSubject(),
'properties' => $this->getProperties(),
'aliases' => $this->getAliases(),
'links' => $this->getLinks()
];

return array_filter($data);
}

}

Loading

0 comments on commit 5efc448

Please sign in to comment.