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

LibreSign / libresign / 22879968752

09 Mar 2026 11:41PM UTC coverage: 54.172%. First build
22879968752

Pull #7234

github

web-flow
Merge 36ebad0b2 into f13d63039
Pull Request #7234: chore: migration to vue3

1 of 16 new or added lines in 2 files covered. (6.25%)

9868 of 18216 relevant lines covered (54.17%)

6.38 hits per line

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

4.55
/lib/Settings/Admin.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\Settings;
10

11
use OCA\Libresign\AppInfo\Application;
12
use OCA\Libresign\Exception\LibresignException;
13
use OCA\Libresign\Handler\CertificateEngine\CertificateEngineFactory;
14
use OCA\Libresign\Service\CertificatePolicyService;
15
use OCA\Libresign\Service\DocMdp\ConfigService as DocMdpConfigService;
16
use OCA\Libresign\Service\FooterService;
17
use OCA\Libresign\Service\IdentifyMethodService;
18
use OCA\Libresign\Service\SignatureBackgroundService;
19
use OCA\Libresign\Service\SignatureTextService;
20
use OCP\AppFramework\Http\TemplateResponse;
21
use OCP\AppFramework\Services\IInitialState;
22
use OCP\IAppConfig;
23
use OCP\Settings\ISettings;
24
use OCP\Util;
25

26
/**
27
 * @psalm-import-type LibresignAdminSignatureEngine from \OCA\Libresign\ResponseDefinitions
28
 * @psalm-import-type LibresignAdminSigningMode from \OCA\Libresign\ResponseDefinitions
29
 * @psalm-import-type LibresignAdminWorkerType from \OCA\Libresign\ResponseDefinitions
30
 */
31
class Admin implements ISettings {
32
        public const PASSWORD_PLACEHOLDER = '••••••••';
33

34
        public function __construct(
35
                private IInitialState $initialState,
36
                private IdentifyMethodService $identifyMethodService,
37
                private CertificateEngineFactory $certificateEngineFactory,
38
                private CertificatePolicyService $certificatePolicyService,
39
                private IAppConfig $appConfig,
40
                private SignatureTextService $signatureTextService,
41
                private SignatureBackgroundService $signatureBackgroundService,
42
                private FooterService $footerService,
43
                private DocMdpConfigService $docMdpConfigService,
44
        ) {
45
        }
2✔
46
        #[\Override]
47
        public function getForm(): TemplateResponse {
48
                Util::addScript(Application::APP_ID, 'libresign-settings');
×
49
                Util::addStyle(Application::APP_ID, 'libresign-settings');
×
50
                try {
51
                        $signatureParsed = $this->signatureTextService->parse();
×
52
                        $this->initialState->provideInitialState('signature_text_parsed', $signatureParsed['parsed']);
×
53
                } catch (LibresignException $e) {
×
54
                        $this->initialState->provideInitialState('signature_text_parsed', '');
×
55
                        $this->initialState->provideInitialState('signature_text_template_error', $e->getMessage());
×
56
                }
57
                $this->initialState->provideInitialState('certificate_engine', $this->certificateEngineFactory->getEngine()->getName());
×
58
                $this->initialState->provideInitialState('certificate_policies_oid', $this->certificatePolicyService->getOid());
×
59
                $this->initialState->provideInitialState('certificate_policies_cps', $this->certificatePolicyService->getCps());
×
60
                $this->initialState->provideInitialState('config_path', $this->appConfig->getValueString(Application::APP_ID, 'config_path'));
×
61
                $this->initialState->provideInitialState('default_signature_font_size', SignatureTextService::SIGNATURE_DEFAULT_FONT_SIZE);
×
62
                $this->initialState->provideInitialState('default_signature_height', SignatureTextService::DEFAULT_SIGNATURE_HEIGHT);
×
63
                $this->initialState->provideInitialState('default_signature_text_template', $this->signatureTextService->getDefaultTemplate());
×
64
                $this->initialState->provideInitialState('default_signature_width', SignatureTextService::DEFAULT_SIGNATURE_WIDTH);
×
65
                $this->initialState->provideInitialState('default_template_font_size', $this->signatureTextService->getDefaultTemplateFontSize());
×
66
                $this->initialState->provideInitialState('identify_methods', $this->identifyMethodService->getIdentifyMethodsSettings());
×
67
                $this->initialState->provideInitialState('legal_information', $this->appConfig->getValueString(Application::APP_ID, 'legal_information', ''));
×
68
                $this->initialState->provideInitialState('signature_available_variables', $this->signatureTextService->getAvailableVariables());
×
69
                $this->initialState->provideInitialState('signature_background_type', $this->signatureBackgroundService->getSignatureBackgroundType());
×
70
                $this->initialState->provideInitialState('signature_font_size', $this->signatureTextService->getSignatureFontSize());
×
71
                $this->initialState->provideInitialState('signature_height', $this->signatureTextService->getFullSignatureHeight());
×
72
                $this->initialState->provideInitialState('signature_preview_zoom_level', $this->appConfig->getValueFloat(Application::APP_ID, 'signature_preview_zoom_level', 100));
×
73
                $this->initialState->provideInitialState('footer_preview_zoom_level', $this->appConfig->getValueFloat(Application::APP_ID, 'footer_preview_zoom_level', 100));
×
74
                $this->initialState->provideInitialState('footer_preview_width', $this->appConfig->getValueInt(Application::APP_ID, 'footer_preview_width', 595));
×
75
                $this->initialState->provideInitialState('footer_preview_height', $this->appConfig->getValueInt(Application::APP_ID, 'footer_preview_height', 100));
×
76
                $this->initialState->provideInitialState('footer_template_variables', $this->footerService->getTemplateVariablesMetadata());
×
77
                $this->initialState->provideInitialState('footer_template', $this->footerService->getTemplate());
×
78
                $this->initialState->provideInitialState('footer_template_is_default', $this->footerService->isDefaultTemplate());
×
NEW
79
                $this->initialState->provideInitialState('signature_engine', $this->getSignatureEngineInitialState());
×
80
                $this->initialState->provideInitialState('signature_render_mode', $this->signatureTextService->getRenderMode());
×
81
                $this->initialState->provideInitialState('signature_text_template', $this->signatureTextService->getTemplate());
×
82
                $this->initialState->provideInitialState('signature_width', $this->signatureTextService->getFullSignatureWidth());
×
83
                $this->initialState->provideInitialState('template_font_size', $this->signatureTextService->getTemplateFontSize());
×
84
                $this->initialState->provideInitialState('tsa_url', $this->appConfig->getValueString(Application::APP_ID, 'tsa_url', ''));
×
85
                $this->initialState->provideInitialState('tsa_policy_oid', $this->appConfig->getValueString(Application::APP_ID, 'tsa_policy_oid', ''));
×
86
                $this->initialState->provideInitialState('tsa_auth_type', $this->appConfig->getValueString(Application::APP_ID, 'tsa_auth_type', 'none'));
×
87
                $this->initialState->provideInitialState('tsa_username', $this->appConfig->getValueString(Application::APP_ID, 'tsa_username', ''));
×
88
                $this->initialState->provideInitialState('tsa_password', $this->appConfig->getValueString(Application::APP_ID, 'tsa_password', self::PASSWORD_PLACEHOLDER));
×
89
                $this->initialState->provideInitialState('docmdp_config', $this->docMdpConfigService->getConfig());
×
90
                $this->initialState->provideInitialState('signature_flow', $this->appConfig->getValueString(Application::APP_ID, 'signature_flow', \OCA\Libresign\Enum\SignatureFlow::NONE->value));
×
NEW
91
                $this->initialState->provideInitialState('signing_mode', $this->getSigningModeInitialState());
×
NEW
92
                $this->initialState->provideInitialState('worker_type', $this->getWorkerTypeInitialState());
×
93
                $this->initialState->provideInitialState('identification_documents', $this->appConfig->getValueBool(Application::APP_ID, 'identification_documents', false));
×
94
                $this->initialState->provideInitialState('approval_group', $this->appConfig->getValueArray(Application::APP_ID, 'approval_group', ['admin']));
×
95
                $this->initialState->provideInitialState('envelope_enabled', $this->appConfig->getValueBool(Application::APP_ID, 'envelope_enabled', true));
×
96
                $this->initialState->provideInitialState('parallel_workers', $this->appConfig->getValueString(Application::APP_ID, 'parallel_workers', '4'));
×
97
                $this->initialState->provideInitialState('show_confetti_after_signing', $this->appConfig->getValueBool(Application::APP_ID, 'show_confetti_after_signing', true));
×
98
                $this->initialState->provideInitialState('crl_external_validation_enabled', $this->appConfig->getValueBool(Application::APP_ID, 'crl_external_validation_enabled', true));
×
99
                $this->initialState->provideInitialState('ldap_extension_available', function_exists('ldap_connect'));
×
100
                return new TemplateResponse(Application::APP_ID, 'admin_settings');
×
101
        }
102

103
        /**
104
         * @psalm-return 'libresign'
105
         */
106
        #[\Override]
107
        public function getSection(): string {
108
                return Application::APP_ID;
1✔
109
        }
110

111
        /**
112
         * @psalm-return 100
113
         */
114
        #[\Override]
115
        public function getPriority(): int {
116
                return 100;
1✔
117
        }
118

119
        /** @return LibresignAdminSignatureEngine */
120
        private function getSignatureEngineInitialState(): string {
NEW
121
                $engine = $this->appConfig->getValueString(Application::APP_ID, 'signature_engine', 'JSignPdf');
×
NEW
122
                if ($engine === 'PhpNative') {
×
NEW
123
                        return $engine;
×
124
                }
NEW
125
                return 'JSignPdf';
×
126
        }
127

128
        /** @return LibresignAdminSigningMode */
129
        private function getSigningModeInitialState(): string {
NEW
130
                $mode = $this->appConfig->getValueString(Application::APP_ID, 'signing_mode', 'sync');
×
NEW
131
                if ($mode === 'async') {
×
NEW
132
                        return $mode;
×
133
                }
NEW
134
                return 'sync';
×
135
        }
136

137
        /** @return LibresignAdminWorkerType */
138
        private function getWorkerTypeInitialState(): string {
NEW
139
                $workerType = $this->appConfig->getValueString(Application::APP_ID, 'worker_type', 'local');
×
NEW
140
                if ($workerType === 'external') {
×
NEW
141
                        return $workerType;
×
142
                }
NEW
143
                return 'local';
×
144
        }
145
}
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