KHealthCertificate

ktestcertificate.cpp
1 /*
2  * SPDX-FileCopyrightText: 2021 Volker Krause <[email protected]>
3  * SPDX-License-Identifier: LGPL-2.0-or-later
4  */
5 
6 #include "ktestcertificate.h"
7 #include "khealthcertificatetypes_p.h"
8 
9 class KTestCertificatePrivate : public QSharedData
10 {
11 public:
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;
23  QString certificateIssuer;
24  QString certificateId;
25  QDateTime certificateIssueDate;
26  QDateTime certificateExpiryDate;
27  QByteArray rawData;
29 };
30 
31 KHEALTHCERTIFICATE_MAKE_GADGET(Test)
32 KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QString, name, setName)
33 KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QDate, dateOfBirth, setDateOfBirth)
34 KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QDate, date, setDate)
35 KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QString, disease, setDisease)
36 KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QString, testType, setTestType)
37 KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QString, testName, setTestName)
38 KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QUrl, testUrl, setTestUrl)
39 KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, KTestCertificate::Result, result, setResult)
40 KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QString, resultString, setResultString)
41 KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QString, testCenter, setTestCenter)
42 KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QString, country, setCountry)
43 KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QString, certificateIssuer, setCertificateIssuer)
44 KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QString, certificateId, setCertificateId)
45 KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QDateTime, certificateIssueDate, setCertificateIssueDate)
46 KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QDateTime, certificateExpiryDate, setCertificateExpiryDate)
47 KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, QByteArray, rawData, setRawData)
48 KHEALTHCERTIFICATE_MAKE_PROPERTY(Test, KHealthCertificate::SignatureValidation, signatureState, setSignatureState)
49 
50 KHealthCertificate::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) {
56  return KHealthCertificate::Invalid;
57  }
58  if (d->result == Positive) {
59  return KHealthCertificate::Invalid;
60  }
61 
62  if (d->date.addDays(2) < QDate::currentDate()) {
63  return KHealthCertificate::Invalid;
64  }
65  if (d->signatureState == KHealthCertificate::UnknownSignature) {
66  return KHealthCertificate::Partial;
67  }
68 
69  return d->result == Negative ? KHealthCertificate::Valid : KHealthCertificate::Unknown;
70 }
71 
72 #include "moc_ktestcertificate.moc"
QStringView country(QStringView ifopt)
Dummy RTTI for QML, which doesn&#39;t support instanceof on Q_GADGETs...
QString name(const QVariant &location)
SignatureValidation
Result of attempting to verify the cryptographic signature of a certificate.
signature verification was attempted but didn&#39;t yield a result, e.g. due to a missing certificate of ...
A test certificate.
QDateTime currentDateTime()
QDate currentDate()
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Oct 18 2021 23:21:56 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.