Advertisement
Guest User

Untitled

a guest
May 19th, 2017
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.76 KB | None | 0 0
  1. From 37997a4fc4560352e7f41964781a758eab4382f7 Mon Sep 17 00:00:00 2001
  2. From: Thiago Macieira <thiago.macieira@nokia.com>
  3. Date: Tue, 16 Mar 2010 19:30:52 +0100
  4. Subject: [PATCH] Get rid of the QAuthenticatorPrivate::realm member
  5.  
  6. This is now only in the options hash.
  7. ---
  8. src/network/kernel/qauthenticator.cpp |   24 +++++++++++++-----------
  9.  src/network/kernel/qauthenticator_p.h |    1 -
  10.  2 files changed, 13 insertions(+), 12 deletions(-)
  11.  
  12. diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp
  13. index 95be0d1..621e9f5 100644
  14. --- a/src/network/kernel/qauthenticator.cpp
  15. +++ b/src/network/kernel/qauthenticator.cpp
  16. @@ -110,7 +110,12 @@ static QByteArray qNtlmPhase3(QAuthenticatorPrivate *ctx, const QByteArray& phas
  17.  
  18.    \section2 NTLM version 1
  19.  
  20. -  The NTLM authentication mechanism currently supports no incoming or outgoing options.
  21. +  \table
  22. +    \header \o Option \o Direction \o Description
  23. +    \row \o \tt{realm} \o Incoming \o Contains the realm of the authentication, the same as realm()
  24. +  \endtable
  25. +
  26. +  The NTLM authentication mechanism supports no outgoing options.
  27.  
  28.    \section2 Digest-MD5
  29.  
  30. @@ -180,7 +185,6 @@ bool QAuthenticator::operator==(const QAuthenticator &other) const
  31.          return true;
  32.      return d->user == other.d->user
  33.          && d->password == other.d->password
  34. -        && d->realm == other.d->realm
  35.          && d->method == other.d->method
  36.          && d->options == other.d->options
  37.          && d->outgoingOptions == other.d->outgoingOptions;
  38. @@ -396,16 +400,13 @@ void QAuthenticatorPrivate::parseHttpResponse(const QHttpResponseHeader &header,
  39.  
  40.      switch(method) {
  41.      case Basic:
  42. -        realm = QString::fromLatin1(options.value("realm"));
  43.          if (user.isEmpty())
  44.              phase = Done;
  45.          break;
  46.      case Ntlm:
  47.          // #### extract from header
  48. -        realm.clear();
  49.          break;
  50.      case DigestMd5: {
  51. -        realm = QString::fromLatin1(options.value("realm"));
  52.          if (options.value("stale").toLower() == "true")
  53.              phase = Start;
  54.          if (user.isEmpty())
  55. @@ -413,7 +414,6 @@ void QAuthenticatorPrivate::parseHttpResponse(const QHttpResponseHeader &header,
  56.          break;
  57.      }
  58.      default:
  59. -        realm.clear();
  60.          challenge = QByteArray();
  61.          phase = Invalid;
  62.      }
  63. @@ -628,10 +628,11 @@ QByteArray QAuthenticatorPrivate::digestMd5Response(const QByteArray &challenge,
  64.      QByteArray nonce = options.value("nonce");
  65.      QByteArray opaque = options.value("opaque");
  66.      QByteArray qop = options.value("qop");
  67. +    QByteArray realm = options.value("realm");
  68.  
  69.  //    qDebug() << "calculating digest: method=" << method << "path=" << path;
  70.      QByteArray response = digestMd5ResponseHelper(options.value("algorithm"), user.toLatin1(),
  71. -                                              realm.toLatin1(), password.toLatin1(),
  72. +                                              realm, password.toLatin1(),
  73.                                                nonce, nonceCountString,
  74.                                                cnonce, qop, method,
  75.                                                path, QByteArray());
  76. @@ -639,7 +640,7 @@ QByteArray QAuthenticatorPrivate::digestMd5Response(const QByteArray &challenge,
  77.  
  78.      QByteArray credentials;
  79.      credentials += "username=\"" + user.toLatin1() + "\", ";
  80. -    credentials += "realm=\"" + realm.toLatin1() + "\", ";
  81. +    credentials += "realm=\"" + realm + "\", ";
  82.      credentials += "nonce=\"" + nonce + "\", ";
  83.      credentials += "uri=\"" + path + "\", ";
  84.      if (!opaque.isEmpty())
  85. @@ -1128,7 +1129,8 @@ static QByteArray qNtlmPhase3(QAuthenticatorPrivate *ctx, const QByteArray& phas
  86.  
  87.      bool unicode = ch.flags & NTLMSSP_NEGOTIATE_UNICODE;
  88.  
  89. -    ctx->realm = ch.targetNameStr;
  90. +    QString realm = ch.targetNameStr;
  91. +    ctx->options[QLatin1String("realm")] = realm;
  92.  
  93.      pb.flags = NTLMSSP_NEGOTIATE_NTLM;
  94.      if (unicode)
  95. @@ -1140,8 +1142,8 @@ static QByteArray qNtlmPhase3(QAuthenticatorPrivate *ctx, const QByteArray& phas
  96.      int offset = QNtlmPhase3BlockBase::Size;
  97.      Q_ASSERT(QNtlmPhase3BlockBase::Size == sizeof(QNtlmPhase3BlockBase));
  98.      
  99. -    offset = qEncodeNtlmString(pb.domain, offset, ctx->realm, unicode);
  100. -    pb.domainStr = ctx->realm;
  101. +    offset = qEncodeNtlmString(pb.domain, offset, realm, unicode);
  102. +    pb.domainStr = realm;
  103.      offset = qEncodeNtlmString(pb.user, offset, ctx->user, unicode);
  104.      pb.userStr = ctx->user;
  105.  
  106. diff --git a/src/network/kernel/qauthenticator_p.h b/src/network/kernel/qauthenticator_p.h
  107. index 36227cc..c9bbfa2 100644
  108. --- a/src/network/kernel/qauthenticator_p.h
  109. +++ b/src/network/kernel/qauthenticator_p.h
  110. @@ -75,7 +75,6 @@ public:
  111.      QVariantHash options;
  112.      QVariantHash outgoingOptions;
  113.      Method method;
  114. -    QString realm;
  115.      QByteArray challenge;
  116.  
  117.      enum Phase {
  118. --
  119. 1.7.0.rc2.29.g363cd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement