From 8054a813ea973b69fa655ce0cdfb516db58e4295 Mon Sep 17 00:00:00 2001 From: Manjeet Dahiya Date: Sun, 18 Oct 2009 22:54:04 +0000 Subject: XEP-0078: Non-SASL Authentication Implementation --- source/QXmppNonSASLAuth.cpp | 71 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 source/QXmppNonSASLAuth.cpp (limited to 'source/QXmppNonSASLAuth.cpp') diff --git a/source/QXmppNonSASLAuth.cpp b/source/QXmppNonSASLAuth.cpp new file mode 100644 index 00000000..883bdc0d --- /dev/null +++ b/source/QXmppNonSASLAuth.cpp @@ -0,0 +1,71 @@ +#include "QXmppNonSASLAuth.h" +#include "QXmppUtils.h" +#include + +QXmppNonSASLAuthTypesRequestIq::QXmppNonSASLAuthTypesRequestIq() : QXmppIq(QXmppIq::Get) +{ + +} + +void QXmppNonSASLAuthTypesRequestIq::setUsername( const QString &username ) +{ + m_username = username; +} + +QByteArray QXmppNonSASLAuthTypesRequestIq::toXmlElementFromChild() const +{ + QByteArray resultingXml; + resultingXml += ""; + resultingXml += "" + escapeString(m_username).toUtf8() + ""; + resultingXml += ""; + return resultingXml; +} + +QXmppNonSASLAuthIq::QXmppNonSASLAuthIq() : QXmppIq(QXmppIq::Set), m_useplaintext(false) +{ + +} + +QByteArray QXmppNonSASLAuthIq::toXmlElementFromChild() const +{ + QByteArray resultingXml; + resultingXml += ""; + resultingXml += "" + escapeString(m_username).toUtf8() + ""; + if ( m_useplaintext ) + resultingXml += "" + escapeString(m_password).toUtf8() + ""; + else + {//SHA1(concat(sid, password)). + QByteArray textSid = m_sid.toUtf8(); + QByteArray encodedPassword = m_password.toUtf8(); + QByteArray digest = QCryptographicHash::hash(textSid + encodedPassword, QCryptographicHash::Sha1 ).toHex(); + resultingXml += "" + digest + ""; + } + resultingXml += "" + escapeString(m_resource).toUtf8() + ""; + resultingXml += ""; + return resultingXml; +} + +void QXmppNonSASLAuthIq::setUsername( const QString &username ) +{ + m_username = username; +} + +void QXmppNonSASLAuthIq::setPassword( const QString &password ) +{ + m_password = password; +} + +void QXmppNonSASLAuthIq::setResource( const QString &resource ) +{ + m_resource = resource; +} + +void QXmppNonSASLAuthIq::setStreamId( const QString &sid ) +{ + m_sid = sid; +} + +void QXmppNonSASLAuthIq::setUsePlainText( bool use ) +{ + m_useplaintext = use; +} -- cgit v1.2.3