AusweisApp2
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"
30
31#include <QDebug>
32#include <QPointer>
33#include <QSharedPointer>
34#include <QSslCertificate>
35#include <QUrl>
36
37class test_StateRedirectBrowser;
38class test_StatePreVerification;
39class test_StateCertificateDescriptionCheck;
40
41namespace governikus
42{
43class TestAuthContext;
44
46 : public WorkflowContext
47{
48 Q_OBJECT
49 friend class ::test_StateRedirectBrowser;
50 friend class ::test_StatePreVerification;
51 friend class ::test_StateProcessCertificatesFromEac2;
52 friend class ::test_StateCertificateDescriptionCheck;
53 friend class TestAuthContext;
54
55 private:
56 bool mTcTokenNotFound;
57 bool mErrorReportedToServer;
58 bool mSkipRedirect;
59 bool mShowChangePinView;
60
61 QSharedPointer<ActivationContext> mActivationContext;
62 QUrl mTcTokenUrl;
63 QSharedPointer<const TcToken> mTcToken;
64 QUrl mRefreshUrl;
65 QString mReceivedMessageId;
66 QSharedPointer<StartPaos> mStartPaos;
67 QSharedPointer<InitializeFramework> mInitializeFramework;
68 QSharedPointer<InitializeFrameworkResponse> mInitializeFrameworkResponse;
69 QSharedPointer<DIDAuthenticateEAC1> mDIDAuthenticateEAC1;
70 QSharedPointer<DIDAuthenticateResponseEAC1> mDIDAuthenticateResponseEAC1;
71 QSharedPointer<DIDAuthenticateEAC2> mDIDAuthenticateEAC2;
72 QSharedPointer<DIDAuthenticateResponseEAC2> mDIDAuthenticateResponseEACAdditionalInputType;
73 QSharedPointer<DIDAuthenticateEACAdditional> mDIDAuthenticateEACAdditionalInputType;
74 QSharedPointer<DIDAuthenticateResponseEAC2> mDIDAuthenticateResponseEAC2;
75 QSharedPointer<Transmit> mTransmit;
76 QSharedPointer<TransmitResponse> mTransmitResponse;
77 QSharedPointer<StartPaosResponse> mStartPaosResponse;
78 QSharedPointer<AccessRightManager> mAccessRightManager;
79 QMultiMap<QUrl, QSslCertificate> mCertificates;
80 QSharedPointer<const CVCertificate> mDvCvc;
81 CVCertificateChainBuilder mCvcChainBuilderProd;
82 CVCertificateChainBuilder mCvcChainBuilderTest;
83 QByteArray mSslSession;
84
85 Q_SIGNALS:
88 void fireAccessRightManagerCreated(QSharedPointer<AccessRightManager> pAccessRightManager);
89
90 protected:
91 explicit AuthContext(const Action pAction, const QSharedPointer<ActivationContext>& pActivationContext);
92
93 public:
94 explicit AuthContext(const QSharedPointer<ActivationContext>& pActivationContext);
95
96 [[nodiscard]] bool isErrorReportedToServer() const
97 {
98 return mErrorReportedToServer;
99 }
100
101
102 void setErrorReportedToServer(bool pErrorReportedToServer)
103 {
104 mErrorReportedToServer = pErrorReportedToServer;
105 }
106
107
108 [[nodiscard]] bool showChangePinView() const
109 {
110 return mShowChangePinView;
111 }
112
113
115
116
117 [[nodiscard]] bool isTcTokenNotFound() const
118 {
119 return mTcTokenNotFound;
120 }
121
122
123 void setTcTokenNotFound(bool pTcTokenNotFound)
124 {
125 mTcTokenNotFound = pTcTokenNotFound;
126 }
127
128
129 [[nodiscard]] QVector<AcceptedEidType> getAcceptedEidTypes() const override
130 {
131
132 if (isCanAllowedMode() || !mDIDAuthenticateEAC1)
133 {
134 return {AcceptedEidType::CARD_CERTIFIED};
135 }
136
137 return mDIDAuthenticateEAC1->getAcceptedEidTypes();
138 }
139
140
141 [[nodiscard]] bool isSkipRedirect() const
142 {
143 return mSkipRedirect;
144 }
145
146
147 void setSkipRedirect(bool pSkipRedirect)
148 {
149 mSkipRedirect = pSkipRedirect;
150 }
151
152
153 [[nodiscard]] QList<QSslCertificate> getCertificateList() const
154 {
155 return mCertificates.values();
156 }
157
158
159 void addCertificateData(const QUrl& pUrl, const QSslCertificate& pCert)
160 {
161 QUrl originUrl = UrlUtil::getUrlOrigin(pUrl);
162 qDebug() << "Adding certificate CN=" << pCert.subjectInfo(QSslCertificate::CommonName) << "SN=" << pCert.serialNumber() << "for URL origin" << originUrl;
163 mCertificates.insert(originUrl, pCert);
164 }
165
166
168 {
169 return mActivationContext.data();
170 }
171
172
173 [[nodiscard]] const QUrl& getTcTokenUrl() const
174 {
175 return mTcTokenUrl;
176 }
177
178
179 void setTcTokenUrl(const QUrl& pTcTokenUrl)
180 {
181 mTcTokenUrl = pTcTokenUrl;
182 }
183
184
185 [[nodiscard]] const QSharedPointer<const TcToken>& getTcToken() const
186 {
187 return mTcToken;
188 }
189
190
191 void setTcToken(const QSharedPointer<const TcToken>& pTcToken)
192 {
193 mTcToken = pTcToken;
194 }
195
196
197 [[nodiscard]] const QString& getReceivedMessageId() const
198 {
199 return mReceivedMessageId;
200 }
201
202
203 void setReceivedMessageId(const QString& pReceivedMessageId)
204 {
205 mReceivedMessageId = pReceivedMessageId;
206 }
207
208
209 [[nodiscard]] const QUrl& getRefreshUrl() const
210 {
211 return mRefreshUrl;
212 }
213
214
215 void setRefreshUrl(const QUrl& pRefreshUrl)
216 {
217 mRefreshUrl = pRefreshUrl;
218 }
219
220
221 [[nodiscard]] const QSharedPointer<DIDAuthenticateEAC1>& getDidAuthenticateEac1() const
222 {
223 return mDIDAuthenticateEAC1;
224 }
225
226
227 void setDidAuthenticateEac1(const QSharedPointer<DIDAuthenticateEAC1>& pDIDAuthenticateEAC1)
228 {
229 mDIDAuthenticateEAC1 = pDIDAuthenticateEAC1;
231 Q_EMIT fireIsSmartCardAllowedChanged();
232 }
233
234
235 [[nodiscard]] const QSharedPointer<DIDAuthenticateEAC2>& getDidAuthenticateEac2() const
236 {
237 return mDIDAuthenticateEAC2;
238 }
239
240
241 void setDidAuthenticateEac2(const QSharedPointer<DIDAuthenticateEAC2>& pDidAuthenticateEac2)
242 {
243 mDIDAuthenticateEAC2 = pDidAuthenticateEac2;
244 }
245
246
247 [[nodiscard]] const QSharedPointer<DIDAuthenticateResponseEAC1>& getDidAuthenticateResponseEac1() const
248 {
249 return mDIDAuthenticateResponseEAC1;
250 }
251
252
253 void setDidAuthenticateResponseEac1(const QSharedPointer<DIDAuthenticateResponseEAC1>& pDidAuthenticateResponseEac1)
254 {
255 mDIDAuthenticateResponseEAC1 = pDidAuthenticateResponseEac1;
256 }
257
258
259 [[nodiscard]] const QSharedPointer<DIDAuthenticateResponseEAC2>& getDidAuthenticateResponseEacAdditionalInputType() const
260 {
261 return mDIDAuthenticateResponseEACAdditionalInputType;
262 }
263
264
265 void setDidAuthenticateResponseEacAdditionalInputType(const QSharedPointer<DIDAuthenticateResponseEAC2>& pDidAuthenticateResponseEacAdditionalInputType)
266 {
267 mDIDAuthenticateResponseEACAdditionalInputType = pDidAuthenticateResponseEacAdditionalInputType;
268 }
269
270
271 [[nodiscard]] const QSharedPointer<DIDAuthenticateEACAdditional>& getDidAuthenticateEacAdditional() const
272 {
273 return mDIDAuthenticateEACAdditionalInputType;
274 }
275
276
277 void setDidAuthenticateEacAdditional(const QSharedPointer<DIDAuthenticateEACAdditional>& pDidAuthenticateEacAdditionalInputType)
278 {
279 mDIDAuthenticateEACAdditionalInputType = pDidAuthenticateEacAdditionalInputType;
280 }
281
282
283 [[nodiscard]] const QSharedPointer<DIDAuthenticateResponseEAC2>& getDidAuthenticateResponseEac2() const
284 {
285 return mDIDAuthenticateResponseEAC2;
286 }
287
288
289 void setDidAuthenticateResponseEac2(const QSharedPointer<DIDAuthenticateResponseEAC2>& pDidAuthenticateResponseEac2)
290 {
291 mDIDAuthenticateResponseEAC2 = pDidAuthenticateResponseEac2;
292 }
293
294
295 [[nodiscard]] const QSharedPointer<InitializeFramework>& getInitializeFramework() const
296 {
297 return mInitializeFramework;
298 }
299
300
301 void setInitializeFramework(const QSharedPointer<InitializeFramework>& pInitializeFramework)
302 {
303 mInitializeFramework = pInitializeFramework;
304 }
305
306
307 [[nodiscard]] const QSharedPointer<InitializeFrameworkResponse>& getInitializeFrameworkResponse() const
308 {
309 return mInitializeFrameworkResponse;
310 }
311
312
313 void setInitializeFrameworkResponse(const QSharedPointer<InitializeFrameworkResponse>& pInitializeFrameworkResponse)
314 {
315 mInitializeFrameworkResponse = pInitializeFrameworkResponse;
316 }
317
318
319 [[nodiscard]] const QSharedPointer<StartPaosResponse>& getStartPaosResponse() const
320 {
321 return mStartPaosResponse;
322 }
323
324
325 void setStartPaosResponse(const QSharedPointer<StartPaosResponse>& pStartPaosResponse)
326 {
327 mStartPaosResponse = pStartPaosResponse;
328 }
329
330
331 [[nodiscard]] const QSharedPointer<TransmitResponse>& getTransmitResponse()
332 {
333 return mTransmitResponse;
334 }
335
336
337 void setTransmitResponse(const QSharedPointer<TransmitResponse>& pTransmitResponse)
338 {
339 Q_ASSERT(!pTransmitResponse.isNull());
340 mTransmitResponse = pTransmitResponse;
341 }
342
343
344 [[nodiscard]] const QSharedPointer<Transmit>& getTransmit()
345 {
346 return mTransmit;
347 }
348
349
350 void setTransmit(const QSharedPointer<Transmit>& pTransmit)
351 {
352 Q_ASSERT(!pTransmit.isNull());
353 mTransmit = pTransmit;
354 }
355
356
357 [[nodiscard]] QSharedPointer<AccessRightManager> getAccessRightManager() const
358 {
359 return mAccessRightManager;
360 }
361
362
363 [[nodiscard]] QByteArray encodeEffectiveChat();
364
365
366 [[nodiscard]] const QSharedPointer<StartPaos>& getStartPaos() const
367 {
368 return mStartPaos;
369 }
370
371
372 void setStartPaos(const QSharedPointer<StartPaos>& pStartPaos)
373 {
374 mStartPaos = pStartPaos;
375 }
376
377
378 [[nodiscard]] CVCertificateChain getChainStartingWith(const QSharedPointer<const CVCertificate>& pChainRoot) const;
379
380
381 [[nodiscard]] bool hasChainForCertificationAuthority(const EstablishPaceChannelOutput& pPaceOutput) const;
382
383
385
386
387 void initCvcChainBuilder(const QVector<QSharedPointer<const CVCertificate>>& pAdditionalCertificates = QVector<QSharedPointer<const CVCertificate>>());
388
389
390 [[nodiscard]] const QSharedPointer<const CVCertificate>& getDvCvc() const
391 {
392 return mDvCvc;
393 }
394
395
396 void setDvCvc(const QSharedPointer<const CVCertificate>& dvCvc)
397 {
398 mDvCvc = dvCvc;
399 }
400
401
402 void initAccessRightManager(const QSharedPointer<const CVCertificate>& pTerminalCvc);
403 [[nodiscard]] bool isCanAllowedMode() const override;
404
405 [[nodiscard]] const QByteArray& getSslSession() const;
406 void setSslSession(const QByteArray& pSession);
407};
408
409} // namespace governikus
Definition: ActivationContext.h:19
Definition: AuthContext.h:47
bool isSkipRedirect() const
Definition: AuthContext.h:141
const QSharedPointer< const TcToken > & getTcToken() const
Definition: AuthContext.h:185
const QString & getReceivedMessageId() const
Definition: AuthContext.h:197
friend class TestAuthContext
Definition: AuthContext.h:53
bool isTcTokenNotFound() const
Definition: AuthContext.h:117
const QSharedPointer< InitializeFramework > & getInitializeFramework() const
Definition: AuthContext.h:295
void setTcTokenNotFound(bool pTcTokenNotFound)
Definition: AuthContext.h:123
void setTransmitResponse(const QSharedPointer< TransmitResponse > &pTransmitResponse)
Definition: AuthContext.h:337
const QSharedPointer< TransmitResponse > & getTransmitResponse()
Definition: AuthContext.h:331
void addCertificateData(const QUrl &pUrl, const QSslCertificate &pCert)
Definition: AuthContext.h:159
void setReceivedMessageId(const QString &pReceivedMessageId)
Definition: AuthContext.h:203
const QByteArray & getSslSession() const
Definition: AuthContext.cpp:83
void setTcToken(const QSharedPointer< const TcToken > &pTcToken)
Definition: AuthContext.h:191
void fireAccessRightManagerCreated(QSharedPointer< AccessRightManager > pAccessRightManager)
void setDidAuthenticateEacAdditional(const QSharedPointer< DIDAuthenticateEACAdditional > &pDidAuthenticateEacAdditionalInputType)
Definition: AuthContext.h:277
void setTcTokenUrl(const QUrl &pTcTokenUrl)
Definition: AuthContext.h:179
void setSkipRedirect(bool pSkipRedirect)
Definition: AuthContext.h:147
const QSharedPointer< const CVCertificate > & getDvCvc() const
Definition: AuthContext.h:390
void setDidAuthenticateEac1(const QSharedPointer< DIDAuthenticateEAC1 > &pDIDAuthenticateEAC1)
Definition: AuthContext.h:227
void setErrorReportedToServer(bool pErrorReportedToServer)
Definition: AuthContext.h:102
bool isCanAllowedMode() const override
Definition: AuthContext.cpp:77
const QSharedPointer< DIDAuthenticateEAC2 > & getDidAuthenticateEac2() const
Definition: AuthContext.h:235
void setRefreshUrl(const QUrl &pRefreshUrl)
Definition: AuthContext.h:215
const QSharedPointer< StartPaos > & getStartPaos() const
Definition: AuthContext.h:366
const QSharedPointer< DIDAuthenticateResponseEAC2 > & getDidAuthenticateResponseEacAdditionalInputType() const
Definition: AuthContext.h:259
bool isErrorReportedToServer() const
Definition: AuthContext.h:96
QByteArray encodeEffectiveChat()
Definition: AuthContext.cpp:95
QVector< AcceptedEidType > getAcceptedEidTypes() const override
Definition: AuthContext.h:129
void setSslSession(const QByteArray &pSession)
Definition: AuthContext.cpp:89
void setStartPaos(const QSharedPointer< StartPaos > &pStartPaos)
Definition: AuthContext.h:372
QSharedPointer< AccessRightManager > getAccessRightManager() const
Definition: AuthContext.h:357
const QSharedPointer< StartPaosResponse > & getStartPaosResponse() const
Definition: AuthContext.h:319
const QUrl & getRefreshUrl() const
Definition: AuthContext.h:209
bool showChangePinView() const
Definition: AuthContext.h:108
const QSharedPointer< Transmit > & getTransmit()
Definition: AuthContext.h:344
void setDidAuthenticateEac2(const QSharedPointer< DIDAuthenticateEAC2 > &pDidAuthenticateEac2)
Definition: AuthContext.h:241
void setDvCvc(const QSharedPointer< const CVCertificate > &dvCvc)
Definition: AuthContext.h:396
bool hasChainForCertificationAuthority(const EstablishPaceChannelOutput &pPaceOutput) const
Definition: AuthContext.cpp:126
const QSharedPointer< InitializeFrameworkResponse > & getInitializeFrameworkResponse() const
Definition: AuthContext.h:307
const QSharedPointer< DIDAuthenticateResponseEAC2 > & getDidAuthenticateResponseEac2() const
Definition: AuthContext.h:283
QList< QSslCertificate > getCertificateList() const
Definition: AuthContext.h:153
const QSharedPointer< DIDAuthenticateResponseEAC1 > & getDidAuthenticateResponseEac1() const
Definition: AuthContext.h:247
const QSharedPointer< DIDAuthenticateEACAdditional > & getDidAuthenticateEacAdditional() const
Definition: AuthContext.h:271
void setInitializeFramework(const QSharedPointer< InitializeFramework > &pInitializeFramework)
Definition: AuthContext.h:301
CVCertificateChain getChainForCertificationAuthority(const EstablishPaceChannelOutput &pPaceOutput) const
Definition: AuthContext.cpp:132
void setDidAuthenticateResponseEac1(const QSharedPointer< DIDAuthenticateResponseEAC1 > &pDidAuthenticateResponseEac1)
Definition: AuthContext.h:253
void fireDidAuthenticateEac1Changed()
void requestChangePinView()
Definition: AuthContext.cpp:55
const QUrl & getTcTokenUrl() const
Definition: AuthContext.h:173
void setInitializeFrameworkResponse(const QSharedPointer< InitializeFrameworkResponse > &pInitializeFrameworkResponse)
Definition: AuthContext.h:313
ActivationContext * getActivationContext() const
Definition: AuthContext.h:167
void initCvcChainBuilder(const QVector< QSharedPointer< const CVCertificate > > &pAdditionalCertificates=QVector< QSharedPointer< const CVCertificate > >())
Definition: AuthContext.cpp:144
CVCertificateChain getChainStartingWith(const QSharedPointer< const CVCertificate > &pChainRoot) const
Definition: AuthContext.cpp:106
void setDidAuthenticateResponseEac2(const QSharedPointer< DIDAuthenticateResponseEAC2 > &pDidAuthenticateResponseEac2)
Definition: AuthContext.h:289
void initAccessRightManager(const QSharedPointer< const CVCertificate > &pTerminalCvc)
Definition: AuthContext.cpp:68
const QSharedPointer< DIDAuthenticateEAC1 > & getDidAuthenticateEac1() const
Definition: AuthContext.h:221
void setTransmit(const QSharedPointer< Transmit > &pTransmit)
Definition: AuthContext.h:350
void setDidAuthenticateResponseEacAdditionalInputType(const QSharedPointer< DIDAuthenticateResponseEAC2 > &pDidAuthenticateResponseEacAdditionalInputType)
Definition: AuthContext.h:265
void setStartPaosResponse(const QSharedPointer< StartPaosResponse > &pStartPaosResponse)
Definition: AuthContext.h:325
Definition: CVCertificateChainBuilder.h:22
Definition: CVCertificateChain.h:24
Definition: EstablishPaceChannelOutput.h:50
Implementation of GeneralAuthenticate response APDUs.
Definition: CommandApdu.h:16