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 mReceivedBrowserSendFailed;
63 bool mSkipMobileRedirect;
64 bool mShowChangePinView;
65
66 QUrl mActivationUrl;
67 QUrl mTcTokenUrl;
69 QUrl mRefreshUrl;
70 QString mReceivedMessageId;
72 QSharedPointer<InitializeFramework> mInitializeFramework;
73 QSharedPointer<InitializeFrameworkResponse> mInitializeFrameworkResponse;
74 QSharedPointer<DIDAuthenticateEAC1> mDIDAuthenticateEAC1;
75 QSharedPointer<DIDAuthenticateResponseEAC1> mDIDAuthenticateResponseEAC1;
76 QSharedPointer<DIDAuthenticateEAC2> mDIDAuthenticateEAC2;
77 QSharedPointer<DIDAuthenticateResponseEAC2> mDIDAuthenticateResponseEACAdditionalInputType;
78 QSharedPointer<DIDAuthenticateEACAdditional> mDIDAuthenticateEACAdditionalInputType;
79 QSharedPointer<DIDAuthenticateResponseEAC2> mDIDAuthenticateResponseEAC2;
81 QSharedPointer<TransmitResponse> mTransmitResponse;
82 QSharedPointer<StartPaosResponse> mStartPaosResponse;
83 QSharedPointer<AccessRightManager> mAccessRightManager;
86 CVCertificateChainBuilder mCvcChainBuilderProd;
87 CVCertificateChainBuilder mCvcChainBuilderTest;
88 QByteArray mSslSession;
89 BrowserHandler mBrowserHandler;
90
95
96 protected:
97 explicit AuthContext(const Action pAction, bool pActivateUi = true, const QUrl& pActivationUrl = QUrl(), const BrowserHandler& pHandler = BrowserHandler());
98
99 public:
100 explicit AuthContext(bool pActivateUi = true, const QUrl& pActivationUrl = QUrl(), const BrowserHandler& pHandler = BrowserHandler());
101
103 {
104 return mActivationUrl;
105 }
106
107
109 {
110 return mErrorReportedToServer;
111 }
112
113
115 {
116 return mReceivedBrowserSendFailed;
117 }
118
119
121
122
124 {
125 mErrorReportedToServer = pErrorReportedToServer;
126 }
127
128
130 {
131 return mShowChangePinView;
132 }
133
134
136
137
139 {
140 return mTcTokenNotFound;
141 }
142
143
145 {
146 mTcTokenNotFound = pTcTokenNotFound;
147 }
148
149
150 [[nodiscard]] QList<AcceptedEidType> getAcceptedEidTypes() const override
151 {
152 if (isCanAllowedMode() || !mDIDAuthenticateEAC1)
153 {
154 return {AcceptedEidType::CARD_CERTIFIED};
155 }
156
157 return mDIDAuthenticateEAC1->getAcceptedEidTypes();
158 }
159
160
162 {
163 return mSkipMobileRedirect;
164 }
165
166
168 {
169 mSkipMobileRedirect = pSkipRedirect;
170 }
171
172
173 [[nodiscard]] QList<QSslCertificate> getCertificateList() const
174 {
175 return mCertificates.values();
176 }
177
178
180 {
181 QUrl originUrl = UrlUtil::getUrlOrigin(pUrl);
182 qDebug() << "Adding certificate CN=" << pCert.subjectInfo(QSslCertificate::CommonName) << "SN=" << pCert.serialNumber() << "for URL origin" << originUrl;
183 mCertificates.insert(originUrl, pCert);
184 }
185
186
188 {
189 return mBrowserHandler;
190 }
191
192
193 [[nodiscard]] const QUrl& getTcTokenUrl() const
194 {
195 return mTcTokenUrl;
196 }
197
198
200 {
201 mTcTokenUrl = pTcTokenUrl;
202 }
203
204
206 {
207 return mTcToken;
208 }
209
210
212 {
213 mTcToken = pTcToken;
214 }
215
216
217 [[nodiscard]] const QString& getReceivedMessageId() const
218 {
219 return mReceivedMessageId;
220 }
221
222
224 {
225 mReceivedMessageId = pReceivedMessageId;
226 }
227
228
229 [[nodiscard]] const QUrl& getRefreshUrl() const
230 {
231 return mRefreshUrl;
232 }
233
234
236 {
237 mRefreshUrl = pRefreshUrl;
238 }
239
240
242 {
243 return mDIDAuthenticateEAC1;
244 }
245
246
254
255
257 {
258 return mDIDAuthenticateEAC2;
259 }
260
261
266
267
269 {
270 return mDIDAuthenticateResponseEAC1;
271 }
272
273
278
279
281 {
282 return mDIDAuthenticateResponseEACAdditionalInputType;
283 }
284
285
290
291
293 {
294 return mDIDAuthenticateEACAdditionalInputType;
295 }
296
297
302
303
305 {
306 return mDIDAuthenticateResponseEAC2;
307 }
308
309
314
315
317 {
318 return mInitializeFramework;
319 }
320
321
326
327
329 {
330 return mInitializeFrameworkResponse;
331 }
332
333
338
339
341 {
342 return mStartPaosResponse;
343 }
344
345
350
351
353 {
354 return mTransmitResponse;
355 }
356
357
363
364
366 {
367 return mTransmit;
368 }
369
370
372 {
373 Q_ASSERT(!pTransmit.isNull());
374 mTransmit = pTransmit;
375 }
376
377
379 {
380 return mAccessRightManager;
381 }
382
383
385
386
388 {
389 return mStartPaos;
390 }
391
392
394 {
395 mStartPaos = pStartPaos;
396 }
397
398
400
401
403
404
406
407
409
410
412 {
413 return mDvCvc;
414 }
415
416
418 {
419 mDvCvc = dvCvc;
420 }
421
422
424 [[nodiscard]] bool isCanAllowedMode() const override;
425
426 [[nodiscard]] const QByteArray& getSslSession() const;
427 void setSslSession(const QByteArray& pSession);
428};
429
430} // namespace governikus
Definition AuthContext.h:48
const QSharedPointer< const TcToken > & getTcToken() const
Definition AuthContext.h:205
const QString & getReceivedMessageId() const
Definition AuthContext.h:217
friend class TestAuthContext
Definition AuthContext.h:54
bool isTcTokenNotFound() const
Definition AuthContext.h:138
bool isReceivedBrowserSendFailed() const
Definition AuthContext.h:114
const QSharedPointer< InitializeFramework > & getInitializeFramework() const
Definition AuthContext.h:316
void setTcTokenNotFound(bool pTcTokenNotFound)
Definition AuthContext.h:144
void setTransmitResponse(const QSharedPointer< TransmitResponse > &pTransmitResponse)
Definition AuthContext.h:358
const QSharedPointer< TransmitResponse > & getTransmitResponse()
Definition AuthContext.h:352
void addCertificateData(const QUrl &pUrl, const QSslCertificate &pCert)
Definition AuthContext.h:179
void setReceivedMessageId(const QString &pReceivedMessageId)
Definition AuthContext.h:223
const QByteArray & getSslSession() const
Definition AuthContext.cpp:95
void setTcToken(const QSharedPointer< const TcToken > &pTcToken)
Definition AuthContext.h:211
bool isSkipMobileRedirect() const
Definition AuthContext.h:161
void fireAccessRightManagerCreated(QSharedPointer< AccessRightManager > pAccessRightManager)
void setDidAuthenticateEacAdditional(const QSharedPointer< DIDAuthenticateEACAdditional > &pDidAuthenticateEacAdditionalInputType)
Definition AuthContext.h:298
void setTcTokenUrl(const QUrl &pTcTokenUrl)
Definition AuthContext.h:199
const QSharedPointer< const CVCertificate > & getDvCvc() const
Definition AuthContext.h:411
void setDidAuthenticateEac1(const QSharedPointer< DIDAuthenticateEAC1 > &pDIDAuthenticateEAC1)
Definition AuthContext.h:247
void setErrorReportedToServer(bool pErrorReportedToServer)
Definition AuthContext.h:123
bool isCanAllowedMode() const override
Definition AuthContext.cpp:89
const QSharedPointer< DIDAuthenticateEAC2 > & getDidAuthenticateEac2() const
Definition AuthContext.h:256
void setReceivedBrowserSendFailed(bool pReceivedBrowserSendFailed)
Definition AuthContext.cpp:57
QList< AcceptedEidType > getAcceptedEidTypes() const override
Definition AuthContext.h:150
void setRefreshUrl(const QUrl &pRefreshUrl)
Definition AuthContext.h:235
const QSharedPointer< StartPaos > & getStartPaos() const
Definition AuthContext.h:387
const QSharedPointer< DIDAuthenticateResponseEAC2 > & getDidAuthenticateResponseEacAdditionalInputType() const
Definition AuthContext.h:280
QUrl getActivationUrl() const
Definition AuthContext.h:102
bool isErrorReportedToServer() const
Definition AuthContext.h:108
void initCvcChainBuilder(const QList< QSharedPointer< const CVCertificate > > &pAdditionalCertificates=QList< QSharedPointer< const CVCertificate > >())
Definition AuthContext.cpp:156
QByteArray encodeEffectiveChat()
Definition AuthContext.cpp:107
void setSslSession(const QByteArray &pSession)
Definition AuthContext.cpp:101
void setStartPaos(const QSharedPointer< StartPaos > &pStartPaos)
Definition AuthContext.h:393
QSharedPointer< AccessRightManager > getAccessRightManager() const
Definition AuthContext.h:378
const QSharedPointer< StartPaosResponse > & getStartPaosResponse() const
Definition AuthContext.h:340
const QUrl & getRefreshUrl() const
Definition AuthContext.h:229
bool showChangePinView() const
Definition AuthContext.h:129
const QSharedPointer< Transmit > & getTransmit()
Definition AuthContext.h:365
void setDidAuthenticateEac2(const QSharedPointer< DIDAuthenticateEAC2 > &pDidAuthenticateEac2)
Definition AuthContext.h:262
void setDvCvc(const QSharedPointer< const CVCertificate > &dvCvc)
Definition AuthContext.h:417
bool hasChainForCertificationAuthority(const EstablishPaceChannelOutput &pPaceOutput) const
Definition AuthContext.cpp:138
const QSharedPointer< InitializeFrameworkResponse > & getInitializeFrameworkResponse() const
Definition AuthContext.h:328
const QSharedPointer< DIDAuthenticateResponseEAC2 > & getDidAuthenticateResponseEac2() const
Definition AuthContext.h:304
QList< QSslCertificate > getCertificateList() const
Definition AuthContext.h:173
const QSharedPointer< DIDAuthenticateResponseEAC1 > & getDidAuthenticateResponseEac1() const
Definition AuthContext.h:268
const QSharedPointer< DIDAuthenticateEACAdditional > & getDidAuthenticateEacAdditional() const
Definition AuthContext.h:292
void setMobileSkipRedirect(bool pSkipRedirect=true)
Definition AuthContext.h:167
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:322
CVCertificateChain getChainForCertificationAuthority(const EstablishPaceChannelOutput &pPaceOutput) const
Definition AuthContext.cpp:144
void setDidAuthenticateResponseEac1(const QSharedPointer< DIDAuthenticateResponseEAC1 > &pDidAuthenticateResponseEac1)
Definition AuthContext.h:274
void fireDidAuthenticateEac1Changed()
void requestChangePinView()
Definition AuthContext.cpp:67
const QUrl & getTcTokenUrl() const
Definition AuthContext.h:193
BrowserHandler getBrowserHandler() const
Definition AuthContext.h:187
void setInitializeFrameworkResponse(const QSharedPointer< InitializeFrameworkResponse > &pInitializeFrameworkResponse)
Definition AuthContext.h:334
CVCertificateChain getChainStartingWith(const QSharedPointer< const CVCertificate > &pChainRoot) const
Definition AuthContext.cpp:118
void setDidAuthenticateResponseEac2(const QSharedPointer< DIDAuthenticateResponseEAC2 > &pDidAuthenticateResponseEac2)
Definition AuthContext.h:310
void initAccessRightManager(const QSharedPointer< const CVCertificate > &pTerminalCvc)
Definition AuthContext.cpp:80
const QSharedPointer< DIDAuthenticateEAC1 > & getDidAuthenticateEac1() const
Definition AuthContext.h:241
void setTransmit(const QSharedPointer< Transmit > &pTransmit)
Definition AuthContext.h:371
void setDidAuthenticateResponseEacAdditionalInputType(const QSharedPointer< DIDAuthenticateResponseEAC2 > &pDidAuthenticateResponseEacAdditionalInputType)
Definition AuthContext.h:286
void setStartPaosResponse(const QSharedPointer< StartPaosResponse > &pStartPaosResponse)
Definition AuthContext.h:346
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