diff options
| author | Jonah BrĂ¼chert <jbb.prv@gmx.de> | 2020-03-28 23:48:44 +0100 |
|---|---|---|
| committer | LNJ <lnj@kaidan.im> | 2020-03-29 00:03:43 +0100 |
| commit | ecd3d0a1ce24750f725bbfd98330fc1498e327a5 (patch) | |
| tree | 87ea55c304056837b9cf95c8fac58e3f4a77af62 /src/base/QXmppSasl.cpp | |
| parent | efc82e3307ac28ca0eb9639274301e9cb350e257 (diff) | |
| download | qxmpp-ecd3d0a1ce24750f725bbfd98330fc1498e327a5.tar.gz | |
Expand QSL and QBL
So they don't leak into the public API
Diffstat (limited to 'src/base/QXmppSasl.cpp')
| -rw-r--r-- | src/base/QXmppSasl.cpp | 206 |
1 files changed, 103 insertions, 103 deletions
diff --git a/src/base/QXmppSasl.cpp b/src/base/QXmppSasl.cpp index 29b9b5d2..8d5217fb 100644 --- a/src/base/QXmppSasl.cpp +++ b/src/base/QXmppSasl.cpp @@ -131,15 +131,15 @@ void QXmppSaslAuth::setValue(const QByteArray &value) void QXmppSaslAuth::parse(const QDomElement &element) { - m_mechanism = element.attribute(QSL("mechanism")); + m_mechanism = element.attribute(QStringLiteral("mechanism")); m_value = QByteArray::fromBase64(element.text().toLatin1()); } void QXmppSaslAuth::toXml(QXmlStreamWriter *writer) const { - writer->writeStartElement(QSL("auth")); + writer->writeStartElement(QStringLiteral("auth")); writer->writeDefaultNamespace(ns_xmpp_sasl); - writer->writeAttribute(QSL("mechanism"), m_mechanism); + writer->writeAttribute(QStringLiteral("mechanism"), m_mechanism); if (!m_value.isEmpty()) writer->writeCharacters(m_value.toBase64()); writer->writeEndElement(); @@ -167,7 +167,7 @@ void QXmppSaslChallenge::parse(const QDomElement &element) void QXmppSaslChallenge::toXml(QXmlStreamWriter *writer) const { - writer->writeStartElement(QSL("challenge")); + writer->writeStartElement(QStringLiteral("challenge")); writer->writeDefaultNamespace(ns_xmpp_sasl); if (!m_value.isEmpty()) writer->writeCharacters(m_value.toBase64()); @@ -196,7 +196,7 @@ void QXmppSaslFailure::parse(const QDomElement &element) void QXmppSaslFailure::toXml(QXmlStreamWriter *writer) const { - writer->writeStartElement(QSL("failure")); + writer->writeStartElement(QStringLiteral("failure")); writer->writeDefaultNamespace(ns_xmpp_sasl); if (!m_condition.isEmpty()) writer->writeEmptyElement(m_condition); @@ -225,7 +225,7 @@ void QXmppSaslResponse::parse(const QDomElement &element) void QXmppSaslResponse::toXml(QXmlStreamWriter *writer) const { - writer->writeStartElement(QSL("response")); + writer->writeStartElement(QStringLiteral("response")); writer->writeDefaultNamespace(ns_xmpp_sasl); if (!m_value.isEmpty()) writer->writeCharacters(m_value.toBase64()); @@ -243,7 +243,7 @@ void QXmppSaslSuccess::parse(const QDomElement &element) void QXmppSaslSuccess::toXml(QXmlStreamWriter *writer) const { - writer->writeStartElement(QSL("success")); + writer->writeStartElement(QStringLiteral("success")); writer->writeDefaultNamespace(ns_xmpp_sasl); writer->writeEndElement(); } @@ -271,35 +271,35 @@ QXmppSaslClient::~QXmppSaslClient() QStringList QXmppSaslClient::availableMechanisms() { - return QStringList() << QSL("SCRAM-SHA-256") - << QSL("SCRAM-SHA-1") - << QSL("DIGEST-MD5") - << QSL("PLAIN") - << QSL("ANONYMOUS") - << QSL("X-FACEBOOK-PLATFORM") - << QSL("X-MESSENGER-OAUTH2") - << QSL("X-OAUTH2"); + return QStringList() << QStringLiteral("SCRAM-SHA-256") + << QStringLiteral("SCRAM-SHA-1") + << QStringLiteral("DIGEST-MD5") + << QStringLiteral("PLAIN") + << QStringLiteral("ANONYMOUS") + << QStringLiteral("X-FACEBOOK-PLATFORM") + << QStringLiteral("X-MESSENGER-OAUTH2") + << QStringLiteral("X-OAUTH2"); } /// Creates an SASL client for the given mechanism. QXmppSaslClient *QXmppSaslClient::create(const QString &mechanism, QObject *parent) { - if (mechanism == QSL("PLAIN")) { + if (mechanism == QStringLiteral("PLAIN")) { return new QXmppSaslClientPlain(parent); - } else if (mechanism == QSL("DIGEST-MD5")) { + } else if (mechanism == QStringLiteral("DIGEST-MD5")) { return new QXmppSaslClientDigestMd5(parent); - } else if (mechanism == QSL("ANONYMOUS")) { + } else if (mechanism == QStringLiteral("ANONYMOUS")) { return new QXmppSaslClientAnonymous(parent); - } else if (mechanism == QSL("SCRAM-SHA-1")) { + } else if (mechanism == QStringLiteral("SCRAM-SHA-1")) { return new QXmppSaslClientScram(QCryptographicHash::Sha1, parent); - } else if (mechanism == QSL("SCRAM-SHA-256")) { + } else if (mechanism == QStringLiteral("SCRAM-SHA-256")) { return new QXmppSaslClientScram(QCryptographicHash::Sha256, parent); - } else if (mechanism == QSL("X-FACEBOOK-PLATFORM")) { + } else if (mechanism == QStringLiteral("X-FACEBOOK-PLATFORM")) { return new QXmppSaslClientFacebook(parent); - } else if (mechanism == QSL("X-MESSENGER-OAUTH2")) { + } else if (mechanism == QStringLiteral("X-MESSENGER-OAUTH2")) { return new QXmppSaslClientWindowsLive(parent); - } else if (mechanism == QSL("X-OAUTH2")) { + } else if (mechanism == QStringLiteral("X-OAUTH2")) { return new QXmppSaslClientGoogle(parent); } else { return nullptr; @@ -369,7 +369,7 @@ QXmppSaslClientAnonymous::QXmppSaslClientAnonymous(QObject *parent) QString QXmppSaslClientAnonymous::mechanism() const { - return QSL("ANONYMOUS"); + return QStringLiteral("ANONYMOUS"); } bool QXmppSaslClientAnonymous::respond(const QByteArray &challenge, QByteArray &response) @@ -380,13 +380,13 @@ bool QXmppSaslClientAnonymous::respond(const QByteArray &challenge, QByteArray & m_step++; return true; } else { - warning(QSL("QXmppSaslClientAnonymous : Invalid step")); + warning(QStringLiteral("QXmppSaslClientAnonymous : Invalid step")); return false; } } QXmppSaslClientDigestMd5::QXmppSaslClientDigestMd5(QObject *parent) - : QXmppSaslClient(parent), m_nc(QBL("00000001")), m_step(0) + : QXmppSaslClient(parent), m_nc(QByteArrayLiteral("00000001")), m_step(0) { m_cnonce = generateNonce(); } @@ -399,7 +399,7 @@ QString QXmppSaslClientDigestMd5::mechanism() const bool QXmppSaslClientDigestMd5::respond(const QByteArray &challenge, QByteArray &response) { Q_UNUSED(challenge); - const QByteArray digestUri = QSL("%1/%2").arg(serviceType(), host()).toUtf8(); + const QByteArray digestUri = QStringLiteral("%1/%2").arg(serviceType(), host()).toUtf8(); if (m_step == 0) { response = QByteArray(); @@ -408,38 +408,38 @@ bool QXmppSaslClientDigestMd5::respond(const QByteArray &challenge, QByteArray & } else if (m_step == 1) { const QMap<QByteArray, QByteArray> input = QXmppSaslDigestMd5::parseMessage(challenge); - if (!input.contains(QBL("nonce"))) { - warning(QSL("QXmppSaslClientDigestMd5 : Invalid input on step 1")); + if (!input.contains(QByteArrayLiteral("nonce"))) { + warning(QStringLiteral("QXmppSaslClientDigestMd5 : Invalid input on step 1")); return false; } // determine realm - const QByteArray realm = input.value(QBL("realm")); + const QByteArray realm = input.value(QByteArrayLiteral("realm")); // determine quality of protection - const QList<QByteArray> qops = input.value(QBL("qop"), QBL("auth")).split(','); - if (!qops.contains(QBL("auth"))) { - warning(QSL("QXmppSaslClientDigestMd5 : Invalid quality of protection")); + const QList<QByteArray> qops = input.value(QByteArrayLiteral("qop"), QByteArrayLiteral("auth")).split(','); + if (!qops.contains(QByteArrayLiteral("auth"))) { + warning(QStringLiteral("QXmppSaslClientDigestMd5 : Invalid quality of protection")); return false; } - m_nonce = input.value(QBL("nonce")); + m_nonce = input.value(QByteArrayLiteral("nonce")); m_secret = QCryptographicHash::hash( - username().toUtf8() + QBL(":") + realm + QBL(":") + password().toUtf8(), + username().toUtf8() + QByteArrayLiteral(":") + realm + QByteArrayLiteral(":") + password().toUtf8(), QCryptographicHash::Md5); // Build response QMap<QByteArray, QByteArray> output; - output[QBL("username")] = username().toUtf8(); + output[QByteArrayLiteral("username")] = username().toUtf8(); if (!realm.isEmpty()) - output[QBL("realm")] = realm; - output[QBL("nonce")] = m_nonce; - output[QBL("qop")] = QBL("auth"); - output[QBL("cnonce")] = m_cnonce; - output[QBL("nc")] = m_nc; - output[QBL("digest-uri")] = digestUri; - output[QBL("response")] = calculateDigest(QBL("AUTHENTICATE"), digestUri, m_secret, m_nonce, m_cnonce, m_nc); - output[QBL("charset")] = QBL("utf-8"); + output[QByteArrayLiteral("realm")] = realm; + output[QByteArrayLiteral("nonce")] = m_nonce; + output[QByteArrayLiteral("qop")] = QByteArrayLiteral("auth"); + output[QByteArrayLiteral("cnonce")] = m_cnonce; + output[QByteArrayLiteral("nc")] = m_nc; + output[QByteArrayLiteral("digest-uri")] = digestUri; + output[QByteArrayLiteral("response")] = calculateDigest(QByteArrayLiteral("AUTHENTICATE"), digestUri, m_secret, m_nonce, m_cnonce, m_nc); + output[QByteArrayLiteral("charset")] = QByteArrayLiteral("utf-8"); response = QXmppSaslDigestMd5::serializeMessage(output); m_step++; @@ -448,8 +448,8 @@ bool QXmppSaslClientDigestMd5::respond(const QByteArray &challenge, QByteArray & const QMap<QByteArray, QByteArray> input = QXmppSaslDigestMd5::parseMessage(challenge); // check new challenge - if (input.value(QBL("rspauth")) != calculateDigest(QByteArray(), digestUri, m_secret, m_nonce, m_cnonce, m_nc)) { - warning(QSL("QXmppSaslClientDigestMd5 : Invalid challenge on step 2")); + if (input.value(QByteArrayLiteral("rspauth")) != calculateDigest(QByteArray(), digestUri, m_secret, m_nonce, m_cnonce, m_nc)) { + warning(QStringLiteral("QXmppSaslClientDigestMd5 : Invalid challenge on step 2")); return false; } @@ -457,7 +457,7 @@ bool QXmppSaslClientDigestMd5::respond(const QByteArray &challenge, QByteArray & m_step++; return true; } else { - warning(QSL("QXmppSaslClientDigestMd5 : Invalid step")); + warning(QStringLiteral("QXmppSaslClientDigestMd5 : Invalid step")); return false; } } @@ -469,7 +469,7 @@ QXmppSaslClientFacebook::QXmppSaslClientFacebook(QObject *parent) QString QXmppSaslClientFacebook::mechanism() const { - return QSL("X-FACEBOOK-PLATFORM"); + return QStringLiteral("X-FACEBOOK-PLATFORM"); } bool QXmppSaslClientFacebook::respond(const QByteArray &challenge, QByteArray &response) @@ -482,26 +482,26 @@ bool QXmppSaslClientFacebook::respond(const QByteArray &challenge, QByteArray &r } else if (m_step == 1) { // parse request QUrlQuery requestUrl(challenge); - if (!requestUrl.hasQueryItem(QSL("method")) || !requestUrl.hasQueryItem(QSL("nonce"))) { - warning(QSL("QXmppSaslClientFacebook : Invalid challenge, nonce or method missing")); + if (!requestUrl.hasQueryItem(QStringLiteral("method")) || !requestUrl.hasQueryItem(QStringLiteral("nonce"))) { + warning(QStringLiteral("QXmppSaslClientFacebook : Invalid challenge, nonce or method missing")); return false; } // build response QUrlQuery responseUrl; - responseUrl.addQueryItem(QSL("access_token"), password()); - responseUrl.addQueryItem(QSL("api_key"), username()); - responseUrl.addQueryItem(QSL("call_id"), nullptr); - responseUrl.addQueryItem(QSL("method"), requestUrl.queryItemValue(QSL("method"))); - responseUrl.addQueryItem(QSL("nonce"), requestUrl.queryItemValue(QSL("nonce"))); - responseUrl.addQueryItem(QSL("v"), QSL("1.0")); + responseUrl.addQueryItem(QStringLiteral("access_token"), password()); + responseUrl.addQueryItem(QStringLiteral("api_key"), username()); + responseUrl.addQueryItem(QStringLiteral("call_id"), nullptr); + responseUrl.addQueryItem(QStringLiteral("method"), requestUrl.queryItemValue(QStringLiteral("method"))); + responseUrl.addQueryItem(QStringLiteral("nonce"), requestUrl.queryItemValue(QStringLiteral("nonce"))); + responseUrl.addQueryItem(QStringLiteral("v"), QStringLiteral("1.0")); response = responseUrl.query().toUtf8(); m_step++; return true; } else { - warning(QSL("QXmppSaslClientFacebook : Invalid step")); + warning(QStringLiteral("QXmppSaslClientFacebook : Invalid step")); return false; } } @@ -513,7 +513,7 @@ QXmppSaslClientGoogle::QXmppSaslClientGoogle(QObject *parent) QString QXmppSaslClientGoogle::mechanism() const { - return QSL("X-OAUTH2"); + return QStringLiteral("X-OAUTH2"); } bool QXmppSaslClientGoogle::respond(const QByteArray &challenge, QByteArray &response) @@ -525,7 +525,7 @@ bool QXmppSaslClientGoogle::respond(const QByteArray &challenge, QByteArray &res m_step++; return true; } else { - warning(QSL("QXmppSaslClientGoogle : Invalid step")); + warning(QStringLiteral("QXmppSaslClientGoogle : Invalid step")); return false; } } @@ -537,7 +537,7 @@ QXmppSaslClientPlain::QXmppSaslClientPlain(QObject *parent) QString QXmppSaslClientPlain::mechanism() const { - return QSL("PLAIN"); + return QStringLiteral("PLAIN"); } bool QXmppSaslClientPlain::respond(const QByteArray &challenge, QByteArray &response) @@ -548,7 +548,7 @@ bool QXmppSaslClientPlain::respond(const QByteArray &challenge, QByteArray &resp m_step++; return true; } else { - warning(QSL("QXmppSaslClientPlain : Invalid step")); + warning(QStringLiteral("QXmppSaslClientPlain : Invalid step")); return false; } } @@ -561,10 +561,10 @@ QXmppSaslClientScram::QXmppSaslClientScram(QCryptographicHash::Algorithm algorit if (m_algorithm == QCryptographicHash::Sha256) { m_dklen = 32; - m_mechanism = QSL("SCRAM-SHA-256"); + m_mechanism = QStringLiteral("SCRAM-SHA-256"); } else { m_dklen = 20; - m_mechanism = QSL("SCRAM-SHA-1"); + m_mechanism = QStringLiteral("SCRAM-SHA-1"); } } @@ -577,8 +577,8 @@ bool QXmppSaslClientScram::respond(const QByteArray &challenge, QByteArray &resp { Q_UNUSED(challenge); if (m_step == 0) { - m_gs2Header = QBL("n,,"); - m_clientFirstMessageBare = QBL("n=") + username().toUtf8() + QBL(",r=") + m_nonce; + m_gs2Header = QByteArrayLiteral("n,,"); + m_clientFirstMessageBare = QByteArrayLiteral("n=") + username().toUtf8() + QByteArrayLiteral(",r=") + m_nonce; response = m_gs2Header + m_clientFirstMessageBare; m_step++; @@ -594,20 +594,20 @@ bool QXmppSaslClientScram::respond(const QByteArray &challenge, QByteArray &resp } // calculate proofs - const QByteArray clientFinalMessageBare = QBL("c=") + m_gs2Header.toBase64() + QBL(",r=") + nonce; + const QByteArray clientFinalMessageBare = QByteArrayLiteral("c=") + m_gs2Header.toBase64() + QByteArrayLiteral(",r=") + nonce; const QByteArray saltedPassword = deriveKeyPbkdf2(m_algorithm, password().toUtf8(), salt, iterations, m_dklen); - const QByteArray clientKey = QMessageAuthenticationCode::hash(QBL("Client Key"), saltedPassword, m_algorithm); + const QByteArray clientKey = QMessageAuthenticationCode::hash(QByteArrayLiteral("Client Key"), saltedPassword, m_algorithm); const QByteArray storedKey = QCryptographicHash::hash(clientKey, m_algorithm); - const QByteArray authMessage = m_clientFirstMessageBare + QBL(",") + challenge + QBL(",") + clientFinalMessageBare; + const QByteArray authMessage = m_clientFirstMessageBare + QByteArrayLiteral(",") + challenge + QByteArrayLiteral(",") + clientFinalMessageBare; QByteArray clientProof = QMessageAuthenticationCode::hash(authMessage, storedKey, m_algorithm); std::transform(clientProof.cbegin(), clientProof.cend(), clientKey.cbegin(), clientProof.begin(), std::bit_xor<char>()); - const QByteArray serverKey = QMessageAuthenticationCode::hash(QBL("Server Key"), saltedPassword, m_algorithm); + const QByteArray serverKey = QMessageAuthenticationCode::hash(QByteArrayLiteral("Server Key"), saltedPassword, m_algorithm); m_serverSignature = QMessageAuthenticationCode::hash(authMessage, serverKey, m_algorithm); - response = clientFinalMessageBare + QBL(",p=") + clientProof.toBase64(); + response = clientFinalMessageBare + QByteArrayLiteral(",p=") + clientProof.toBase64(); m_step++; return true; } else if (m_step == 2) { @@ -616,7 +616,7 @@ bool QXmppSaslClientScram::respond(const QByteArray &challenge, QByteArray &resp m_step++; return QByteArray::fromBase64(input.value('v')) == m_serverSignature; } else { - warning(QSL("QXmppSaslClientPlain : Invalid step")); + warning(QStringLiteral("QXmppSaslClientPlain : Invalid step")); return false; } } @@ -628,7 +628,7 @@ QXmppSaslClientWindowsLive::QXmppSaslClientWindowsLive(QObject *parent) QString QXmppSaslClientWindowsLive::mechanism() const { - return QSL("X-MESSENGER-OAUTH2"); + return QStringLiteral("X-MESSENGER-OAUTH2"); } bool QXmppSaslClientWindowsLive::respond(const QByteArray &challenge, QByteArray &response) @@ -640,7 +640,7 @@ bool QXmppSaslClientWindowsLive::respond(const QByteArray &challenge, QByteArray m_step++; return true; } else { - warning(QSL("QXmppSaslClientWindowsLive : Invalid step")); + warning(QStringLiteral("QXmppSaslClientWindowsLive : Invalid step")); return false; } } @@ -668,11 +668,11 @@ QXmppSaslServer::~QXmppSaslServer() QXmppSaslServer *QXmppSaslServer::create(const QString &mechanism, QObject *parent) { - if (mechanism == QSL("PLAIN")) { + if (mechanism == QStringLiteral("PLAIN")) { return new QXmppSaslServerPlain(parent); - } else if (mechanism == QSL("DIGEST-MD5")) { + } else if (mechanism == QStringLiteral("DIGEST-MD5")) { return new QXmppSaslServerDigestMd5(parent); - } else if (mechanism == QSL("ANONYMOUS")) { + } else if (mechanism == QStringLiteral("ANONYMOUS")) { return new QXmppSaslServerAnonymous(parent); } else { return nullptr; @@ -742,7 +742,7 @@ QXmppSaslServerAnonymous::QXmppSaslServerAnonymous(QObject *parent) QString QXmppSaslServerAnonymous::mechanism() const { - return QSL("ANONYMOUS"); + return QStringLiteral("ANONYMOUS"); } QXmppSaslServer::Response QXmppSaslServerAnonymous::respond(const QByteArray &request, QByteArray &response) @@ -753,7 +753,7 @@ QXmppSaslServer::Response QXmppSaslServerAnonymous::respond(const QByteArray &re response = QByteArray(); return Succeeded; } else { - warning(QSL("QXmppSaslServerAnonymous : Invalid step")); + warning(QStringLiteral("QXmppSaslServerAnonymous : Invalid step")); return Failed; } } @@ -766,52 +766,52 @@ QXmppSaslServerDigestMd5::QXmppSaslServerDigestMd5(QObject *parent) QString QXmppSaslServerDigestMd5::mechanism() const { - return QSL("DIGEST-MD5"); + return QStringLiteral("DIGEST-MD5"); } QXmppSaslServer::Response QXmppSaslServerDigestMd5::respond(const QByteArray &request, QByteArray &response) { if (m_step == 0) { QMap<QByteArray, QByteArray> output; - output[QBL("nonce")] = m_nonce; + output[QByteArrayLiteral("nonce")] = m_nonce; if (!realm().isEmpty()) - output[QBL("realm")] = realm().toUtf8(); - output[QBL("qop")] = QBL("auth"); - output[QBL("charset")] = QBL("utf-8"); - output[QBL("algorithm")] = QBL("md5-sess"); + output[QByteArrayLiteral("realm")] = realm().toUtf8(); + output[QByteArrayLiteral("qop")] = QByteArrayLiteral("auth"); + output[QByteArrayLiteral("charset")] = QByteArrayLiteral("utf-8"); + output[QByteArrayLiteral("algorithm")] = QByteArrayLiteral("md5-sess"); m_step++; response = QXmppSaslDigestMd5::serializeMessage(output); return Challenge; } else if (m_step == 1) { const QMap<QByteArray, QByteArray> input = QXmppSaslDigestMd5::parseMessage(request); - const QByteArray realm = input.value(QBL("realm")); - const QByteArray digestUri = input.value(QBL("digest-uri")); + const QByteArray realm = input.value(QByteArrayLiteral("realm")); + const QByteArray digestUri = input.value(QByteArrayLiteral("digest-uri")); - if (input.value(QBL("qop")) != QBL("auth")) { - warning(QSL("QXmppSaslServerDigestMd5 : Invalid quality of protection")); + if (input.value(QByteArrayLiteral("qop")) != QByteArrayLiteral("auth")) { + warning(QStringLiteral("QXmppSaslServerDigestMd5 : Invalid quality of protection")); return Failed; } - setUsername(QString::fromUtf8(input.value(QBL("username")))); + setUsername(QString::fromUtf8(input.value(QByteArrayLiteral("username")))); if (password().isEmpty() && passwordDigest().isEmpty()) return InputNeeded; - m_nc = input.value(QBL("nc")); - m_cnonce = input.value(QBL("cnonce")); + m_nc = input.value(QByteArrayLiteral("nc")); + m_cnonce = input.value(QByteArrayLiteral("cnonce")); if (!password().isEmpty()) { m_secret = QCryptographicHash::hash( - username().toUtf8() + QBL(":") + realm + QBL(":") + password().toUtf8(), + username().toUtf8() + QByteArrayLiteral(":") + realm + QByteArrayLiteral(":") + password().toUtf8(), QCryptographicHash::Md5); } else { m_secret = passwordDigest(); } - if (input.value(QBL("response")) != calculateDigest(QBL("AUTHENTICATE"), digestUri, m_secret, m_nonce, m_cnonce, m_nc)) + if (input.value(QByteArrayLiteral("response")) != calculateDigest(QByteArrayLiteral("AUTHENTICATE"), digestUri, m_secret, m_nonce, m_cnonce, m_nc)) return Failed; QMap<QByteArray, QByteArray> output; - output[QBL("rspauth")] = calculateDigest(QByteArray(), digestUri, m_secret, m_nonce, m_cnonce, m_nc); + output[QByteArrayLiteral("rspauth")] = calculateDigest(QByteArray(), digestUri, m_secret, m_nonce, m_cnonce, m_nc); m_step++; response = QXmppSaslDigestMd5::serializeMessage(output); @@ -821,7 +821,7 @@ QXmppSaslServer::Response QXmppSaslServerDigestMd5::respond(const QByteArray &re response = QByteArray(); return Succeeded; } else { - warning(QSL("QXmppSaslServerDigestMd5 : Invalid step")); + warning(QStringLiteral("QXmppSaslServerDigestMd5 : Invalid step")); return Failed; } } @@ -833,7 +833,7 @@ QXmppSaslServerPlain::QXmppSaslServerPlain(QObject *parent) QString QXmppSaslServerPlain::mechanism() const { - return QSL("PLAIN"); + return QStringLiteral("PLAIN"); } QXmppSaslServer::Response QXmppSaslServerPlain::respond(const QByteArray &request, QByteArray &response) @@ -846,7 +846,7 @@ QXmppSaslServer::Response QXmppSaslServerPlain::respond(const QByteArray &reques QList<QByteArray> auth = request.split('\0'); if (auth.size() != 3) { - warning(QSL("QXmppSaslServerPlain : Invalid input")); + warning(QStringLiteral("QXmppSaslServerPlain : Invalid input")); return Failed; } setUsername(QString::fromUtf8(auth[1])); @@ -856,7 +856,7 @@ QXmppSaslServer::Response QXmppSaslServerPlain::respond(const QByteArray &reques response = QByteArray(); return InputNeeded; } else { - warning(QSL("QXmppSaslServerPlain : Invalid step")); + warning(QStringLiteral("QXmppSaslServerPlain : Invalid step")); return Failed; } } @@ -871,7 +871,7 @@ QMap<QByteArray, QByteArray> QXmppSaslDigestMd5::parseMessage(const QByteArray & QMap<QByteArray, QByteArray> map; int startIndex = 0; int pos = 0; - while ((pos = ba.indexOf(QSL("="), startIndex)) >= 0) { + while ((pos = ba.indexOf(QStringLiteral("="), startIndex)) >= 0) { // key get name and skip equals const QByteArray key = ba.mid(startIndex, pos - startIndex).trimmed(); pos++; @@ -914,7 +914,7 @@ QByteArray QXmppSaslDigestMd5::serializeMessage(const QMap<QByteArray, QByteArra for (const auto &key : map.keys()) { if (!ba.isEmpty()) ba.append(','); - ba.append(key + QBL("=")); + ba.append(key + QByteArrayLiteral("=")); QByteArray value = map[key]; const char *separators = "()<>@,;:\\\"/[]?={} \t"; bool quote = false; @@ -925,9 +925,9 @@ QByteArray QXmppSaslDigestMd5::serializeMessage(const QMap<QByteArray, QByteArra } } if (quote) { - value.replace(QBL("\\"), QBL("\\\\")); - value.replace(QBL("\""), QBL("\\\"")); - ba.append(QSL("\"") + value + QSL("\"")); + value.replace(QByteArrayLiteral("\\"), QByteArrayLiteral("\\\\")); + value.replace(QByteArrayLiteral("\""), QByteArrayLiteral("\\\"")); + ba.append(QStringLiteral("\"") + value + QStringLiteral("\"")); } else ba.append(value); } |
