chore: Relocate classes

Signed-off-by: Rubén D <nuxsmin@syspass.org>
This commit is contained in:
Rubén D
2024-04-21 21:09:32 +02:00
parent 5e1f4be413
commit cda692d4de
285 changed files with 1037 additions and 1550 deletions

View File

@@ -1,64 +0,0 @@
<?php
/*
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
* sysPass is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* sysPass 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\DataModel;
use SP\Domain\Common\Models\ItemWithIdAndNameModel;
/**
* Class ActionData
*
* @package SP\DataModel
*/
class Action implements ItemWithIdAndNameModel
{
public function __construct(
private readonly int $id,
private readonly string $name,
private readonly string $text,
private readonly string $route
) {
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function getText(): string
{
return $this->text;
}
public function getRoute(): string
{
return $this->route;
}
}

View File

@@ -1,48 +0,0 @@
<?php
/*
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
* sysPass is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* sysPass 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\DataModel\Dto;
/**
* Class ConfigRequest
*/
class ConfigRequest
{
private array $data = [];
public function add(string $param, string $value): void
{
$this->data[$param] = $value;
}
public function get(string $param): ?string
{
return $this->data[$param] ?? null;
}
public function getData(): array
{
return $this->data;
}
}

View File

@@ -1,113 +0,0 @@
<?php
/*
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
* sysPass is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* sysPass 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\DataModel;
use ReflectionClass;
use SP\Domain\Common\Attributes\Encryptable;
use SP\Domain\Core\Crypt\CryptInterface;
use SP\Domain\Core\Exceptions\CryptException;
/**
* Trait EncryptedModel
*/
trait EncryptedModel
{
protected ?string $key = null;
/**
* Encrypt the encryptable property and returns a new object with the encrypted property and key
*
* @param string $password
* @param CryptInterface $crypt
*
* @return EncryptedModel
* @throws CryptException
*/
public function encrypt(string $password, CryptInterface $crypt): static
{
$reflectionClass = new ReflectionClass($this);
foreach ($reflectionClass->getAttributes(Encryptable::class) as $attribute) {
/** @var Encryptable $instance */
$instance = $attribute->newInstance();
$data = $this->{$instance->getDataProperty()};
if ($data !== null) {
$key = $crypt->makeSecuredKey($password);
return $this->mutate([
$instance->getKeyProperty() => $key,
$instance->getDataProperty() => $crypt->encrypt(
$data,
$key,
$password
)
]);
}
}
return $this;
}
/**
* Decrypt the encryptable property and returns a new object with the decryped property and key
*
* @param string $password
* @param CryptInterface $crypt
*
* @return EncryptedModel
* @throws CryptException
*/
public function decrypt(string $password, CryptInterface $crypt): static
{
$reflectionClass = new ReflectionClass($this);
foreach ($reflectionClass->getAttributes(Encryptable::class) as $attribute) {
/** @var Encryptable $instance */
$instance = $attribute->newInstance();
$data = $this->{$instance->getDataProperty()};
$key = $this->{$instance->getKeyProperty()};
if ($data !== null && $key !== null) {
return $this->mutate([
$instance->getDataProperty() => $crypt->decrypt(
$data,
$key,
$password
)
]);
}
}
return $this;
}
public function getKey(): ?string
{
return $this->key;
}
}

View File

@@ -1,102 +0,0 @@
<?php
/*
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
* sysPass is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* sysPass 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\DataModel;
use SP\Domain\Common\Models\ItemWithIdAndNameModel;
use SP\Domain\Common\Models\Model;
/**
* Class FileData
*
* @package SP\DataModel
*/
class File extends Model implements ItemWithIdAndNameModel
{
protected ?int $id = null;
protected ?int $accountId = null;
protected ?string $name = null;
protected ?string $type = null;
protected ?string $content = null;
protected ?string $extension = null;
protected ?string $thumb = null;
protected ?int $size = null;
public function getId(): ?int
{
return $this->id;
}
public function getAccountId(): ?int
{
return $this->accountId;
}
public function getName(): ?string
{
return $this->name;
}
public function getType(): ?string
{
return $this->type;
}
public function getContent(): ?string
{
return $this->content;
}
public function getExtension(): ?string
{
return $this->extension;
}
public function getThumb(): ?string
{
return $this->thumb;
}
/**
* @param string $thumb
*/
public function setThumb(string $thumb): void
{
$this->thumb = $thumb;
}
public function getSize(): ?int
{
return $this->size;
}
public function getRoundSize(): float
{
if (null === $this->size) {
return 0.0;
}
return round($this->size / 1000, 2);
}
}

View File

@@ -1,46 +0,0 @@
<?php
/*
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
* sysPass is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* sysPass 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\DataModel;
/**
* Class FileExtData
*
* @package SP\DataModel
*/
class FileExtData extends File
{
protected ?string $clientName = null;
protected ?string $accountName = null;
public function getClientName(): ?string
{
return $this->clientName;
}
public function getAccountName(): ?string
{
return $this->accountName;
}
}

View File

@@ -1,49 +0,0 @@
<?php
/*
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
* sysPass is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* sysPass 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\DataModel;
use SP\Domain\Common\Models\ItemWithIdAndNameModel;
use SP\Domain\Common\Models\Model;
/**
* Class ItemData
*
* @package SP\DataModel
*/
class Item extends Model implements ItemWithIdAndNameModel
{
protected ?int $id = null;
protected ?string $name = null;
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
}

View File

@@ -1,58 +0,0 @@
<?php
/*
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
* sysPass is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* sysPass 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\DataModel;
use SP\Util\Filter;
/**
* Class ItemSearchData
*/
class ItemSearchData
{
public function __construct(
private ?string $seachString = null,
private readonly ?int $limitStart = 0,
private readonly ?int $limitCount = 0,
) {
if (!empty($seachString)) {
$this->seachString = Filter::safeSearchString($seachString);
}
}
public function getSeachString(): ?string
{
return $this->seachString;
}
public function getLimitStart(): int
{
return $this->limitStart;
}
public function getLimitCount(): int
{
return $this->limitCount;
}
}

View File

@@ -1,54 +0,0 @@
<?php
/*
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2023, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
* sysPass is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* sysPass 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\DataModel;
use SP\Domain\Account\Models\PublicLink;
/**
* Class PublicLinkListData
*
* @package SP\DataModel
*/
class PublicLinkList extends PublicLink
{
protected ?string $userName = null;
protected ?string $userLogin = null;
protected ?string $accountName = null;
public function getName(): ?string
{
return $this->accountName;
}
public function getUserLogin(): ?string
{
return $this->userLogin;
}
public function getAccountName(): ?string
{
return $this->accountName;
}
}

View File

@@ -1,310 +0,0 @@
<?php
/*
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
* sysPass is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* sysPass 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\DataModel;
/**
* Class PublickLinkOldData
*
* @package SP\DataModel
*/
class PublickLinkOldData
{
/**
* @var int
*/
protected $itemId = 0;
/**
* @var int
*/
protected $userId = 0;
/**
* @var string
*/
protected $linkHash = '';
/**
* @var int
*/
protected $typeId = 0;
/**
* @var bool
*/
protected $notify = false;
/**
* @var int
*/
protected $dateAdd = 0;
/**
* @var int
*/
protected $dateExpire = 0;
/**
* @var string
*/
protected $pass = '';
/**
* @var string
*/
protected $passIV = '';
/**
* @var int
*/
protected $countViews = 0;
/**
* @var int
*/
protected $maxCountViews = 0;
/**
* @var array
*/
protected $useInfo = [];
/**
* @var string
*/
protected $data;
/**
* @return int
*/
public function getItemId()
{
return $this->itemId;
}
/**
* @param int $itemId
*/
public function setItemId($itemId)
{
$this->itemId = $itemId;
}
/**
* @return int
*/
public function getUserId()
{
return $this->userId;
}
/**
* @param int $userId
*/
public function setUserId($userId)
{
$this->userId = $userId;
}
/**
* @return string
*/
public function getLinkHash()
{
return $this->linkHash;
}
/**
* @param string $linkHash
*/
public function setLinkHash($linkHash)
{
$this->linkHash = $linkHash;
}
/**
* @return int
*/
public function getTypeId()
{
return $this->typeId;
}
/**
* @param int $typeId
*/
public function setTypeId($typeId)
{
$this->typeId = $typeId;
}
/**
* @return boolean
*/
public function isNotify()
{
return (bool)$this->notify;
}
/**
* @param boolean $notify
*/
public function setNotify($notify)
{
$this->notify = $notify;
}
/**
* @return int
*/
public function getDateAdd()
{
return $this->dateAdd;
}
/**
* @param int $dateAdd
*/
public function setDateAdd($dateAdd)
{
$this->dateAdd = $dateAdd;
}
/**
* @return int
*/
public function getDateExpire()
{
return $this->dateExpire;
}
/**
* @param int $dateExpire
*/
public function setDateExpire($dateExpire)
{
$this->dateExpire = $dateExpire;
}
/**
* @return string
*/
public function getPass()
{
return $this->pass;
}
/**
* @param string $pass
*/
public function setPass($pass)
{
$this->pass = $pass;
}
/**
* @return string
*/
public function getPassIV()
{
return $this->passIV;
}
/**
* @param string $passIV
*/
public function setPassIV($passIV)
{
$this->passIV = $passIV;
}
/**
* @return int
*/
public function getCountViews()
{
return $this->countViews;
}
/**
* @param int $countViews
*/
public function setCountViews($countViews)
{
$this->countViews = $countViews;
}
/**
* @return int
*/
public function addCountViews()
{
return $this->countViews++;
}
/**
* @return int
*/
public function getMaxCountViews()
{
return $this->maxCountViews;
}
/**
* @param int $maxCountViews
*/
public function setMaxCountViews($maxCountViews)
{
$this->maxCountViews = $maxCountViews;
}
/**
* @return array
*/
public function getUseInfo()
{
return $this->useInfo;
}
/**
* @param array $useInfo
*/
public function setUseInfo(array $useInfo)
{
$this->useInfo = $useInfo;
}
/**
* @param array $useInfo
*/
public function addUseInfo($useInfo)
{
$this->useInfo[] = $useInfo;
}
/**
* @return string
*/
public function getData()
{
return $this->data;
}
/**
* @param string $data
*/
public function setData($data)
{
$this->data = $data;
}
}