diff options
Diffstat (limited to 'Swiften/SASL/DIGESTMD5ClientAuthenticator.cpp')
-rw-r--r-- | Swiften/SASL/DIGESTMD5ClientAuthenticator.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/Swiften/SASL/DIGESTMD5ClientAuthenticator.cpp b/Swiften/SASL/DIGESTMD5ClientAuthenticator.cpp index 050b73b..6892948 100644 --- a/Swiften/SASL/DIGESTMD5ClientAuthenticator.cpp +++ b/Swiften/SASL/DIGESTMD5ClientAuthenticator.cpp @@ -13,7 +13,7 @@ namespace Swift { -DIGESTMD5ClientAuthenticator::DIGESTMD5ClientAuthenticator(const String& host, const String& nonce) : ClientAuthenticator("DIGEST-MD5"), step(Initial), host(host), cnonce(nonce) { +DIGESTMD5ClientAuthenticator::DIGESTMD5ClientAuthenticator(const std::string& host, const std::string& nonce) : ClientAuthenticator("DIGEST-MD5"), step(Initial), host(host), cnonce(nonce) { } boost::optional<ByteArray> DIGESTMD5ClientAuthenticator::getResponse() const { @@ -21,29 +21,29 @@ boost::optional<ByteArray> DIGESTMD5ClientAuthenticator::getResponse() const { return boost::optional<ByteArray>(); } else if (step == Response) { - String realm; + std::string realm; if (challenge.getValue("realm")) { realm = *challenge.getValue("realm"); } - String qop = "auth"; - String digestURI = "xmpp/" + host; - String nc = "00000001"; + std::string qop = "auth"; + std::string digestURI = "xmpp/" + host; + std::string nc = "00000001"; // Compute the response value ByteArray A1 = MD5::getHash(getAuthenticationID() + ":" + realm + ":" + getPassword()) + ":" + *challenge.getValue("nonce") + ":" + cnonce; - if (!getAuthorizationID().isEmpty()) { + if (!getAuthorizationID().empty()) { A1 += ":" + getAuthenticationID(); } - String A2 = "AUTHENTICATE:" + digestURI; + std::string A2 = "AUTHENTICATE:" + digestURI; - String responseValue = Hexify::hexify(MD5::getHash( + std::string responseValue = Hexify::hexify(MD5::getHash( Hexify::hexify(MD5::getHash(A1)) + ":" + *challenge.getValue("nonce") + ":" + nc + ":" + cnonce + ":" + qop + ":" + Hexify::hexify(MD5::getHash(A2)))); DIGESTMD5Properties response; response.setValue("username", getAuthenticationID()); - if (!realm.isEmpty()) { + if (!realm.empty()) { response.setValue("realm", realm); } response.setValue("nonce", *challenge.getValue("nonce")); @@ -53,7 +53,7 @@ boost::optional<ByteArray> DIGESTMD5ClientAuthenticator::getResponse() const { response.setValue("digest-uri", digestURI); response.setValue("charset", "utf-8"); response.setValue("response", responseValue); - if (!getAuthorizationID().isEmpty()) { + if (!getAuthorizationID().empty()) { response.setValue("authzid", getAuthorizationID()); } return response.serialize(); |