AusweisApp
Lade ...
Suche ...
Keine Treffer
AuthContext.h
gehe zur Dokumentation dieser Datei
1
5#pragma once
6
7#include "NetworkManager.h"
8#include "TcToken.h"
9#include "UrlUtil.h"
10#include "asn1/CVCertificate.h"
25
26#include <QDebug>
27#include <QPointer>
28#include <QSharedPointer>
29#include <QSslCertificate>
30#include <QUrl>
31
32#include <functional>
33
34class test_StateRedirectBrowser;
35class test_StatePreVerification;
36class test_StateCertificateDescriptionCheck;
37
38namespace governikus
39{
40class TestAuthContext;
41
43 : public WorkflowContext
44{
46 friend class ::test_StateRedirectBrowser;
47 friend class ::test_StatePreVerification;
48 friend class ::test_StateProcessCertificatesFromEac2;
49 friend class ::test_StateCertificateDescriptionCheck;
50 friend class TestAuthContext;
51
52 public:
53 using BrowserHandler = std::function<QString (const QSharedPointer<AuthContext>&)>;
54
55 private:
56 bool mTcTokenNotFound;
57 bool mErrorReportedToServer;
58 bool mReceivedBrowserSendFailed;
59 bool mSkipMobileRedirect;
60 bool mChangeTransportPin;
61
62 QUrl mActivationUrl;
63 QUrl mTcTokenUrl;
65 QUrl mRefreshUrl;
66 QString mReceivedMessageId;
68 QSharedPointer<InitializeFramework> mInitializeFramework;
69 QSharedPointer<InitializeFrameworkResponse> mInitializeFrameworkResponse;
70 QSharedPointer<DIDAuthenticateEAC1> mDIDAuthenticateEAC1;
71 QSharedPointer<DIDAuthenticateResponseEAC1> mDIDAuthenticateResponseEAC1;
72 QSharedPointer<DIDAuthenticateEAC2> mDIDAuthenticateEAC2;
73 QSharedPointer<DIDAuthenticateResponseEAC2> mDIDAuthenticateResponseEACAdditionalInputType;
74 QSharedPointer<DIDAuthenticateEACAdditional> mDIDAuthenticateEACAdditionalInputType;
75 QSharedPointer<DIDAuthenticateResponseEAC2> mDIDAuthenticateResponseEAC2;
77 QSharedPointer<TransmitResponse> mTransmitResponse;
78 QSharedPointer<StartPaosResponse> mStartPaosResponse;
79 QSharedPointer<AccessRightManager> mAccessRightManager;
82 CVCertificateChainBuilder mCvcChainBuilderProd;
83 CVCertificateChainBuilder mCvcChainBuilderTest;
84 QByteArray mSslSession;
85 BrowserHandler mBrowserHandler;
86
91
92 protected:
93 explicit AuthContext(const Action pAction, bool pActivateUi = true, const QUrl& pActivationUrl = QUrl(), const BrowserHandler& pHandler = BrowserHandler());
94
95 public:
96 explicit AuthContext(bool pActivateUi = true, const QUrl& pActivationUrl = QUrl(), const BrowserHandler& pHandler = BrowserHandler());
97
99 {
100 return mActivationUrl;
101 }
102
103
105 {
106 return mErrorReportedToServer;
107 }
108
109
111 {
112 return mReceivedBrowserSendFailed;
113 }
114
115
117
118
120 {
121 mErrorReportedToServer = pErrorReportedToServer;
122 }
123
124
126 {
127 return mChangeTransportPin;
128 }
129
130
132
133
135 {
136 return mTcTokenNotFound;
137 }
138
139
141 {
142 mTcTokenNotFound = pTcTokenNotFound;
143 }
144
145
146 [[nodiscard]] QList<AcceptedEidType> getAcceptedEidTypes() const override
147 {
148 if (isCanAllowedMode() || !mDIDAuthenticateEAC1)
149 {
150 return {AcceptedEidType::CARD_CERTIFIED};
151 }
152
153 return mDIDAuthenticateEAC1->getAcceptedEidTypes();
154 }
155
156
158 {
159 return mSkipMobileRedirect;
160 }
161
162
164 {
165 mSkipMobileRedirect = pSkipRedirect;
166 }
167
168
169 [[nodiscard]] QList<QSslCertificate> getCertificateList() const
170 {
171 return mCertificates.values();
172 }
173
174
176 {
177 QUrl originUrl = UrlUtil::getUrlOrigin(pUrl);
178 qDebug() << "Adding certificate CN=" << pCert.subjectInfo(QSslCertificate::CommonName) << "SN=" << pCert.serialNumber() << "for URL origin" << originUrl;
179 mCertificates.insert(originUrl, pCert);
180 }
181
182
184 {
185 return mBrowserHandler;
186 }
187
188
189 [[nodiscard]] const QUrl& getTcTokenUrl() const
190 {
191 return mTcTokenUrl;
192 }
193
194
196 {
197 mTcTokenUrl = pTcTokenUrl;
198 }
199
200
202 {
203 return mTcToken;
204 }
205
206
208 {
209 mTcToken = pTcToken;
210 }
211
212
213 [[nodiscard]] const QString& getReceivedMessageId() const
214 {
215 return mReceivedMessageId;
216 }
217
218
220 {
221 mReceivedMessageId = pReceivedMessageId;
222 }
223
224
225 [[nodiscard]] const QUrl& getRefreshUrl() const
226 {
227 return mRefreshUrl;
228 }
229
230
232 {
233 mRefreshUrl = pRefreshUrl;
234 }
235
236
238 {
239 return mDIDAuthenticateEAC1;
240 }
241
242
250
251
253 {
254 return mDIDAuthenticateEAC2;
255 }
256
257
262
263
265 {
266 return mDIDAuthenticateResponseEAC1;
267 }
268
269
274
275
277 {
278 return mDIDAuthenticateResponseEACAdditionalInputType;
279 }
280
281
286
287
289 {
290 return mDIDAuthenticateEACAdditionalInputType;
291 }
292
293
298
299
301 {
302 return mDIDAuthenticateResponseEAC2;
303 }
304
305
310
311
313 {
314 return mInitializeFramework;
315 }
316
317
322
323
325 {
326 return mInitializeFrameworkResponse;
327 }
328
329
334
335
337 {
338 return mStartPaosResponse;
339 }
340
341
346
347
349 {
350 return mTransmitResponse;
351 }
352
353
359
360
362 {
363 return mTransmit;
364 }
365
366
368 {
369 Q_ASSERT(!pTransmit.isNull());
370 mTransmit = pTransmit;
371 }
372
373
375 {
376 return mAccessRightManager;
377 }
378
379
381
382
384 {
385 return mStartPaos;
386 }
387
388
390 {
391 mStartPaos = pStartPaos;
392 }
393
394
396
397
399
400
402
403
405
406
408 {
409 return mDvCvc;
410 }
411
412
414 {
415 mDvCvc = dvCvc;
416 }
417
418
420 [[nodiscard]] bool isCanAllowedMode() const override;
421
422 [[nodiscard]] const QByteArray& getSslSession() const;
423 void setSslSession(const QByteArray& pSession);
424};
425
426} // namespace governikus
Definition AuthContext.h:44
const QSharedPointer< const TcToken > & getTcToken() const
Definition AuthContext.h:201
const QString & getReceivedMessageId() const
Definition AuthContext.h:213
friend class TestAuthContext
Definition AuthContext.h:50
bool isTcTokenNotFound() const
Definition AuthContext.h:134
bool isReceivedBrowserSendFailed() const
Definition AuthContext.h:110
const QSharedPointer< InitializeFramework > & getInitializeFramework() const
Definition AuthContext.h:312
void setTcTokenNotFound(bool pTcTokenNotFound)
Definition AuthContext.h:140
void setTransmitResponse(const QSharedPointer< TransmitResponse > &pTransmitResponse)
Definition AuthContext.h:354
const QSharedPointer< TransmitResponse > & getTransmitResponse()
Definition AuthContext.h:348
void addCertificateData(const QUrl &pUrl, const QSslCertificate &pCert)
Definition AuthContext.h:175
void setReceivedMessageId(const QString &pReceivedMessageId)
Definition AuthContext.h:219
const QByteArray & getSslSession() const
Definition AuthContext.cpp:95
void setTcToken(const QSharedPointer< const TcToken > &pTcToken)
Definition AuthContext.h:207
bool isSkipMobileRedirect() const
Definition AuthContext.h:157
void fireAccessRightManagerCreated(QSharedPointer< AccessRightManager > pAccessRightManager)
void setDidAuthenticateEacAdditional(const QSharedPointer< DIDAuthenticateEACAdditional > &pDidAuthenticateEacAdditionalInputType)
Definition AuthContext.h:294
void setTcTokenUrl(const QUrl &pTcTokenUrl)
Definition AuthContext.h:195
const QSharedPointer< const CVCertificate > & getDvCvc() const
Definition AuthContext.h:407
void setDidAuthenticateEac1(const QSharedPointer< DIDAuthenticateEAC1 > &pDIDAuthenticateEAC1)
Definition AuthContext.h:243
void setErrorReportedToServer(bool pErrorReportedToServer)
Definition AuthContext.h:119
bool isCanAllowedMode() const override
Definition AuthContext.cpp:89
const QSharedPointer< DIDAuthenticateEAC2 > & getDidAuthenticateEac2() const
Definition AuthContext.h:252
void setReceivedBrowserSendFailed(bool pReceivedBrowserSendFailed)
Definition AuthContext.cpp:57
QList< AcceptedEidType > getAcceptedEidTypes() const override
Definition AuthContext.h:146
void setRefreshUrl(const QUrl &pRefreshUrl)
Definition AuthContext.h:231
const QSharedPointer< StartPaos > & getStartPaos() const
Definition AuthContext.h:383
const QSharedPointer< DIDAuthenticateResponseEAC2 > & getDidAuthenticateResponseEacAdditionalInputType() const
Definition AuthContext.h:276
QUrl getActivationUrl() const
Definition AuthContext.h:98
bool isErrorReportedToServer() const
Definition AuthContext.h:104
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:389
QSharedPointer< AccessRightManager > getAccessRightManager() const
Definition AuthContext.h:374
const QSharedPointer< StartPaosResponse > & getStartPaosResponse() const
Definition AuthContext.h:336
const QUrl & getRefreshUrl() const
Definition AuthContext.h:225
const QSharedPointer< Transmit > & getTransmit()
Definition AuthContext.h:361
void setDidAuthenticateEac2(const QSharedPointer< DIDAuthenticateEAC2 > &pDidAuthenticateEac2)
Definition AuthContext.h:258
void setDvCvc(const QSharedPointer< const CVCertificate > &dvCvc)
Definition AuthContext.h:413
bool hasChainForCertificationAuthority(const EstablishPaceChannelOutput &pPaceOutput) const
Definition AuthContext.cpp:138
const QSharedPointer< InitializeFrameworkResponse > & getInitializeFrameworkResponse() const
Definition AuthContext.h:324
const QSharedPointer< DIDAuthenticateResponseEAC2 > & getDidAuthenticateResponseEac2() const
Definition AuthContext.h:300
void requestChangeTransportPin()
Definition AuthContext.cpp:67
QList< QSslCertificate > getCertificateList() const
Definition AuthContext.h:169
const QSharedPointer< DIDAuthenticateResponseEAC1 > & getDidAuthenticateResponseEac1() const
Definition AuthContext.h:264
const QSharedPointer< DIDAuthenticateEACAdditional > & getDidAuthenticateEacAdditional() const
Definition AuthContext.h:288
void setMobileSkipRedirect(bool pSkipRedirect=true)
Definition AuthContext.h:163
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:318
CVCertificateChain getChainForCertificationAuthority(const EstablishPaceChannelOutput &pPaceOutput) const
Definition AuthContext.cpp:144
void setDidAuthenticateResponseEac1(const QSharedPointer< DIDAuthenticateResponseEAC1 > &pDidAuthenticateResponseEac1)
Definition AuthContext.h:270
void fireDidAuthenticateEac1Changed()
const QUrl & getTcTokenUrl() const
Definition AuthContext.h:189
BrowserHandler getBrowserHandler() const
Definition AuthContext.h:183
void setInitializeFrameworkResponse(const QSharedPointer< InitializeFrameworkResponse > &pInitializeFrameworkResponse)
Definition AuthContext.h:330
CVCertificateChain getChainStartingWith(const QSharedPointer< const CVCertificate > &pChainRoot) const
Definition AuthContext.cpp:118
void setDidAuthenticateResponseEac2(const QSharedPointer< DIDAuthenticateResponseEAC2 > &pDidAuthenticateResponseEac2)
Definition AuthContext.h:306
void initAccessRightManager(const QSharedPointer< const CVCertificate > &pTerminalCvc)
Definition AuthContext.cpp:80
const QSharedPointer< DIDAuthenticateEAC1 > & getDidAuthenticateEac1() const
Definition AuthContext.h:237
bool changeTransportPin() const
Definition AuthContext.h:125
void setTransmit(const QSharedPointer< Transmit > &pTransmit)
Definition AuthContext.h:367
void setDidAuthenticateResponseEacAdditionalInputType(const QSharedPointer< DIDAuthenticateResponseEAC2 > &pDidAuthenticateResponseEacAdditionalInputType)
Definition AuthContext.h:282
void setStartPaosResponse(const QSharedPointer< StartPaosResponse > &pStartPaosResponse)
Definition AuthContext.h:342
std::function< QString(const QSharedPointer< AuthContext > &)> BrowserHandler
Definition AuthContext.h:53
Definition CVCertificateChainBuilder.h:18
Definition CVCertificateChain.h:24
Definition EstablishPaceChannelOutput.h:45
Defines the AccessRight and AccessRole enum.
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:112