diff options
author | Markus Goetz <Markus.Goetz@nokia.com> | 2010-10-18 14:21:47 (GMT) |
---|---|---|
committer | Markus Goetz <Markus.Goetz@nokia.com> | 2010-10-27 12:40:26 (GMT) |
commit | 4c29a590cbdd68006906cb8ce3250f8d19caa3d6 (patch) | |
tree | f8c2f23570085a6eaab2a9d0927830e0bd2ac3e3 /src/network/kernel | |
parent | b6b276495b0d02e3bcfa62b793c83f5adcf178c7 (diff) | |
download | Qt-4c29a590cbdd68006906cb8ce3250f8d19caa3d6.zip Qt-4c29a590cbdd68006906cb8ce3250f8d19caa3d6.tar.gz Qt-4c29a590cbdd68006906cb8ce3250f8d19caa3d6.tar.bz2 |
QAuthenticator: Fix NTLMv2 credential caching of QNAM
QNetworkAccessManager used the user() function for caching
the credentials when doing HTTP authentication with NTLMv2. For that
to work it needs to return the same value as was put in with setUser().
Reviewed-by: Peter Hartmann
Reviewed-by: Prasanth
Task-Number: QTBUG-13234
Diffstat (limited to 'src/network/kernel')
-rw-r--r-- | src/network/kernel/qauthenticator.cpp | 14 | ||||
-rw-r--r-- | src/network/kernel/qauthenticator_p.h | 1 |
2 files changed, 9 insertions, 6 deletions
diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index f97d833..220f7da 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -232,19 +232,21 @@ void QAuthenticator::setUser(const QString &user) //domain name is present d->realm.clear(); d->userDomain = user.left(separatorPosn); - d->user = user.mid(separatorPosn + 1); + d->extractedUser = user.mid(separatorPosn + 1); + d->user = user; } else if((separatorPosn = user.indexOf(QLatin1String("@"))) != -1) { //domain name is present d->realm.clear(); d->userDomain = user.left(separatorPosn); - d->user = user.left(separatorPosn); + d->extractedUser = user.left(separatorPosn); + d->user = user; } else { + d->extractedUser = user; d->user = user; d->realm.clear(); d->userDomain.clear(); } break; - // For other auth mechanisms, domain name will be part of username default: d->user = user; break; @@ -1196,7 +1198,7 @@ static QByteArray qCreatev2Hash(const QAuthenticatorPrivate *ctx, Q_ASSERT(hashKey.size() == 16); // Assuming the user and domain is always unicode in challenge QByteArray message = - qStringAsUcs2Le(ctx->user.toUpper()) + + qStringAsUcs2Le(ctx->extractedUser.toUpper()) + qStringAsUcs2Le(phase3->domainStr); phase3->v2Hash = qEncodeHmacMd5(hashKey, message); @@ -1401,8 +1403,8 @@ static QByteArray qNtlmPhase3(QAuthenticatorPrivate *ctx, const QByteArray& phas pb.domainStr = ctx->userDomain; } - offset = qEncodeNtlmString(pb.user, offset, ctx->user, unicode); - pb.userStr = ctx->user; + offset = qEncodeNtlmString(pb.user, offset, ctx->extractedUser, unicode); + pb.userStr = ctx->extractedUser; offset = qEncodeNtlmString(pb.workstation, offset, ctx->workstation, unicode); pb.workstationStr = ctx->workstation; diff --git a/src/network/kernel/qauthenticator_p.h b/src/network/kernel/qauthenticator_p.h index 4e09360..9f2e607 100644 --- a/src/network/kernel/qauthenticator_p.h +++ b/src/network/kernel/qauthenticator_p.h @@ -71,6 +71,7 @@ public: QAtomicInt ref; QString user; + QString extractedUser; QString password; QVariantHash options; Method method; |