AusweisApp2
MobileEIDTypeInfo.h
gehe zur Dokumentation dieser Datei
1 
7 #pragma once
8 
9 
10 #include "SecurityInfo.h"
11 
12 
13 namespace governikus
14 {
15 
28 {
29  ASN1_OBJECT* mProtocol;
30  ASN1_TYPE* mRequiredData;
31 };
32 DECLARE_ASN1_FUNCTIONS(mobileeidtypeinfo_st)
34 
35 
36 /*
37  * Wrapper for structure mobileeidtypeinfo_st.
38  */
40  : public SecurityInfo
41 {
42  friend class QSharedPointer<const MobileEIDTypeInfo>;
43 
44  private:
45  const QSharedPointer<const mobileeidtypeinfo_st> mDelegate;
46 
47  explicit MobileEIDTypeInfo(const QSharedPointer<const mobileeidtypeinfo_st>& pDelegate);
48  [[nodiscard]] ASN1_OBJECT* getProtocolObjectIdentifier() const override;
49  static bool acceptsProtocol(const ASN1_OBJECT* pObjectIdentifier);
50 
51  public:
52  static QSharedPointer<const MobileEIDTypeInfo> decode(const QByteArray& pBytes)
53  {
54  if (const auto& delegate = decodeObject<mobileeidtypeinfo_st>(pBytes, false))
55  {
56  if (MobileEIDTypeInfo::acceptsProtocol(delegate->mProtocol))
57  {
58  return QSharedPointer<const MobileEIDTypeInfo>::create(delegate);
59  }
60  }
61  return QSharedPointer<const MobileEIDTypeInfo>();
62  }
63 
64 
65  [[nodiscard]] QByteArray encode() const
66  {
67  return encodeObject(const_cast<mobileeidtypeinfo_st*>(mDelegate.data()));
68  }
69 
70 
71 };
72 
73 
74 inline QDebug operator<<(QDebug pDbg, const QSharedPointer<const MobileEIDTypeInfo>& pMobileEIDTypeInfo)
75 {
76  QDebugStateSaver saver(pDbg);
77  pDbg.nospace().noquote() << pMobileEIDTypeInfo->getOid();
78  return pDbg;
79 }
80 
81 
82 } // namespace governikus
#define DECLARE_ASN1_OBJECT(name)
Definition: ASN1TemplateUtil.h:169
Definition: MobileEIDTypeInfo.h:41
QByteArray encode() const
Definition: MobileEIDTypeInfo.h:65
static QSharedPointer< const MobileEIDTypeInfo > decode(const QByteArray &pBytes)
Definition: MobileEIDTypeInfo.h:52
Definition: SecurityInfo.h:47
A simple template renderer.
Definition: ActivationContext.h:15
QByteArray encodeObject(T *pObject)
Template function for encoding an OpenSSL type as DER encoded QByteArray.
Definition: ASN1TemplateUtil.h:64
QDebug operator<<(QDebug pDbg, const CommandApdu &pCommandApdu)
Definition: CommandApdu.h:91
Definition: MobileEIDTypeInfo.h:28
ASN1_TYPE * mRequiredData
Definition: MobileEIDTypeInfo.h:30
ASN1_OBJECT * mProtocol
Definition: MobileEIDTypeInfo.h:29