KHealthCertificate

ktestcertificate.cpp
1/*
2 * SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
3 * SPDX-License-Identifier: LGPL-2.0-or-later
4 */
5
6#include "ktestcertificate.h"
7#include "khealthcertificatetypes_p.h"
8
9class KTestCertificatePrivate : public QSharedData
10{
11public:
12 QString name;
13 QDate dateOfBirth;
14 QDate date;
15 QString disease;
16 QString testType;
17 QString testName;
18 QUrl testUrl;
19 KTestCertificate::Result result = KTestCertificate::Unknown;
20 QString resultString;
21 QString testCenter;
22 QString country;
23 QString certificateIssuer;
24 QString certificateId;
25 QDateTime certificateIssueDate;
26 QDateTime certificateExpiryDate;
27 QByteArray rawData;
29};
30
31KHEALTHCERTIFICATE_MAKE_GADGET(Test)
32KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QString, name, setName)
33KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QDate, dateOfBirth, setDateOfBirth)
34KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QDate, date, setDate)
35KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QString, disease, setDisease)
36KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QString, testType, setTestType)
37KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QString, testName, setTestName)
38KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QUrl, testUrl, setTestUrl)
39KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, KTestCertificate::Result, result, setResult)
40KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QString, resultString, setResultString)
41KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QString, testCenter, setTestCenter)
42KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QString, country, setCountry)
43KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QString, certificateIssuer, setCertificateIssuer)
44KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QString, certificateId, setCertificateId)
45KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QDateTime, certificateIssueDate, setCertificateIssueDate)
46KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QDateTime, certificateExpiryDate, setCertificateExpiryDate)
47KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QByteArray, rawData, setRawData)
48KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, KHealthCertificate::SignatureValidation, signatureState, setSignatureState)
49
50KHealthCertificate::CertificateValidation KTestCertificate::validationState() const
51{
52 if (d->certificateIssueDate > QDateTime::currentDateTime() || (d->certificateExpiryDate.isValid() && d->certificateExpiryDate < QDateTime::currentDateTime())) {
53 return KHealthCertificate::Invalid;
54 }
55 if (d->signatureState == KHealthCertificate::InvalidSignature || d->result == Unknown) {
56 return KHealthCertificate::Invalid;
57 }
58
59 if (d->result == Positive || !isCurrent()) {
60 return KHealthCertificate::Partial;
61 }
62 if (d->signatureState == KHealthCertificate::UnknownSignature) {
63 return KHealthCertificate::Partial;
64 }
65
66 return KHealthCertificate::Valid;
67}
68
70{
71 return d->date.addDays(2) >= QDate::currentDate();
72}
73
74#include "moc_ktestcertificate.moc"
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 test certificate.
bool isCurrent
Indicates whether the result is still current.
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.