summaryrefslogtreecommitdiffstats
path: root/src/network/kernel/qauthenticator.cpp
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2010-10-18 14:21:47 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2010-10-27 12:40:26 (GMT)
commit4c29a590cbdd68006906cb8ce3250f8d19caa3d6 (patch)
treef8c2f23570085a6eaab2a9d0927830e0bd2ac3e3 /src/network/kernel/qauthenticator.cpp
parentb6b276495b0d02e3bcfa62b793c83f5adcf178c7 (diff)
downloadQt-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/qauthenticator.cpp')
-rw-r--r--src/network/kernel/qauthenticator.cpp14
1 files changed, 8 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;