AusweisApp
Lade ...
Suche ...
Keine Treffer
AuthContext.h
gehe zur Dokumentation dieser Datei
1
9#pragma once
10
11#include "NetworkManager.h"
12#include "TcToken.h"
13#include "UrlUtil.h"
14#include "asn1/CVCertificate.h"
29
30#include <QDebug>
31#include <QPointer>
32#include <QSharedPointer>
33#include <QSslCertificate>
34#include <QUrl>
35
36#include <functional>
37
38class test_StateRedirectBrowser;
39class test_StatePreVerification;
40class test_StateCertificateDescriptionCheck;
41
42namespace governikus
43{
44class TestAuthContext;
45
47 : public WorkflowContext
48{
50 friend class ::test_StateRedirectBrowser;
51 friend class ::test_StatePreVerification;
52 friend class ::test_StateProcessCertificatesFromEac2;
53 friend class ::test_StateCertificateDescriptionCheck;
54 friend class TestAuthContext;
55
56 public:
57 using BrowserHandler = std::function<QString (const QSharedPointer<AuthContext>&)>;
58
59 private:
60 bool mTcTokenNotFound;
61 bool mErrorReportedToServer;
62 bool mSkipMobileRedirect;
63 bool mShowChangePinView;
64
65 QUrl mActivationUrl;
66 QUrl mTcTokenUrl;
68 QUrl mRefreshUrl;
69 QString mReceivedMessageId;
71 QSharedPointer<InitializeFramework> mInitializeFramework;
72 QSharedPointer<InitializeFrameworkResponse> mInitializeFrameworkResponse;
73 QSharedPointer<DIDAuthenticateEAC1> mDIDAuthenticateEAC1;
74 QSharedPointer<DIDAuthenticateResponseEAC1> mDIDAuthenticateResponseEAC1;
75 QSharedPointer<DIDAuthenticateEAC2> mDIDAuthenticateEAC2;
76 QSharedPointer<DIDAuthenticateResponseEAC2> mDIDAuthenticateResponseEACAdditionalInputType;
77 QSharedPointer<DIDAuthenticateEACAdditional> mDIDAuthenticateEACAdditionalInputType;
78 QSharedPointer<DIDAuthenticateResponseEAC2> mDIDAuthenticateResponseEAC2;
80 QSharedPointer<TransmitResponse> mTransmitResponse;
81 QSharedPointer<StartPaosResponse> mStartPaosResponse;
82 QSharedPointer<AccessRightManager> mAccessRightManager;
85 CVCertificateChainBuilder mCvcChainBuilderProd;
86 CVCertificateChainBuilder mCvcChainBuilderTest;
87 QByteArray mSslSession;
88 BrowserHandler mBrowserHandler;
89
94
95 protected:
96 explicit AuthContext(const Action pAction, bool pActivateUi = true, const QUrl& pActivationUrl = QUrl(), const BrowserHandler& pHandler = BrowserHandler());
97
98 public:
99 explicit AuthContext(bool pActivateUi = true, const QUrl& pActivationUrl = QUrl(), const BrowserHandler& pHandler = BrowserHandler());
100
102 {
103 return mActivationUrl;
104 }
105
106
108 {
109 return mErrorReportedToServer;
110 }
111
112
114 {
115 mErrorReportedToServer = pErrorReportedToServer;
116 }
117
118
120 {
121 return mShowChangePinView;
122 }
123
124
126
127
129 {
130 return mTcTokenNotFound;
131 }
132
133
135 {
136 mTcTokenNotFound = pTcTokenNotFound;
137 }
138
139
140 [[nodiscard]] QList<AcceptedEidType> getAcceptedEidTypes() const override
141 {
142
143 if (isCanAllowedMode() || !mDIDAuthenticateEAC1)
144 {
145 return {AcceptedEidType::CARD_CERTIFIED};
146 }
147
148 return mDIDAuthenticateEAC1->getAcceptedEidTypes();
149 }
150
151
153 {
154 return mSkipMobileRedirect;
155 }
156
157
159 {
160 mSkipMobileRedirect = pSkipRedirect;
161 }
162
163
164 [[nodiscard]] QList<QSslCertificate> getCertificateList() const
165 {
166 return mCertificates.values();
167 }
168
169
171 {
172 QUrl originUrl = UrlUtil::getUrlOrigin(pUrl);
173 qDebug() << "Adding certificate CN=" << pCert.subjectInfo(QSslCertificate::CommonName) << "SN=" << pCert.serialNumber() << "for URL origin" << originUrl;
174 mCertificates.insert(originUrl, pCert);
175 }
176
177
179 {
180 return mBrowserHandler;
181 }
182
183
184 [[nodiscard]] const QUrl& getTcTokenUrl() const
185 {
186 return mTcTokenUrl;
187 }
188
189
191 {
192 mTcTokenUrl = pTcTokenUrl;
193 }
194
195
197 {
198 return mTcToken;
199 }
200
201
203 {
204 mTcToken = pTcToken;
205 }
206
207
208 [[nodiscard]] const QString& getReceivedMessageId() const
209 {
210 return mReceivedMessageId;
211 }
212
213
215 {
216 mReceivedMessageId = pReceivedMessageId;
217 }
218
219
220 [[nodiscard]] const QUrl& getRefreshUrl() const
221 {
222 return mRefreshUrl;
223 }
224
225
227 {
228 mRefreshUrl = pRefreshUrl;
229 }
230
231
233 {
234 return mDIDAuthenticateEAC1;
235 }
236
237
245
246
248 {
249 return mDIDAuthenticateEAC2;
250 }
251
252
257
258
260 {
261 return mDIDAuthenticateResponseEAC1;
262 }
263
264
269
270
272 {
273 return mDIDAuthenticateResponseEACAdditionalInputType;
274 }
275
276
281
282
284 {
285 return mDIDAuthenticateEACAdditionalInputType;
286 }
287
288
293
294
296 {
297 return mDIDAuthenticateResponseEAC2;
298 }
299
300
305
306
308 {
309 return mInitializeFramework;
310 }
311
312
317
318
320 {
321 return mInitializeFrameworkResponse;
322 }
323
324
329
330
332 {
333 return mStartPaosResponse;
334 }
335
336
341
342
344 {
345 return mTransmitResponse;
346 }
347
348
354
355
357 {
358 return mTransmit;
359 }
360
361
363 {
364 Q_ASSERT(!pTransmit.isNull());
365 mTransmit = pTransmit;
366 }
367
368
370 {
371 return mAccessRightManager;
372 }
373
374
376
377
379 {
380 return mStartPaos;
381 }
382
383
385 {
386 mStartPaos = pStartPaos;
387 }
388
389
391
392
394
395
397
398
400
401
403 {
404 return mDvCvc;
405 }
406
407
409 {
410 mDvCvc = dvCvc;
411 }
412
413
415 [[nodiscard]] bool isCanAllowedMode() const override;
416
417 [[nodiscard]] const QByteArray& getSslSession() const;
418 void setSslSession(const QByteArray& pSession);
419};
420
421} // namespace governikus
Definition AuthContext.h:48
const QSharedPointer< const TcToken > & getTcToken() const
Definition AuthContext.h:196
const QString & getReceivedMessageId() const
Definition AuthContext.h:208
friend class TestAuthContext
Definition AuthContext.h:54
bool isTcTokenNotFound() const
Definition AuthContext.h:128
const QSharedPointer< InitializeFramework > & getInitializeFramework() const
Definition AuthContext.h:307
void setTcTokenNotFound(bool pTcTokenNotFound)
Definition AuthContext.h:134
void setTransmitResponse(const QSharedPointer< TransmitResponse > &pTransmitResponse)
Definition AuthContext.h:349
const QSharedPointer< TransmitResponse > & getTransmitResponse()
Definition AuthContext.h:343
void addCertificateData(const QUrl &pUrl, const QSslCertificate &pCert)
Definition AuthContext.h:170
void setReceivedMessageId(const QString &pReceivedMessageId)
Definition AuthContext.h:214
const QByteArray & getSslSession() const
Definition AuthContext.cpp:84
void setTcToken(const QSharedPointer< const TcToken > &pTcToken)
Definition AuthContext.h:202
bool isSkipMobileRedirect() const
Definition AuthContext.h:152
void fireAccessRightManagerCreated(QSharedPointer< AccessRightManager > pAccessRightManager)
void setDidAuthenticateEacAdditional(const QSharedPointer< DIDAuthenticateEACAdditional > &pDidAuthenticateEacAdditionalInputType)
Definition AuthContext.h:289
void setTcTokenUrl(const QUrl &pTcTokenUrl)
Definition AuthContext.h:190
const QSharedPointer< const CVCertificate > & getDvCvc() const
Definition AuthContext.h:402
void setDidAuthenticateEac1(const QSharedPointer< DIDAuthenticateEAC1 > &pDIDAuthenticateEAC1)
Definition AuthContext.h:238
void setErrorReportedToServer(bool pErrorReportedToServer)
Definition AuthContext.h:113
bool isCanAllowedMode() const override
Definition AuthContext.cpp:78
const QSharedPointer< DIDAuthenticateEAC2 > & getDidAuthenticateEac2() const
Definition AuthContext.h:247
QList< AcceptedEidType > getAcceptedEidTypes() const override
Definition AuthContext.h:140
void setRefreshUrl(const QUrl &pRefreshUrl)
Definition AuthContext.h:226
const QSharedPointer< StartPaos > & getStartPaos() const
Definition AuthContext.h:378
const QSharedPointer< DIDAuthenticateResponseEAC2 > & getDidAuthenticateResponseEacAdditionalInputType() const
Definition AuthContext.h:271
QUrl getActivationUrl() const
Definition AuthContext.h:101
bool isErrorReportedToServer() const
Definition AuthContext.h:107
void initCvcChainBuilder(const QList< QSharedPointer< const CVCertificate > > &pAdditionalCertificates=QList< QSharedPointer< const CVCertificate > >())
Definition AuthContext.cpp:145
QByteArray encodeEffectiveChat()
Definition AuthContext.cpp:96
void setSslSession(const QByteArray &pSession)
Definition AuthContext.cpp:90
void setStartPaos(const QSharedPointer< StartPaos > &pStartPaos)
Definition AuthContext.h:384
QSharedPointer< AccessRightManager > getAccessRightManager() const
Definition AuthContext.h:369
const QSharedPointer< StartPaosResponse > & getStartPaosResponse() const
Definition AuthContext.h:331
const QUrl & getRefreshUrl() const
Definition AuthContext.h:220
bool showChangePinView() const
Definition AuthContext.h:119
const QSharedPointer< Transmit > & getTransmit()
Definition AuthContext.h:356
void setDidAuthenticateEac2(const QSharedPointer< DIDAuthenticateEAC2 > &pDidAuthenticateEac2)
Definition AuthContext.h:253
void setDvCvc(const QSharedPointer< const CVCertificate > &dvCvc)
Definition AuthContext.h:408
bool hasChainForCertificationAuthority(const EstablishPaceChannelOutput &pPaceOutput) const
Definition AuthContext.cpp:127
const QSharedPointer< InitializeFrameworkResponse > & getInitializeFrameworkResponse() const
Definition AuthContext.h:319
const QSharedPointer< DIDAuthenticateResponseEAC2 > & getDidAuthenticateResponseEac2() const
Definition AuthContext.h:295
QList< QSslCertificate > getCertificateList() const
Definition AuthContext.h:164
const QSharedPointer< DIDAuthenticateResponseEAC1 > & getDidAuthenticateResponseEac1() const
Definition AuthContext.h:259
const QSharedPointer< DIDAuthenticateEACAdditional > & getDidAuthenticateEacAdditional() const
Definition AuthContext.h:283
void setMobileSkipRedirect(bool pSkipRedirect=true)
Definition AuthContext.h:158
AuthContext(const Action pAction, bool pActivateUi=true, const QUrl &pActivationUrl=QUrl(), const BrowserHandler &pHandler=BrowserHandler())
Definition AuthContext.cpp:16
void setInitializeFramework(const QSharedPointer< InitializeFramework > &pInitializeFramework)
Definition AuthContext.h:313
CVCertificateChain getChainForCertificationAuthority(const EstablishPaceChannelOutput &pPaceOutput) const
Definition AuthContext.cpp:133
void setDidAuthenticateResponseEac1(const QSharedPointer< DIDAuthenticateResponseEAC1 > &pDidAuthenticateResponseEac1)
Definition AuthContext.h:265
void fireDidAuthenticateEac1Changed()
void requestChangePinView()
Definition AuthContext.cpp:56
const QUrl & getTcTokenUrl() const
Definition AuthContext.h:184
BrowserHandler getBrowserHandler() const
Definition AuthContext.h:178
void setInitializeFrameworkResponse(const QSharedPointer< InitializeFrameworkResponse > &pInitializeFrameworkResponse)
Definition AuthContext.h:325
CVCertificateChain getChainStartingWith(const QSharedPointer< const CVCertificate > &pChainRoot) const
Definition AuthContext.cpp:107
void setDidAuthenticateResponseEac2(const QSharedPointer< DIDAuthenticateResponseEAC2 > &pDidAuthenticateResponseEac2)
Definition AuthContext.h:301
void initAccessRightManager(const QSharedPointer< const CVCertificate > &pTerminalCvc)
Definition AuthContext.cpp:69
const QSharedPointer< DIDAuthenticateEAC1 > & getDidAuthenticateEac1() const
Definition AuthContext.h:232
void setTransmit(const QSharedPointer< Transmit > &pTransmit)
Definition AuthContext.h:362
void setDidAuthenticateResponseEacAdditionalInputType(const QSharedPointer< DIDAuthenticateResponseEAC2 > &pDidAuthenticateResponseEacAdditionalInputType)
Definition AuthContext.h:277
void setStartPaosResponse(const QSharedPointer< StartPaosResponse > &pStartPaosResponse)
Definition AuthContext.h:337
std::function< QString(const QSharedPointer< AuthContext > &)> BrowserHandler
Definition AuthContext.h:57
Definition CVCertificateChainBuilder.h:22
Definition CVCertificateChain.h:24
Definition EstablishPaceChannelOutput.h:49
Implementation of GeneralAuthenticate response APDUs.
Definition CommandApdu.h:17
QSharedPointer< T > decodeObject(const QByteArray &pData, bool pLogging=true)
Template function for decoding an OpenSSL type from DER encoded QByteArray.
Definition ASN1TemplateUtil.h:114