aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2012-09-03 13:50:21 +0200
committerJeremy Lainé <jeremy.laine@m4x.org>2012-09-03 13:50:21 +0200
commitd51c6b146d8ca9d1a39bf2fbb6b7d5124dedf09b (patch)
treee561fc568dc844304974382825144d29225900b5 /src/client
parent088cf8e7232a25b31d8acc447e2224bc147b5411 (diff)
downloadqxmpp-d51c6b146d8ca9d1a39bf2fbb6b7d5124dedf09b.tar.gz
make it possible to disable non-SASL authentication
Diffstat (limited to 'src/client')
-rw-r--r--src/client/QXmppConfiguration.cpp31
-rw-r--r--src/client/QXmppConfiguration.h3
-rw-r--r--src/client/QXmppOutgoingClient.cpp10
3 files changed, 26 insertions, 18 deletions
diff --git a/src/client/QXmppConfiguration.cpp b/src/client/QXmppConfiguration.cpp
index b9452f38..d8a4b82e 100644
--- a/src/client/QXmppConfiguration.cpp
+++ b/src/client/QXmppConfiguration.cpp
@@ -58,10 +58,9 @@ public:
int keepAliveTimeout;
// will keep reconnecting if disconnected, default is true
bool autoReconnectionEnabled;
- bool useSASLAuthentication; ///< flag to specify what authentication system
- ///< to be used
- ///< defualt is true and use SASL
- ///< false would use NonSASL if available
+ // which authentication systems to use (if any)
+ bool useSASLAuthentication;
+ bool useNonSASLAuthentication;
// default is true
bool ignoreSslErrors;
@@ -84,6 +83,7 @@ QXmppConfigurationPrivate::QXmppConfigurationPrivate()
, keepAliveTimeout(20)
, autoReconnectionEnabled(true)
, useSASLAuthentication(true)
+ , useNonSASLAuthentication(true)
, ignoreSslErrors(true)
, streamSecurityMode(QXmppConfiguration::TLSEnabled)
, nonSASLAuthMechanism(QXmppConfiguration::NonSASLDigest)
@@ -410,25 +410,34 @@ void QXmppConfiguration::setIgnoreSslErrors(bool value)
d->ignoreSslErrors = value;
}
-/// Returns the type of authentication system specified by the user.
-/// \return true if SASL was specified else false. If the specified
-/// system is not available QXmpp will resort to the other one.
+/// Returns whether to make use of SASL authentication.
bool QXmppConfiguration::useSASLAuthentication() const
{
return d->useSASLAuthentication;
}
-/// Returns the type of authentication system specified by the user.
-/// \param useSASL to hint to use SASL authentication system if available.
-/// false will specify to use NonSASL XEP-0078: Non-SASL Authentication
-/// If the specified one is not availbe, library will use the othe one
+/// Sets whether to make use of SASL authentication.
void QXmppConfiguration::setUseSASLAuthentication(bool useSASL)
{
d->useSASLAuthentication = useSASL;
}
+/// Returns whether to make use of non-SASL authentication.
+
+bool QXmppConfiguration::useNonSASLAuthentication() const
+{
+ return d->useNonSASLAuthentication;
+}
+
+/// Sets whether to make use of non-SASL authentication.
+
+void QXmppConfiguration::setUseNonSASLAuthentication(bool useNonSASL)
+{
+ d->useNonSASLAuthentication = useNonSASL;
+}
+
/// Returns the specified security mode for the stream. The default value is
/// QXmppConfiguration::TLSEnabled.
/// \return StreamSecurityMode
diff --git a/src/client/QXmppConfiguration.h b/src/client/QXmppConfiguration.h
index 34017973..4a690edf 100644
--- a/src/client/QXmppConfiguration.h
+++ b/src/client/QXmppConfiguration.h
@@ -119,6 +119,9 @@ public:
bool useSASLAuthentication() const;
void setUseSASLAuthentication(bool);
+ bool useNonSASLAuthentication() const;
+ void setUseNonSASLAuthentication(bool);
+
bool ignoreSslErrors() const;
void setIgnoreSslErrors(bool);
diff --git a/src/client/QXmppOutgoingClient.cpp b/src/client/QXmppOutgoingClient.cpp
index c3e6c1f9..370cd2aa 100644
--- a/src/client/QXmppOutgoingClient.cpp
+++ b/src/client/QXmppOutgoingClient.cpp
@@ -353,13 +353,7 @@ void QXmppOutgoingClient::handleStanza(const QDomElement &nodeRecv)
// handle authentication
const bool nonSaslAvailable = features.nonSaslAuthMode() != QXmppStreamFeatures::Disabled;
const bool saslAvailable = !features.authMechanisms().isEmpty();
- const bool useSasl = configuration().useSASLAuthentication();
- if((saslAvailable && nonSaslAvailable && !useSasl) ||
- (!saslAvailable && nonSaslAvailable))
- {
- sendNonSASLAuthQuery();
- }
- else if(saslAvailable)
+ if (saslAvailable && configuration().useSASLAuthentication())
{
// supported and preferred SASL auth mechanisms
const QStringList supportedMechanisms = QXmppSaslClient::availableMechanisms();
@@ -410,6 +404,8 @@ void QXmppOutgoingClient::handleStanza(const QDomElement &nodeRecv)
return;
}
sendPacket(QXmppSaslAuth(d->saslClient->mechanism(), response));
+ } else if(nonSaslAvailable && configuration().useNonSASLAuthentication()) {
+ sendNonSASLAuthQuery();
}
// check whether bind is available