Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-22858

QAuthenticator methods setUser and setPassword need better documentation

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Done
    • P3: Somewhat important
    • 5.0.0
    • 4.7.2
    • None
    • qt-everywhere-opensource-src-4.7.2
      SH4 architecture, embedded development

    • 7dffcf8a74de16c977ddff930dd17973d2abdf9d

    Description

      Whenever an authentication fails once and QNetworkAccessManager::authenticationRequired is re-called it is not clear that for the authentication process to be interrupted the methods setUser/setPassword must not be called.
      For example, the following code results in endless stream of signal authenticationRequired.

      void AccessNetwork::authenticationRequired(QNetworkReply *reply, QAuthenticator *auth) {
          auth->setUser(QString(username.c_str()));
          auth->setPassword(QString(password.c_str()));
      }
      
      

      Also the following code will result in a loop.

      void AccessNetwork::authenticationRequired(QNetworkReply *reply, QAuthenticator *auth) {
          if (auth->user() == QString(username.c_str()) && auth->password() == QString(password.c_str())) {
      	auth->setUser(QString());
      	auth->setPassword(QString());
          } else {
      	auth->setUser(QString(username.c_str()));
      	auth->setPassword(QString(password.c_str()));
          }
      }
      
      

      That seems to happen in the code of void QAuthenticator::detach() that creates a new QAuthenticatorPrivate everytime setUser/setPassword methods are called.
      I suggest that the documentation of setUser/setPassword have a warning about this behaviour.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            phartman Peter Hartmann (closed Nokia identity) (Inactive)
            luckijr Lucky Junior
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes