AusweisApp
Lade ...
Suche ...
Keine Treffer
IfdMessage.h
gehe zur Dokumentation dieser Datei
1
5#pragma once
6
7#include "EnumHelper.h"
8#include "IfdVersion.h"
9
10#include <QJsonDocument>
11#include <QJsonObject>
12#include <QString>
13
14
15#define VALUE_NAME(_name, _key)\
16 inline QLatin1String _name(){\
17 return QLatin1String(_key);\
18 }
19
20
21namespace governikus
22{
42
43
44class IfdMessage
45{
46 private:
47 bool mIncomplete;
48 IfdMessageType mMessageType;
49 QString mContextHandle;
50
51 protected:
52 [[nodiscard]] virtual QJsonObject createMessageBody(const QString& pContextHandle) const;
53 static QByteArray toByteArray(const QJsonObject& pJsonObject);
54
55 void ensureType(IfdMessageType pType);
56 void markIncomplete(const QString& pLogMessage);
57 void missingValue(const QLatin1String& pName);
58 void invalidType(const QLatin1String& pName, const QLatin1String& pExpectedType);
59 bool getBoolValue(const QJsonObject& pJsonObject, const QLatin1String& pName);
60 int getIntValue(const QJsonObject& pJsonObject, const QLatin1String& pName, int pDefault);
61 QString getStringValue(const QJsonObject& pJsonObject, const QLatin1String& pName);
62
63 public:
64 static QJsonObject parseByteArray(const QByteArray& pMessage);
65
66 explicit IfdMessage(IfdMessageType pType);
67 explicit IfdMessage(const QJsonObject& pMessageObject);
68 virtual ~IfdMessage() = default;
69
70 [[nodiscard]] bool isIncomplete() const;
71 [[nodiscard]] IfdMessageType getType() const;
72 [[nodiscard]] const QString& getContextHandle() const;
73
74 [[nodiscard]] virtual QByteArray toByteArray(IfdVersion::Version pIfdVersion, const QString& pContextHandle = QString()) const;
75};
76
77
78} // namespace governikus
#define defineEnumType(enumName,...)
Definition EnumHelper.h:85
Version
Definition IfdVersion.h:17
Implementation of GeneralAuthenticate response APDUs.
Definition CommandApdu.h:17
UNDEFINED
Definition SecurityProtocol.h:22
QSharedPointer< T > decodeObject(const QByteArray &pData, bool pLogging=true)
Template function for decoding an OpenSSL type from DER encoded QByteArray.
Definition ASN1TemplateUtil.h:114