Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
CertificateValidityPolicy
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
1 / 1
 getLeafExpiryDays
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2
3declare(strict_types=1);
4/**
5 * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
6 * SPDX-License-Identifier: AGPL-3.0-or-later
7 */
8
9namespace OCA\Libresign\Service;
10
11use OCA\Libresign\Service\IdentifyMethod\SignatureMethod\ISignatureMethod;
12
13class CertificateValidityPolicy {
14    private const int CLICK_TO_SIGN_CERT_VALIDITY_DAYS = 1;
15
16    public function getLeafExpiryDays(?string $signatureMethodName, bool $signWithoutPassword): ?int {
17        if (!$signWithoutPassword) {
18            return null;
19        }
20        if ($signatureMethodName === ISignatureMethod::SIGNATURE_METHOD_CLICK_TO_SIGN) {
21            return self::CLICK_TO_SIGN_CERT_VALIDITY_DAYS;
22        }
23        return null;
24    }
25}