KHealthCertificate

krecoverycertificate.cpp
1/*
2 * SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
3 * SPDX-License-Identifier: LGPL-2.0-or-later
4 */
5
6#include "krecoverycertificate.h"
7#include "khealthcertificatetypes_p.h"
8
9class KRecoveryCertificatePrivate : public QSharedData
10{
11public:
12 QString name;
13 QDate dateOfBirth;
14 QDate dateOfPositiveTest;
15 QDate validFrom;
16 QDate validUntil;
17 QString disease;
18 QString certificateIssuer;
19 QString certificateId;
20 QDateTime certificateIssueDate;
21 QDateTime certificateExpiryDate;
22 QByteArray rawData;
24};
25
26KHEALTHCERTIFICATE_MAKE_GADGET(Recovery)
27KHEALTHCERTIFICATE_MAKE_PROPERTY(Recovery, QString, name, setName)
28KHEALTHCERTIFICATE_MAKE_PROPERTY(Recovery, QDate, dateOfBirth, setDateOfBirth)
29KHEALTHCERTIFICATE_MAKE_PROPERTY(Recovery, QDate, dateOfPositiveTest, setDateOfPositiveTest)
30KHEALTHCERTIFICATE_MAKE_PROPERTY(Recovery, QDate, validFrom, setValidFrom)
31KHEALTHCERTIFICATE_MAKE_PROPERTY(Recovery, QDate, validUntil, setValidUntil)
32KHEALTHCERTIFICATE_MAKE_PROPERTY(Recovery, QString, disease, setDisease)
33KHEALTHCERTIFICATE_MAKE_PROPERTY(Recovery, QString, certificateId, setCertificateId)
34KHEALTHCERTIFICATE_MAKE_PROPERTY(Recovery, QString, certificateIssuer, setCertificateIssuer)
35KHEALTHCERTIFICATE_MAKE_PROPERTY(Recovery, QDateTime, certificateIssueDate, setCertificateIssueDate)
36KHEALTHCERTIFICATE_MAKE_PROPERTY(Recovery, QDateTime, certificateExpiryDate, setCertificateExpiryDate)
37KHEALTHCERTIFICATE_MAKE_PROPERTY(Recovery, QByteArray, rawData, setRawData)
38KHEALTHCERTIFICATE_MAKE_PROPERTY(Recovery, KHealthCertificate::SignatureValidation, signatureState, setSignatureState)
39
40KHealthCertificate::CertificateValidation KRecoveryCertificate::validationState() const
41{
42 if (d->certificateIssueDate > QDateTime::currentDateTime() || (d->certificateExpiryDate.isValid() && d->certificateExpiryDate < QDateTime::currentDateTime())) {
43 return KHealthCertificate::Invalid;
44 }
45 if (d->signatureState == KHealthCertificate::InvalidSignature) {
46 return KHealthCertificate::Invalid;
47 }
48
49 if (d->signatureState == KHealthCertificate::UnknownSignature) {
50 return KHealthCertificate::Partial;
51 }
52
53 const auto today = QDate::currentDate();
54 if (d->validFrom.isValid() && d->validFrom > today) {
55 return KHealthCertificate::Invalid;
56 }
57 if (d->validUntil.isValid() && d->validUntil < today) {
58 return KHealthCertificate::Invalid;
59 }
60
61 if (d->validFrom.isValid() && d->validFrom <= today && d->validUntil.isValid() && d->validUntil >= today) {
62 return KHealthCertificate::Valid;
63 }
64
65 return KHealthCertificate::Unknown;
66}
67
68#include "moc_krecoverycertificate.cpp"
Dummy RTTI for QML, which doesn't support instanceof on Q_GADGETs...
SignatureValidation
Result of attempting to verify the cryptographic signature of a certificate.
@ InvalidSignature
signature is invalid
@ UnknownSignature
signature verification was attempted but didn't yield a result, e.g. due to a missing certificate of ...
A recovery certificate.
QDate currentDate()
QDateTime currentDateTime()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:52 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.