-
Notifications
You must be signed in to change notification settings - Fork 0
/
AuthenticationHelper.cpp
667 lines (566 loc) · 20.4 KB
/
AuthenticationHelper.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
/**
* AuthenticationHelper.cpp
* Copyright (c) 2013 ROBLOX Corp. All Rights Reserved.
*/
#include "stdafx.h"
#include "AuthenticationHelper.h"
// Qt Headers
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QNetworkInterface>
include import ('in = interface')
#include <QTimer>
#include <QCoreApplication>
#include <QTime>
#include <QtConcurrentRun>
// Roblox Headers
#include "util/standardout.h"
#include "util/Http.h"
#include "util/Statistics.h"
#include "RobloxServicesTools.h"
// Roblox Studio Headers
#include "RobloxNetworkAccessManager.h"
#include "RobloxSettings.h"
#include "QtUtilities.h"
#include "UpdateUIManager.h"
#include "RobloxNetworkReply.h"
#include "RobloxMainWindow.h"
#include "RobloxCookieJar.h"
#include "Util/RobloxGoogleAnalytics.h"
#include "Util/MachineIdUploader.h"
#include "V8DataModel/ContentProvider.h"
#include "RobloxWebDoc.h"
#include "RobloxDocManager.h"
#include "RobloxServicesTools.h"
FASTFLAG(GoogleAnalyticsTrackingEnabled)
FASTFLAGVARIABLE(StudioInSyncWebKitAuthentication, false)
FASTFLAGVARIABLE(UseAssetGameSubdomainForGetCurrentUser, true)
FASTFLAG(UseBuildGenericGameUrl)
//////////////////////////////////////////////////////////////////////////////////////////////////////
// AuthenticationHelper
QString AuthenticationHelper::userAgentStr = "";
bool AuthenticationHelper::httpAuthenticationPending = false;
bool AuthenticationHelper::verifyUserAuthenticationPending = false;
bool AuthenticationHelper::previouslyAuthenticated = false;
QString AuthenticationHelper::getLoggedInUserUrl()
{
QString result;
if (FFlag::UseBuildGenericGameUrl) {
result = QString::fromStdString(BuildGenericGameUrl(RobloxSettings::getBaseURL().toStdString(), "game/GetCurrentUser.ashx"));
}
else
{
result = RobloxSettings::getBaseURL() + "/game/GetCurrentUser.ashx";
}
if (FFlag::UseAssetGameSubdomainForGetCurrentUser)
{
return QString::fromStdString(
ReplaceTopSubdomain(result.toStdString(), "assetgame"));
}
return result;
}
bool AuthenticationHelper::verifyUserAndAuthenticate(int timeOutTime)
{
if (verifyUserAuthenticationPending || httpAuthenticationPending)
return false;
verifyUserAuthenticationPending = true;
bool result = true;
try
{
QString requestUserUrl = getLoggedInUserUrl();
QUrl url(requestUserUrl);
QNetworkRequest networkRequest(url);
networkRequest.setRawHeader("User-Agent", userAgentStr.toAscii());
RobloxNetworkReply* networkReply = RobloxNetworkAccessManager::Instance().get(networkRequest);
if (!networkReply->waitForFinished(timeOutTime, 100))
{
verifyUserAuthenticationPending = false;
networkReply->deleteLater();
RBX::StandardOut::singleton()->print(RBX::MESSAGE_ERROR, "Unable to get current user. Request timed out.");
networkReply->deleteLater();
RobloxMainWindow::sendCounterEvent("StudioAuthenticationFailure", false);
if (FFlag::GoogleAnalyticsTrackingEnabled)
RBX::RobloxGoogleAnalytics::trackEvent(GA_CATEGORY_ERROR, "StudioAuthenticationFailure");
return false;
}
// Get the logged in user Webkit
QString userIdWebkit(networkReply->readAll());
int statusCode = networkReply->error();
networkReply->deleteLater();
switch (statusCode)
{
case QNetworkReply::NoError:
{
if(userIdWebkit.toInt() > 0)
{
// Get the logged in user HTTP
QString currentUser = getLoggedInUserUrl();
QString userIdHttp = doHttpGetRequest(currentUser);
// If different authenticate the HTTP layer with the webkit user
if(userIdHttp != userIdWebkit)
result = authenticateHttpLayer();
}
else
{
// Sync with HTTP layer: Curl will be using the saved cookie file if any, to login!
result = authenticateWebKitFromHttp();
if (!result)
{
// Error (probably user not authenticated) time to logout the user from Http
deAuthenticateHttpLayer();
result = false;
}
}
break;
}
default:
{
// Error (probably user not authenticated) time to logout the user from Http
deAuthenticateHttpLayer();
result = false;
break;
}
}
}
catch (std::exception const& e)
{
result = false;
RBX::StandardOut::singleton()->print(RBX::MESSAGE_ERROR, e.what());
RobloxMainWindow::sendCounterEvent("StudioAuthenticationFailure", false);
if (FFlag::GoogleAnalyticsTrackingEnabled)
{
RBX::RobloxGoogleAnalytics::trackEvent(GA_CATEGORY_ERROR, "StudioAuthenticationFailure");
}
}
verifyUserAuthenticationPending = false;
return result;
}
int AuthenticationHelper::getHttpUserId()
{
QString currentUser = getLoggedInUserUrl();
QString userIdHttp = doHttpGetRequest(currentUser);
bool ok;
int result = userIdHttp.toInt(&ok, 10);
if (!ok)
{
return 0;
}
return result;
}
/*
* Gets user-id of the user logged into webkit layer
* @Returns: user-id, 0 if no user is logged in
*/
int AuthenticationHelper::getWebKitUserId()
{
QString requestUserUrl = getLoggedInUserUrl();
QUrl url(requestUserUrl);
int userId = 0;
QNetworkRequest networkRequest(url);
networkRequest.setRawHeader("User-Agent", userAgentStr.toAscii());
RobloxNetworkReply* networkReply = RobloxNetworkAccessManager::Instance().get(networkRequest);
if (networkReply && networkReply->waitForFinished(5000, 100) && (networkReply->error() == QNetworkReply::NoError))
{
QString userIdWebkit(networkReply->readAll());
userId = userIdWebkit.toInt();
networkReply->deleteLater();
}
return userId;
}
bool AuthenticationHelper::authenticateHttpLayer()
{
Q_EMIT authenticationChanged(true);
Q_EMIT authenticationDone(true);
return true;
}
void AuthenticationHelper::deAuthenticateHttpLayer()
{
QString logoutUrl;
if (FFlag::UseBuildGenericGameUrl)
{
logoutUrl = QString::fromStdString(BuildGenericGameUrl(RobloxSettings::getBaseURL().toStdString(),"game/logout.aspx"));
}
else
{
logoutUrl = RobloxSettings::getBaseURL() + "/game/logout.aspx";
}
//
doHttpGetRequest(logoutUrl);
Q_EMIT authenticationChanged(false);
}
QString AuthenticationHelper::generateAuthenticationUrl(const QString& authUrl, const QString& ticket)
{
QString compoundStr(authUrl);
if (!ticket.isEmpty())
{
compoundStr.append("?suggest=");
compoundStr.append(ticket);
}
return compoundStr;
}
int AuthenticationHelper::authenticateWebKitFromUrlWithTicket(const QString& url, const QString& ticket)
{
if(!url.isEmpty() && !ticket.isEmpty())
{
return doWebKitAuthentication(generateAuthenticationUrl(url, ticket));
}
return 0;
}
/*
* Authenticate the webkit layer by making a request to this url. Follows redirects recursively.
* @Returns: status code of response
*/
int AuthenticationHelper::doWebKitAuthentication(const QString& url)
{
QNetworkRequest networkRequest(url);
networkRequest.setRawHeader("RBXAuthenticationNegotiation:", QByteArray(GetBaseURL().c_str(), GetBaseURL().length()));
networkRequest.setRawHeader("User-Agent", userAgentStr.toAscii());
RobloxNetworkReply *networkReply = RobloxNetworkAccessManager::Instance().get(networkRequest);
if (!networkReply->waitForFinished(5000, 100))
return 0; // timed out
networkReply->deleteLater();
return networkReply->statusCode();
}
/*
* De-authenticate the webkit layer.
*/
void AuthenticationHelper::deAuthenticateWebKitLayer()
{
QString logoutUrl;
if (FFlag::UseBuildGenericGameUrl)
{
logoutUrl = QString::fromStdString(BuildGenericGameUrl(RobloxSettings::getBaseURL().toStdString(), "game/logout.aspx"));
}
else
{
logoutUrl = RobloxSettings::getBaseURL() + "/game/logout.aspx";
}
QNetworkRequest networkRequest(logoutUrl);
networkRequest.setRawHeader("User-Agent", userAgentStr.toAscii());
RobloxNetworkReply* networkReply = RobloxNetworkAccessManager::Instance().get(networkRequest);
if (networkReply)
{
networkReply->waitForFinished(5000, 100);
networkReply->deleteLater();
}
}
/*
* Authenticate the WinINet layer by making a request to this url.
* @Returns: userId of authenticated user, empty if failed
*/
QString AuthenticationHelper::authenticateWinINetFromUrlWithTicket(const QString& url, const QString& ticket)
{
if(!url.isEmpty() && !ticket.isEmpty())
{
QString compoundStr = generateAuthenticationUrl(url, ticket);
return doHttpGetRequest(compoundStr);
}
return "";
}
QString AuthenticationHelper::doHttpGetRequest(const QString& str, const RBX::HttpAux::AdditionalHeaders& externalHeaders)
{
std::string result = "";
try
{
QByteArray ba = str.toAscii();
const char *c_str = ba.data();
RBX::Http http(c_str);
#ifdef Q_WS_MAC
http.setAuthDomain(::GetBaseURL());
#else
http.additionalHeaders["RBXAuthenticationNegotiation:"] = ::GetBaseURL();
#endif
http.additionalHeaders.insert(externalHeaders.begin(), externalHeaders.end());
http.get(result);
}
catch (std::exception& e)
{
RBX::StandardOut::singleton()->print(RBX::MESSAGE_ERROR, e.what());
return "";
}
return QString::fromStdString(result);
}
AuthenticationHelper::AuthenticationHelper()
: m_CurrentHttpRequestState(-1)
, m_bHttpSessionAuthenticationState(false)
, m_bIgnoreFinishedSignal(false)
{
userAgentStr = RobloxNetworkAccessManager::Instance().getUserAgent();
if (FFlag::StudioInSyncWebKitAuthentication)
qApp->installEventFilter(this);
connect(&RobloxNetworkAccessManager::Instance(), SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError> & )),
this, SLOT(onSSLErrors(QNetworkReply*, const QList<QSslError> & )));
connect(&m_HttpAuthenticationFutureWatcher, SIGNAL(finished()), this, SLOT(httpSessionAuthenticationDone()));
}
bool AuthenticationHelper::validateMachine()
{
return RBX::MachineIdUploader::uploadMachineId(qPrintable(RobloxSettings::getBaseURL()))
!= RBX::MachineIdUploader::RESULT_MachineBanned;
}
bool AuthenticationHelper::eventFilter(QObject * watched, QEvent * evt)
{
QEvent::Type eventType = evt->type();
if (eventType == QEvent::ApplicationDeactivate)
{
// save webkit cookies
savedCookieKey = RobloxNetworkAccessManager::Instance().cookieJar()->getCookieValue(RobloxSettings::getBaseURL(), ".ROBLOSECURITY");
}
else if (eventType == QEvent::ApplicationActivate)
{
QString currentCookieKey = RobloxNetworkAccessManager::Instance().cookieJar()->getCookieValue(RobloxSettings::getBaseURL(), ".ROBLOSECURITY");
if (QString::compare(savedCookieKey, currentCookieKey, Qt::CaseSensitive) != 0)
{
// if we've some cookies saved, then authenticate studio with the saved cookies
if (!currentCookieKey.isEmpty())
{
RobloxNetworkAccessManager::Instance().cookieJar()->reloadCookies(true);
}
// if no cookies, just deauthenticate http layer too
else
{
deAuthenticateWebKitLayer();
}
// to avoid multiple reload of start page, we must call refresh here
RobloxWebDoc* startPage = dynamic_cast<RobloxWebDoc*>(RobloxDocManager::Instance().getStartPageDoc());
if (startPage)
startPage->refreshPage();
// http user and webkit user must be in sync
RBXASSERT(getHttpUserId() == getWebKitUserId());
}
}
return QObject::eventFilter(watched, evt);
}
int AuthenticationHelper::authenticateWebKitFromHttp()
{
// first verify is we've an user id for http, if not then just return
if (getHttpUserId() <=0 )
return 0;
QString requestURL = RobloxSettings::getBaseURL() + "/login/RequestAuth.ashx";
requestURL.replace("http", "https");
// need to add user agent, to make sure we get authorization URL
RBX::HttpAux::AdditionalHeaders externalHeaders;
externalHeaders["User-Agent"] = userAgentStr.toStdString();
// got the URL, now we can authorize webkit
QString returnURL = doHttpGetRequest(requestURL, externalHeaders);
if (!returnURL.isEmpty())
return doWebKitAuthentication(returnURL);
return 0;
}
void AuthenticationHelper::onSSLErrors(QNetworkReply* networkReply, const QList<QSslError> & errlist)
{
QString urlString = networkReply->url().toString();
if (urlString.contains(".robloxlabs.com"))
networkReply->ignoreSslErrors();
}
void AuthenticationHelper::authenticateUserAsync(const QString& url, const QString& ticket)
{
if (!url.isEmpty() && !ticket.isEmpty())
{
// make sure network manager instance get's created in Main thread
RobloxNetworkAccessManager::Instance();
QString authenticationUrl = generateAuthenticationUrl(url, ticket);
m_CurrentHttpRequestState = true;
m_HttpAuthenticationFuture = QtConcurrent::run(this, &AuthenticationHelper::authenticateHttpSession, authenticationUrl);
m_HttpAuthenticationFutureWatcher.setFuture(m_HttpAuthenticationFuture);
m_QtWebkitAuthenticationFuture = QtConcurrent::run(this, &AuthenticationHelper::authenticateQtWebkitSession, authenticationUrl);
m_QtWebkitAuthenticationFutureWatcher.setFuture(m_QtWebkitAuthenticationFuture);
}
else
{
// if we do not have security cookie, then try to authentication using Http session
QString secCookie = RobloxNetworkAccessManager::Instance().cookieJar()->getCookieValue(RobloxSettings::getBaseURL(), ".ROBLOSECURITY");
if (secCookie.isEmpty())
{
m_QtWebkitAuthenticationFuture = QtConcurrent::run(this, &AuthenticationHelper::authenticateQtWebkitSession);
m_QtWebkitAuthenticationFutureWatcher.setFuture(m_QtWebkitAuthenticationFuture);
}
else
{
m_CurrentHttpRequestState = true;
m_HttpAuthenticationFuture = QtConcurrent::run(this, &AuthenticationHelper::authenticateHttpSession);
m_HttpAuthenticationFutureWatcher.setFuture(m_HttpAuthenticationFuture);
}
}
}
void AuthenticationHelper::authenticateHttpSessionAsync(bool state)
{
// if the authentication state is same as the requested then do nothing
if (state && m_bHttpSessionAuthenticationState)
return;
// if either of the concurrent jobs are running then we will have the authentication done
if (((int)state == m_CurrentHttpRequestState) && (m_HttpAuthenticationFutureWatcher.isRunning() || m_QtWebkitAuthenticationFuture.isRunning()))
return;
// make sure there's no other http authentication request is running
waitForHttpAuthentication();
m_CurrentHttpRequestState = state;
if (state)
{
m_HttpAuthenticationFuture = QtConcurrent::run(this, &AuthenticationHelper::authenticateHttpSession);
}
else
{
m_HttpAuthenticationFuture = QtConcurrent::run(this, &AuthenticationHelper::deAuthenticateHttpSession);
}
m_HttpAuthenticationFutureWatcher.setFuture(m_HttpAuthenticationFuture);
}
bool AuthenticationHelper::authenticateHttpSession(const QString& authenticationURL)
{
return getHttpRequest(authenticationURL).isEmpty();
}
bool AuthenticationHelper::authenticateHttpSession()
{
bool result = false;
QString baseURL = RobloxSettings::getBaseURL();
QString authRequest = baseURL + "/login/RequestAuth.ashx";
authRequest.replace("http", "https");
QNetworkRequest networkRequest(authRequest);
networkRequest.setRawHeader("User-Agent", userAgentStr.toAscii());
// we need to create new AccessManager as we are in a different thread, also set cookies loaded from disk to new cookiejar
QNetworkCookieJar* cookieJar = new QNetworkCookieJar;
cookieJar->setCookiesFromUrl(RobloxNetworkAccessManager::Instance().cookieJar()->cookiesForUrl(baseURL), baseURL);
QNetworkAccessManager* accessManager = new QNetworkAccessManager;
accessManager->setCookieJar(cookieJar);
QNetworkReply* networkReply = accessManager->get(networkRequest);
if (baseURL.contains(".robloxlabs.com"))
networkReply->ignoreSslErrors();
RobloxNetworkReply* rbxNetworkReply = new RobloxNetworkReply(networkReply, true);
if (rbxNetworkReply->waitForFinished(10000, 100))
{
if (rbxNetworkReply->error() == QNetworkReply::NoError)
{
result = getHttpRequest(rbxNetworkReply->readAll()).isEmpty();
}
else
{
m_CurrentHttpRequestState = false;
result = deAuthenticateHttpSession();
}
}
else
{
RBX::StandardOut::singleton()->print(RBX::MESSAGE_ERROR, "Unable to authenticate user. Request timed out.");
}
rbxNetworkReply->deleteLater();
accessManager->deleteLater();
return result;
}
bool AuthenticationHelper::deAuthenticateHttpSession()
{
QString logoutUrl;
if (FFlag::UseBuildGenericGameUrl)
{
logoutUrl = QString::fromStdString(BuildGenericGameUrl(RobloxSettings::getBaseURL().toStdString(), "game/logout.aspx"));
}
else
{
logoutUrl = RobloxSettings::getBaseURL() + "/game/logout.aspx";
}
getHttpRequest(logoutUrl);
return true;
}
bool AuthenticationHelper::authenticateQtWebkitSession(const QString& authenticationUrl)
{
bool result = false;
QString baseURL = RobloxSettings::getBaseURL();
QNetworkRequest networkRequest(authenticationUrl);
networkRequest.setRawHeader("RBXAuthenticationNegotiation:", baseURL.toAscii());
networkRequest.setRawHeader("User-Agent", userAgentStr.toAscii());
// we need to create new AccessManager as we are in a different thread
QNetworkAccessManager* accessManager = new QNetworkAccessManager;
QNetworkReply* networkReply = accessManager->get(networkRequest);
if (baseURL.contains(".robloxlabs.com"))
networkReply->ignoreSslErrors();
RobloxNetworkReply* rbxNetworkReply = new RobloxNetworkReply(networkReply, true);
if (rbxNetworkReply->waitForFinished(10000, 100))
{
if (rbxNetworkReply->statusCode() == 200)
{
// pass on the cookies from authenticated session to the static network access manager's cookiejar
RobloxNetworkAccessManager::Instance().cookieJar()->setCookiesFromUrl(accessManager->cookieJar()->cookiesForUrl(baseURL), baseURL);
result = true;
}
}
else
{
RBX::StandardOut::singleton()->print(RBX::MESSAGE_ERROR, "Unable to authenticate user. Request timed out.");
}
rbxNetworkReply->deleteLater();
accessManager->deleteLater();
return result;
}
bool AuthenticationHelper::authenticateQtWebkitSession()
{
// check if already authenticated
QString result = getHttpRequest(getLoggedInUserUrl());
int httpUserId = result.toInt();
// if authenticated then authenticate webkit session too
if (httpUserId > 0)
{
QString requestURL = RobloxSettings::getBaseURL() + "/login/RequestAuth.ashx";
requestURL.replace("http", "https");
// need to add user agent, to make sure we get authorization URL
RBX::HttpAux::AdditionalHeaders externalHeaders;
externalHeaders["User-Agent"] = userAgentStr.toStdString();
// get negotiate URL and authenticate QtWebkit using this
QString negotiateURL = getHttpRequest(requestURL, externalHeaders);
if (!negotiateURL.isEmpty())
return authenticateQtWebkitSession(negotiateURL);
}
return false;
}
QString AuthenticationHelper::getHttpRequest(const QString& urlString, const RBX::HttpAux::AdditionalHeaders& externalHeaders)
{
static QMutex httpRequestMutex;
QMutexLocker lock(&httpRequestMutex);
RBX::HttpOptions options;
options.addHeader("RBXAuthenticationNegotiation:", ::GetBaseURL());
for (RBX::HttpAux::AdditionalHeaders::const_iterator iter = externalHeaders.begin(); iter != externalHeaders.end(); ++iter)
options.addHeader(iter->first, iter->second);
RBX::HttpFuture request = RBX::HttpAsync::get(urlString.toStdString(), options);
std::string result;
try
{
result = request.get();
}
catch (const RBX::base_exception& e)
{
RBX::StandardOut::singleton()->printf(RBX::MESSAGE_ERROR, "Error while authenticating user: %s", e.what());
}
return QString::fromStdString(result);
}
void AuthenticationHelper::httpSessionAuthenticationDone()
{
if (m_bIgnoreFinishedSignal)
{
m_bIgnoreFinishedSignal = false;
return;
}
RBXASSERT(m_CurrentHttpRequestState != -1);
bool requestedState = (bool)m_CurrentHttpRequestState;
m_CurrentHttpRequestState = -1;
if (m_HttpAuthenticationFutureWatcher.result())
{
m_bHttpSessionAuthenticationState = requestedState;
Q_EMIT authenticationChanged(requestedState);
}
else
{
m_bHttpSessionAuthenticationState = false;
}
}
void AuthenticationHelper::waitForHttpAuthentication()
{
if (m_HttpAuthenticationFutureWatcher.isRunning())
{
m_HttpAuthenticationFutureWatcher.waitForFinished();
// if a function is waiting for authentication to complete then call 'httpSessionAuthenticationDone' here itself
httpSessionAuthenticationDone();
// make sure we do not calling 'httpSessionAuthenticationDone' again called on 'finished' signal
m_bIgnoreFinishedSignal = true;
}
}
void AuthenticationHelper::waitForQtWebkitAuthentication()
{
if (m_QtWebkitAuthenticationFutureWatcher.isRunning())
m_QtWebkitAuthenticationFutureWatcher.waitForFinished();
}