From 8a67a046bbe3ebca606eed2f1a238866bfa5436b Mon Sep 17 00:00:00 2001 From: Vitor Mattos Date: Sun, 24 Mar 2024 16:45:23 -0300 Subject: [PATCH] Rename class to prevent duplicated class name in different namespaces Signed-off-by: Vitor Mattos [skip ci] --- lib/Listener/MailNotifyListener.php | 4 +- .../IdentifyMethod/AbstractIdentifyMethod.php | 70 +++++++++---------- lib/Service/IdentifyMethod/Account.php | 18 ++--- lib/Service/IdentifyMethod/Email.php | 44 ++++++------ ...yMethodService.php => IdentifyService.php} | 2 +- .../SignatureMethod/ClickToSign.php | 8 +-- .../SignatureMethod/EmailToken.php | 16 ++--- .../SignatureMethod/Password.php | 10 +-- 8 files changed, 86 insertions(+), 86 deletions(-) rename lib/Service/IdentifyMethod/{IdentifyMethodService.php => IdentifyService.php} (99%) diff --git a/lib/Listener/MailNotifyListener.php b/lib/Listener/MailNotifyListener.php index d8547272c4..a353c60ab9 100644 --- a/lib/Listener/MailNotifyListener.php +++ b/lib/Listener/MailNotifyListener.php @@ -27,7 +27,7 @@ use OCA\Libresign\Db\File as FileEntity; use OCA\Libresign\Db\SignRequest; use OCA\Libresign\Events\SendSignNotificationEvent; -use OCA\Libresign\Service\IdentifyMethod\IdentifyMethodService; +use OCA\Libresign\Service\IdentifyMethod\IdentifyService; use OCA\Libresign\Service\IdentifyMethod\IIdentifyMethod; use OCA\Libresign\Service\MailService; use OCP\EventDispatcher\Event; @@ -41,7 +41,7 @@ class MailNotifyListener implements IEventListener { public function __construct( protected IUserSession $userSession, protected IUserManager $userManager, - protected IdentifyMethodService $identifyMethodService, + protected IdentifyService $identifyService, protected MailService $mail, private LoggerInterface $logger, ) { diff --git a/lib/Service/IdentifyMethod/AbstractIdentifyMethod.php b/lib/Service/IdentifyMethod/AbstractIdentifyMethod.php index 5e7a475f62..51b9653a50 100644 --- a/lib/Service/IdentifyMethod/AbstractIdentifyMethod.php +++ b/lib/Service/IdentifyMethod/AbstractIdentifyMethod.php @@ -48,7 +48,7 @@ abstract class AbstractIdentifyMethod implements IIdentifyMethod { */ protected array $signatureMethods = []; public function __construct( - protected IdentifyMethodService $identifyMethodService, + protected IdentifyService $identifyService, ) { $className = (new \ReflectionClass($this))->getShortName(); $this->name = lcfirst($className); @@ -107,9 +107,9 @@ public function notify(bool $isNew): bool { if (!$this->willNotify) { return false; } - $signRequest = $this->identifyMethodService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId()); - $libresignFile = $this->identifyMethodService->getFileMapper()->getById($signRequest->getFileId()); - $this->identifyMethodService->getEventDispatcher()->dispatchTyped(new SendSignNotificationEvent( + $signRequest = $this->identifyService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId()); + $libresignFile = $this->identifyService->getFileMapper()->getById($signRequest->getFileId()); + $this->identifyService->getEventDispatcher()->dispatchTyped(new SendSignNotificationEvent( $signRequest, $libresignFile, $this, @@ -132,35 +132,35 @@ public function validateToIdentify(): void { } protected function throwIfFileNotFound(): void { - $signRequest = $this->identifyMethodService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId()); - $fileEntity = $this->identifyMethodService->getFileMapper()->getById($signRequest->getFileId()); + $signRequest = $this->identifyService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId()); + $fileEntity = $this->identifyService->getFileMapper()->getById($signRequest->getFileId()); $nodeId = $fileEntity->getNodeId(); - $mountsContainingFile = $this->identifyMethodService->getUserMountCache()->getMountsForFileId($nodeId); + $mountsContainingFile = $this->identifyService->getUserMountCache()->getMountsForFileId($nodeId); foreach ($mountsContainingFile as $fileInfo) { - $this->identifyMethodService->getRootFolder()->getByIdInPath($nodeId, $fileInfo->getMountPoint()); + $this->identifyService->getRootFolder()->getByIdInPath($nodeId, $fileInfo->getMountPoint()); } - $fileToSign = $this->identifyMethodService->getRootFolder()->getById($nodeId); + $fileToSign = $this->identifyService->getRootFolder()->getById($nodeId); if (count($fileToSign) < 1) { throw new LibresignException(json_encode([ 'action' => JSActions::ACTION_DO_NOTHING, - 'errors' => [$this->identifyMethodService->getL10n()->t('File not found')], + 'errors' => [$this->identifyService->getL10n()->t('File not found')], ])); } } protected function throwIfMaximumValidityExpired(): void { - $maximumValidity = (int) $this->identifyMethodService->getAppConfig()->getAppValue('maximum_validity', (string) SessionService::NO_MAXIMUM_VALIDITY); + $maximumValidity = (int) $this->identifyService->getAppConfig()->getAppValue('maximum_validity', (string) SessionService::NO_MAXIMUM_VALIDITY); if ($maximumValidity <= 0) { return; } - $signRequest = $this->identifyMethodService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId()); - $now = $this->identifyMethodService->getTimeFactory()->getTime(); + $signRequest = $this->identifyService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId()); + $now = $this->identifyService->getTimeFactory()->getTime(); if ($signRequest->getCreatedAt() + $maximumValidity < $now) { throw new LibresignException(json_encode([ 'action' => JSActions::ACTION_DO_NOTHING, - 'errors' => [$this->identifyMethodService->getL10n()->t('Link expired.')], + 'errors' => [$this->identifyService->getL10n()->t('Link expired.')], ])); } } @@ -169,37 +169,37 @@ protected function throwIfInvalidToken(): void { if (empty($this->codeSentByUser)) { return; } - if (!$this->identifyMethodService->getHasher()->verify($this->codeSentByUser, $this->getEntity()->getCode())) { - throw new LibresignException($this->identifyMethodService->getL10n()->t('Invalid code.')); + if (!$this->identifyService->getHasher()->verify($this->codeSentByUser, $this->getEntity()->getCode())) { + throw new LibresignException($this->identifyService->getL10n()->t('Invalid code.')); } } protected function renewSession(): void { - $this->identifyMethodService->getSessionService()->setIdentifyMethodId($this->getEntity()->getId()); - $renewalInterval = (int) $this->identifyMethodService->getAppConfig()->getAppValue('renewal_interval', (string) SessionService::NO_RENEWAL_INTERVAL); + $this->identifyService->getSessionService()->setIdentifyMethodId($this->getEntity()->getId()); + $renewalInterval = (int) $this->identifyService->getAppConfig()->getAppValue('renewal_interval', (string) SessionService::NO_RENEWAL_INTERVAL); if ($renewalInterval <= 0) { return; } - $this->identifyMethodService->getSessionService()->resetDurationOfSignPage(); + $this->identifyService->getSessionService()->resetDurationOfSignPage(); } protected function updateIdentifiedAt(): void { if ($this->getEntity()->getCode() && !$this->getEntity()->getIdentifiedAtDate()) { return; } - $this->getEntity()->setIdentifiedAtDate($this->identifyMethodService->getTimeFactory()->getDateTime()); + $this->getEntity()->setIdentifiedAtDate($this->identifyService->getTimeFactory()->getDateTime()); $this->willNotify = false; $isNew = $this->identifyMethodService->save($this->getEntity()); $this->notify($isNew); } protected function throwIfRenewalIntervalExpired(): void { - $renewalInterval = (int) $this->identifyMethodService->getAppConfig()->getAppValue('renewal_interval', (string) SessionService::NO_RENEWAL_INTERVAL); + $renewalInterval = (int) $this->identifyService->getAppConfig()->getAppValue('renewal_interval', (string) SessionService::NO_RENEWAL_INTERVAL); if ($renewalInterval <= 0) { return; } - $signRequest = $this->identifyMethodService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId()); - $startTime = $this->identifyMethodService->getSessionService()->getSignStartTime(); + $signRequest = $this->identifyService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId()); + $startTime = $this->identifyService->getSessionService()->getSignStartTime(); $createdAt = $signRequest->getCreatedAt(); $lastAttempt = $this->getEntity()->getLastAttemptDate()?->format('U'); $lastActionDate = max( @@ -207,8 +207,8 @@ protected function throwIfRenewalIntervalExpired(): void { $createdAt, $lastAttempt, ); - $now = $this->identifyMethodService->getTimeFactory()->getTime(); - $this->identifyMethodService->getLogger()->debug('AbstractIdentifyMethod::throwIfRenewalIntervalExpired Times', [ + $now = $this->identifyService->getTimeFactory()->getTime(); + $this->identifyService->getLogger()->debug('AbstractIdentifyMethod::throwIfRenewalIntervalExpired Times', [ 'renewalInterval' => $renewalInterval, 'startTime' => $startTime, 'createdAt' => $createdAt, @@ -217,13 +217,13 @@ protected function throwIfRenewalIntervalExpired(): void { 'now' => $now, ]); if ($lastActionDate + $renewalInterval < $now) { - $this->identifyMethodService->getLogger()->debug('AbstractIdentifyMethod::throwIfRenewalIntervalExpired Exception'); + $this->identifyService->getLogger()->debug('AbstractIdentifyMethod::throwIfRenewalIntervalExpired Exception'); $blur = new Blur($this->getEntity()->getIdentifierValue()); throw new LibresignException(json_encode([ 'action' => $this->getRenewAction(), // TRANSLATORS title that is displayed at screen to notify the signer that the link to sign the document expired - 'title' => $this->identifyMethodService->getL10n()->t('Link expired'), - 'body' => $this->identifyMethodService->getL10n()->t(<<<'BODY' + 'title' => $this->identifyService->getL10n()->t('Link expired'), + 'body' => $this->identifyService->getL10n()->t(<<<'BODY' The link to sign the document has expired. We will send a new link to the email %1$s. Click below to receive the new link and be able to sign the document. @@ -232,7 +232,7 @@ protected function throwIfRenewalIntervalExpired(): void { ), 'uuid' => $signRequest->getUuid(), // TRANSLATORS Button to renew the link to sign the document. Renew is the action to generate a new sign link when the link expired. - 'renewButton' => $this->identifyMethodService->getL10n()->t('Renew'), + 'renewButton' => $this->identifyService->getL10n()->t('Renew'), ])); } } @@ -246,15 +246,15 @@ private function getRenewAction(): int { } protected function throwIfAlreadySigned(): void { - $signRequest = $this->identifyMethodService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId()); - $fileEntity = $this->identifyMethodService->getFileMapper()->getById($signRequest->getFileId()); + $signRequest = $this->identifyService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId()); + $fileEntity = $this->identifyService->getFileMapper()->getById($signRequest->getFileId()); if ($fileEntity->getStatus() === FileEntity::STATUS_SIGNED || (!is_null($signRequest) && $signRequest->getSigned()) ) { throw new LibresignException(json_encode([ 'action' => JSActions::ACTION_REDIRECT, - 'errors' => [$this->identifyMethodService->getL10n()->t('File already signed.')], - 'redirect' => $this->identifyMethodService->getUrlGenerator()->linkToRoute( + 'errors' => [$this->identifyService->getL10n()->t('File already signed.')], + 'redirect' => $this->identifyService->getUrlGenerator()->linkToRoute( 'libresign.page.validationFile', ['uuid' => $signRequest->getUuid()] ), @@ -288,7 +288,7 @@ private function overrideImmutable(array $immutable): void { } private function loadSavedSettings(): void { - $config = $this->identifyMethodService->getSavedSettings(); + $config = $this->identifyService->getSavedSettings(); $this->settings = array_reduce($config, function ($carry, $config) { if ($config['name'] === $this->name) { return $config; @@ -325,7 +325,7 @@ public function save(): void { } public function delete(): void { - $this->identifyMethodService->delete($this->getEntity()); + $this->identifyService->delete($this->getEntity()); } private function removeKeysThatDontExists(array $default): void { diff --git a/lib/Service/IdentifyMethod/Account.php b/lib/Service/IdentifyMethod/Account.php index fdbb4aa008..e1b011ddd1 100644 --- a/lib/Service/IdentifyMethod/Account.php +++ b/lib/Service/IdentifyMethod/Account.php @@ -44,7 +44,7 @@ class Account extends AbstractIdentifyMethod { public function __construct( - protected IdentifyMethodService $identifyMethodService, + protected IdentifyService $identifyService, private IUserManager $userManager, private IEventDispatcher $eventDispatcher, private IdentifyMethodMapper $identifyMethodMapper, @@ -61,21 +61,21 @@ public function __construct( private EmailToken $emailToken, ) { // TRANSLATORS Name of possible authenticator method. This signalize that the signer could be identified by Nextcloud acccount - $this->friendlyName = $this->identifyMethodService->getL10n()->t('Account'); + $this->friendlyName = $this->identifyService->getL10n()->t('Account'); $this->signatureMethods = [ $this->password->getName() => $this->password, $this->clickToSign->getName() => $this->clickToSign, $this->emailToken->getName() => $this->emailToken, ]; parent::__construct( - $identifyMethodService, + $identifyService, ); } public function validateToRequest(): void { $signer = $this->userManager->get($this->entity->getIdentifierValue()); if (!$signer) { - throw new LibresignException($this->identifyMethodService->getL10n()->t('User not found.')); + throw new LibresignException($this->identifyService->getL10n()->t('User not found.')); } } @@ -100,7 +100,7 @@ private function getSigner(): IUser { if (empty($signer) || count($signer) > 1) { throw new LibresignException(json_encode([ 'action' => JSActions::ACTION_DO_NOTHING, - 'errors' => [$this->identifyMethodService->getL10n()->t('Invalid user')], + 'errors' => [$this->identifyService->getL10n()->t('Invalid user')], ])); } $signer = current($signer); @@ -112,17 +112,17 @@ private function authenticatedUserIsTheSigner(IUser $signer): void { if ($this->userSession->getUser() !== $signer) { throw new LibresignException(json_encode([ 'action' => JSActions::ACTION_DO_NOTHING, - 'errors' => [$this->identifyMethodService->getL10n()->t('Invalid user')], + 'errors' => [$this->identifyService->getL10n()->t('Invalid user')], ])); } } private function throwIfNotAuthenticated(): void { if (!$this->userSession->getUser() instanceof IUser) { - $signRequest = $this->identifyMethodService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId()); + $signRequest = $this->identifyService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId()); throw new LibresignException(json_encode([ 'action' => JSActions::ACTION_REDIRECT, - 'errors' => [$this->identifyMethodService->getL10n()->t('You are not logged in. Please log in.')], + 'errors' => [$this->identifyService->getL10n()->t('You are not logged in. Please log in.')], 'redirect' => $this->urlGenerator->linkToRoute('core.login.showLoginForm', [ 'redirect_url' => $this->urlGenerator->linkToRoute( 'libresign.page.sign', @@ -146,7 +146,7 @@ public function getSettings(): array { } private function isEnabledByDefault(): bool { - $config = $this->identifyMethodService->getAppConfig()->getAppValue('identify_methods', '[]'); + $config = $this->identifyService->getAppConfig()->getAppValue('identify_methods', '[]'); $config = json_decode($config, true); if (json_last_error() !== JSON_ERROR_NONE || !is_array($config)) { return true; diff --git a/lib/Service/IdentifyMethod/Email.php b/lib/Service/IdentifyMethod/Email.php index 93c859b858..6aad0a9722 100644 --- a/lib/Service/IdentifyMethod/Email.php +++ b/lib/Service/IdentifyMethod/Email.php @@ -38,7 +38,7 @@ class Email extends AbstractIdentifyMethod { public function __construct( - protected IdentifyMethodService $identifyMethodService, + protected IdentifyService $identifyService, private IdentifyMethodMapper $identifyMethodMapper, private IRootFolder $root, private ITimeFactory $timeFactory, @@ -49,13 +49,13 @@ public function __construct( private IUserSession $userSession, ) { // TRANSLATORS Name of possible authenticator method. This signalize that the signer could be identified by email - $this->friendlyName = $this->identifyMethodService->getL10n()->t('Email'); + $this->friendlyName = $this->identifyService->getL10n()->t('Email'); $this->signatureMethods = [ $this->clickToSign->getName() => $this->clickToSign, $this->emailToken->getName() => $this->emailToken, ]; parent::__construct( - $identifyMethodService, + $identifyService, ); } @@ -85,25 +85,25 @@ protected function throwIfNeedToCreateAccount() { if (!$settings['can_create_account']) { return; } - if ($this->identifyMethodService->getSessionService()->getSignStartTime()) { + if ($this->identifyService->getSessionService()->getSignStartTime()) { return; } $email = $this->getEntity()->getIdentifierValue(); - $signer = $this->identifyMethodService->getUserManager()->getByEmail($email); + $signer = $this->identifyService->getUserManager()->getByEmail($email); if (!$signer) { throw new LibresignException(json_encode([ 'action' => JSActions::ACTION_CREATE_ACCOUNT, 'settings' => ['accountHash' => md5($email)], - 'message' => $this->identifyMethodService->getL10n()->t('You need to create an account to sign this file.'), + 'message' => $this->identifyService->getL10n()->t('You need to create an account to sign this file.'), ])); } - $signRequest = $this->identifyMethodService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId()); + $signRequest = $this->identifyService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId()); throw new LibresignException(json_encode([ 'action' => JSActions::ACTION_REDIRECT, - 'errors' => [$this->identifyMethodService->getL10n()->t('User already exists. Please login.')], - 'redirect' => $this->identifyMethodService->getUrlGenerator()->linkToRoute('core.login.showLoginForm', [ - 'redirect_url' => $this->identifyMethodService->getUrlGenerator()->linkToRoute( + 'errors' => [$this->identifyService->getL10n()->t('User already exists. Please login.')], + 'redirect' => $this->identifyService->getUrlGenerator()->linkToRoute('core.login.showLoginForm', [ + 'redirect_url' => $this->identifyService->getUrlGenerator()->linkToRoute( 'libresign.page.sign', ['uuid' => $signRequest->getUuid()] ), @@ -123,7 +123,7 @@ private function throwIfIsAuthenticatedWithDifferentAccount(): void { } throw new LibresignException(json_encode([ 'action' => JSActions::ACTION_DO_NOTHING, - 'errors' => [$this->identifyMethodService->getL10n()->t('Invalid user')], + 'errors' => [$this->identifyService->getL10n()->t('Invalid user')], ])); } } @@ -134,7 +134,7 @@ private function throwIfAccountAlreadyExists(): void { return; } $email = $this->entity->getIdentifierValue(); - $signer = $this->identifyMethodService->getUserManager()->getByEmail($email); + $signer = $this->identifyService->getUserManager()->getByEmail($email); if (!$signer) { return; } @@ -143,12 +143,12 @@ private function throwIfAccountAlreadyExists(): void { return; } } - $signRequest = $this->identifyMethodService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId()); + $signRequest = $this->identifyService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId()); throw new LibresignException(json_encode([ 'action' => JSActions::ACTION_REDIRECT, - 'errors' => [$this->identifyMethodService->getL10n()->t('User already exists. Please login.')], - 'redirect' => $this->identifyMethodService->getUrlGenerator()->linkToRoute('core.login.showLoginForm', [ - 'redirect_url' => $this->identifyMethodService->getUrlGenerator()->linkToRoute( + 'errors' => [$this->identifyService->getL10n()->t('User already exists. Please login.')], + 'redirect' => $this->identifyService->getUrlGenerator()->linkToRoute('core.login.showLoginForm', [ + 'redirect_url' => $this->identifyService->getUrlGenerator()->linkToRoute( 'libresign.page.sign', ['uuid' => $signRequest->getUuid()] ), @@ -159,11 +159,11 @@ private function throwIfAccountAlreadyExists(): void { public function validateToCreateAccount(string $value): void { $this->throwIfInvalidEmail(); $this->throwIfNotAllowedToCreateAccount(); - if ($this->identifyMethodService->getUserManager()->userExists($value)) { - throw new LibresignException($this->identifyMethodService->getL10n()->t('User already exists')); + if ($this->identifyService->getUserManager()->userExists($value)) { + throw new LibresignException($this->identifyService->getL10n()->t('User already exists')); } if ($this->getEntity()->getIdentifierValue() !== $value) { - throw new LibresignException($this->identifyMethodService->getL10n()->t('This is not your file')); + throw new LibresignException($this->identifyService->getL10n()->t('This is not your file')); } } @@ -172,14 +172,14 @@ private function throwIfNotAllowedToCreateAccount(): void { if (!$settings['can_create_account']) { throw new LibresignException(json_encode([ 'action' => JSActions::ACTION_SHOW_ERROR, - 'errors' => [$this->identifyMethodService->getL10n()->t('It is not possible to create new accounts.')], + 'errors' => [$this->identifyService->getL10n()->t('It is not possible to create new accounts.')], ])); } } private function throwIfInvalidEmail(): void { if (!filter_var($this->entity->getIdentifierValue(), FILTER_VALIDATE_EMAIL)) { - throw new LibresignException($this->identifyMethodService->getL10n()->t('Invalid email')); + throw new LibresignException($this->identifyService->getL10n()->t('Invalid email')); } } @@ -193,7 +193,7 @@ public function getSettings(): array { 'can_create_account' => true, ], immutable: [ - 'test_url' => $this->identifyMethodService->getUrlGenerator()->linkToRoute('settings.MailSettings.sendTestMail'), + 'test_url' => $this->identifyService->getUrlGenerator()->linkToRoute('settings.MailSettings.sendTestMail'), ] ); return $this->settings; diff --git a/lib/Service/IdentifyMethod/IdentifyMethodService.php b/lib/Service/IdentifyMethod/IdentifyService.php similarity index 99% rename from lib/Service/IdentifyMethod/IdentifyMethodService.php rename to lib/Service/IdentifyMethod/IdentifyService.php index 0c4ca480eb..aee753572e 100644 --- a/lib/Service/IdentifyMethod/IdentifyMethodService.php +++ b/lib/Service/IdentifyMethod/IdentifyService.php @@ -40,7 +40,7 @@ use OCP\Security\IHasher; use Psr\Log\LoggerInterface; -class IdentifyMethodService { +class IdentifyService { private array $savedSettings = []; public function __construct( private IdentifyMethodMapper $identifyMethodMapper, diff --git a/lib/Service/IdentifyMethod/SignatureMethod/ClickToSign.php b/lib/Service/IdentifyMethod/SignatureMethod/ClickToSign.php index 65fec18e2f..09942e1883 100644 --- a/lib/Service/IdentifyMethod/SignatureMethod/ClickToSign.php +++ b/lib/Service/IdentifyMethod/SignatureMethod/ClickToSign.php @@ -24,16 +24,16 @@ namespace OCA\Libresign\Service\IdentifyMethod\SignatureMethod; -use OCA\Libresign\Service\IdentifyMethod\IdentifyMethodService; +use OCA\Libresign\Service\IdentifyMethod\IdentifyService; class ClickToSign extends AbstractSignatureMethod { public function __construct( - protected IdentifyMethodService $identifyMethodService, + protected IdentifyService $identifyService, ) { // TRANSLATORS Name of possible authenticator method. This signalize that the signer only need to click to sign after was identified - $this->friendlyName = $this->identifyMethodService->getL10n()->t('Click to sign'); + $this->friendlyName = $this->identifyService->getL10n()->t('Click to sign'); parent::__construct( - $identifyMethodService, + $identifyService, ); } } diff --git a/lib/Service/IdentifyMethod/SignatureMethod/EmailToken.php b/lib/Service/IdentifyMethod/SignatureMethod/EmailToken.php index ec93663569..73022180c7 100644 --- a/lib/Service/IdentifyMethod/SignatureMethod/EmailToken.php +++ b/lib/Service/IdentifyMethod/SignatureMethod/EmailToken.php @@ -26,18 +26,18 @@ use OCA\Libresign\Exception\LibresignException; use OCA\Libresign\Helper\JSActions; -use OCA\Libresign\Service\IdentifyMethod\IdentifyMethodService; +use OCA\Libresign\Service\IdentifyMethod\IdentifyService; use Wobeto\EmailBlur\Blur; class EmailToken extends AbstractSignatureMethod implements IToken { public function __construct( - protected IdentifyMethodService $identifyMethodService, + protected IdentifyService $identifyService, protected TokenService $tokenService, ) { // TRANSLATORS Name of possible authenticator method. This signalize that the signer could be identified by email - $this->friendlyName = $this->identifyMethodService->getL10n()->t('Email token'); + $this->friendlyName = $this->identifyService->getL10n()->t('Email token'); parent::__construct( - $identifyMethodService, + $identifyService, ); } @@ -47,13 +47,13 @@ public function toArray(): array { if ($entity->getIdentifierKey() === 'email') { $email = $entity->getIdentifierValue(); } elseif ($entity->getIdentifierKey() === 'account') { - $signer = $this->identifyMethodService->getUserManager()->get($entity->getIdentifierValue()); + $signer = $this->identifyService->getUserManager()->get($entity->getIdentifierValue()); $email = $signer->getEMailAddress(); } if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { throw new LibresignException(json_encode([ 'action' => JSActions::ACTION_DO_NOTHING, - 'errors' => [$this->identifyMethodService->getL10n()->t('Invalid email')], + 'errors' => [$this->identifyService->getL10n()->t('Invalid email')], ])); } $return = parent::toArray(); @@ -73,7 +73,7 @@ private function blurEmail(string $email): string { } public function requestCode(string $identify): void { - $signRequestMapper = $this->identifyMethodService->getSignRequestMapper(); + $signRequestMapper = $this->identifyService->getSignRequestMapper(); $signRequest = $signRequestMapper->getById($this->getEntity()->getSignRequestId()); $displayName = $signRequest->getDisplayName(); if ($identify === $displayName) { @@ -81,6 +81,6 @@ public function requestCode(string $identify): void { } $code = $this->tokenService->sendCodeByEmail($identify, $displayName); $this->getEntity()->setCode($code); - $this->identifyMethodService->save($this->getEntity()); + $this->identifyService->save($this->getEntity()); } } diff --git a/lib/Service/IdentifyMethod/SignatureMethod/Password.php b/lib/Service/IdentifyMethod/SignatureMethod/Password.php index 9fb59b9567..492b444539 100644 --- a/lib/Service/IdentifyMethod/SignatureMethod/Password.php +++ b/lib/Service/IdentifyMethod/SignatureMethod/Password.php @@ -26,19 +26,19 @@ use OCA\Libresign\Exception\LibresignException; use OCA\Libresign\Handler\Pkcs12Handler; -use OCA\Libresign\Service\IdentifyMethod\IdentifyMethodService; +use OCA\Libresign\Service\IdentifyMethod\IdentifyService; use OCP\IUserSession; class Password extends AbstractSignatureMethod { public function __construct( - protected IdentifyMethodService $identifyMethodService, + protected IdentifyService $identifyService, protected Pkcs12Handler $pkcs12Handler, private IUserSession $userSession, ) { // TRANSLATORS Name of possible authenticator method. This signalize that the signer could be identified by certificate password - $this->friendlyName = $this->identifyMethodService->getL10n()->t('Certificate with password'); + $this->friendlyName = $this->identifyService->getL10n()->t('Certificate with password'); parent::__construct( - $identifyMethodService, + $identifyService, ); } @@ -46,7 +46,7 @@ public function validateToIdentify(): void { $pfx = $this->pkcs12Handler->getPfx($this->userSession->getUser()?->getUID()); openssl_pkcs12_read($pfx, $cert_info, $this->getEntity()->getIdentifierValue()); if (empty($cert_info)) { - throw new LibresignException($this->identifyMethodService->getL10n()->t('Invalid password')); + throw new LibresignException($this->identifyService->getL10n()->t('Invalid password')); } }