Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions lib/Handler/SignEngine/IPkcs12SignEngineHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
Comment thread
vitormattos marked this conversation as resolved.

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: Copyright (c) 2026 Rolf39
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\Libresign\Handler\SignEngine;

interface IPkcs12SignEngineHandler extends ISignEngineHandler {
public function setCertificate(string $certificate): self;
public function getCertificate(): string;
public function readCertificate(): array;
public function setPassword(string $password): self;
public function getPassword(): string;
}
5 changes: 0 additions & 5 deletions lib/Handler/SignEngine/ISignEngineHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
interface ISignEngineHandler {
public function setInputFile(File $inputFile): self;
public function getInputFile(): File;
public function setCertificate(string $certificate): self;
public function getCertificate(): string;
public function readCertificate(): array;
public function setPassword(string $password): self;
public function getPassword(): string;
public function sign(): File;
public function getSignedContent(): string;
public function getSignatureParams(): array;
Expand Down
2 changes: 1 addition & 1 deletion lib/Handler/SignEngine/SignEngineHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
use OCP\IL10N;
use Psr\Log\LoggerInterface;

abstract class SignEngineHandler implements ISignEngineHandler {
abstract class SignEngineHandler implements IPkcs12SignEngineHandler {
private File $inputFile;
protected string $certificate = '';
private string $pfxFilename = 'signature.pfx';
Expand Down
3 changes: 2 additions & 1 deletion lib/Service/SignFileService.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use OCA\Libresign\Handler\PdfTk\Pdf;
use OCA\Libresign\Handler\SignEngine\ISignEngineHandler;
use OCA\Libresign\Handler\SignEngine\Pkcs12Handler;
use OCP\Libresign\Handler\SignEngine\IPkcs12SignEngineHandler;
use OCA\Libresign\Handler\SignEngine\SignEngineFactory;
use OCA\Libresign\Handler\SignEngine\SignEngineHandler;
use OCA\Libresign\Helper\JSActions;
Expand Down Expand Up @@ -87,7 +88,7 @@
private string $userUniqueIdentifier = '';
private string $friendlyName = '';
private ?IUser $user = null;
private ?ISignEngineHandler $engine = null;
private ?IPkcs12SignEngineHandler $engine = null;

Check failure on line 91 in lib/Service/SignFileService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedClass

lib/Service/SignFileService.php:91:10: UndefinedClass: Class, interface or enum named OCP\Libresign\Handler\SignEngine\IPkcs12SignEngineHandler does not exist (see https://psalm.dev/019)

public function __construct(
protected IL10N $l10n,
Expand Down Expand Up @@ -877,7 +878,7 @@
$this->signRequest->setSignedHash($hash);
$this->signRequest->setStatusEnum(\OCA\Libresign\Enum\SignRequestStatus::SIGNED);

$certificateInfo = $this->getEngine()->readCertificate();

Check failure on line 881 in lib/Service/SignFileService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedInterfaceMethod

lib/Service/SignFileService.php:881:42: UndefinedInterfaceMethod: Method OCA\Libresign\Handler\SignEngine\ISignEngineHandler::readCertificate does not exist (see https://psalm.dev/181)
$this->storeCertificateInfoInMetadata($certificateInfo);

$this->signRequestMapper->update($this->signRequest);
Expand Down Expand Up @@ -929,7 +930,7 @@
$certificateSerialNumber = null;
if ($this->signWithoutPassword) {
try {
$certificateInfo = $this->getEngine()->readCertificate();

Check failure on line 933 in lib/Service/SignFileService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedInterfaceMethod

lib/Service/SignFileService.php:933:44: UndefinedInterfaceMethod: Method OCA\Libresign\Handler\SignEngine\ISignEngineHandler::readCertificate does not exist (see https://psalm.dev/181)
if (isset($certificateInfo['serialNumber']) && is_string($certificateInfo['serialNumber'])) {
$certificateSerialNumber = $certificateInfo['serialNumber'];
} else {
Expand Down Expand Up @@ -1179,7 +1180,7 @@

protected function readCertificate(): array {
return $this->getEngine()
->readCertificate();

Check failure on line 1183 in lib/Service/SignFileService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedInterfaceMethod

lib/Service/SignFileService.php:1183:6: UndefinedInterfaceMethod: Method OCA\Libresign\Handler\SignEngine\ISignEngineHandler::readCertificate does not exist (see https://psalm.dev/181)
}

/**
Expand Down Expand Up @@ -1228,20 +1229,20 @@
return strcasecmp($file->getExtension(), 'pdf') === 0;
}

protected function getEngine(): ISignEngineHandler {

Check failure on line 1232 in lib/Service/SignFileService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

InvalidReturnType

lib/Service/SignFileService.php:1232:34: InvalidReturnType: The declared return type 'OCA\Libresign\Handler\SignEngine\ISignEngineHandler' for OCA\Libresign\Service\SignFileService::getEngine is incorrect, got 'OCA\Libresign\Handler\SignEngine\ISignEngineHandler|OCP\Libresign\Handler\SignEngine\IPkcs12SignEngineHandler' (see https://psalm.dev/011)
if (!$this->engine) {
$originalFile = $this->getFileToSign();
$this->engine = $this->identifyEngine($originalFile);

Check failure on line 1235 in lib/Service/SignFileService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

InvalidPropertyAssignmentValue

lib/Service/SignFileService.php:1235:20: InvalidPropertyAssignmentValue: $this->engine with declared type 'OCP\Libresign\Handler\SignEngine\IPkcs12SignEngineHandler|null' cannot be assigned type 'OCA\Libresign\Handler\SignEngine\ISignEngineHandler' (see https://psalm.dev/145)

$this->configureEngine();
}
return $this->engine;

Check failure on line 1239 in lib/Service/SignFileService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

InvalidReturnStatement

lib/Service/SignFileService.php:1239:10: InvalidReturnStatement: The inferred type 'OCA\Libresign\Handler\SignEngine\ISignEngineHandler|OCP\Libresign\Handler\SignEngine\IPkcs12SignEngineHandler' does not match the declared return type 'OCA\Libresign\Handler\SignEngine\ISignEngineHandler' for OCA\Libresign\Service\SignFileService::getEngine (see https://psalm.dev/128)
}

private function configureEngine(): void {
$this->engine

Check failure on line 1243 in lib/Service/SignFileService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedClass

lib/Service/SignFileService.php:1243:3: UndefinedClass: Class, interface or enum named OCP\Libresign\Handler\SignEngine\IPkcs12SignEngineHandler does not exist (see https://psalm.dev/019)
->setInputFile($this->getFileToSign())
->setCertificate($this->getOrGeneratePfxContent($this->engine))

Check failure on line 1245 in lib/Service/SignFileService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

InvalidArgument

lib/Service/SignFileService.php:1245:52: InvalidArgument: Argument 1 of OCA\Libresign\Service\SignFileService::getOrGeneratePfxContent expects OCA\Libresign\Handler\SignEngine\SignEngineHandler, but OCP\Libresign\Handler\SignEngine\IPkcs12SignEngineHandler|null provided (see https://psalm.dev/004)
->setPassword($this->password);

if ($this->engine::class === Pkcs12Handler::class) {
Expand Down
Loading