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;
}
#[\Override]
public function getIdentifier() {
return Application::APP_ID;
}
#[\Override]
public function getName() {
return 'LibreSign';
}
#[\Override]
public function getPriority() {
return 31;
}
#[\Override]
public function getIcon() {
return $this->url->getAbsoluteURL($this->url->imagePath('libresign', 'app-dark.svg'));
}
#[\Override]
public function filterTypes(array $types) {
return array_intersect(self::ALLOWED_TYPES, $types);
}
#[\Override]
public function allowedApps() {
return [
Application::APP_ID,

View file

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

View file

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

View file

@ -26,6 +26,7 @@ class FileSigned extends LibresignActivitySettings {
/**
* {@inheritdoc}
*/
#[\Override]
public function getIdentifier(): string {
return SignedEvent::FILE_SIGNED;
}
@ -33,6 +34,7 @@ class FileSigned extends LibresignActivitySettings {
/**
* {@inheritdoc}
*/
#[\Override]
public function getName(): string {
return $this->l->t('A document has been <strong>signed</strong>');
}
@ -40,6 +42,7 @@ class FileSigned extends LibresignActivitySettings {
/**
* {@inheritdoc}
*/
#[\Override]
public function getPriority(): int {
return 52;
}
@ -47,6 +50,7 @@ class FileSigned extends LibresignActivitySettings {
/**
* {@inheritdoc}
*/
#[\Override]
public function canChangeNotification(): bool {
if (!$this->userSession->getUser() instanceof IUser) {
return true;
@ -62,6 +66,7 @@ class FileSigned extends LibresignActivitySettings {
/**
* {@inheritdoc}
*/
#[\Override]
public function canChangeMail() {
if (!$this->userSession->getUser() instanceof IUser) {
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
* @since 20.0.0
*/
#[\Override]
public function getIdentifier(): string {
return SendSignNotificationEvent::FILE_TO_SIGN;
}
@ -29,6 +30,7 @@ class FileToSign extends LibresignActivitySettings {
* @return string A translated string
* @since 11.0.0
*/
#[\Override]
public function getName(): string {
return $this->l->t('You have a <strong>file to sign</strong>');
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -12,6 +12,7 @@ use DateTime;
use OCP\Files\File;
class Pkcs7Handler extends SignEngineHandler {
#[\Override]
public function sign(): File {
$p7sFile = $this->getP7sFile();
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.
*/
#[\Override]
public function getCertificateChain($resource): array {
$metadata = stream_get_meta_data($resource);
$lastModifiedTime = filemtime($metadata['uri']);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -19,6 +19,7 @@ class Version7000Date20221026003343 extends SimpleMigrationStep {
) {
}
#[\Override]
public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void {
$rootCert = [];
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:
* {"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 {
$rootCert = $this->appConfig->getValueString(Application::APP_ID, 'rootCert');
$rootCert = json_decode($rootCert, true);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -20,6 +20,7 @@ class Version8000Date20230608004729 extends SimpleMigrationStep {
) {
}
#[\Override]
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
$cfsslBin = $this->appConfig->getValueString(Application::APP_ID, 'cfssl_bin');
$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 {
$this->installService->installPdftk();
if ($rootCert = $this->appConfig->getValueArray(Application::APP_ID, 'rootCert')) {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -16,6 +16,7 @@ class Signal extends TwofactorGateway {
ISignatureMethod::SIGNATURE_METHOD_SIGNAL,
];
#[\Override]
public function getFriendlyName(): string {
// TRANSLATORS Name of possible authenticator method. This signalize that the signer could be identified by 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 {
private bool $enabled = false;
#[\Override]
public function enable(): void {
$this->enabled = true;
}
#[\Override]
public function isEnabled(): bool {
return $this->enabled;
}
#[\Override]
public function toArray(): array {
return [
'label' => $this->getFriendlyName(),

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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