migrate therinaldos.com data
Build & Deploy to DigitalOcean Space / build (push) Failing after 2m38s

This commit is contained in:
2024-05-05 15:50:45 -04:00
commit ef1ff240d4
23182 changed files with 3801898 additions and 0 deletions
@@ -0,0 +1,327 @@
<?php
declare(strict_types=1);
/**
* Circles - Bring cloud-users closer together.
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2017
* @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 OCA\Circles\Model\Federated;
use OCA\Circles\Tools\Db\IQueryRow;
use OCA\Circles\Tools\Exceptions\InvalidItemException;
use OCA\Circles\Tools\Model\SimpleDataStore;
use OCA\Circles\Tools\Traits\TArrayTools;
use JsonSerializable;
/**
* Class EventWrapper
*
* @package OCA\Circles\Model\Remote
*/
class EventWrapper implements IQueryRow, JsonSerializable {
use TArrayTools;
public const STATUS_INIT = 0;
public const STATUS_FAILED = 1;
public const STATUS_DONE = 8;
public const STATUS_OVER = 9;
/** @var string */
private $token = '';
/** @var FederatedEvent */
private $event;
/** @var SimpleDataStore */
private $result;
/** @var string */
private $instance = '';
/** @var int */
private $interface = 0;
/** @var int */
private $severity = FederatedEvent::SEVERITY_LOW;
/** @var int */
private $retry = 0;
/** @var int */
private $status = 0;
/** @var int */
private $creation;
public function __construct() {
$this->result = new SimpleDataStore();
}
/**
* @return string
*/
public function getToken(): string {
return $this->token;
}
/**
* @param string $token
*
* @return self
*/
public function setToken(string $token): self {
$this->token = $token;
return $this;
}
/**
* @return FederatedEvent
*/
public function getEvent(): FederatedEvent {
return $this->event;
}
/**
* @param FederatedEvent $event
*
* @return self
*/
public function setEvent(FederatedEvent $event): self {
$this->event = $event;
return $this;
}
/**
* @return bool
*/
public function hasEvent(): bool {
return ($this->event !== null);
}
/**
* @param SimpleDataStore $result
*
* @return $this
*/
public function setResult(SimpleDataStore $result): self {
$this->result = $result;
return $this;
}
/**
* @return SimpleDataStore
*/
public function getResult(): SimpleDataStore {
return $this->result;
}
/**
* @return string
*/
public function getInstance(): string {
return $this->instance;
}
/**
* @param string $instance
*
* @return self
*/
public function setInstance(string $instance): self {
$this->instance = $instance;
return $this;
}
/**
* @return int
*/
public function getInterface(): int {
return $this->interface;
}
/**
* @param int $interface
*
* @return self
*/
public function setInterface(int $interface): self {
$this->interface = $interface;
return $this;
}
/**
* @return int
*/
public function getSeverity(): int {
return $this->severity;
}
/**
* @param int $severity
*
* @return self
*/
public function setSeverity(int $severity): self {
$this->severity = $severity;
return $this;
}
/**
* @param int $retry
*
* @return EventWrapper
*/
public function setRetry(int $retry): self {
$this->retry = $retry;
return $this;
}
/**
* @return int
*/
public function getRetry(): int {
return $this->retry;
}
/**
* @return int
*/
public function getStatus(): int {
return $this->status;
}
/**
* @param int $status
*
* @return self
*/
public function setStatus(int $status): self {
$this->status = $status;
return $this;
}
/**
* @return int
*/
public function getCreation(): int {
return $this->creation;
}
/**
* @param int $creation
*
* @return self
*/
public function setCreation(int $creation): self {
$this->creation = $creation;
return $this;
}
/**
* @param array $data
*
* @return self
* @throws InvalidItemException
*/
public function import(array $data): self {
$this->setToken($this->get('token', $data));
$this->setInstance($this->get('instance', $data));
$this->setInterface($this->getInt('interface', $data));
$this->setSeverity($this->getInt('severity', $data, FederatedEvent::SEVERITY_LOW));
$this->setStatus($this->getInt('status', $data, self::STATUS_INIT));
$event = new FederatedEvent();
$event->import($this->getArray('event', $data));
$this->setEvent($event);
$this->setResult(new SimpleDataStore($this->getArray('result', $data)));
$this->setCreation($this->getInt('creation', $data));
return $this;
}
/**
* @return array
*/
public function jsonSerialize(): array {
return [
'token' => $this->getToken(),
'instance' => $this->getInstance(),
'interface' => $this->getInterface(),
'event' => $this->getEvent(),
'result' => $this->getResult(),
'severity' => $this->getSeverity(),
'status' => $this->getStatus()
// 'creation' => $this->getCreation()
];
}
/**
* @param array $data
*
* @return IQueryRow
* @throws InvalidItemException
*/
public function importFromDatabase(array $data): IQueryRow {
$this->setToken($this->get('token', $data));
$this->setInstance($this->get('instance', $data));
$this->setInterface($this->getInt('interface', $data));
$this->setSeverity($this->getInt('severity', $data, FederatedEvent::SEVERITY_LOW));
$this->setStatus($this->getInt('status', $data, self::STATUS_INIT));
$event = new FederatedEvent();
$event->import($this->getArray('event', $data));
$this->setEvent($event);
$this->setResult(new SimpleDataStore($this->getArray('result', $data)));
return $this;
}
}
@@ -0,0 +1,643 @@
<?php
declare(strict_types=1);
/**
* Circles - Bring cloud-users closer together.
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2021
* @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 OCA\Circles\Model\Federated;
use OCA\Circles\Tools\Exceptions\InvalidItemException;
use OCA\Circles\Tools\Model\SimpleDataStore;
use OCA\Circles\Tools\Traits\TArrayTools;
use JsonSerializable;
use OCA\Circles\Model\Circle;
use OCA\Circles\Model\Member;
/**
* Class FederatedEvent
*
* @package OCA\Circles\Model\Federated
*/
class FederatedEvent implements JsonSerializable {
public const SEVERITY_LOW = 1;
public const SEVERITY_HIGH = 3;
public const BYPASS_CIRCLE = 1;
public const BYPASS_LOCALCIRCLECHECK = 2;
public const BYPASS_LOCALMEMBERCHECK = 4;
public const BYPASS_INITIATORCHECK = 8;
public const BYPASS_INITIATORMEMBERSHIP = 16;
use TArrayTools;
/** @var string */
private $class;
/** @var string */
private $origin = '';
/** @var Circle */
private $circle;
/** @var string */
private $itemId = '';
/** @var string */
private $itemSource = '';
/** @var Member */
private $member;
/** @var Member[] */
private $members = [];
/** @var SimpleDataStore */
private $params;
/** @var SimpleDataStore */
private $internal;
/** @var SimpleDataStore */
private $data;
/** @var int */
private $severity = self::SEVERITY_LOW;
/** @var array */
private $outcome = [];
/** @var SimpleDataStore */
private $result;
/** @var bool */
private $async = false;
/** @var bool */
private $limitedToInstanceWithMember = false;
/** @var bool */
private $dataRequestOnly = false;
/** @var string */
private $sender = '';
/** @var string */
private $wrapperToken = '';
/** @var int */
private $bypass = 0;
/**
* FederatedEvent constructor.
*
* @param string $class
*/
public function __construct(string $class = '') {
$this->class = $class;
$this->params = new SimpleDataStore();
$this->internal = new SimpleDataStore();
$this->data = new SimpleDataStore();
$this->result = new SimpleDataStore();
}
/**
* @return string
*/
public function getClass(): string {
return $this->class;
}
/**
* @param mixed $class
*
* @return self
*/
public function setClass($class): self {
$this->class = $class;
return $this;
}
/**
* Origin of the event.
*
* @return string
*/
public function getOrigin(): string {
return $this->origin;
}
/**
* @param string $origin
*
* @return self
*/
public function setOrigin(string $origin): self {
$this->origin = $origin;
return $this;
}
/**
* @return bool
*/
public function isAsync(): bool {
return $this->async;
}
/**
* @param bool $async
*
* @return self
*/
public function setAsync(bool $async): self {
$this->async = $async;
return $this;
}
/**
* @return bool
*/
public function isLimitedToInstanceWithMember(): bool {
return $this->limitedToInstanceWithMember;
}
/**
* @param bool $limitedToInstanceWithMember
*
* @return self
*/
public function setLimitedToInstanceWithMember(bool $limitedToInstanceWithMember): self {
$this->limitedToInstanceWithMember = $limitedToInstanceWithMember;
return $this;
}
/**
* @return bool
*/
public function isDataRequestOnly(): bool {
return $this->dataRequestOnly;
}
/**
* @param bool $dataRequestOnly
*
* @return self
*/
public function setDataRequestOnly(bool $dataRequestOnly): self {
$this->dataRequestOnly = $dataRequestOnly;
return $this;
}
/**
*
* Origin of the request
*
* @param string $sender
*
* @return self
*/
public function setSender(string $sender): self {
$this->sender = $sender;
return $this;
}
/**
* @return string
*/
public function getSender(): string {
return $this->sender;
}
/**
* @param string $wrapperToken
*
* @return FederatedEvent
*/
public function setWrapperToken(string $wrapperToken): self {
$this->wrapperToken = $wrapperToken;
return $this;
}
/**
* @return string
*/
public function getWrapperToken(): string {
return $this->wrapperToken;
}
/**
* @return bool
*/
public function hasCircle(): bool {
return ($this->circle !== null);
}
/**
* @param Circle $circle
*
* @return self
*/
public function setCircle(Circle $circle): self {
$this->circle = $circle;
return $this;
}
/**
* @return Circle
*/
public function getCircle(): Circle {
return $this->circle;
}
/**
* @param string $itemId
*
* @return self
*/
public function setItemId(string $itemId): self {
$this->itemId = $itemId;
return $this;
}
/**
* @return string
*/
public function getItemId(): string {
return $this->itemId;
}
/**
* @param string $itemSource
*
* @return self
*/
public function setItemSource(string $itemSource): self {
$this->itemSource = $itemSource;
return $this;
}
/**
* @return string
*/
public function getItemSource(): string {
return $this->itemSource;
}
/**
* @return Member
*/
public function getMember(): Member {
return $this->member;
}
/**
* @param Member|null $member
*
* @return self
*/
public function setMember(?Member $member): self {
$this->member = $member;
return $this;
}
/**
* @return bool
*/
public function hasMember(): bool {
return ($this->member !== null);
}
/**
* @return Member[]
*/
public function getMembers(): array {
return $this->members;
}
/**
* @param Member[] $members
*
* @return self
*/
public function setMembers(array $members): self {
$this->members = $members;
return $this;
}
/**
* @param SimpleDataStore $params
*
* @return self
*/
public function setParams(SimpleDataStore $params): self {
$this->params = $params;
return $this;
}
/**
* @return SimpleDataStore
*/
public function getParams(): SimpleDataStore {
return $this->params;
}
/**
* @param SimpleDataStore $internal
*
* @return self
*/
public function setInternal(SimpleDataStore $internal): self {
$this->internal = $internal;
return $this;
}
/**
* @return SimpleDataStore
*/
public function getInternal(): SimpleDataStore {
return $this->internal;
}
/**
* @return $this
*/
public function resetInternal(): self {
$this->internal = new SimpleDataStore();
return $this;
}
/**
* @param SimpleDataStore $data
*
* @return self
*/
public function setData(SimpleDataStore $data): self {
$this->data = $data;
return $this;
}
/**
* @return SimpleDataStore
*/
public function getData(): SimpleDataStore {
return $this->data;
}
/**
* @return $this
*/
public function resetData(): self {
$this->resetInternal();
$this->data = new SimpleDataStore();
return $this;
}
/**
* @return int
*/
public function getSeverity(): int {
return $this->severity;
}
/**
* @param int $severity
*
* @return self
*/
public function setSeverity(int $severity): self {
$this->severity = $severity;
return $this;
}
/**
* @return array
*/
public function getOutcome(): array {
return $this->outcome;
}
/**
* @param array $data
*
* @return $this
*/
public function setOutcome(array $data): self {
$this->outcome = $data;
return $this;
}
/**
* @return SimpleDataStore
*/
public function getResult(): SimpleDataStore {
return $this->result;
}
/**
* @param SimpleDataStore $result
*
* @return self
*/
public function setResult(SimpleDataStore $result): self {
$this->result = $result;
return $this;
}
/**
* @return $this
*/
public function resetResult(): self {
$this->result = new SimpleDataStore();
return $this;
}
/**
* @param string $key
* @param array $result
*
* @return $this
*/
public function setResultEntry(string $key, array $result): self {
if (is_null($this->result)) {
$this->result = new SimpleDataStore();
}
$this->result->sData($key, new SimpleDataStore($result));
return $this;
}
/**
* @param string $key
* @param array $result
*
* @return $this
*/
public function addResultEntry(string $key, array $result): self {
if (is_null($this->result)) {
$this->result = new SimpleDataStore();
}
$this->result->aData($key, new SimpleDataStore($result));
return $this;
}
/**
* @param int $flag
*
* @return FederatedEvent
*/
public function bypass(int $flag): self {
if (!$this->canBypass($flag)) {
$this->bypass += $flag;
}
return $this;
}
/**
* @param int $flag
*
* @return bool
*/
public function canBypass(int $flag): bool {
return (($this->bypass & $flag) !== 0);
}
/**
* @param array $data
*
* @return self
* @throws InvalidItemException
*/
public function import(array $data): self {
$this->setClass($this->get('class', $data));
$this->setSeverity($this->getInt('severity', $data));
$this->setParams(new SimpleDataStore($this->getArray('params', $data)));
$this->setInternal(new SimpleDataStore($this->getArray('internal', $data)));
$this->setData(new SimpleDataStore($this->getArray('data', $data)));
$this->setResult(new SimpleDataStore($this->getArray('result', $data)));
$this->setOrigin($this->get('origin', $data));
$this->setItemId($this->get('itemId', $data));
try {
$circle = new Circle();
$circle->import($this->getArray('circle', $data));
$this->setCircle($circle);
} catch (InvalidItemException $e) {
}
if (array_key_exists('member', $data)) {
$member = new Member();
$member->import($this->getArray('member', $data));
$this->setMember($member);
}
$members = [];
foreach ($this->getArray('members', $data) as $item) {
$member = new Member();
$members[] = $member->import($item);
}
$this->setMembers($members);
return $this;
}
/**
* @return array
*/
public function jsonSerialize(): array {
$arr = [
'class' => $this->getClass(),
'severity' => $this->getSeverity(),
'params' => $this->getParams(),
'internal' => $this->getInternal(),
'data' => $this->getData(),
'result' => $this->getResult(),
'origin' => $this->getOrigin(),
'sender' => $this->getSender(),
'itemId' => $this->getItemId(),
'outcome' => $this->getOutcome(),
'members' => $this->getMembers()
];
if ($this->hasCircle()) {
$arr['circle'] = $this->getCircle();
}
if ($this->hasMember()) {
$arr['member'] = $this->getMember();
}
return $arr;
}
}
@@ -0,0 +1,225 @@
<?php
declare(strict_types=1);
/**
* Circles - Bring cloud-users closer together.
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2021
* @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 OCA\Circles\Model\Federated;
use OCA\Circles\Tools\Db\IQueryRow;
use OCA\Circles\Tools\IDeserializable;
use OCA\Circles\Tools\Model\SimpleDataStore;
use OCA\Circles\Tools\Traits\TArrayTools;
use JsonSerializable;
use OCA\Circles\IFederatedModel;
use OCA\Circles\Model\ManagedModel;
/**
* Class FederatedShare
*
* @package OCA\Circles\Model\Federated
*/
class FederatedShare extends ManagedModel implements IFederatedModel, JsonSerializable, IQueryRow, IDeserializable {
use TArrayTools;
/** @var int */
private $id = 0;
/** @var string */
private $itemId = '';
/** @var string */
private $circleId = '';
/** @var string */
private $instance = '';
/** @var string */
private $lockStatus = '';
/** @var SimpleDataStore */
private $data;
/**
* FederatedShare constructor.
*/
public function __construct() {
}
/**
* @param int $id
*
* @return FederatedShare
*/
public function setId(int $id): self {
$this->id = $id;
return $this;
}
/**
* @return int
*/
public function getId(): int {
return $this->id;
}
/**
* @param string $itemId
*
* @return FederatedShare
*/
public function setItemId(string $itemId): self {
$this->itemId = $itemId;
return $this;
}
/**
* @return string
*/
public function getItemId(): string {
return $this->itemId;
}
/**
* @param string $circleId
*
* @return FederatedShare
*/
public function setCircleId(string $circleId): self {
$this->circleId = $circleId;
return $this;
}
/**
* @return string
*/
public function getCircleId(): string {
return $this->circleId;
}
/**
* @param string $instance
*
* @return FederatedShare
*/
public function setInstance(string $instance): self {
$this->instance = $instance;
return $this;
}
/**
* @param string $lockStatus
*
* @return FederatedShare
*/
public function setLockStatus(string $lockStatus): self {
$this->lockStatus = $lockStatus;
return $this;
}
/**
* @return string
*/
public function getLockStatus(): string {
return $this->lockStatus;
}
/**
* @return string
*/
public function getInstance(): string {
return $this->instance;
}
/**
* @return bool
*/
public function isLocal(): bool {
return $this->getManager()->isLocalInstance($this->getInstance());
}
/**
* @param array $data
*
* @return IDeserializable
*/
public function import(array $data): IDeserializable {
$this->setId($this->getInt('id', $data));
$this->setItemId($this->get('itemId', $data));
$this->setCircleId($this->get('circleId', $data));
$this->setInstance($this->get('instance', $data));
return $this;
}
/**
* @param array $data
*
* @return IQueryRow
*/
public function importFromDatabase(array $data): IQueryRow {
$this->setId($this->getInt('id', $data));
$this->setItemId($this->get('item_id', $data));
$this->setCircleId($this->get('circle_id', $data));
$this->setInstance($this->get('instance', $data));
if ($this->getInstance() === '') {
$this->setInstance($this->getManager()->getLocalInstance());
}
return $this;
}
/**
* @return array
*/
public function jsonSerialize(): array {
return [
'id' => $this->getId(),
'itemId' => $this->getItemId(),
'circleId' => $this->getCircleId(),
'instance' => $this->getInstance()
];
}
}
@@ -0,0 +1,562 @@
<?php
declare(strict_types=1);
/**
* Circles - Bring cloud-users closer together.
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2021
* @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 OCA\Circles\Model\Federated;
use OCA\Circles\Tools\Db\IQueryRow;
use OCA\Circles\Tools\Model\NCSignatory;
use OCA\Circles\Tools\Traits\TArrayTools;
use JsonSerializable;
use OCA\Circles\Exceptions\RemoteNotFoundException;
use OCA\Circles\Exceptions\RemoteUidException;
/**
* Class AppService
*
* @package OCA\Circles\Model
*/
class RemoteInstance extends NCSignatory implements IQueryRow, JsonSerializable {
use TArrayTools;
public const TYPE_UNKNOWN = 'Unknown'; // not trusted
public const TYPE_PASSIVE = 'Passive'; // Minimum information about Federated Circles are broadcasted if a member belongs to the circle.
public const TYPE_EXTERNAL = 'External'; // info about Federated Circles and their members are broadcasted if a member belongs to the circle.
public const TYPE_TRUSTED = 'Trusted'; // everything about Federated Circles are broadcasted.
public const TYPE_GLOBALSCALE = 'GlobalScale'; // every Circle is broadcasted,
public static $LIST_TYPE = [
self::TYPE_UNKNOWN,
self::TYPE_PASSIVE,
self::TYPE_EXTERNAL,
self::TYPE_TRUSTED,
self::TYPE_GLOBALSCALE
];
public const ROOT = 'root';
public const TEST = 'test';
public const ALIASES = 'aliases';
public const INCOMING = 'incoming';
public const EVENT = 'event';
public const CIRCLES = 'circles';
public const CIRCLE = 'circle';
public const MEMBERS = 'members';
public const MEMBER = 'member';
public const MEMBERSHIPS = 'memberships';
public const INHERITED = 'inherited';
public const UID = 'uid';
public const AUTH_SIGNED = 'auth-signed';
/** @var int */
private $dbId = 0;
/** @var string */
private $type = self::TYPE_UNKNOWN;
/** @var int */
private $interface = 0;
/** @var string */
private $test = '';
/** @var array */
private $aliases = [];
/** @var string */
private $incoming = '';
/** @var string */
private $root = '';
/** @var string */
private $event = '';
/** @var string */
private $circles = '';
/** @var string */
private $circle = '';
/** @var string */
private $members = '';
/** @var string */
private $member = '';
/** @var string */
private $inherited = '';
/** @var string */
private $memberships = '';
/** @var string */
private $uid = '';
/** @var string */
private $authSigned = '';
/** @var bool */
private $identityAuthed = false;
/**
* @param int $dbId
*
* @return self
*/
public function setDbId(int $dbId): self {
$this->dbId = $dbId;
return $this;
}
/**
* @return int
*/
public function getDbId(): int {
return $this->dbId;
}
/**
* @param string $type
*
* @return $this
*/
public function setType(string $type): self {
$this->type = $type;
return $this;
}
/**
* @return string
*/
public function getType(): string {
return $this->type;
}
/**
* @param int $interface
*
* @return RemoteInstance
*/
public function setInterface(int $interface): self {
$this->interface = $interface;
return $this;
}
/**
* @return int
*/
public function getInterface(): int {
return $this->interface;
}
/**
* @param array $aliases
*
* @return RemoteInstance
*/
public function setAliases(array $aliases): self {
$this->aliases = $aliases;
return $this;
}
/**
* @return array
*/
public function getAliases(): array {
return $this->aliases;
}
/**
* @return string
*/
public function getIncoming(): string {
return $this->incoming;
}
/**
* @param string $incoming
*
* @return self
*/
public function setIncoming(string $incoming): self {
$this->incoming = $incoming;
return $this;
}
/**
* @return string
*/
public function getRoot(): string {
return $this->root;
}
/**
* @param string $root
*
* @return $this
*/
public function setRoot(string $root): self {
$this->root = $root;
return $this;
}
/**
* @return string
*/
public function getEvent(): string {
return $this->event;
}
/**
* @param string $event
*
* @return self
*/
public function setEvent(string $event): self {
$this->event = $event;
return $this;
}
/**
* @param string $test
*
* @return RemoteInstance
*/
public function setTest(string $test): self {
$this->test = $test;
return $this;
}
/**
* @return string
*/
public function getTest(): string {
return $this->test;
}
/**
* @return string
*/
public function getCircles(): string {
return $this->circles;
}
/**
* @param string $circles
*
* @return self
*/
public function setCircles(string $circles): self {
$this->circles = $circles;
return $this;
}
/**
* @return string
*/
public function getCircle(): string {
return $this->circle;
}
/**
* @param string $circle
*
* @return self
*/
public function setCircle(string $circle): self {
$this->circle = $circle;
return $this;
}
/**
* @return string
*/
public function getMembers(): string {
return $this->members;
}
/**
* @param string $members
*
* @return self
*/
public function setMembers(string $members): self {
$this->members = $members;
return $this;
}
/**
* @return string
*/
public function getInherited(): string {
return $this->inherited;
}
/**
* @param string $inherited
*
* @return self
*/
public function setInherited(string $inherited): self {
$this->inherited = $inherited;
return $this;
}
/**
* @return string
*/
public function getMemberships(): string {
return $this->memberships;
}
/**
* @param string $memberships
*
* @return self
*/
public function setMemberships(string $memberships): self {
$this->memberships = $memberships;
return $this;
}
/**
* @return string
*/
public function getMember(): string {
return $this->member;
}
/**
* @param string $member
*
* @return self
*/
public function setMember(string $member): self {
$this->member = $member;
return $this;
}
/**
* @return $this
*/
public function setUidFromKey(): self {
$this->setUid(hash('sha512', $this->getPublicKey()));
return $this;
}
/**
* @param string $uid
*
* @return RemoteInstance
*/
public function setUid(string $uid): self {
$this->uid = $uid;
return $this;
}
/**
* @param bool $shorten
*
* @return string
*/
public function getUid(bool $shorten = false): string {
if ($shorten) {
return substr($this->uid, 0, 18);
}
return $this->uid;
}
/**
* @param string $authSigned
*
* @return RemoteInstance
*/
public function setAuthSigned(string $authSigned): self {
$this->authSigned = $authSigned;
return $this;
}
/**
* @return string
*/
public function getAuthSigned(): string {
return $this->authSigned;
}
/**
* @param bool $identityAuthed
*
* @return RemoteInstance
*/
public function setIdentityAuthed(bool $identityAuthed): self {
$this->identityAuthed = $identityAuthed;
return $this;
}
/**
* @return bool
*/
public function isIdentityAuthed(): bool {
return $this->identityAuthed;
}
/**
* @throws RemoteUidException
*/
public function mustBeIdentityAuthed(): void {
if (!$this->isIdentityAuthed()) {
throw new RemoteUidException('identity not authed');
}
}
/**
* @param array $data
*
* @return NCSignatory
*/
public function import(array $data): NCSignatory {
parent::import($data);
$this->setTest($this->get(self::TEST, $data))
->setAliases($this->getArray(self::ALIASES, $data))
->setEvent($this->get(self::EVENT, $data))
->setRoot($this->get(self::ROOT, $data))
->setIncoming($this->get(self::INCOMING, $data))
->setCircles($this->get(self::CIRCLES, $data))
->setCircle($this->get(self::CIRCLE, $data))
->setMembers($this->get(self::MEMBERS, $data))
->setMember($this->get(self::MEMBER, $data))
->setInherited($this->get(self::INHERITED, $data))
->setMemberships($this->get(self::MEMBERSHIPS, $data))
->setUid($this->get(self::UID, $data));
$algo = '';
$authSigned = trim($this->get(self::AUTH_SIGNED, $data), ':');
if (strpos($authSigned, ':') > 0) {
[$algo, $authSigned] = explode(':', $authSigned);
}
$this->setAuthSigned($authSigned)
->setAlgorithm($algo);
return $this;
}
/**
* @return array
*/
public function jsonSerialize(): array {
$data = [
self::UID => $this->getUid(true),
self::ROOT => $this->getRoot(),
self::EVENT => $this->getEvent(),
self::INCOMING => $this->getIncoming(),
self::TEST => $this->getTest(),
self::CIRCLES => $this->getCircles(),
self::CIRCLE => $this->getCircle(),
self::MEMBERS => $this->getMembers(),
self::MEMBER => $this->getMember(),
self::INHERITED => $this->getInherited(),
self::MEMBERSHIPS => $this->getMemberships()
];
if ($this->getAuthSigned() !== '') {
$data[self::AUTH_SIGNED] = $this->getAlgorithm() . ':' . $this->getAuthSigned();
}
if (!empty($this->getAliases())) {
$data[self::ALIASES] = $this->getAliases();
}
return array_filter(array_merge($data, parent::jsonSerialize()));
}
/**
* @param array $data
* @param string $prefix
*
* @return self
* @throws RemoteNotFoundException
*/
public function importFromDatabase(array $data, string $prefix = ''): IQueryRow {
if ($this->getInt($prefix . 'id', $data) === 0) {
throw new RemoteNotFoundException();
}
$this->setDbId($this->getInt($prefix . 'id', $data));
$this->import($this->getArray($prefix . 'item', $data));
$this->setOrigData($this->getArray($prefix . 'item', $data));
$this->setType($this->get($prefix . 'type', $data));
$this->setInterface($this->getInt($prefix . 'interface', $data));
$this->setInstance($this->get($prefix . 'instance', $data));
$this->setId($this->get($prefix . 'href', $data));
return $this;
}
}