AusweisApp2
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{
23defineEnumType(IfdMessageType,
24 IFDEstablishContext,
25 IFDEstablishContextResponse,
26 IFDGetStatus,
27 IFDStatus,
28 IFDConnect,
29 IFDConnectResponse,
30 IFDDisconnect,
31 IFDDisconnectResponse,
32 IFDError,
33 IFDTransmit,
34 IFDTransmitResponse,
35 IFDEstablishPACEChannel,
36 IFDEstablishPACEChannelResponse,
37 IFDModifyPIN,
38 IFDModifyPINResponse,
40
41
42class IfdMessage
43{
44 private:
45 bool mIncomplete;
46 IfdMessageType mMessageType;
47 QString mContextHandle;
48
49 protected:
50 [[nodiscard]] virtual QJsonObject createMessageBody(const QString& pContextHandle) const;
51 static QByteArray toByteArray(const QJsonObject& pJsonObject);
52
53 void markIncomplete(const QString& pLogMessage);
54 void missingValue(const QLatin1String& pName);
55 void invalidType(const QLatin1String& pName, const QLatin1String& pExpectedType);
56 bool getBoolValue(const QJsonObject& pJsonObject, const QLatin1String& pName);
57 int getIntValue(const QJsonObject& pJsonObject, const QLatin1String& pName, int pDefault);
58 QString getStringValue(const QJsonObject& pJsonObject, const QLatin1String& pName);
59
60 public:
61 static QJsonObject parseByteArray(const QByteArray& pMessage);
62
63 explicit IfdMessage(IfdMessageType pType);
64 explicit IfdMessage(const QJsonObject& pMessageObject);
65 virtual ~IfdMessage() = default;
66
67 [[nodiscard]] bool isIncomplete() const;
68 [[nodiscard]] IfdMessageType getType() const;
69 [[nodiscard]] const QString& getContextHandle() const;
70
71 [[nodiscard]] virtual QByteArray toByteArray(IfdVersion::Version pIfdVersion, const QString& pContextHandle = QString()) const;
72};
73
74
75} // namespace governikus
#define defineEnumType(enumName,...)
Definition EnumHelper.h:98
Version
Definition IfdVersion.h:17
Implementation of GeneralAuthenticate response APDUs.
Definition CommandApdu.h:16
UNDEFINED
Definition SecurityProtocol.h:22
Oid getType() const