AusweisApp2
 Alle Klassen Namensbereiche Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Propertys Freundbeziehungen Makrodefinitionen
AuthContext.h
gehe zur Dokumentation dieser Datei
1 
7 #pragma once
8 
9 #include "asn1/CVCertificate.h"
11 #include "ActivationContext.h"
13 #include "NetworkManager.h"
19 #include "paos/invoke/StartPaos.h"
21 #include "paos/MessageIdHandler.h"
25 #include "paos/retrieve/DidList.h"
29 #include "paos/retrieve/Transmit.h"
30 #include "TcToken.h"
31 #include "UrlUtil.h"
32 
33 #include <QDebug>
34 #include <QPointer>
35 #include <QSharedPointer>
36 #include <QSslCertificate>
37 #include <QUrl>
38 
39 class test_StateRedirectBrowser;
40 class test_StatePreVerification;
41 class test_StateProcessCertificatesFromEac2;
42 class test_StateCertificateDescriptionCheck;
43 
44 namespace governikus
45 {
46 
48  : public WorkflowContext
49 {
50  Q_OBJECT
51 
52  private:
53  friend class ::test_StatePrepareChat;
54  friend class ::test_StateRedirectBrowser;
55  friend class ::test_StatePreVerification;
56  friend class ::test_StateProcessCertificatesFromEac2;
57  friend class ::test_StateCertificateDescriptionCheck;
58 
59  bool mTcTokenNotFound;
60  bool mErrorReportedToServer;
61 
62  QSharedPointer<ActivationContext> mActivationContext;
63  QUrl mTcTokenUrl;
64  QSharedPointer<TcToken> mTcToken;
65  QUrl mRefreshUrl;
66  QSharedPointer<MessageIdHandler> mMessageIdHandler;
67  QSharedPointer<StartPaos> mStartPaos;
68  QSharedPointer<InitializeFramework> mInitializeFramework;
69  QSharedPointer<InitializeFrameworkResponse> mInitializeFrameworkResponse;
70  QSharedPointer<DIDList> mDIDList;
71  QSharedPointer<DIDListResponse> mDIDListResponse;
72  QSharedPointer<DIDAuthenticateEAC1> mDIDAuthenticateEAC1;
73  QSharedPointer<DIDAuthenticateResponseEAC1> mDIDAuthenticateResponseEAC1;
74  QSharedPointer<DIDAuthenticateEAC2> mDIDAuthenticateEAC2;
75  QSharedPointer<DIDAuthenticateResponseEAC2> mDIDAuthenticateResponseEACAdditionalInputType;
76  QSharedPointer<DIDAuthenticateEACAdditional> mDIDAuthenticateEACAdditionalInputType;
77  QSharedPointer<DIDAuthenticateResponseEAC2> mDIDAuthenticateResponseEAC2;
78  QVector<QSharedPointer<Transmit> > mTransmits;
79  QVector<QSharedPointer<TransmitResponse> > mTransmitResponses;
80  bool mTransmitResponseFailed;
81  QSharedPointer<Disconnect> mDisconnect;
82  QSharedPointer<DisconnectResponse> mDisconnectResponse;
83  QSharedPointer<StartPaosResponse> mStartPaosResponse;
84  QSet<AccessRight> mEffectiveAccessRights;
85  QSet<AccessRight> mRequiredAccessRights;
86  QSet<AccessRight> mOptionalAccessRights;
87  QMultiMap<QUrl, QSslCertificate> mCertificates;
88  QSharedPointer<const CVCertificate> mTerminalCvc, mDvCvc;
89  CVCertificateChainBuilder mCvcChainBuilderProd, mCvcChainBuilderTest;
90  QByteArray mSslSession;
91 
92  void initializeChat();
93  bool removeForbiddenAccessRights(QSet<AccessRight>& pSet);
94 
95  Q_SIGNALS:
99 
100  public:
101  AuthContext(const QSharedPointer<ActivationContext>& pActivationContext);
102  virtual ~AuthContext();
103 
104 
106  {
107  return mErrorReportedToServer;
108  }
109 
110 
111  void setErrorReportedToServer(bool pErrorReportedToServer)
112  {
113  mErrorReportedToServer = pErrorReportedToServer;
114  }
115 
116 
117  bool isTcTokenNotFound() const
118  {
119  return mTcTokenNotFound;
120  }
121 
122 
123  void setTcTokenNotFound(bool pTcTokenNotFound)
124  {
125  mTcTokenNotFound = pTcTokenNotFound;
126  }
127 
128 
129  QList<QSslCertificate> getCertificateList() const
130  {
131  return mCertificates.values();
132  }
133 
134 
135  bool containsCertificateFor(const QUrl& pUrl) const
136  {
137  return mCertificates.contains(UrlUtil::getUrlOrigin(pUrl));
138  }
139 
140 
141  void addCertificateData(const QUrl& pUrl, const QSslCertificate& pCert)
142  {
143  QUrl originUrl = UrlUtil::getUrlOrigin(pUrl);
144  qDebug() << "Adding certificate CN=" << pCert.subjectInfo(QSslCertificate::CommonName) << "SN=" << pCert.serialNumber() << "for URL origin" << originUrl;
145  mCertificates.insertMulti(originUrl, pCert);
146  }
147 
148 
150  {
151  return mActivationContext.data();
152  }
153 
154 
155  const QUrl& getTcTokenUrl() const
156  {
157  return mTcTokenUrl;
158  }
159 
160 
161  void setTcTokenUrl(const QUrl& pTcTokenUrl)
162  {
163  mTcTokenUrl = pTcTokenUrl;
164  }
165 
166 
167  const QSharedPointer<TcToken>& getTcToken() const
168  {
169  return mTcToken;
170  }
171 
172 
173  void setTcToken(const QSharedPointer<TcToken>& pTcToken)
174  {
175  mTcToken = pTcToken;
176  }
177 
178 
179  const QSharedPointer<MessageIdHandler>& getMessageIdHandler() const
180  {
181  return mMessageIdHandler;
182  }
183 
184 
185  const QUrl& getRefreshUrl() const
186  {
187  return mRefreshUrl;
188  }
189 
190 
191  void setRefreshUrl(const QUrl& pRefreshUrl)
192  {
193  mRefreshUrl = pRefreshUrl;
194  }
195 
196 
197  const QSharedPointer<DIDAuthenticateEAC1>& getDidAuthenticateEac1() const
198  {
199  return mDIDAuthenticateEAC1;
200  }
201 
202 
203  void setDidAuthenticateEac1(const QSharedPointer<DIDAuthenticateEAC1>& pDIDAuthenticateEAC1)
204  {
205  mDIDAuthenticateEAC1 = pDIDAuthenticateEAC1;
207  }
208 
209 
210  const QSharedPointer<DIDAuthenticateEAC2>& getDidAuthenticateEac2() const
211  {
212  return mDIDAuthenticateEAC2;
213  }
214 
215 
216  void setDidAuthenticateEac2(const QSharedPointer<DIDAuthenticateEAC2>& pDidAuthenticateEac2)
217  {
218  mDIDAuthenticateEAC2 = pDidAuthenticateEac2;
219  }
220 
221 
222  const QSharedPointer<DIDAuthenticateResponseEAC1>& getDidAuthenticateResponseEac1() const
223  {
224  return mDIDAuthenticateResponseEAC1;
225  }
226 
227 
228  void setDidAuthenticateResponseEac1(const QSharedPointer<DIDAuthenticateResponseEAC1>& pDidAuthenticateResponseEac1)
229  {
230  mDIDAuthenticateResponseEAC1 = pDidAuthenticateResponseEac1;
231  }
232 
233 
234  const QSharedPointer<DIDAuthenticateResponseEAC2>& getDidAuthenticateResponseEacAdditionalInputType() const
235  {
236  return mDIDAuthenticateResponseEACAdditionalInputType;
237  }
238 
239 
240  void setDidAuthenticateResponseEacAdditionalInputType(const QSharedPointer<DIDAuthenticateResponseEAC2>& pDidAuthenticateResponseEacAdditionalInputType)
241  {
242  mDIDAuthenticateResponseEACAdditionalInputType = pDidAuthenticateResponseEacAdditionalInputType;
243  }
244 
245 
246  const QSharedPointer<DIDAuthenticateEACAdditional>& getDidAuthenticateEacAdditional() const
247  {
248  return mDIDAuthenticateEACAdditionalInputType;
249  }
250 
251 
252  void setDidAuthenticateEacAdditional(const QSharedPointer<DIDAuthenticateEACAdditional>& pDidAuthenticateEacAdditionalInputType)
253  {
254  mDIDAuthenticateEACAdditionalInputType = pDidAuthenticateEacAdditionalInputType;
255  }
256 
257 
258  const QSharedPointer<DIDAuthenticateResponseEAC2>& getDidAuthenticateResponseEac2() const
259  {
260  return mDIDAuthenticateResponseEAC2;
261  }
262 
263 
264  void setDidAuthenticateResponseEac2(const QSharedPointer<DIDAuthenticateResponseEAC2>& pDidAuthenticateResponseEac2)
265  {
266  mDIDAuthenticateResponseEAC2 = pDidAuthenticateResponseEac2;
267  }
268 
269 
270  const QSharedPointer<DIDList>& getDidList() const
271  {
272  return mDIDList;
273  }
274 
275 
276  void setDidList(const QSharedPointer<DIDList>& pDidList)
277  {
278  mDIDList = pDidList;
279  }
280 
281 
282  const QSharedPointer<DIDListResponse>& getDidListResponse()
283  {
284  return mDIDListResponse;
285  }
286 
287 
288  void setDidListResponse(const QSharedPointer<DIDListResponse>& pDidListResponse)
289  {
290  mDIDListResponse = pDidListResponse;
291  }
292 
293 
294  const QSharedPointer<InitializeFramework>& getInitializeFramework() const
295  {
296  return mInitializeFramework;
297  }
298 
299 
300  void setInitializeFramework(const QSharedPointer<InitializeFramework>& pInitializeFramework)
301  {
302  mInitializeFramework = pInitializeFramework;
303  }
304 
305 
306  const QSharedPointer<InitializeFrameworkResponse>& getInitializeFrameworkResponse() const
307  {
308  return mInitializeFrameworkResponse;
309  }
310 
311 
312  void setInitializeFrameworkResponse(const QSharedPointer<InitializeFrameworkResponse>& pInitializeFrameworkResponse)
313  {
314  mInitializeFrameworkResponse = pInitializeFrameworkResponse;
315  }
316 
317 
318  const QSharedPointer<Disconnect>& getDisconnect() const
319  {
320  return mDisconnect;
321  }
322 
323 
324  void setDisconnect(const QSharedPointer<Disconnect>& pDisconnect)
325  {
326  mDisconnect = pDisconnect;
327  }
328 
329 
330  const QSharedPointer<DisconnectResponse>& getDisconnectResponse()
331  {
332  return mDisconnectResponse;
333  }
334 
335 
336  void setDisconnectResponse(const QSharedPointer<DisconnectResponse>& pDisconnectResponse)
337  {
338  mDisconnectResponse = pDisconnectResponse;
339  }
340 
341 
342  const QSharedPointer<StartPaosResponse>& getStartPaosResponse() const
343  {
344  return mStartPaosResponse;
345  }
346 
347 
348  void setStartPaosResponse(const QSharedPointer<StartPaosResponse>& pStartPaosResponse)
349  {
350  mStartPaosResponse = pStartPaosResponse;
351  }
352 
353 
354  const QVector<QSharedPointer<TransmitResponse> >& getTransmitResponses()
355  {
356  return mTransmitResponses;
357  }
358 
359 
360  void addTransmitResponse(const QSharedPointer<TransmitResponse>& pTransmitResponse)
361  {
362  Q_ASSERT(!pTransmitResponse.isNull());
363  mTransmitResponses += pTransmitResponse;
364  }
365 
366 
368  {
369  return mTransmitResponseFailed;
370  }
371 
372 
373  void setTransmitResponseFailed(bool pFailed)
374  {
375  mTransmitResponseFailed = pFailed;
376  }
377 
378 
379  const QVector<QSharedPointer<Transmit> >& getTransmits()
380  {
381  return mTransmits;
382  }
383 
384 
385  void addTransmit(const QSharedPointer<Transmit>& pTransmit)
386  {
387  Q_ASSERT(!pTransmit.isNull());
388  mTransmits += pTransmit;
389  }
390 
391 
392  QString getRequiredAge() const;
393 
394  const QSet<AccessRight>& getOptionalAccessRights() const
395  {
396  return mOptionalAccessRights;
397  }
398 
399 
400  const QSet<AccessRight>& getRequiredAccessRights() const
401  {
402  return mRequiredAccessRights;
403  }
404 
405 
406  const QSet<AccessRight> getEffectiveAccessRights() const
407  {
408  return mEffectiveAccessRights;
409  }
410 
411 
415  bool addEffectiveAccessRight(AccessRight pAccessRight);
416 
417 
421  bool removeEffectiveAccessRight(AccessRight pAccessRight);
422 
423 
428  bool setEffectiveAccessRights(const QSet<AccessRight>& pAccessRights);
429 
430 
431  QByteArray encodeEffectiveChat();
432 
433 
434  const QSharedPointer<StartPaos>& getStartPaos() const
435  {
436  return mStartPaos;
437  }
438 
439 
440  void setStartPaos(const QSharedPointer<StartPaos>& pStartPaos)
441  {
442  mStartPaos = pStartPaos;
443  }
444 
445 
446  CVCertificateChain getChainStartingWith(const QSharedPointer<const CVCertificate>& pChainRoot) const;
447 
448 
449  bool hasChainForCertificationAuthority(const EstablishPACEChannelOutput& pPaceOutput) const;
450 
451 
453 
454 
455  void initCvcChainBuilder(const QVector<QSharedPointer<const CVCertificate> >& pAdditionalCertificates = QVector<QSharedPointer<const CVCertificate> >());
456 
457 
458  const QSharedPointer<const CVCertificate>& getDvCvc() const
459  {
460  return mDvCvc;
461  }
462 
463 
464  void setDvCvc(const QSharedPointer<const CVCertificate>& dvCvc)
465  {
466  mDvCvc = dvCvc;
467  }
468 
469 
470  const QSharedPointer<const CVCertificate>& getTerminalCvc() const
471  {
472  return mTerminalCvc;
473  }
474 
475 
476  void setTerminalCvc(const QSharedPointer<const CVCertificate>& pTerminalCvc);
477 
478  const QByteArray& getSslSession() const;
479  void setSslSession(const QByteArray& pSession);
480 };
481 
482 } /* namespace governikus */
const QSharedPointer< DisconnectResponse > & getDisconnectResponse()
Definition: AuthContext.h:330
void setDidList(const QSharedPointer< DIDList > &pDidList)
Definition: AuthContext.h:276
Definition: AuthContext.h:47
bool hasChainForCertificationAuthority(const EstablishPACEChannelOutput &pPaceOutput) const
Definition: AuthContext.cpp:266
const QSharedPointer< const CVCertificate > & getDvCvc() const
Definition: AuthContext.h:458
const QUrl & getRefreshUrl() const
Definition: AuthContext.h:185
const QSharedPointer< const CVCertificate > & getTerminalCvc() const
Definition: AuthContext.h:470
void setStartPaos(const QSharedPointer< StartPaos > &pStartPaos)
Definition: AuthContext.h:440
QString getRequiredAge() const
Definition: AuthContext.cpp:299
const QVector< QSharedPointer< Transmit > > & getTransmits()
Definition: AuthContext.h:379
void setDisconnectResponse(const QSharedPointer< DisconnectResponse > &pDisconnectResponse)
Definition: AuthContext.h:336
Definition: CVCertificateChainBuilder.h:19
bool addEffectiveAccessRight(AccessRight pAccessRight)
Definition: AuthContext.cpp:151
const QSharedPointer< DIDAuthenticateEAC2 > & getDidAuthenticateEac2() const
Definition: AuthContext.h:210
void addTransmit(const QSharedPointer< Transmit > &pTransmit)
Definition: AuthContext.h:385
const QSharedPointer< DIDListResponse > & getDidListResponse()
Definition: AuthContext.h:282
void setDidAuthenticateEac2(const QSharedPointer< DIDAuthenticateEAC2 > &pDidAuthenticateEac2)
Definition: AuthContext.h:216
const QSharedPointer< DIDAuthenticateEAC1 > & getDidAuthenticateEac1() const
Definition: AuthContext.h:197
const QSharedPointer< Disconnect > & getDisconnect() const
Definition: AuthContext.h:318
bool containsCertificateFor(const QUrl &pUrl) const
Definition: AuthContext.h:135
QList< QSslCertificate > getCertificateList() const
Definition: AuthContext.h:129
const QSet< AccessRight > & getOptionalAccessRights() const
Definition: AuthContext.h:394
void fireAuthenticationDataChanged()
AuthContext(const QSharedPointer< ActivationContext > &pActivationContext)
Definition: AuthContext.cpp:17
void setDvCvc(const QSharedPointer< const CVCertificate > &dvCvc)
Definition: AuthContext.h:464
const QSharedPointer< InitializeFramework > & getInitializeFramework() const
Definition: AuthContext.h:294
void setInitializeFrameworkResponse(const QSharedPointer< InitializeFrameworkResponse > &pInitializeFrameworkResponse)
Definition: AuthContext.h:312
const QSharedPointer< InitializeFrameworkResponse > & getInitializeFrameworkResponse() const
Definition: AuthContext.h:306
void setTcTokenUrl(const QUrl &pTcTokenUrl)
Definition: AuthContext.h:161
void setStartPaosResponse(const QSharedPointer< StartPaosResponse > &pStartPaosResponse)
Definition: AuthContext.h:348
Definition: CVCertificateChain.h:21
void setRefreshUrl(const QUrl &pRefreshUrl)
Definition: AuthContext.h:191
void addCertificateData(const QUrl &pUrl, const QSslCertificate &pCert)
Definition: AuthContext.h:141
static QUrl getUrlOrigin(const QUrl &pUrl)
Determines the URL origin, i.e.
Definition: UrlUtil.cpp:19
bool getTransmitResponseFailed() const
Definition: AuthContext.h:367
void setSslSession(const QByteArray &pSession)
Definition: AuthContext.cpp:229
CVCertificateChain getChainStartingWith(const QSharedPointer< const CVCertificate > &pChainRoot) const
Definition: AuthContext.cpp:254
void setDidAuthenticateResponseEacAdditionalInputType(const QSharedPointer< DIDAuthenticateResponseEAC2 > &pDidAuthenticateResponseEacAdditionalInputType)
Definition: AuthContext.h:240
void fireDidAuthenticateEac1Changed()
const QUrl & getTcTokenUrl() const
Definition: AuthContext.h:155
void setDidAuthenticateEac1(const QSharedPointer< DIDAuthenticateEAC1 > &pDIDAuthenticateEAC1)
Definition: AuthContext.h:203
Definition: WorkflowContext.h:19
void setDidListResponse(const QSharedPointer< DIDListResponse > &pDidListResponse)
Definition: AuthContext.h:288
void setErrorReportedToServer(bool pErrorReportedToServer)
Definition: AuthContext.h:111
bool isErrorReportedToServer() const
Definition: AuthContext.h:105
const QSet< AccessRight > & getRequiredAccessRights() const
Definition: AuthContext.h:400
void setTerminalCvc(const QSharedPointer< const CVCertificate > &pTerminalCvc)
Definition: AuthContext.cpp:210
const QSharedPointer< DIDAuthenticateEACAdditional > & getDidAuthenticateEacAdditional() const
Definition: AuthContext.h:246
bool removeEffectiveAccessRight(AccessRight pAccessRight)
Definition: AuthContext.cpp:169
void setDidAuthenticateResponseEac2(const QSharedPointer< DIDAuthenticateResponseEAC2 > &pDidAuthenticateResponseEac2)
Definition: AuthContext.h:264
Definition: EstablishPACEChannel.h:98
void setDidAuthenticateResponseEac1(const QSharedPointer< DIDAuthenticateResponseEAC1 > &pDidAuthenticateResponseEac1)
Definition: AuthContext.h:228
QByteArray encodeEffectiveChat()
Definition: AuthContext.cpp:235
const QVector< QSharedPointer< TransmitResponse > > & getTransmitResponses()
Definition: AuthContext.h:354
const QSharedPointer< TcToken > & getTcToken() const
Definition: AuthContext.h:167
ActivationContext * getActivationContext() const
Definition: AuthContext.h:149
void setInitializeFramework(const QSharedPointer< InitializeFramework > &pInitializeFramework)
Definition: AuthContext.h:300
const QSharedPointer< DIDAuthenticateResponseEAC2 > & getDidAuthenticateResponseEacAdditionalInputType() const
Definition: AuthContext.h:234
const QSharedPointer< DIDAuthenticateResponseEAC2 > & getDidAuthenticateResponseEac2() const
Definition: AuthContext.h:258
void setTcToken(const QSharedPointer< TcToken > &pTcToken)
Definition: AuthContext.h:173
const QSharedPointer< DIDList > & getDidList() const
Definition: AuthContext.h:270
const QByteArray & getSslSession() const
Definition: AuthContext.cpp:223
const QSharedPointer< MessageIdHandler > & getMessageIdHandler() const
Definition: AuthContext.h:179
const QSet< AccessRight > getEffectiveAccessRights() const
Definition: AuthContext.h:406
void setDisconnect(const QSharedPointer< Disconnect > &pDisconnect)
Definition: AuthContext.h:324
const QSharedPointer< DIDAuthenticateResponseEAC1 > & getDidAuthenticateResponseEac1() const
Definition: AuthContext.h:222
const QSharedPointer< StartPaosResponse > & getStartPaosResponse() const
Definition: AuthContext.h:342
void setTransmitResponseFailed(bool pFailed)
Definition: AuthContext.h:373
virtual ~AuthContext()
Definition: AuthContext.cpp:55
void setTcTokenNotFound(bool pTcTokenNotFound)
Definition: AuthContext.h:123
bool isTcTokenNotFound() const
Definition: AuthContext.h:117
void addTransmitResponse(const QSharedPointer< TransmitResponse > &pTransmitResponse)
Definition: AuthContext.h:360
CVCertificateChain getChainForCertificationAuthority(const EstablishPACEChannelOutput &pPaceOutput) const
Definition: AuthContext.cpp:272
void initCvcChainBuilder(const QVector< QSharedPointer< const CVCertificate > > &pAdditionalCertificates=QVector< QSharedPointer< const CVCertificate > >())
Definition: AuthContext.cpp:284
Definition: ActivationContext.h:18
const QSharedPointer< StartPaos > & getStartPaos() const
Definition: AuthContext.h:434
void setDidAuthenticateEacAdditional(const QSharedPointer< DIDAuthenticateEACAdditional > &pDidAuthenticateEacAdditionalInputType)
Definition: AuthContext.h:252
bool setEffectiveAccessRights(const QSet< AccessRight > &pAccessRights)
Definition: AuthContext.cpp:186