From 821ac0b4dbeccd98d4483efcafecd82efbd55d8f Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Thu, 26 Aug 2010 07:50:11 +0000 Subject: rework QXmppPasswordChecker --- examples/example_8_server/main.cpp | 6 +++--- src/QXmppIncomingClient.cpp | 12 +++++------- src/QXmppIncomingClient.h | 4 ++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/examples/example_8_server/main.cpp b/examples/example_8_server/main.cpp index c6c6027d..b5e8cc44 100644 --- a/examples/example_8_server/main.cpp +++ b/examples/example_8_server/main.cpp @@ -33,7 +33,7 @@ class passwordChecker : public QXmppPasswordChecker { /// Checks that the given credentials are valid. - bool checkCredentials(const QString &username, const QString &password) + bool checkPassword(const QString &username, const QString &password) { return (username == USERNAME && password == PASSWORD); }; @@ -50,8 +50,8 @@ class passwordChecker : public QXmppPasswordChecker } }; - /// Returns true as we support retrieving a password. - bool hasPasswords() const + /// Returns true as we implemented getPassword(). + bool hasGetPassword() const { return true; }; diff --git a/src/QXmppIncomingClient.cpp b/src/QXmppIncomingClient.cpp index e66b893f..6a2e5c49 100644 --- a/src/QXmppIncomingClient.cpp +++ b/src/QXmppIncomingClient.cpp @@ -146,7 +146,7 @@ void QXmppIncomingClient::handleStream(const QDomElement &streamElement) { QList mechanisms; mechanisms << QXmppConfiguration::SASLPlain; - if (d->passwordChecker->hasPasswords()) + if (d->passwordChecker->hasGetPassword()) mechanisms << QXmppConfiguration::SASLDigestMD5; features.setAuthMechanisms(mechanisms); } @@ -183,7 +183,7 @@ void QXmppIncomingClient::handleStanza(const QDomElement &nodeRecv) const QString username = QString::fromUtf8(auth[1]); const QString password = QString::fromUtf8(auth[2]); - if (d->passwordChecker && d->passwordChecker->checkCredentials(username, password)) + if (d->passwordChecker && d->passwordChecker->checkPassword(username, password)) { d->username = username; sendData(""); @@ -314,7 +314,7 @@ void QXmppIncomingClient::slotTimeout() /// Retrieves the password for the given username. /// -/// Reimplement this method to support DIGEST-MD5 authentication. +/// You need to reimplement this method to support DIGEST-MD5 authentication. /// /// \param username /// \param password @@ -326,12 +326,10 @@ bool QXmppPasswordChecker::getPassword(const QString &username, QString &passwor return false; } -/// Returns true if it is possible to retrieve passwords. +/// Returns true if the getPassword() method is implemented. /// -/// Reimplement this method and return true if you provided a -/// getPassword() method. -bool QXmppPasswordChecker::hasPasswords() const +bool QXmppPasswordChecker::hasGetPassword() const { return false; } diff --git a/src/QXmppIncomingClient.h b/src/QXmppIncomingClient.h index 25022d0c..532d0bc2 100644 --- a/src/QXmppIncomingClient.h +++ b/src/QXmppIncomingClient.h @@ -38,9 +38,9 @@ public: /// /// \param username /// \param password - virtual bool checkCredentials(const QString &username, const QString &password) = 0; + virtual bool checkPassword(const QString &username, const QString &password) = 0; virtual bool getPassword(const QString &username, QString &password); - virtual bool hasPasswords() const; + virtual bool hasGetPassword() const; }; /// \brief The QXmppIncomingClient class represents an incoming XMPP stream -- cgit v1.2.3