aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2012-07-20 09:21:12 +0200
committerJeremy Lainé <jeremy.laine@m4x.org>2012-07-20 09:21:12 +0200
commitfc010e259215f270c2c400c682feadf6d4d570c9 (patch)
treec4d7cda45495af1a418e8f9fe8527cceda3d63eb /src
parent0c523e7b9658921c49a87a253adb4cc625c4a36a (diff)
downloadqxmpp-fc010e259215f270c2c400c682feadf6d4d570c9.tar.gz
SASL: don't hardcode service type
Diffstat (limited to 'src')
-rw-r--r--src/base/QXmppSaslAuth.cpp33
-rw-r--r--src/base/QXmppSaslAuth.h7
-rw-r--r--src/client/QXmppOutgoingClient.cpp3
3 files changed, 31 insertions, 12 deletions
diff --git a/src/base/QXmppSaslAuth.cpp b/src/base/QXmppSaslAuth.cpp
index e913a8d8..9152d523 100644
--- a/src/base/QXmppSaslAuth.cpp
+++ b/src/base/QXmppSaslAuth.cpp
@@ -34,7 +34,8 @@
class QXmppSaslClientPrivate
{
public:
- QString server;
+ QString host;
+ QString serviceType;
QString username;
QString password;
};
@@ -64,21 +65,35 @@ QXmppSaslClient* QXmppSaslClient::create(const QString &mechanism)
}
}
-/// Returns the server.
+/// Returns the host.
-QString QXmppSaslClient::server() const
+QString QXmppSaslClient::host() const
{
- return d->server;
+ return d->host;
}
-/// Sets the server.
+/// Sets the host.
-void QXmppSaslClient::setServer(const QString &server)
+void QXmppSaslClient::setHost(const QString &host)
{
- d->server = server;
+ d->host = host;
}
-/// Returns the username.
+/// Returns the service type, e.g. "xmpp".
+
+QString QXmppSaslClient::serviceType() const
+{
+ return d->serviceType;
+}
+
+/// Sets the service type, e.g. "xmpp".
+
+void QXmppSaslClient::setServiceType(const QString &serviceType)
+{
+ d->serviceType = serviceType;
+}
+
+/// Returns the host.
QString QXmppSaslClient::username() const
{
@@ -167,7 +182,7 @@ bool QXmppSaslClientDigestMd5::respond(const QByteArray &challenge, QByteArray &
m_saslDigest.setQop("auth");
m_saslDigest.setCnonce(QXmppSaslDigestMd5::generateNonce());
m_saslDigest.setNc("00000001");
- m_saslDigest.setDigestUri(QString("xmpp/%1").arg(server()).toUtf8());
+ m_saslDigest.setDigestUri(QString("%1/%2").arg(serviceType(), host()).toUtf8());
m_saslDigest.setNonce(input.value("nonce"));
m_saslDigest.setSecret(QCryptographicHash::hash(
username().toUtf8() + ":" + realm + ":" + password().toUtf8(),
diff --git a/src/base/QXmppSaslAuth.h b/src/base/QXmppSaslAuth.h
index cb6fc467..ad8c78b5 100644
--- a/src/base/QXmppSaslAuth.h
+++ b/src/base/QXmppSaslAuth.h
@@ -82,8 +82,11 @@ public:
QXmppSaslClient();
virtual ~QXmppSaslClient();
- QString server() const;
- void setServer(const QString &server);
+ QString host() const;
+ void setHost(const QString &host);
+
+ QString serviceType() const;
+ void setServiceType(const QString &serviceType);
QString username() const;
void setUsername(const QString &username);
diff --git a/src/client/QXmppOutgoingClient.cpp b/src/client/QXmppOutgoingClient.cpp
index 9abd85a4..4177f0b2 100644
--- a/src/client/QXmppOutgoingClient.cpp
+++ b/src/client/QXmppOutgoingClient.cpp
@@ -366,7 +366,8 @@ void QXmppOutgoingClient::handleStanza(const QDomElement &nodeRecv)
return;
}
info(QString("SASL mechanism '%1' selected").arg(d->saslClient->mechanism()));
- d->saslClient->setServer(configuration().domain());
+ d->saslClient->setHost(configuration().host());
+ d->saslClient->setServiceType("xmpp");
if (d->saslClient->mechanism() == "X-FACEBOOK-PLATFORM") {
d->saslClient->setUsername(configuration().facebookAppId());
d->saslClient->setPassword(configuration().facebookAccessToken());