• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LibreSign / libresign / 22603185457

03 Mar 2026 12:58AM UTC coverage: 53.56%. First build
22603185457

Pull #2595

github

web-flow
Merge df6ade764 into 94e35a169
Pull Request #2595: [WIP] Sign usign only PHP

0 of 56 new or added lines in 3 files covered. (0.0%)

9583 of 17892 relevant lines covered (53.56%)

6.39 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

2.66
/lib/Service/Install/ConfigureCheckService.php
1
<?php
2

3
declare(strict_types=1);
4
/**
5
 * SPDX-FileCopyrightText: 2020-2024 LibreCode coop and contributors
6
 * SPDX-License-Identifier: AGPL-3.0-or-later
7
 */
8

9
namespace OCA\Libresign\Service\Install;
10

11
use OC\AppConfig;
12
use OC\SystemConfig;
13
use OCA\Libresign\AppInfo\Application;
14
use OCA\Libresign\Handler\CertificateEngine\CertificateEngineFactory;
15
use OCA\Libresign\Handler\SignEngine\JSignPdfHandler;
16
use OCA\Libresign\Helper\ConfigureCheckHelper;
17
use OCA\Libresign\Helper\JavaHelper;
18
use OCP\App\IAppManager;
19
use OCP\IAppConfig;
20
use OCP\IURLGenerator;
21
use Psr\Log\LoggerInterface;
22

23
class ConfigureCheckService {
24
        private string $architecture;
25
        private bool $isCacheDisabled = false;
26
        private array $result = [];
27
        public function __construct(
28
                private IAppConfig $appConfig,
29
                private SystemConfig $systemConfig,
30
                private AppConfig $ocAppConfig,
31
                protected IAppManager $appManager,
32
                protected IURLGenerator $urlGenerator,
33
                private JSignPdfHandler $jSignPdfHandler,
34
                private CertificateEngineFactory $certificateEngineFactory,
35
                private SignSetupService $signSetupService,
36
                private LoggerInterface $logger,
37
                protected JavaHelper $javaHelper,
38
        ) {
39
                $this->architecture = php_uname('m');
7✔
40
        }
41

42
        public function disableCache(): void {
43
                $this->isCacheDisabled = true;
×
44
        }
45

46
        /**
47
         * Get result of all checks
48
         *
49
         * @return ConfigureCheckHelper[]
50
         */
51
        public function checkAll(): array {
52
                if ($this->isCacheDisabled) {
×
53
                        $this->ocAppConfig->clearCache();
×
54
                }
55
                $result = [];
×
56
                $result = array_merge($result, $this->checkSign());
×
57
                $result = array_merge($result, $this->checkCertificate());
×
58
                return $result;
×
59
        }
60

61
        /**
62
         * Check all requirements to sign
63
         *
64
         * @return ConfigureCheckHelper[]
65
         */
66
        public function checkSign(): array {
67
                $return = [];
×
68
                $return = array_merge($return, $this->checkJava());
×
69
                $return = array_merge($return, $this->checkPdftk());
×
70
                $return = array_merge($return, $this->checkJSignPdf());
×
71
                $return = array_merge($return, $this->checkPoppler());
×
72
                $return = array_merge($return, $this->checkImagick());
×
73
                return $return;
×
74
        }
75

76
        public function checkPoppler(): array {
77
                $return = $this->checkPdfSig();
×
78
                $return = array_merge($return, $this->checkPdfinfo());
×
79
                return $return;
×
80
        }
81

82
        public function checkPdfSig(): array {
83
                if (!empty($this->result['poppler'])) {
×
84
                        return $this->result['poppler'];
×
85
                }
86
                // The output of this command go to STDERR and exec get the STDOUT
87
                // With 2>&1 the STRERR is redirected to STDOUT
88
                exec('pdfsig -v 2>&1', $version, $retval);
×
89
                if ($retval !== 0) {
×
90
                        return $this->result['poppler'] = [
×
91
                                (new ConfigureCheckHelper())
×
92
                                        ->setInfoMessage('Poppler utils not installed')
×
93
                                        ->setResource('pdfsig')
×
94
                                        ->setTip('Install the package poppler-utils at your operational system to be possible get more details about validation of signatures.'),
×
95
                        ];
×
96
                }
97
                if (!$version) {
×
98
                        return $this->result['poppler'] = [
×
99
                                (new ConfigureCheckHelper())
×
100
                                        ->setErrorMessage('Fail to retrieve pdfsig version')
×
101
                                        ->setResource('pdfsig')
×
102
                                        ->setTip("The command <pdfsig -v> executed by PHP haven't any output."),
×
103
                        ];
×
104
                }
105
                $returnValue = preg_match('/pdfsig version (?<version>.*)/', implode(PHP_EOL, $version), $matches);
×
106
                if ($returnValue !== 1) {
×
107
                        return $this->result['poppler'] = [
×
108
                                (new ConfigureCheckHelper())
×
109
                                        ->setErrorMessage('Fail to retrieve pdfsig version')
×
110
                                        ->setResource('pdfsig')
×
111
                                        ->setTip("This is a poppler-utils dependency and wasn't possible to parse the output of command pdfsig -v"),
×
112
                        ];
×
113
                }
114
                return $this->result['poppler'] = [(new ConfigureCheckHelper())
×
115
                        ->setSuccessMessage('pdfsig version: ' . $matches['version'])
×
116
                        ->setResource('pdfsig')
×
117
                ];
×
118
        }
119

120
        public function checkPdfinfo(): array {
121
                if (!empty($this->result['pdfinfo'])) {
×
122
                        return $this->result['pdfinfo'];
×
123
                }
124
                // The output of this command go to STDERR and exec get the STDOUT
125
                // With 2>&1 the STRERR is redirected to STDOUT
126
                exec('pdfinfo -v 2>&1', $version, $retval);
×
127
                if ($retval !== 0) {
×
128
                        return $this->result['pdfinfo'] = [
×
129
                                (new ConfigureCheckHelper())
×
130
                                        ->setInfoMessage('Poppler utils not installed')
×
131
                                        ->setResource('pdfinfo')
×
132
                                        ->setTip('Install the package poppler-utils at your operational system have a fallback to fetch page dimensions.'),
×
133
                        ];
×
134
                }
135
                if (!$version) {
×
136
                        return $this->result['pdfinfo'] = [
×
137
                                (new ConfigureCheckHelper())
×
138
                                        ->setErrorMessage('Fail to retrieve pdfinfo version')
×
139
                                        ->setResource('pdfinfo')
×
140
                                        ->setTip("The command <pdfinfo -v> executed by PHP haven't any output."),
×
141
                        ];
×
142
                }
143
                $returnValue = preg_match('/pdfinfo version (?<version>.*)/', implode(PHP_EOL, $version), $matches);
×
144
                if (!$returnValue) {
×
145
                        return $this->result['pdfinfo'] = [
×
146
                                (new ConfigureCheckHelper())
×
147
                                        ->setErrorMessage('Fail to retrieve pdfinfo version')
×
148
                                        ->setResource('pdfinfo')
×
149
                                        ->setTip("This is a poppler-utils dependency and wasn't possible to parse the output of command pdfinfo -v"),
×
150
                        ];
×
151
                }
152
                return $this->result['pdfinfo'] = [(new ConfigureCheckHelper())
×
153
                        ->setSuccessMessage('pdfinfo version: ' . $matches['version'])
×
154
                        ->setResource('pdfinfo')
×
155
                ];
×
156
        }
157

158
        /**
159
         * Check all requirements to use JSignPdf
160
         *
161
         * @return ConfigureCheckHelper[]
162
         */
163
        public function checkJSignPdf(): array {
164
                if (!empty($this->result['jsignpdf'])) {
×
165
                        return $this->result['jsignpdf'];
×
166
                }
167

NEW
168
                $signatureEngine = $this->appConfig->getValueString(Application::APP_ID, 'signature_engine', 'jsignpdf');
×
NEW
169
                if ($signatureEngine !== 'jsignpdf') {
×
NEW
170
                        return [];
×
171
                }
172

173
                $jsignpdJarPath = $this->appConfig->getValueString(Application::APP_ID, 'jsignpdf_jar_path');
×
174
                if ($jsignpdJarPath) {
×
175
                        $resultOfVerify = $this->verify('jsignpdf');
×
176
                        if (count($resultOfVerify)) {
×
177
                                [$errorMessage, $tip] = $this->getErrorAndTipToResultOfVerify($resultOfVerify, 'jsignpdf');
×
178
                                return $this->result['jsignpdf'] = [
×
179
                                        (new ConfigureCheckHelper())
×
180
                                                ->setErrorMessage($errorMessage)
×
181
                                                ->setResource('jsignpdf')
×
182
                                                ->setTip($tip),
×
183
                                ];
×
184
                        }
185
                        if (file_exists($jsignpdJarPath)) {
×
186
                                if (!$this->isJavaOk()) {
×
187
                                        return $this->result['jsignpdf'] = [
×
188
                                                (new ConfigureCheckHelper())
×
189
                                                        ->setErrorMessage('Necessary Java to run JSignPdf')
×
190
                                                        ->setResource('jsignpdf')
×
191
                                                        ->setTip('Run occ libresign:install --java'),
×
192
                                        ];
×
193
                                }
194
                                $jsignPdf = $this->jSignPdfHandler->getJSignPdf();
×
195
                                $jsignPdf->setParam($this->jSignPdfHandler->getJSignParam());
×
196
                                $currentVersion = $jsignPdf->getVersion();
×
197
                                $return = [];
×
198
                                if ($currentVersion < InstallService::JSIGNPDF_VERSION) {
×
199
                                        if (!$currentVersion) {
×
200
                                                $message = 'Necessary install the version ' . InstallService::JSIGNPDF_VERSION;
×
201
                                        } else {
202
                                                $message = 'Necessary bump JSignPdf versin from ' . $currentVersion . ' to ' . InstallService::JSIGNPDF_VERSION;
×
203
                                        }
204
                                        $return[] = (new ConfigureCheckHelper())
×
205
                                                ->setErrorMessage($message)
×
206
                                                ->setResource('jsignpdf')
×
207
                                                ->setTip('Run occ libresign:install --jsignpdf');
×
208
                                }
209
                                if ($currentVersion > InstallService::JSIGNPDF_VERSION) {
×
210
                                        $return[] = (new ConfigureCheckHelper())
×
211
                                                ->setErrorMessage('Necessary downgrade JSignPdf versin from ' . $currentVersion . ' to ' . InstallService::JSIGNPDF_VERSION)
×
212
                                                ->setResource('jsignpdf')
×
213
                                                ->setTip('Run occ libresign:install --jsignpdf');
×
214
                                }
215
                                $return[] = (new ConfigureCheckHelper())
×
216
                                        ->setSuccessMessage('JSignPdf version: ' . $currentVersion)
×
217
                                        ->setResource('jsignpdf');
×
218
                                $return[] = (new ConfigureCheckHelper())
×
219
                                        ->setSuccessMessage('JSignPdf path: ' . $jsignpdJarPath)
×
220
                                        ->setResource('jsignpdf');
×
221
                                return $return;
×
222
                        }
223
                        return $this->result['jsignpdf'] = [
×
224
                                (new ConfigureCheckHelper())
×
225
                                        ->setErrorMessage('JSignPdf binary not found: ' . $jsignpdJarPath)
×
226
                                        ->setResource('jsignpdf')
×
227
                                        ->setTip('Run occ libresign:install --jsignpdf'),
×
228
                        ];
×
229
                }
230
                return $this->result['jsignpdf'] = [
×
231
                        (new ConfigureCheckHelper())
×
232
                                ->setErrorMessage('JSignPdf not found')
×
233
                                ->setResource('jsignpdf')
×
234
                                ->setTip('Run occ libresign:install --jsignpdf'),
×
235
                ];
×
236
        }
237

238
        /**
239
         * Check all requirements to use PDFtk
240
         *
241
         * @return ConfigureCheckHelper[]
242
         */
243
        public function checkPdftk(): array {
244
                if (!empty($this->result['pdftk'])) {
×
245
                        return $this->result['pdftk'];
×
246
                }
247
                $pdftkPath = $this->appConfig->getValueString(Application::APP_ID, 'pdftk_path');
×
248
                if ($pdftkPath) {
×
249
                        $resultOfVerify = $this->verify('pdftk');
×
250
                        if (count($resultOfVerify)) {
×
251
                                [$errorMessage, $tip] = $this->getErrorAndTipToResultOfVerify($resultOfVerify, 'pdftk');
×
252
                                return $this->result['pdftk'] = [
×
253
                                        (new ConfigureCheckHelper())
×
254
                                                ->setErrorMessage($errorMessage)
×
255
                                                ->setResource('pdftk')
×
256
                                                ->setTip($tip),
×
257
                                ];
×
258
                        }
259
                        if (file_exists($pdftkPath)) {
×
260
                                if (!$this->isJavaOk()) {
×
261
                                        return $this->result['pdftk'] = [
×
262
                                                (new ConfigureCheckHelper())
×
263
                                                        ->setErrorMessage('Necessary Java to run PDFtk')
×
264
                                                        ->setResource('jsignpdf')
×
265
                                                        ->setTip('Run occ libresign:install --java'),
×
266
                                        ];
×
267
                                }
268
                                $javaPath = $this->javaHelper->getJavaPath();
×
269
                                $version = [];
×
270
                                \exec($javaPath . ' -jar ' . $pdftkPath . ' --version 2>&1', $version, $resultCode);
×
271
                                if ($resultCode !== 0) {
×
272
                                        return $this->result['pdftk'] = [
×
273
                                                (new ConfigureCheckHelper())
×
274
                                                        ->setErrorMessage('Failure to check PDFtk version.')
×
275
                                                        ->setResource('java')
×
276
                                                        ->setTip('Run occ libresign:install --pdftk'),
×
277
                                        ];
×
278
                                }
279
                                if (isset($version[0])) {
×
280
                                        preg_match('/pdftk port to java (?<version>.*) a Handy Tool/', $version[0], $matches);
×
281
                                        if (isset($matches['version'])) {
×
282
                                                if ($matches['version'] === InstallService::PDFTK_VERSION) {
×
283
                                                        return $this->result['pdftk'] = [
×
284
                                                                $this->result['pdftk'][] = (new ConfigureCheckHelper())
×
285
                                                                        ->setSuccessMessage('PDFtk version: ' . InstallService::PDFTK_VERSION)
×
286
                                                                        ->setResource('pdftk'),
×
287
                                                                $this->result['pdftk'][] = (new ConfigureCheckHelper())
×
288
                                                                        ->setSuccessMessage('PDFtk path: ' . $pdftkPath)
×
289
                                                                        ->setResource('pdftk'),
×
290
                                                        ];
×
291
                                                }
292
                                                $message = 'Necessary install the version ' . InstallService::PDFTK_VERSION;
×
293
                                                return $this->result['pdftk'] = [
×
294
                                                        (new ConfigureCheckHelper())
×
295
                                                                ->setErrorMessage($message)
×
296
                                                                ->setResource('jsignpdf')
×
297
                                                                ->setTip('Run occ libresign:install --jsignpdf')
×
298
                                                ];
×
299
                                        }
300
                                }
301
                                return $this->result['pdftk'] = [
×
302
                                        (new ConfigureCheckHelper())
×
303
                                                ->setErrorMessage('PDFtk binary is invalid: ' . $pdftkPath)
×
304
                                                ->setResource('pdftk')
×
305
                                                ->setTip('Run occ libresign:install --pdftk'),
×
306
                                ];
×
307
                        }
308
                        return $this->result['pdftk'] = [
×
309
                                (new ConfigureCheckHelper())
×
310
                                        ->setErrorMessage('PDFtk binary not found: ' . $pdftkPath)
×
311
                                        ->setResource('pdftk')
×
312
                                        ->setTip('Run occ libresign:install --pdftk'),
×
313
                        ];
×
314
                }
315
                return $this->result['pdftk'] = [
×
316
                        (new ConfigureCheckHelper())
×
317
                                ->setErrorMessage('PDFtk not found')
×
318
                                ->setResource('pdftk')
×
319
                                ->setTip('Run occ libresign:install --pdftk'),
×
320
                ];
×
321
        }
322

323
        public function isDebugEnabled(): bool {
324
                return $this->systemConfig->getValue('debug', false) === true;
×
325
        }
326

327
        private function verify(string $resource): array {
328
                $this->signSetupService->willUseLocalCert($this->isDebugEnabled());
×
329
                $result = $this->signSetupService->verify($this->architecture, $resource);
×
330
                if (count($result) === 1 && $this->isDebugEnabled()) {
×
331
                        if (isset($result['SIGNATURE_DATA_NOT_FOUND'])) {
×
332
                                return [];
×
333
                        }
334
                        if (isset($result['EMPTY_SIGNATURE_DATA'])) {
×
335
                                return [];
×
336
                        }
337
                }
338
                return $result;
×
339
        }
340

341
        private function getErrorAndTipToResultOfVerify(array $result, string $resource): array {
342
                if (count($result) === 1 && !$this->isDebugEnabled()) {
×
343
                        if (isset($result['SIGNATURE_DATA_NOT_FOUND'])) {
×
344
                                return [
×
345
                                        'Signature data not found.',
×
346
                                        "Sounds that you are running from source code of LibreSign.\nEnable debug mode by: occ config:system:set debug --value true --type boolean",
×
347
                                ];
×
348
                        }
349
                        if (isset($result['EMPTY_SIGNATURE_DATA'])) {
×
350
                                return [
×
351
                                        'Your signature data is empty.',
×
352
                                        "Sounds that you are running from source code of LibreSign.\nEnable debug mode by: occ config:system:set debug --value true --type boolean",
×
353
                                ];
×
354
                        }
355
                }
356
                if (isset($result['HASH_FILE_ERROR'])) {
×
357
                        if ($this->isDebugEnabled()) {
×
358
                                return [
×
359
                                        'Invalid hash of binaries files.',
×
360
                                        'Debug mode is enabled at your config.php and your LibreSign app was signed using a production signature. If you are not working at development of LibreSign, disable your debug mode or run the command: occ libresign install --' . $resource . ' --use-local-cert',
×
361
                                ];
×
362
                        }
363
                }
364
                $this->logger->error('Invalid hash of binaries files', ['result' => $result]);
×
365
                if ($this->appManager->isEnabledForUser('logreader')) {
×
366
                        return [
×
367
                                'Invalid hash of binaries files.',
×
368
                                'Check your nextcloud.log file on '
×
369
                                . $this->urlGenerator->linkToRouteAbsolute('settings.adminsettings.form', ['section' => 'logging'])
×
370
                                . ' and run occ libresign:install --all',
×
371
                        ];
×
372
                }
373
                return [
×
374
                        'Invalid hash of binaries files.',
×
375
                        'Check your nextcloud.log file and run occ libresign:install --all',
×
376
                ];
×
377
        }
378

379
        /**
380
         * Check all requirements to use Java
381
         *
382
         * @return ConfigureCheckHelper[]
383
         */
384
        private function checkJava(): array {
385
                if (!empty($this->result['java'])) {
×
386
                        return $this->result['java'];
×
387
                }
388

NEW
389
                $signatureEngine = $this->appConfig->getValueString(Application::APP_ID, 'signature_engine', 'jsignpdf');
×
NEW
390
                if ($signatureEngine !== 'jsignpdf') {
×
NEW
391
                        return [];
×
392
                }
393

394
                $javaPath = $this->javaHelper->getJavaPath();
×
395
                if ($javaPath) {
×
396
                        $resultOfVerify = $this->verify('java');
×
397
                        if (count($resultOfVerify)) {
×
398
                                [$errorMessage, $tip] = $this->getErrorAndTipToResultOfVerify($resultOfVerify, 'java');
×
399
                                return $this->result['java'] = [
×
400
                                        (new ConfigureCheckHelper())
×
401
                                                ->setErrorMessage($errorMessage)
×
402
                                                ->setResource('java')
×
403
                                                ->setTip($tip),
×
404
                                ];
×
405
                        }
406
                        if (file_exists($javaPath)) {
×
407
                                \exec($javaPath . ' -version 2>&1', $javaVersion, $resultCode);
×
408
                                if (empty($javaVersion)) {
×
409
                                        return $this->result['java'] = [
×
410
                                                (new ConfigureCheckHelper())
×
411
                                                        ->setErrorMessage(
×
412
                                                                'Failed to execute Java. Sounds that your operational system is blocking the JVM.'
×
413
                                                        )
×
414
                                                        ->setResource('java')
×
415
                                                        ->setTip('https://github.com/LibreSign/libresign/issues/2327#issuecomment-1961988790'),
×
416
                                        ];
×
417
                                }
418
                                if ($resultCode !== 0) {
×
419
                                        return $this->result['java'] = [
×
420
                                                (new ConfigureCheckHelper())
×
421
                                                        ->setErrorMessage('Failure to check Java version.')
×
422
                                                        ->setResource('java')
×
423
                                                        ->setTip('Run occ libresign:install --java'),
×
424
                                        ];
×
425
                                }
426
                                $javaVersion = current($javaVersion);
×
427
                                if ($javaVersion !== InstallService::JAVA_VERSION) {
×
428
                                        return $this->result['java'] = [
×
429
                                                (new ConfigureCheckHelper())
×
430
                                                        ->setErrorMessage(
×
431
                                                                sprintf(
×
432
                                                                        'Invalid java version. Found: %s expected: %s',
×
433
                                                                        $javaVersion,
×
434
                                                                        InstallService::JAVA_VERSION
×
435
                                                                )
×
436
                                                        )
×
437
                                                        ->setResource('java')
×
438
                                                        ->setTip('Run occ libresign:install --java'),
×
439
                                        ];
×
440
                                }
441
                                \exec($javaPath . ' -XshowSettings:properties -version 2>&1', $output, $resultCode);
×
442
                                preg_match('/native.encoding = (?<encoding>.*)\n/', implode("\n", $output), $matches);
×
443
                                if (!isset($matches['encoding'])) {
×
444
                                        return $this->result['java'] = [
×
445
                                                (new ConfigureCheckHelper())
×
446
                                                        ->setErrorMessage('Java encoding not found.')
×
447
                                                        ->setResource('java')
×
448
                                                        ->setTip(sprintf('The command %s need to have native.encoding', $javaPath . ' -XshowSettings:properties -version')),
×
449
                                        ];
×
450
                                }
451
                                if (!str_contains($matches['encoding'], 'UTF-8')) {
×
452
                                        $detectedEncoding = trim($matches['encoding']);
×
453
                                        $phpLocale = setlocale(LC_CTYPE, 0);
×
454
                                        $phpLcAll = getenv('LC_ALL');
×
455
                                        $phpLang = getenv('LANG');
×
456

457
                                        $tip = sprintf(
×
458
                                                "Java detected encoding \"%s\" but UTF-8 is required.\n\n"
×
459
                                                . "**Current PHP environment:**\n"
×
460
                                                . "- LC_CTYPE: %s\n"
×
461
                                                . "- LC_ALL: %s\n"
×
462
                                                . "- LANG: %s\n\n"
×
463
                                                . "**To fix this issue:**\n"
×
464
                                                . "1. Set LC_ALL and LANG environment variables (e.g., LC_ALL=en_US.UTF-8) for your web server user\n"
×
465
                                                . "2. Restart your web server after making changes\n"
×
466
                                                . "3. Verify with command: `locale charmap` (should return UTF-8)\n\n"
×
467
                                                . 'For more details, see: [Issue #4872](https://github.com/LibreSign/libresign/issues/4872)',
×
468
                                                $detectedEncoding,
×
469
                                                $phpLocale ?: 'not set',
×
470
                                                $phpLcAll ?: 'not set',
×
471
                                                $phpLang ?: 'not set'
×
472
                                        );
×
473
                                        return $this->result['java'] = [
×
474
                                                (new ConfigureCheckHelper())
×
475
                                                        ->setInfoMessage(sprintf(
×
476
                                                                'Non-UTF-8 encoding detected: %s. This may cause issues with accented or special characters',
×
477
                                                                $detectedEncoding
×
478
                                                        ))
×
479
                                                        ->setResource('java')
×
480
                                                        ->setTip($tip),
×
481
                                        ];
×
482
                                }
483
                                return $this->result['java'] = [
×
484
                                        (new ConfigureCheckHelper())
×
485
                                                ->setSuccessMessage('Java version: ' . $javaVersion)
×
486
                                                ->setResource('java'),
×
487
                                        (new ConfigureCheckHelper())
×
488
                                                ->setSuccessMessage('Java binary: ' . $javaPath)
×
489
                                                ->setResource('java'),
×
490
                                ];
×
491
                        }
492
                        return $this->result['java'] = [
×
493
                                (new ConfigureCheckHelper())
×
494
                                        ->setErrorMessage('Java binary not found: ' . $javaPath)
×
495
                                        ->setResource('java')
×
496
                                        ->setTip('Run occ libresign:install --java'),
×
497
                        ];
×
498
                }
499
                return $this->result['java'] = [
×
500
                        (new ConfigureCheckHelper())
×
501
                                ->setErrorMessage('Java not installed')
×
502
                                ->setResource('java')
×
503
                                ->setTip('Run occ libresign:install --java'),
×
504
                ];
×
505
        }
506

507
        private function isJavaOk() : bool {
508
                $checkJava = $this->checkJava();
×
509
                $error = array_filter(
×
510
                        $checkJava,
×
511
                        fn (ConfigureCheckHelper $config) => $config->getStatus() === 'error'
×
512
                );
×
513
                return empty($error);
×
514
        }
515

516

517
        /**
518
         * Check all requirements to use certificate
519
         *
520
         * @return ConfigureCheckHelper[]
521
         */
522
        public function checkCertificate(): array {
523
                try {
524
                        $return = $this->certificateEngineFactory->getEngine()->configureCheck();
×
525
                } catch (\Throwable) {
×
526
                        $return = [
×
527
                                (new ConfigureCheckHelper())
×
528
                                        ->setErrorMessage('Define the certificate engine to use')
×
529
                                        ->setResource('certificate-engine')
×
530
                                        ->setTip(sprintf('Run occ libresign:configure:%s --help',
×
531
                                                $this->certificateEngineFactory->getEngine()->getName()
×
532
                                        )),
×
533
                        ];
×
534
                }
535
                return $return;
×
536
        }
537

538
        /**
539
         * Check if Imagick extension is loaded
540
         *
541
         * @return ConfigureCheckHelper[]
542
         */
543
        public function checkImagick(): array {
544
                if (!empty($this->result['imagick'])) {
2✔
545
                        return $this->result['imagick'];
×
546
                }
547
                if (!extension_loaded('imagick')) {
2✔
548
                        return $this->result['imagick'] = [
1✔
549
                                (new ConfigureCheckHelper())
1✔
550
                                        ->setInfoMessage('Imagick extension is not loaded')
1✔
551
                                        ->setResource('imagick')
1✔
552
                                        ->setTip('Install php-imagick to enable visible signatures, background images, and signature element rendering.'),
1✔
553
                        ];
1✔
554
                }
555
                return $this->result['imagick'] = [];
1✔
556
        }
557
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc