diff --git a/Makefile b/Makefile index 51bd8998a4..29dffe51a8 100644 --- a/Makefile +++ b/Makefile @@ -113,8 +113,8 @@ appstore: clean cp tests/fixtures/small_valid.pdf $(appstore_sign_dir)/$(app_name)/tests/fixtures $(occ) config:app:set libresign certificate_engine --value cfssl - $(occ) libresign:install --all $(occ) libresign:install --all --architecture aarch64 + $(occ) libresign:install --all --architecture x86_64 $(occ) libresign:developer:sign-setup --privateKey=$(cert_dir)/$(app_name).key \ --certificate=$(cert_dir)/$(app_name).crt diff --git a/lib/Command/Developer/SignSetup.php b/lib/Command/Developer/SignSetup.php index 34d80a362a..2e39fb8f0d 100644 --- a/lib/Command/Developer/SignSetup.php +++ b/lib/Command/Developer/SignSetup.php @@ -76,6 +76,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int } } $output->writeln('Successfully signed'); + unlink(__DIR__ . '/../../../build/tools/certificates/local/root.crt'); + unlink(__DIR__ . '/../../../build/tools/certificates/local/libresign.crt'); + unlink(__DIR__ . '/../../../build/tools/certificates/local/libresign.key'); } catch (\Exception $e) { $output->writeln('Error: ' . $e->getMessage()); return 1; diff --git a/lib/Controller/AdminController.php b/lib/Controller/AdminController.php index 4e4c9ccfe4..73e531e326 100644 --- a/lib/Controller/AdminController.php +++ b/lib/Controller/AdminController.php @@ -19,6 +19,7 @@ use OCP\AppFramework\Http; use OCP\AppFramework\Http\Attribute\NoCSRFRequired; use OCP\AppFramework\Http\DataResponse; +use OCP\AppFramework\Services\IAppConfig; use OCP\IEventSource; use OCP\IEventSourceFactory; use OCP\IL10N; @@ -34,6 +35,7 @@ class AdminController extends AEnvironmentAwareController { private IEventSource $eventSource; public function __construct( IRequest $request, + private IAppConfig $appConfig, private ConfigureCheckService $configureCheckService, private InstallService $installService, private CertificateEngineHandler $certificateEngineHandler, @@ -191,8 +193,11 @@ public function installAndValidate(): void { $this->installService->installJava($async); $this->installService->installJSignPdf($async); $this->installService->installPdftk($async); - $this->installService->installCfssl($async); + if ($this->appConfig->getAppValue('certificate_engine') === 'cfssl') { + $this->installService->installCfssl($async); + } + $this->configureCheckService->disableCache(); $this->eventSource->send('configure_check', $this->configureCheckService->checkAll()); $seconds = 0; while ($this->installService->isDownloadWip()) { diff --git a/lib/Service/Install/ConfigureCheckService.php b/lib/Service/Install/ConfigureCheckService.php index 325288a80c..06625c81a5 100644 --- a/lib/Service/Install/ConfigureCheckService.php +++ b/lib/Service/Install/ConfigureCheckService.php @@ -8,6 +8,7 @@ namespace OCA\Libresign\Service\Install; +use OC\AppConfig; use OC\SystemConfig; use OCA\Libresign\Handler\CertificateEngine\Handler as CertificateEngine; use OCA\Libresign\Handler\JSignPdfHandler; @@ -16,9 +17,11 @@ class ConfigureCheckService { private string $architecture; + private bool $isCacheDisabled = false; public function __construct( private IAppConfig $appConfig, private SystemConfig $systemConfig, + private AppConfig $ocAppConfig, private JSignPdfHandler $jSignPdfHandler, private CertificateEngine $certificateEngine, private SignSetupService $signSetupService, @@ -26,12 +29,19 @@ public function __construct( $this->architecture = php_uname('m'); } + public function disableCache(): void { + $this->isCacheDisabled = true; + } + /** * Get result of all checks * * @return ConfigureCheckHelper[] */ public function checkAll(): array { + if ($this->isCacheDisabled) { + $this->ocAppConfig->clearCache(); + } $result = []; $result = array_merge($result, $this->checkSign()); $result = array_merge($result, $this->checkCertificate()); diff --git a/src/store/configureCheck.js b/src/store/configureCheck.js index 50940e9210..087a847641 100644 --- a/src/store/configureCheck.js +++ b/src/store/configureCheck.js @@ -13,6 +13,8 @@ export const useConfigureCheckStore = function(...args) { const store = defineStore('configureCheck', { state: () => ({ items: [], + state: 'in progress', + downloadInProgress: false, }), actions: { @@ -26,11 +28,30 @@ export const useConfigureCheckStore = function(...args) { && this.items.filter((o) => o.resource === 'cfssl').length > 0 && this.items.filter((o) => o.resource === 'cfssl' && o.status === 'error').length === 0 }, + updateItems(items) { + set(this, 'items', items) + const java = this.items.filter((o) => o.resource === 'java' && o.status === 'error').length === 0 + const jsignpdf = this.items.filter((o) => o.resource === 'jsignpdf' && o.status === 'error').length === 0 + const cfssl = this.items.filter((o) => o.resource === 'cfssl' && o.status === 'error').length === 0 + if (!java + || !jsignpdf + || !cfssl + ) { + set(this, 'state', 'need download') + } else { + set(this, 'state', 'done') + } + set(this, 'downloadInProgress', false) + }, async checkSetup() { - const response = await axios.get( + set(this, 'state', 'in progress') + set(this, 'downloadInProgress', true) + await axios.get( generateOcsUrl('/apps/libresign/api/v1/admin/configure-check'), ) - set(this, 'items', response.data.ocs.data) + .then(({ data }) => { + this.updateItems(data.ocs.data) + }) }, }, }) diff --git a/src/views/Settings/ConfigureCheck.vue b/src/views/Settings/ConfigureCheck.vue index 714db56330..33df90b8cd 100644 --- a/src/views/Settings/ConfigureCheck.vue +++ b/src/views/Settings/ConfigureCheck.vue @@ -1,7 +1,7 @@