fix: psalm issues about override

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
This commit is contained in:
Vitor Mattos 2025-10-06 19:48:45 -03:00 committed by Vitor Mattos
parent 9c093bb1dd
commit 034ff9ecbb
No known key found for this signature in database
GPG key ID: 6FECE2AD4809003A
85 changed files with 192 additions and 0 deletions

View file

@ -28,26 +28,32 @@ class Filter implements IFilter {
$this->url = $url; $this->url = $url;
} }
#[\Override]
public function getIdentifier() { public function getIdentifier() {
return Application::APP_ID; return Application::APP_ID;
} }
#[\Override]
public function getName() { public function getName() {
return 'LibreSign'; return 'LibreSign';
} }
#[\Override]
public function getPriority() { public function getPriority() {
return 31; return 31;
} }
#[\Override]
public function getIcon() { public function getIcon() {
return $this->url->getAbsoluteURL($this->url->imagePath('libresign', 'app-dark.svg')); return $this->url->getAbsoluteURL($this->url->imagePath('libresign', 'app-dark.svg'));
} }
#[\Override]
public function filterTypes(array $types) { public function filterTypes(array $types) {
return array_intersect(self::ALLOWED_TYPES, $types); return array_intersect(self::ALLOWED_TYPES, $types);
} }
#[\Override]
public function allowedApps() { public function allowedApps() {
return [ return [
Application::APP_ID, Application::APP_ID,

View file

@ -41,6 +41,7 @@ class Listener implements IEventListener {
) { ) {
} }
#[\Override]
public function handle(Event $event): void { public function handle(Event $event): void {
/** @var SendSignNotificationEvent|SignedEvent $event */ /** @var SendSignNotificationEvent|SignedEvent $event */
match ($event::class) { match ($event::class) {

View file

@ -28,6 +28,7 @@ class SignRequest implements IProvider {
) { ) {
} }
#[\Override]
public function parse($language, IEvent $event, ?IEvent $previousEvent = null): IEvent { public function parse($language, IEvent $event, ?IEvent $previousEvent = null): IEvent {
if ($event->getApp() !== Application::APP_ID) { if ($event->getApp() !== Application::APP_ID) {
throw new UnknownActivityException('app'); throw new UnknownActivityException('app');

View file

@ -28,6 +28,7 @@ class Signed implements IProvider {
) { ) {
} }
#[\Override]
public function parse($language, IEvent $event, ?IEvent $previousEvent = null): IEvent { public function parse($language, IEvent $event, ?IEvent $previousEvent = null): IEvent {
if ($event->getApp() !== Application::APP_ID) { if ($event->getApp() !== Application::APP_ID) {
throw new UnknownActivityException('app'); throw new UnknownActivityException('app');

View file

@ -26,6 +26,7 @@ class FileSigned extends LibresignActivitySettings {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\Override]
public function getIdentifier(): string { public function getIdentifier(): string {
return SignedEvent::FILE_SIGNED; return SignedEvent::FILE_SIGNED;
} }
@ -33,6 +34,7 @@ class FileSigned extends LibresignActivitySettings {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\Override]
public function getName(): string { public function getName(): string {
return $this->l->t('A document has been <strong>signed</strong>'); return $this->l->t('A document has been <strong>signed</strong>');
} }
@ -40,6 +42,7 @@ class FileSigned extends LibresignActivitySettings {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\Override]
public function getPriority(): int { public function getPriority(): int {
return 52; return 52;
} }
@ -47,6 +50,7 @@ class FileSigned extends LibresignActivitySettings {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\Override]
public function canChangeNotification(): bool { public function canChangeNotification(): bool {
if (!$this->userSession->getUser() instanceof IUser) { if (!$this->userSession->getUser() instanceof IUser) {
return true; return true;
@ -62,6 +66,7 @@ class FileSigned extends LibresignActivitySettings {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\Override]
public function canChangeMail() { public function canChangeMail() {
if (!$this->userSession->getUser() instanceof IUser) { if (!$this->userSession->getUser() instanceof IUser) {
return true; return true;

View file

@ -21,6 +21,7 @@ class FileToSign extends LibresignActivitySettings {
* @return string Lowercase a-z and underscore only identifier. The type of table activity * @return string Lowercase a-z and underscore only identifier. The type of table activity
* @since 20.0.0 * @since 20.0.0
*/ */
#[\Override]
public function getIdentifier(): string { public function getIdentifier(): string {
return SendSignNotificationEvent::FILE_TO_SIGN; return SendSignNotificationEvent::FILE_TO_SIGN;
} }
@ -29,6 +30,7 @@ class FileToSign extends LibresignActivitySettings {
* @return string A translated string * @return string A translated string
* @since 11.0.0 * @since 11.0.0
*/ */
#[\Override]
public function getName(): string { public function getName(): string {
return $this->l->t('You have a <strong>file to sign</strong>'); return $this->l->t('You have a <strong>file to sign</strong>');
} }

View file

@ -15,6 +15,7 @@ abstract class LibresignActivitySettings extends ActivitySettings {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\Override]
public function getGroupIdentifier() { public function getGroupIdentifier() {
return 'libresign'; return 'libresign';
} }
@ -22,6 +23,7 @@ abstract class LibresignActivitySettings extends ActivitySettings {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\Override]
public function getGroupName() { public function getGroupName() {
return 'LibreSign'; return 'LibreSign';
} }
@ -29,30 +31,35 @@ abstract class LibresignActivitySettings extends ActivitySettings {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\Override]
public function getPriority(): int { public function getPriority(): int {
return 51; return 51;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\Override]
public function canChangeNotification(): bool { public function canChangeNotification(): bool {
return true; return true;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\Override]
public function canChangeMail() { public function canChangeMail() {
return true; return true;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\Override]
public function isDefaultEnabledMail() { public function isDefaultEnabledMail() {
return true; return true;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\Override]
public function isDefaultEnabledNotification(): bool { public function isDefaultEnabledNotification(): bool {
return true; return true;
} }

View file

@ -45,6 +45,7 @@ class Application extends App implements IBootstrap {
parent::__construct(self::APP_ID); parent::__construct(self::APP_ID);
} }
#[\Override]
public function boot(IBootContext $context): void { public function boot(IBootContext $context): void {
$server = $context->getServerContainer(); $server = $context->getServerContainer();
@ -54,6 +55,7 @@ class Application extends App implements IBootstrap {
FilesTemplateLoader::register($dispatcher); FilesTemplateLoader::register($dispatcher);
} }
#[\Override]
public function register(IRegistrationContext $context): void { public function register(IRegistrationContext $context): void {
$context->registerMiddleWare(GlobalInjectionMiddleware::class, true); $context->registerMiddleWare(GlobalInjectionMiddleware::class, true);
$context->registerMiddleWare(InjectionMiddleware::class); $context->registerMiddleWare(InjectionMiddleware::class);

View file

@ -28,6 +28,7 @@ class Reminder extends TimedJob {
/** /**
* @inheritDoc * @inheritDoc
*/ */
#[\Override]
public function run($argument): void { public function run($argument): void {
$this->reminderService->sendReminders(); $this->reminderService->sendReminders();
} }

View file

@ -30,6 +30,7 @@ class UserDeleted extends QueuedJob {
/** /**
* @param array $argument * @param array $argument
*/ */
#[\Override]
public function run($argument): void { public function run($argument): void {
if (!isset($argument['user_id'])) { if (!isset($argument['user_id'])) {
return; return;

View file

@ -33,6 +33,7 @@ class Capabilities implements IPublicCapability {
* libresign?: LibresignCapabilities, * libresign?: LibresignCapabilities,
* } * }
*/ */
#[\Override]
public function getCapabilities(): array { public function getCapabilities(): array {
$capabilities = [ $capabilities = [
'features' => self::FEATURES, 'features' => self::FEATURES,

View file

@ -31,6 +31,7 @@ class SignerPlugin implements ISearchPlugin {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\Override]
public function search($search, $limit, $offset, ISearchResult $searchResult): bool { public function search($search, $limit, $offset, ISearchResult $searchResult): bool {
$user = $this->userSession->getUser()->getUID(); $user = $this->userSession->getUser()->getUID();

View file

@ -243,6 +243,7 @@ class AccountFileMapper extends QBMapper {
return $files; return $files;
} }
#[\Override]
public function delete(Entity $entity): Entity { public function delete(Entity $entity): Entity {
$qb = $this->db->getQueryBuilder(); $qb = $this->db->getQueryBuilder();

View file

@ -31,6 +31,7 @@ class PagerFantaQueryAdapter implements AdapterInterface {
} }
} }
#[\Override]
public function getNbResults(): int { public function getNbResults(): int {
$total = $this->countQueryBuilder->executeQuery()->fetchOne(); $total = $this->countQueryBuilder->executeQuery()->fetchOne();
@ -42,6 +43,7 @@ class PagerFantaQueryAdapter implements AdapterInterface {
* *
* @return array * @return array
*/ */
#[\Override]
public function getSlice(int $offset, int $length): iterable { public function getSlice(int $offset, int $length): iterable {
$qb = clone $this->queryBuilder; $qb = clone $this->queryBuilder;

View file

@ -74,6 +74,7 @@ class SignRequestMapper extends QBMapper {
/** /**
* @inheritDoc * @inheritDoc
*/ */
#[\Override]
public function update(Entity $entity): SignRequest { public function update(Entity $entity): SignRequest {
/** @var SignRequest */ /** @var SignRequest */
$signRequest = parent::update($entity); $signRequest = parent::update($entity);

View file

@ -14,6 +14,7 @@ use JsonSerializable;
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
class LibresignException extends \Exception implements JsonSerializable { class LibresignException extends \Exception implements JsonSerializable {
#[\Override]
public function jsonSerialize(): mixed { public function jsonSerialize(): mixed {
return ['message' => $this->getMessage()]; return ['message' => $this->getMessage()];
} }

View file

@ -40,6 +40,7 @@ class TemplateLoader implements IEventListener {
$dispatcher->addServiceListener(LoadSidebar::class, self::class); $dispatcher->addServiceListener(LoadSidebar::class, self::class);
} }
#[\Override]
public function handle(Event $event): void { public function handle(Event $event): void {
if (!($event instanceof LoadSidebar)) { if (!($event instanceof LoadSidebar)) {
return; return;

View file

@ -104,6 +104,7 @@ abstract class AEngineHandler implements IEngineHandler {
return $certContent; return $certContent;
} }
#[\Override]
public function updatePassword(string $certificate, string $currentPrivateKey, string $newPrivateKey): string { public function updatePassword(string $certificate, string $currentPrivateKey, string $newPrivateKey): string {
if (empty($certificate) || empty($currentPrivateKey) || empty($newPrivateKey)) { if (empty($certificate) || empty($currentPrivateKey) || empty($newPrivateKey)) {
throw new EmptyCertificateException(); throw new EmptyCertificateException();
@ -114,6 +115,7 @@ abstract class AEngineHandler implements IEngineHandler {
return $certContent; return $certContent;
} }
#[\Override]
public function readCertificate(string $certificate, string $privateKey): array { public function readCertificate(string $certificate, string $privateKey): array {
if (empty($certificate) || empty($privateKey)) { if (empty($certificate) || empty($privateKey)) {
throw new EmptyCertificateException(); throw new EmptyCertificateException();
@ -208,6 +210,7 @@ abstract class AEngineHandler implements IEngineHandler {
$this->engine = $engine; $this->engine = $engine;
} }
#[\Override]
public function getEngine(): string { public function getEngine(): string {
if ($this->engine) { if ($this->engine) {
return $this->engine; return $this->engine;
@ -216,6 +219,7 @@ abstract class AEngineHandler implements IEngineHandler {
return $this->engine; return $this->engine;
} }
#[\Override]
public function populateInstance(array $rootCert): IEngineHandler { public function populateInstance(array $rootCert): IEngineHandler {
if (empty($rootCert)) { if (empty($rootCert)) {
$rootCert = $this->appConfig->getValueArray(Application::APP_ID, 'rootCert'); $rootCert = $this->appConfig->getValueArray(Application::APP_ID, 'rootCert');
@ -280,6 +284,7 @@ abstract class AEngineHandler implements IEngineHandler {
return $path; return $path;
} }
#[\Override]
public function setConfigPath(string $configPath): IEngineHandler { public function setConfigPath(string $configPath): IEngineHandler {
if (!$configPath) { if (!$configPath) {
$this->appConfig->deleteKey(Application::APP_ID, 'config_path'); $this->appConfig->deleteKey(Application::APP_ID, 'config_path');
@ -322,6 +327,7 @@ abstract class AEngineHandler implements IEngineHandler {
return str_replace(' ', '+', $this->UID); return str_replace(' ', '+', $this->UID);
} }
#[\Override]
public function expirity(): int { public function expirity(): int {
$expirity = $this->appConfig->getValueInt(Application::APP_ID, 'expiry_in_days', 365); $expirity = $this->appConfig->getValueInt(Application::APP_ID, 'expiry_in_days', 365);
if ($expirity < 0) { if ($expirity < 0) {
@ -330,10 +336,12 @@ abstract class AEngineHandler implements IEngineHandler {
return $expirity; return $expirity;
} }
#[\Override]
public function isSetupOk(): bool { public function isSetupOk(): bool {
return strlen($this->appConfig->getValueString(Application::APP_ID, 'authkey', '')) > 0; return strlen($this->appConfig->getValueString(Application::APP_ID, 'authkey', '')) > 0;
} }
#[\Override]
public function configureCheck(): array { public function configureCheck(): array {
throw new \Exception('Necessary to implement configureCheck method'); throw new \Exception('Necessary to implement configureCheck method');
} }
@ -351,6 +359,7 @@ abstract class AEngineHandler implements IEngineHandler {
return $return; return $return;
} }
#[\Override]
public function toArray(): array { public function toArray(): array {
$return = [ $return = [
'configPath' => $this->getConfigPath(), 'configPath' => $this->getConfigPath(),

View file

@ -54,6 +54,7 @@ class CfsslHandler extends AEngineHandler implements IEngineHandler {
$this->cfsslServerHandler->configCallback(fn () => $this->getConfigPath()); $this->cfsslServerHandler->configCallback(fn () => $this->getConfigPath());
} }
#[\Override]
public function generateRootCert( public function generateRootCert(
string $commonName, string $commonName,
array $names = [], array $names = [],
@ -81,6 +82,7 @@ class CfsslHandler extends AEngineHandler implements IEngineHandler {
return $key; return $key;
} }
#[\Override]
public function generateCertificate(): string { public function generateCertificate(): string {
$certKeys = $this->newCert(); $certKeys = $this->newCert();
return parent::exportToPkcs12( return parent::exportToPkcs12(
@ -96,6 +98,7 @@ class CfsslHandler extends AEngineHandler implements IEngineHandler {
); );
} }
#[\Override]
public function isSetupOk(): bool { public function isSetupOk(): bool {
if (!parent::isSetupOk()) { if (!parent::isSetupOk()) {
return false; return false;
@ -114,6 +117,7 @@ class CfsslHandler extends AEngineHandler implements IEngineHandler {
return false; return false;
} }
#[\Override]
public function configureCheck(): array { public function configureCheck(): array {
$return = $this->checkBinaries(); $return = $this->checkBinaries();
$configPath = $this->getConfigPath(); $configPath = $this->getConfigPath();
@ -134,6 +138,7 @@ class CfsslHandler extends AEngineHandler implements IEngineHandler {
); );
} }
#[\Override]
public function toArray(): array { public function toArray(): array {
$return = parent::toArray(); $return = parent::toArray();
if (!empty($return['configPath'])) { if (!empty($return['configPath'])) {

View file

@ -9,6 +9,7 @@ declare(strict_types=1);
namespace OCA\Libresign\Handler\CertificateEngine; namespace OCA\Libresign\Handler\CertificateEngine;
class NoneHandler extends AEngineHandler implements IEngineHandler { class NoneHandler extends AEngineHandler implements IEngineHandler {
#[\Override]
public function generateRootCert( public function generateRootCert(
string $commonName, string $commonName,
array $names = [], array $names = [],
@ -16,14 +17,17 @@ class NoneHandler extends AEngineHandler implements IEngineHandler {
return ''; return '';
} }
#[\Override]
public function generateCertificate(string $certificate = '', string $privateKey = ''): string { public function generateCertificate(string $certificate = '', string $privateKey = ''): string {
return ''; return '';
} }
#[\Override]
public function isSetupOk(): bool { public function isSetupOk(): bool {
return true; return true;
} }
#[\Override]
public function configureCheck(): array { public function configureCheck(): array {
return []; return [];
} }

View file

@ -36,6 +36,7 @@ class OpenSslHandler extends AEngineHandler implements IEngineHandler {
parent::__construct($config, $appConfig, $appDataFactory, $dateTimeFormatter, $tempManager, $certificatePolicyService); parent::__construct($config, $appConfig, $appDataFactory, $dateTimeFormatter, $tempManager, $certificatePolicyService);
} }
#[\Override]
public function generateRootCert( public function generateRootCert(
string $commonName, string $commonName,
array $names = [], array $names = [],
@ -73,6 +74,7 @@ class OpenSslHandler extends AEngineHandler implements IEngineHandler {
return $options; return $options;
} }
#[\Override]
public function generateCertificate(): string { public function generateCertificate(): string {
$configPath = $this->getConfigPath(); $configPath = $this->getConfigPath();
$rootCertificate = file_get_contents($configPath . DIRECTORY_SEPARATOR . 'ca.pem'); $rootCertificate = file_get_contents($configPath . DIRECTORY_SEPARATOR . 'ca.pem');
@ -207,6 +209,7 @@ class OpenSslHandler extends AEngineHandler implements IEngineHandler {
return $distinguishedNames; return $distinguishedNames;
} }
#[\Override]
public function isSetupOk(): bool { public function isSetupOk(): bool {
$ok = parent::isSetupOk(); $ok = parent::isSetupOk();
if (!$ok) { if (!$ok) {
@ -218,6 +221,7 @@ class OpenSslHandler extends AEngineHandler implements IEngineHandler {
return $certificate && $privateKey; return $certificate && $privateKey;
} }
#[\Override]
public function configureCheck(): array { public function configureCheck(): array {
if ($this->isSetupOk()) { if ($this->isSetupOk()) {
return [(new ConfigureCheckHelper()) return [(new ConfigureCheckHelper())

View file

@ -147,12 +147,14 @@ class JSignPdfHandler extends Pkcs12Handler {
return 'SHA256'; return 'SHA256';
} }
#[\Override]
public function sign(): File { public function sign(): File {
$signedContent = $this->getSignedContent(); $signedContent = $this->getSignedContent();
$this->getInputFile()->putContent($signedContent); $this->getInputFile()->putContent($signedContent);
return $this->getInputFile(); return $this->getInputFile();
} }
#[\Override]
public function getSignedContent(): string { public function getSignedContent(): string {
$param = $this->getJSignParam() $param = $this->getJSignParam()
->setCertificate($this->getCertificate()) ->setCertificate($this->getCertificate())
@ -278,6 +280,7 @@ class JSignPdfHandler extends Pkcs12Handler {
} }
#[\Override]
public function readCertificate(): array { public function readCertificate(): array {
return $this->certificateEngineFactory return $this->certificateEngineFactory
->getEngine() ->getEngine()

View file

@ -83,6 +83,7 @@ class Pkcs12Handler extends SignEngineHandler {
* @throws LibresignException When is not a signed file * @throws LibresignException When is not a signed file
* @return array * @return array
*/ */
#[\Override]
public function getCertificateChain($resource): array { public function getCertificateChain($resource): array {
$signerCounter = 0; $signerCounter = 0;
$certificates = []; $certificates = [];
@ -317,6 +318,7 @@ class Pkcs12Handler extends SignEngineHandler {
return $this->$property; return $this->$property;
} }
#[\Override]
public function sign(): File { public function sign(): File {
$signedContent = $this->getHandler() $signedContent = $this->getHandler()
->setCertificate($this->getCertificate()) ->setCertificate($this->getCertificate())

View file

@ -12,6 +12,7 @@ use DateTime;
use OCP\Files\File; use OCP\Files\File;
class Pkcs7Handler extends SignEngineHandler { class Pkcs7Handler extends SignEngineHandler {
#[\Override]
public function sign(): File { public function sign(): File {
$p7sFile = $this->getP7sFile(); $p7sFile = $this->getP7sFile();
openssl_pkcs12_read($this->getCertificate(), $certificateData, $this->getPassword()); openssl_pkcs12_read($this->getCertificate(), $certificateData, $this->getPassword());
@ -37,6 +38,7 @@ class Pkcs7Handler extends SignEngineHandler {
/** /**
* @todo Replace this method by a real implementation that retrieves the certificate chain and not just the file's last modified time. * @todo Replace this method by a real implementation that retrieves the certificate chain and not just the file's last modified time.
*/ */
#[\Override]
public function getCertificateChain($resource): array { public function getCertificateChain($resource): array {
$metadata = stream_get_meta_data($resource); $metadata = stream_get_meta_data($resource);
$lastModifiedTime = filemtime($metadata['uri']); $lastModifiedTime = filemtime($metadata['uri']);

View file

@ -43,24 +43,29 @@ abstract class SignEngineHandler implements ISignEngineHandler {
/** /**
* @return static * @return static
*/ */
#[\Override]
public function setInputFile(File $inputFile): self { public function setInputFile(File $inputFile): self {
$this->inputFile = $inputFile; $this->inputFile = $inputFile;
return $this; return $this;
} }
#[\Override]
public function getInputFile(): File { public function getInputFile(): File {
return $this->inputFile; return $this->inputFile;
} }
#[\Override]
public function setCertificate(string $certificate): self { public function setCertificate(string $certificate): self {
$this->certificate = $certificate; $this->certificate = $certificate;
return $this; return $this;
} }
#[\Override]
public function getCertificate(): string { public function getCertificate(): string {
return $this->certificate; return $this->certificate;
} }
#[\Override]
public function readCertificate(): array { public function readCertificate(): array {
return $this->getCertificateEngine() return $this->getCertificateEngine()
->readCertificate( ->readCertificate(
@ -69,11 +74,13 @@ abstract class SignEngineHandler implements ISignEngineHandler {
); );
} }
#[\Override]
public function setPassword(string $password): self { public function setPassword(string $password): self {
$this->password = $password; $this->password = $password;
return $this; return $this;
} }
#[\Override]
public function getPassword(): string { public function getPassword(): string {
return $this->password; return $this->password;
} }
@ -97,14 +104,17 @@ abstract class SignEngineHandler implements ISignEngineHandler {
return $this->visibleElements; return $this->visibleElements;
} }
#[\Override]
public function getSignedContent(): string { public function getSignedContent(): string {
return $this->sign()->getContent(); return $this->sign()->getContent();
} }
#[\Override]
public function getSignatureParams(): array { public function getSignatureParams(): array {
return $this->signatureParams; return $this->signatureParams;
} }
#[\Override]
public function setSignatureParams(array $params): self { public function setSignatureParams(array $params): self {
$this->signatureParams = $params; $this->signatureParams = $params;
return $this; return $this;
@ -205,6 +215,7 @@ abstract class SignEngineHandler implements ISignEngineHandler {
return $this->savePfx($uid, $content); return $this->savePfx($uid, $content);
} }
#[\Override]
public function getLastSignedDate(): \DateTime { public function getLastSignedDate(): \DateTime {
$stream = $this->getFileStream(); $stream = $this->getFileStream();

View file

@ -52,6 +52,7 @@ class ConfigureCheckHelper implements JsonSerializable {
return $this; return $this;
} }
#[\Override]
public function jsonSerialize(): array { public function jsonSerialize(): array {
return [ return [
'status' => $this->getStatus(), 'status' => $this->getStatus(),

View file

@ -30,6 +30,7 @@ class BeforeNodeDeletedListener implements IEventListener {
) { ) {
} }
#[\Override]
public function handle(Event $event): void { public function handle(Event $event): void {
if ($event instanceof BeforeNodeDeletedEvent) { if ($event instanceof BeforeNodeDeletedEvent) {
$node = $event->getNode(); $node = $event->getNode();

View file

@ -25,6 +25,7 @@ class LoadAdditionalListener implements IEventListener {
private CertificateEngineFactory $certificateEngineFactory, private CertificateEngineFactory $certificateEngineFactory,
) { ) {
} }
#[\Override]
public function handle(Event $event): void { public function handle(Event $event): void {
if (!($event instanceof LoadAdditionalScriptsEvent)) { if (!($event instanceof LoadAdditionalScriptsEvent)) {
return; return;

View file

@ -23,6 +23,7 @@ class LoadSidebarListener implements IEventListener {
private IAppManager $appManager, private IAppManager $appManager,
) { ) {
} }
#[\Override]
public function handle(Event $event): void { public function handle(Event $event): void {
if (!($event instanceof LoadSidebar)) { if (!($event instanceof LoadSidebar)) {
return; return;

View file

@ -35,6 +35,7 @@ class MailNotifyListener implements IEventListener {
) { ) {
} }
#[\Override]
public function handle(Event $event): void { public function handle(Event $event): void {
/** @var SendSignNotificationEvent|SignedEvent $event */ /** @var SendSignNotificationEvent|SignedEvent $event */
match ($event::class) { match ($event::class) {

View file

@ -36,6 +36,7 @@ class NotificationListener implements IEventListener {
) { ) {
} }
#[\Override]
public function handle(Event $event): void { public function handle(Event $event): void {
if ($event instanceof SendSignNotificationEvent) { if ($event instanceof SendSignNotificationEvent) {
$this->sendSignNotification( $this->sendSignNotification(

View file

@ -20,6 +20,7 @@ class SignedCallbackListener implements IEventListener {
) { ) {
} }
#[\Override]
public function handle(Event $event): void { public function handle(Event $event): void {
/** @var SignedEvent */ /** @var SignedEvent */
if (!($event instanceof SignedEvent)) { if (!($event instanceof SignedEvent)) {

View file

@ -41,6 +41,7 @@ class TwofactorGatewayListener implements IEventListener {
) { ) {
} }
#[\Override]
public function handle(Event $event): void { public function handle(Event $event): void {
/** @var SendSignNotificationEvent|SignedEvent $event */ /** @var SendSignNotificationEvent|SignedEvent $event */
match ($event::class) { match ($event::class) {

View file

@ -21,6 +21,7 @@ class UserDeletedListener implements IEventListener {
) { ) {
} }
#[\Override]
public function handle(Event $event): void { public function handle(Event $event): void {
if (!($event instanceof UserDeletedEvent)) { if (!($event instanceof UserDeletedEvent)) {
return; return;

View file

@ -15,6 +15,7 @@ use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Middleware; use OCP\AppFramework\Middleware;
class GlobalInjectionMiddleware extends Middleware { class GlobalInjectionMiddleware extends Middleware {
#[\Override]
public function afterController(Controller $controller, string $methodName, Response $response) { public function afterController(Controller $controller, string $methodName, Response $response) {
if ($controller instanceof ViewController) { if ($controller instanceof ViewController) {
$policy = new ContentSecurityPolicy(); $policy = new ContentSecurityPolicy();

View file

@ -69,6 +69,7 @@ class InjectionMiddleware extends Middleware {
* @param string $methodName * @param string $methodName
* @throws \Exception * @throws \Exception
*/ */
#[\Override]
public function beforeController(Controller $controller, string $methodName) { public function beforeController(Controller $controller, string $methodName) {
if ($controller instanceof AEnvironmentAwareController) { if ($controller instanceof AEnvironmentAwareController) {
$apiVersion = $this->request->getParam('apiVersion'); $apiVersion = $this->request->getParam('apiVersion');
@ -198,6 +199,7 @@ class InjectionMiddleware extends Middleware {
* @throws \Exception * @throws \Exception
* @return Response * @return Response
*/ */
#[\Override]
public function afterException($controller, $methodName, \Exception $exception): Response { public function afterException($controller, $methodName, \Exception $exception): Response {
if (str_contains($this->request->getHeader('Accept'), 'html')) { if (str_contains($this->request->getHeader('Accept'), 'html')) {
$template = 'external'; $template = 'external';

View file

@ -55,10 +55,12 @@ class DeleteOldBinaries implements IRepairStep {
$this->appData = $appDataFactory->get('libresign'); $this->appData = $appDataFactory->get('libresign');
} }
#[\Override]
public function getName(): string { public function getName(): string {
return 'Delete old binaries'; return 'Delete old binaries';
} }
#[\Override]
public function run(IOutput $output): void { public function run(IOutput $output): void {
$this->scan(); $this->scan();
$this->output = $output; $this->output = $output;

View file

@ -24,10 +24,12 @@ class ResynchronizeDatabaseSequences implements IRepairStep {
) { ) {
} }
#[\Override]
public function getName(): string { public function getName(): string {
return 'Resynchronize database sequences'; return 'Resynchronize database sequences';
} }
#[\Override]
public function run(IOutput $output): void { public function run(IOutput $output): void {
if ($this->connection->getDatabasePlatform() instanceof PostgreSQLPlatform) { if ($this->connection->getDatabasePlatform() instanceof PostgreSQLPlatform) {
$tools = new \OC\DB\PgSqlTools($this->config); $tools = new \OC\DB\PgSqlTools($this->config);

View file

@ -21,6 +21,7 @@ class Version10000Date20240625141149 extends SimpleMigrationStep {
* @param array $options * @param array $options
* @return null|ISchemaWrapper * @return null|ISchemaWrapper
*/ */
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */ /** @var ISchemaWrapper $schema */
$schema = $schemaClosure(); $schema = $schemaClosure();

View file

@ -21,6 +21,7 @@ class Version1000Date20210209004203 extends SimpleMigrationStep {
* @param array $options * @param array $options
* @return ISchemaWrapper * @return ISchemaWrapper
*/ */
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper {
$schema = $schemaClosure(); $schema = $schemaClosure();
$table = $schema->createTable('libresign_file'); $table = $schema->createTable('libresign_file');

View file

@ -21,6 +21,7 @@ class Version1000Date20210209011129 extends SimpleMigrationStep {
* @param array $options * @param array $options
* @return ISchemaWrapper * @return ISchemaWrapper
*/ */
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper {
$schema = $schemaClosure(); $schema = $schemaClosure();
$table = $schema->createTable('libresign_file_user'); $table = $schema->createTable('libresign_file_user');

View file

@ -27,6 +27,7 @@ class Version1000Date20210502200600 extends SimpleMigrationStep {
$this->connection = $connection; $this->connection = $connection;
} }
#[\Override]
public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void { public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void {
$query = $this->connection->getQueryBuilder(); $query = $this->connection->getQueryBuilder();
$query->select('id', 'file_id') $query->select('id', 'file_id')
@ -41,6 +42,7 @@ class Version1000Date20210502200600 extends SimpleMigrationStep {
* *
* @return ISchemaWrapper * @return ISchemaWrapper
*/ */
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper {
/** @var ISchemaWrapper $schema */ /** @var ISchemaWrapper $schema */
$schema = $schemaClosure(); $schema = $schemaClosure();
@ -57,6 +59,7 @@ class Version1000Date20210502200600 extends SimpleMigrationStep {
return $schema; return $schema;
} }
#[\Override]
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void { public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void {
foreach ($this->rows as $row) { foreach ($this->rows as $row) {
$query = $this->connection->getQueryBuilder(); $query = $this->connection->getQueryBuilder();

View file

@ -24,6 +24,7 @@ class Version1000Date20210502200800 extends SimpleMigrationStep {
$this->connection = $connection; $this->connection = $connection;
} }
#[\Override]
public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void { public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void {
$query = $this->connection->getQueryBuilder(); $query = $this->connection->getQueryBuilder();
$query->select('id', 'file_id2') $query->select('id', 'file_id2')
@ -38,6 +39,7 @@ class Version1000Date20210502200800 extends SimpleMigrationStep {
* *
* @return ISchemaWrapper * @return ISchemaWrapper
*/ */
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper {
/** @var ISchemaWrapper $schema */ /** @var ISchemaWrapper $schema */
$schema = $schemaClosure(); $schema = $schemaClosure();
@ -54,6 +56,7 @@ class Version1000Date20210502200800 extends SimpleMigrationStep {
return $schema; return $schema;
} }
#[\Override]
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void { public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void {
foreach ($this->rows as $row) { foreach ($this->rows as $row) {
$query = $this->connection->getQueryBuilder(); $query = $this->connection->getQueryBuilder();

View file

@ -31,6 +31,7 @@ class Version11000Date20250103005204 extends SimpleMigrationStep {
* @param array $options * @param array $options
* @return null|ISchemaWrapper * @return null|ISchemaWrapper
*/ */
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper */ /** @var ISchemaWrapper */
$schema = $schemaClosure(); $schema = $schemaClosure();

View file

@ -32,6 +32,7 @@ class Version11000Date20250114182030 extends SimpleMigrationStep {
* @param Closure(): ISchemaWrapper $schemaClosure * @param Closure(): ISchemaWrapper $schemaClosure
* @param array $options * @param array $options
*/ */
#[\Override]
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
// BACKUP BEGIN // BACKUP BEGIN
$qb1 = $this->connection->getQueryBuilder(); $qb1 = $this->connection->getQueryBuilder();

View file

@ -32,6 +32,7 @@ class Version12000Date20250325143340 extends SimpleMigrationStep {
* @param Closure(): ISchemaWrapper $schemaClosure * @param Closure(): ISchemaWrapper $schemaClosure
* @param array $options * @param array $options
*/ */
#[\Override]
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
$query = $this->connection->getQueryBuilder(); $query = $this->connection->getQueryBuilder();
$query->select('id') $query->select('id')
@ -71,6 +72,7 @@ class Version12000Date20250325143340 extends SimpleMigrationStep {
* @param array $options * @param array $options
* @return null|ISchemaWrapper * @return null|ISchemaWrapper
*/ */
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */ /** @var ISchemaWrapper $schema */
$schema = $schemaClosure(); $schema = $schemaClosure();

View file

@ -38,6 +38,7 @@ class Version12000Date20250325155910 extends SimpleMigrationStep {
* @param array $options * @param array $options
* @return null|ISchemaWrapper * @return null|ISchemaWrapper
*/ */
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */ /** @var ISchemaWrapper $schema */
$schema = $schemaClosure(); $schema = $schemaClosure();
@ -67,6 +68,7 @@ class Version12000Date20250325155910 extends SimpleMigrationStep {
* @param Closure(): ISchemaWrapper $schemaClosure * @param Closure(): ISchemaWrapper $schemaClosure
* @param array $options * @param array $options
*/ */
#[\Override]
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
$this->updateFile(); $this->updateFile();
$this->updateSignRequest(); $this->updateSignRequest();

View file

@ -21,6 +21,7 @@ class Version12000Date20250325174734 extends SimpleMigrationStep {
* @param array $options * @param array $options
* @return null|ISchemaWrapper * @return null|ISchemaWrapper
*/ */
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */ /** @var ISchemaWrapper $schema */
$schema = $schemaClosure(); $schema = $schemaClosure();

View file

@ -27,6 +27,7 @@ class Version12000Date20250517134200 extends SimpleMigrationStep {
* @param Closure(): ISchemaWrapper $schemaClosure * @param Closure(): ISchemaWrapper $schemaClosure
* @param array $options * @param array $options
*/ */
#[\Override]
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
$keys = $this->config->getAppKeys(Application::APP_ID); $keys = $this->config->getAppKeys(Application::APP_ID);
if (in_array('notify_unsigned_user', $keys)) { if (in_array('notify_unsigned_user', $keys)) {

View file

@ -24,6 +24,7 @@ class Version2040Date20210619135352 extends SimpleMigrationStep {
* @param array $options * @param array $options
* @return ISchemaWrapper * @return ISchemaWrapper
*/ */
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper {
$schema = $schemaClosure(); $schema = $schemaClosure();
$table = $schema->createTable('libresign_file_type'); $table = $schema->createTable('libresign_file_type');

View file

@ -25,6 +25,7 @@ class Version2040Date20210730022217 extends SimpleMigrationStep {
* *
* @return ISchemaWrapper * @return ISchemaWrapper
*/ */
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper {
/** @var ISchemaWrapper $schema */ /** @var ISchemaWrapper $schema */
$schema = $schemaClosure(); $schema = $schemaClosure();

View file

@ -25,6 +25,7 @@ class Version2040Date20211010194532 extends SimpleMigrationStep {
* *
* @return ISchemaWrapper * @return ISchemaWrapper
*/ */
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper {
/** @var ISchemaWrapper $schema */ /** @var ISchemaWrapper $schema */
$schema = $schemaClosure(); $schema = $schemaClosure();

View file

@ -25,6 +25,7 @@ class Version2040Date20211010200549 extends SimpleMigrationStep {
* *
* @return ISchemaWrapper * @return ISchemaWrapper
*/ */
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper {
/** @var ISchemaWrapper $schema */ /** @var ISchemaWrapper $schema */
$schema = $schemaClosure(); $schema = $schemaClosure();

View file

@ -28,6 +28,7 @@ class Version2040Date20211027183759 extends SimpleMigrationStep {
) { ) {
} }
#[\Override]
public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void { public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void {
$query = $this->connection->getQueryBuilder(); $query = $this->connection->getQueryBuilder();
$query->select('id', 'node_id', 'user_id') $query->select('id', 'node_id', 'user_id')
@ -42,6 +43,7 @@ class Version2040Date20211027183759 extends SimpleMigrationStep {
* *
* @return ISchemaWrapper * @return ISchemaWrapper
*/ */
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper {
/** @var ISchemaWrapper $schema */ /** @var ISchemaWrapper $schema */
$schema = $schemaClosure(); $schema = $schemaClosure();
@ -56,6 +58,7 @@ class Version2040Date20211027183759 extends SimpleMigrationStep {
return $schema; return $schema;
} }
#[\Override]
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void { public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void {
foreach ($this->rows as $row) { foreach ($this->rows as $row) {
$userFolder = $this->root->getUserFolder($row['user_id']); $userFolder = $this->root->getUserFolder($row['user_id']);

View file

@ -23,6 +23,7 @@ class Version2040Date20211030204227 extends SimpleMigrationStep {
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options * @param array $options
*/ */
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper {
$schema = $schemaClosure(); $schema = $schemaClosure();
/** @var Table */ /** @var Table */

View file

@ -20,6 +20,7 @@ class Version2040Date20220317150846 extends SimpleMigrationStep {
* @param array $options * @param array $options
* @return null|ISchemaWrapper * @return null|ISchemaWrapper
*/ */
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper */ /** @var ISchemaWrapper */
$schema = $schemaClosure(); $schema = $schemaClosure();

View file

@ -19,6 +19,7 @@ class Version7000Date20221026003343 extends SimpleMigrationStep {
) { ) {
} }
#[\Override]
public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void { public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void {
$rootCert = []; $rootCert = [];
if ($commonName = $this->appConfig->getValueString(Application::APP_ID, 'commonName')) { if ($commonName = $this->appConfig->getValueString(Application::APP_ID, 'commonName')) {

View file

@ -26,6 +26,7 @@ class Version7000Date20221028022904 extends SimpleMigrationStep {
* This migration is to convert from the exposed format to this format: * This migration is to convert from the exposed format to this format:
* {"commonName":"Test Company","names":[{"id":"C","value":"BR"},{"id":"O","value":"Organization"},{"id":"OU","value":"Organization Unit"}]} * {"commonName":"Test Company","names":[{"id":"C","value":"BR"},{"id":"O","value":"Organization"},{"id":"OU","value":"Organization Unit"}]}
*/ */
#[\Override]
public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void { public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void {
$rootCert = $this->appConfig->getValueString(Application::APP_ID, 'rootCert'); $rootCert = $this->appConfig->getValueString(Application::APP_ID, 'rootCert');
$rootCert = json_decode($rootCert, true); $rootCert = json_decode($rootCert, true);

View file

@ -21,6 +21,7 @@ class Version7000Date20230225154558 extends SimpleMigrationStep {
* @param array $options * @param array $options
* @return null|ISchemaWrapper * @return null|ISchemaWrapper
*/ */
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper */ /** @var ISchemaWrapper */
$schema = $schemaClosure(); $schema = $schemaClosure();

View file

@ -27,6 +27,7 @@ class Version7000Date20230327094452 extends SimpleMigrationStep {
* *
* {"commonName":"Test Company","names":{"C":"BR","O":"Organization","OU":"Organization Unit"}} * {"commonName":"Test Company","names":{"C":"BR","O":"Organization","OU":"Organization Unit"}}
*/ */
#[\Override]
public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void { public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void {
$rootCert = $this->appConfig->getValueString(Application::APP_ID, 'rootCert'); $rootCert = $this->appConfig->getValueString(Application::APP_ID, 'rootCert');
$rootCert = json_decode($rootCert, true); $rootCert = json_decode($rootCert, true);

View file

@ -21,6 +21,7 @@ class Version8000Date20230402103824 extends SimpleMigrationStep {
* @param array $options * @param array $options
* @return null|ISchemaWrapper * @return null|ISchemaWrapper
*/ */
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper */ /** @var ISchemaWrapper */
$schema = $schemaClosure(); $schema = $schemaClosure();

View file

@ -26,6 +26,7 @@ class Version8000Date20230410230327 extends SimpleMigrationStep {
$this->appData = $appDataFactory->get('libresign'); $this->appData = $appDataFactory->get('libresign');
} }
#[\Override]
public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void { public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void {
$libresignCliPath = $this->appConfig->getValueString(Application::APP_ID, 'libresign_cli_path'); $libresignCliPath = $this->appConfig->getValueString(Application::APP_ID, 'libresign_cli_path');
if (!$libresignCliPath) { if (!$libresignCliPath) {

View file

@ -30,6 +30,7 @@ class Version8000Date20230420125331 extends SimpleMigrationStep {
* @param array $options * @param array $options
* @return null|ISchemaWrapper * @return null|ISchemaWrapper
*/ */
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper */ /** @var ISchemaWrapper */
$schema = $schemaClosure(); $schema = $schemaClosure();
@ -89,6 +90,7 @@ class Version8000Date20230420125331 extends SimpleMigrationStep {
return $schema; return $schema;
} }
#[\Override]
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void { public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void {
$query = $this->connection->getQueryBuilder(); $query = $this->connection->getQueryBuilder();
$query->select('*') $query->select('*')

View file

@ -20,6 +20,7 @@ class Version8000Date20230422191425 extends SimpleMigrationStep {
* @param array $options * @param array $options
* @return null|ISchemaWrapper * @return null|ISchemaWrapper
*/ */
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper */ /** @var ISchemaWrapper */
$schema = $schemaClosure(); $schema = $schemaClosure();

View file

@ -20,6 +20,7 @@ class Version8000Date20230608004729 extends SimpleMigrationStep {
) { ) {
} }
#[\Override]
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
$cfsslBin = $this->appConfig->getValueString(Application::APP_ID, 'cfssl_bin'); $cfsslBin = $this->appConfig->getValueString(Application::APP_ID, 'cfssl_bin');
$cfsslUrl = $this->appConfig->getValueString(Application::APP_ID, 'cfssl_url'); $cfsslUrl = $this->appConfig->getValueString(Application::APP_ID, 'cfssl_url');

View file

@ -22,6 +22,7 @@ class Version8000Date20230730032402 extends SimpleMigrationStep {
) { ) {
} }
#[\Override]
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
$this->installService->installPdftk(); $this->installService->installPdftk();
if ($rootCert = $this->appConfig->getValueArray(Application::APP_ID, 'rootCert')) { if ($rootCert = $this->appConfig->getValueArray(Application::APP_ID, 'rootCert')) {

View file

@ -30,6 +30,7 @@ class Version8000Date20231102215331 extends SimpleMigrationStep {
* @param array $options * @param array $options
* @return null|ISchemaWrapper * @return null|ISchemaWrapper
*/ */
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper */ /** @var ISchemaWrapper */
$schema = $schemaClosure(); $schema = $schemaClosure();
@ -111,6 +112,7 @@ class Version8000Date20231102215331 extends SimpleMigrationStep {
* @param Closure(): ISchemaWrapper $schemaClosure * @param Closure(): ISchemaWrapper $schemaClosure
* @param array $options * @param array $options
*/ */
#[\Override]
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
$qbFetch = $this->connection->getQueryBuilder(); $qbFetch = $this->connection->getQueryBuilder();
$qbRestore = $this->connection->getQueryBuilder(); $qbRestore = $this->connection->getQueryBuilder();

View file

@ -27,6 +27,7 @@ class Version8000Date20231103003922 extends SimpleMigrationStep {
* @param array $options * @param array $options
* @return null|ISchemaWrapper * @return null|ISchemaWrapper
*/ */
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */ /** @var ISchemaWrapper $schema */
$schema = $schemaClosure(); $schema = $schemaClosure();

View file

@ -38,6 +38,7 @@ class Version8000Date20240405142042 extends SimpleMigrationStep {
* @param array $options * @param array $options
* @return null|ISchemaWrapper * @return null|ISchemaWrapper
*/ */
#[\Override]
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */ /** @var ISchemaWrapper $schema */
$schema = $schemaClosure(); $schema = $schemaClosure();

View file

@ -30,14 +30,17 @@ class Notifier implements INotifier {
) { ) {
} }
#[\Override]
public function getID(): string { public function getID(): string {
return Application::APP_ID; return Application::APP_ID;
} }
#[\Override]
public function getName(): string { public function getName(): string {
return $this->factory->get(Application::APP_ID)->t('File sharing'); return $this->factory->get(Application::APP_ID)->t('File sharing');
} }
#[\Override]
public function prepare(INotification $notification, string $languageCode): INotification { public function prepare(INotification $notification, string $languageCode): INotification {
if ($notification->getApp() !== Application::APP_ID) { if ($notification->getApp() !== Application::APP_ID) {
throw new UnknownActivityException(); throw new UnknownActivityException();

View file

@ -47,40 +47,49 @@ abstract class AbstractIdentifyMethod implements IIdentifyMethod {
$this->cleanEntity(); $this->cleanEntity();
} }
#[\Override]
public static function getId(): string { public static function getId(): string {
$id = lcfirst(substr(strrchr(static::class, '\\'), 1)); $id = lcfirst(substr(strrchr(static::class, '\\'), 1));
return $id; return $id;
} }
#[\Override]
public function getName(): string { public function getName(): string {
return $this->name; return $this->name;
} }
#[\Override]
public function getFriendlyName(): string { public function getFriendlyName(): string {
return $this->friendlyName; return $this->friendlyName;
} }
#[\Override]
public function setFriendlyName(string $friendlyName): void { public function setFriendlyName(string $friendlyName): void {
$this->friendlyName = $friendlyName; $this->friendlyName = $friendlyName;
} }
#[\Override]
public function setCodeSentByUser(string $code): void { public function setCodeSentByUser(string $code): void {
$this->codeSentByUser = $code; $this->codeSentByUser = $code;
} }
#[\Override]
public function cleanEntity(): void { public function cleanEntity(): void {
$this->entity = new IdentifyMethod(); $this->entity = new IdentifyMethod();
$this->entity->setIdentifierKey($this->name); $this->entity->setIdentifierKey($this->name);
} }
#[\Override]
public function setEntity(IdentifyMethod $entity): void { public function setEntity(IdentifyMethod $entity): void {
$this->entity = $entity; $this->entity = $entity;
} }
#[\Override]
public function getEntity(): IdentifyMethod { public function getEntity(): IdentifyMethod {
return $this->entity; return $this->entity;
} }
#[\Override]
public function signatureMethodsToArray(): array { public function signatureMethodsToArray(): array {
return array_map(fn (AbstractSignatureMethod $method) => [ return array_map(fn (AbstractSignatureMethod $method) => [
'label' => $method->getFriendlyName(), 'label' => $method->getFriendlyName(),
@ -93,6 +102,7 @@ abstract class AbstractIdentifyMethod implements IIdentifyMethod {
return $this->availableSignatureMethods; return $this->availableSignatureMethods;
} }
#[\Override]
public function getEmptyInstanceOfSignatureMethodByName(string $name): AbstractSignatureMethod { public function getEmptyInstanceOfSignatureMethodByName(string $name): AbstractSignatureMethod {
if (!in_array($name, $this->getAvailableSignatureMethods())) { if (!in_array($name, $this->getAvailableSignatureMethods())) {
throw new InvalidArgumentException(sprintf('%s is not a valid signature method of identify method %s', $name, $this->getName())); throw new InvalidArgumentException(sprintf('%s is not a valid signature method of identify method %s', $name, $this->getName()));
@ -110,15 +120,18 @@ abstract class AbstractIdentifyMethod implements IIdentifyMethod {
/** /**
* @return AbstractSignatureMethod[] * @return AbstractSignatureMethod[]
*/ */
#[\Override]
public function getSignatureMethods(): array { public function getSignatureMethods(): array {
return $this->signatureMethods; return $this->signatureMethods;
} }
#[\Override]
public function getSettings(): array { public function getSettings(): array {
$this->getSettingsFromDatabase(); $this->getSettingsFromDatabase();
return $this->settings; return $this->settings;
} }
#[\Override]
public function notify(): bool { public function notify(): bool {
if (!$this->willNotify) { if (!$this->willNotify) {
return false; return false;
@ -133,19 +146,24 @@ abstract class AbstractIdentifyMethod implements IIdentifyMethod {
return true; return true;
} }
#[\Override]
public function willNotifyUser(bool $willNotify): void { public function willNotifyUser(bool $willNotify): void {
$this->willNotify = $willNotify; $this->willNotify = $willNotify;
} }
#[\Override]
public function validateToRequest(): void { public function validateToRequest(): void {
} }
#[\Override]
public function validateToCreateAccount(string $value): void { public function validateToCreateAccount(string $value): void {
} }
#[\Override]
public function validateToIdentify(): void { public function validateToIdentify(): void {
} }
#[\Override]
public function validateToSign(): void { public function validateToSign(): void {
} }
@ -354,11 +372,13 @@ abstract class AbstractIdentifyMethod implements IIdentifyMethod {
return $customConfig; return $customConfig;
} }
#[\Override]
public function save(): void { public function save(): void {
$this->identifyService->save($this->getEntity()); $this->identifyService->save($this->getEntity());
$this->notify(); $this->notify();
} }
#[\Override]
public function delete(): void { public function delete(): void {
$this->identifyService->delete($this->getEntity()); $this->identifyService->delete($this->getEntity());
} }
@ -370,6 +390,7 @@ abstract class AbstractIdentifyMethod implements IIdentifyMethod {
} }
} }
#[\Override]
public function validateToRenew(?IUser $user = null): void { public function validateToRenew(?IUser $user = null): void {
$this->throwIfMaximumValidityExpired(); $this->throwIfMaximumValidityExpired();
$this->throwIfAlreadySigned(); $this->throwIfAlreadySigned();

View file

@ -53,6 +53,7 @@ class Account extends AbstractIdentifyMethod {
); );
} }
#[\Override]
public function validateToRequest(): void { public function validateToRequest(): void {
$signer = $this->userManager->get($this->entity->getIdentifierValue()); $signer = $this->userManager->get($this->entity->getIdentifierValue());
if (!$signer) { if (!$signer) {
@ -60,6 +61,7 @@ class Account extends AbstractIdentifyMethod {
} }
} }
#[\Override]
public function validateToIdentify(): void { public function validateToIdentify(): void {
$signer = $this->getSigner(); $signer = $this->getSigner();
$this->throwIfNotAuthenticated(); $this->throwIfNotAuthenticated();
@ -72,6 +74,7 @@ class Account extends AbstractIdentifyMethod {
$this->updateIdentifiedAt(); $this->updateIdentifiedAt();
} }
#[\Override]
public function validateToSign(): void { public function validateToSign(): void {
$signer = $this->getSigner(); $signer = $this->getSigner();
$this->throwIfNotAuthenticated(); $this->throwIfNotAuthenticated();
@ -126,6 +129,7 @@ class Account extends AbstractIdentifyMethod {
} }
} }
#[\Override]
public function getSettings(): array { public function getSettings(): array {
if (!empty($this->settings)) { if (!empty($this->settings)) {
return $this->settings; return $this->settings;

View file

@ -43,10 +43,12 @@ class Email extends AbstractIdentifyMethod {
); );
} }
#[\Override]
public function validateToRequest(): void { public function validateToRequest(): void {
$this->throwIfInvalidEmail(); $this->throwIfInvalidEmail();
} }
#[\Override]
public function validateToIdentify(): void { public function validateToIdentify(): void {
$this->throwIfAccountAlreadyExists(); $this->throwIfAccountAlreadyExists();
$this->throwIfIsAuthenticatedWithDifferentAccount(); $this->throwIfIsAuthenticatedWithDifferentAccount();
@ -59,6 +61,7 @@ class Email extends AbstractIdentifyMethod {
$this->updateIdentifiedAt(); $this->updateIdentifiedAt();
} }
#[\Override]
public function validateToSign(): void { public function validateToSign(): void {
$this->throwIfAccountAlreadyExists(); $this->throwIfAccountAlreadyExists();
$this->throwIfIsAuthenticatedWithDifferentAccount(); $this->throwIfIsAuthenticatedWithDifferentAccount();
@ -171,6 +174,7 @@ class Email extends AbstractIdentifyMethod {
])); ]));
} }
#[\Override]
public function validateToCreateAccount(string $value): void { public function validateToCreateAccount(string $value): void {
$this->throwIfInvalidEmail(); $this->throwIfInvalidEmail();
$this->throwIfNotAllowedToCreateAccount(); $this->throwIfNotAllowedToCreateAccount();
@ -198,6 +202,7 @@ class Email extends AbstractIdentifyMethod {
} }
} }
#[\Override]
public function getSettings(): array { public function getSettings(): array {
if (!empty($this->settings)) { if (!empty($this->settings)) {
return $this->settings; return $this->settings;

View file

@ -16,6 +16,7 @@ class Signal extends TwofactorGateway {
ISignatureMethod::SIGNATURE_METHOD_SIGNAL, ISignatureMethod::SIGNATURE_METHOD_SIGNAL,
]; ];
#[\Override]
public function getFriendlyName(): string { public function getFriendlyName(): string {
// TRANSLATORS Name of possible authenticator method. This signalize that the signer could be identified by Signal // TRANSLATORS Name of possible authenticator method. This signalize that the signer could be identified by Signal
return $this->identifyService->getL10n()->t('Signal'); return $this->identifyService->getL10n()->t('Signal');

View file

@ -13,14 +13,17 @@ use OCA\Libresign\Service\IdentifyMethod\AbstractIdentifyMethod;
abstract class AbstractSignatureMethod extends AbstractIdentifyMethod implements ISignatureMethod { abstract class AbstractSignatureMethod extends AbstractIdentifyMethod implements ISignatureMethod {
private bool $enabled = false; private bool $enabled = false;
#[\Override]
public function enable(): void { public function enable(): void {
$this->enabled = true; $this->enabled = true;
} }
#[\Override]
public function isEnabled(): bool { public function isEnabled(): bool {
return $this->enabled; return $this->enabled;
} }
#[\Override]
public function toArray(): array { public function toArray(): array {
return [ return [
'label' => $this->getFriendlyName(), 'label' => $this->getFriendlyName(),

View file

@ -25,10 +25,12 @@ class EmailToken extends AbstractSignatureMethod implements IToken {
); );
} }
#[\Override]
public function validateToSign(): void { public function validateToSign(): void {
$this->throwIfInvalidToken(); $this->throwIfInvalidToken();
} }
#[\Override]
public function toArray(): array { public function toArray(): array {
$entity = $this->getEntity(); $entity = $this->getEntity();
@ -71,6 +73,7 @@ class EmailToken extends AbstractSignatureMethod implements IToken {
return $blur->make(); return $blur->make();
} }
#[\Override]
public function requestCode(string $identifier, string $method): void { public function requestCode(string $identifier, string $method): void {
$signRequestMapper = $this->identifyService->getSignRequestMapper(); $signRequestMapper = $this->identifyService->getSignRequestMapper();
$signRequest = $signRequestMapper->getById($this->getEntity()->getSignRequestId()); $signRequest = $signRequestMapper->getById($this->getEntity()->getSignRequestId());

View file

@ -27,6 +27,7 @@ class Password extends AbstractSignatureMethod {
); );
} }
#[\Override]
public function validateToSign(): void { public function validateToSign(): void {
$this->validateToIdentify(); $this->validateToIdentify();
try { try {
@ -39,6 +40,7 @@ class Password extends AbstractSignatureMethod {
} }
} }
#[\Override]
public function validateToIdentify(): void { public function validateToIdentify(): void {
$this->pkcs12Handler->setPassword($this->codeSentByUser); $this->pkcs12Handler->setPassword($this->codeSentByUser);
$pfx = $this->pkcs12Handler->getPfxOfCurrentSigner($this->userSession->getUser()?->getUID()); $pfx = $this->pkcs12Handler->getPfxOfCurrentSigner($this->userSession->getUser()?->getUID());
@ -47,6 +49,7 @@ class Password extends AbstractSignatureMethod {
} }
} }
#[\Override]
public function toArray(): array { public function toArray(): array {
$return = parent::toArray(); $return = parent::toArray();
$return['hasSignatureFile'] = $this->hasSignatureFile(); $return['hasSignatureFile'] = $this->hasSignatureFile();

View file

@ -23,10 +23,12 @@ class TwofactorGatewayToken extends AbstractSignatureMethod implements IToken {
); );
} }
#[\Override]
public function validateToSign(): void { public function validateToSign(): void {
$this->throwIfInvalidToken(); $this->throwIfInvalidToken();
} }
#[\Override]
public function toArray(): array { public function toArray(): array {
$entity = $this->getEntity(); $entity = $this->getEntity();
@ -74,6 +76,7 @@ class TwofactorGatewayToken extends AbstractSignatureMethod implements IToken {
return $start . str_repeat('*', $maskedLength) . $end; return $start . str_repeat('*', $maskedLength) . $end;
} }
#[\Override]
public function requestCode(string $identifier, string $method): void { public function requestCode(string $identifier, string $method): void {
$signRequestMapper = $this->identifyService->getSignRequestMapper(); $signRequestMapper = $this->identifyService->getSignRequestMapper();
$signRequest = $signRequestMapper->getById($this->getEntity()->getSignRequestId()); $signRequest = $signRequestMapper->getById($this->getEntity()->getSignRequestId());

View file

@ -16,6 +16,7 @@ class Sms extends TwofactorGateway {
ISignatureMethod::SIGNATURE_METHOD_SMS, ISignatureMethod::SIGNATURE_METHOD_SMS,
]; ];
#[\Override]
public function getFriendlyName(): string { public function getFriendlyName(): string {
// TRANSLATORS Name of possible authenticator method. This signalize that the signer could be identified by SMS // TRANSLATORS Name of possible authenticator method. This signalize that the signer could be identified by SMS
return $this->identifyService->getL10n()->t('SMS'); return $this->identifyService->getL10n()->t('SMS');

View file

@ -16,6 +16,7 @@ class Telegram extends TwofactorGateway {
ISignatureMethod::SIGNATURE_METHOD_TELEGRAM, ISignatureMethod::SIGNATURE_METHOD_TELEGRAM,
]; ];
#[\Override]
public function getFriendlyName(): string { public function getFriendlyName(): string {
// TRANSLATORS Name of possible authenticator method. This signalize that the signer could be identified by Telegram // TRANSLATORS Name of possible authenticator method. This signalize that the signer could be identified by Telegram
return $this->identifyService->getL10n()->t('Telegram'); return $this->identifyService->getL10n()->t('Telegram');

View file

@ -36,6 +36,7 @@ class TwofactorGateway extends AbstractIdentifyMethod {
); );
} }
#[\Override]
public function validateToIdentify(): void { public function validateToIdentify(): void {
$this->throwIfMaximumValidityExpired(); $this->throwIfMaximumValidityExpired();
$this->throwIfRenewalIntervalExpired(); $this->throwIfRenewalIntervalExpired();
@ -45,6 +46,7 @@ class TwofactorGateway extends AbstractIdentifyMethod {
$this->updateIdentifiedAt(); $this->updateIdentifiedAt();
} }
#[\Override]
public function validateToSign(): void { public function validateToSign(): void {
$this->throwIfInvalidToken(); $this->throwIfInvalidToken();
$this->throwIfMaximumValidityExpired(); $this->throwIfMaximumValidityExpired();
@ -70,6 +72,7 @@ class TwofactorGateway extends AbstractIdentifyMethod {
return $gateway->isComplete(); return $gateway->isComplete();
} }
#[\Override]
public function getSettings(): array { public function getSettings(): array {
if (!empty($this->settings)) { if (!empty($this->settings)) {
return $this->settings; return $this->settings;

View file

@ -16,6 +16,7 @@ class Whatsapp extends TwofactorGateway {
ISignatureMethod::SIGNATURE_METHOD_WHATSAPP, ISignatureMethod::SIGNATURE_METHOD_WHATSAPP,
]; ];
#[\Override]
public function getFriendlyName(): string { public function getFriendlyName(): string {
// TRANSLATORS Name of possible authenticator method. This signalize that the signer could be identified by WhatsApp // TRANSLATORS Name of possible authenticator method. This signalize that the signer could be identified by WhatsApp
return $this->identifyService->getL10n()->t('WhatsApp'); return $this->identifyService->getL10n()->t('WhatsApp');

View file

@ -16,6 +16,7 @@ class Xmpp extends TwofactorGateway {
ISignatureMethod::SIGNATURE_METHOD_XMPP, ISignatureMethod::SIGNATURE_METHOD_XMPP,
]; ];
#[\Override]
public function getFriendlyName(): string { public function getFriendlyName(): string {
// TRANSLATORS Name of possible authenticator method. This signalize that the signer could be identified by XMPP // TRANSLATORS Name of possible authenticator method. This signalize that the signer could be identified by XMPP
return $this->identifyService->getL10n()->t('XMPP'); return $this->identifyService->getL10n()->t('XMPP');

View file

@ -32,6 +32,7 @@ class Admin implements ISettings {
private SignatureBackgroundService $signatureBackgroundService, private SignatureBackgroundService $signatureBackgroundService,
) { ) {
} }
#[\Override]
public function getForm(): TemplateResponse { public function getForm(): TemplateResponse {
Util::addScript(Application::APP_ID, 'libresign-settings'); Util::addScript(Application::APP_ID, 'libresign-settings');
try { try {
@ -66,6 +67,7 @@ class Admin implements ISettings {
/** /**
* @psalm-return 'libresign' * @psalm-return 'libresign'
*/ */
#[\Override]
public function getSection(): string { public function getSection(): string {
return Application::APP_ID; return Application::APP_ID;
} }
@ -73,6 +75,7 @@ class Admin implements ISettings {
/** /**
* @psalm-return 100 * @psalm-return 100
*/ */
#[\Override]
public function getPriority(): int { public function getPriority(): int {
return 100; return 100;
} }

View file

@ -23,6 +23,7 @@ class AdminSettings implements IIconSection {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\Override]
public function getID(): string { public function getID(): string {
return Application::APP_ID; return Application::APP_ID;
} }
@ -30,6 +31,7 @@ class AdminSettings implements IIconSection {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\Override]
public function getName(): string { public function getName(): string {
return $this->l->t('LibreSign'); return $this->l->t('LibreSign');
} }
@ -37,6 +39,7 @@ class AdminSettings implements IIconSection {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\Override]
public function getPriority(): int { public function getPriority(): int {
return 60; return 60;
} }
@ -44,6 +47,7 @@ class AdminSettings implements IIconSection {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\Override]
public function getIcon(): string { public function getIcon(): string {
return $this->urlGenerator->imagePath(Application::APP_ID, 'app-dark.svg'); return $this->urlGenerator->imagePath(Application::APP_ID, 'app-dark.svg');
} }