diff options
Diffstat (limited to 'Swiften/Serializer/AuthRequestSerializer.cpp')
-rw-r--r-- | Swiften/Serializer/AuthRequestSerializer.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/Swiften/Serializer/AuthRequestSerializer.cpp b/Swiften/Serializer/AuthRequestSerializer.cpp index 0bee302..e38dc85 100644 --- a/Swiften/Serializer/AuthRequestSerializer.cpp +++ b/Swiften/Serializer/AuthRequestSerializer.cpp @@ -4,29 +4,32 @@ * See Documentation/Licenses/GPLv3.txt for more information. */ -#include "Swiften/Serializer/AuthRequestSerializer.h" +#include <Swiften/Serializer/AuthRequestSerializer.h> -#include "Swiften/Elements/AuthRequest.h" -#include "Swiften/StringCodecs/Base64.h" +#include <Swiften/Elements/AuthRequest.h> +#include <Swiften/StringCodecs/Base64.h> +#include <Swiften/Base/SafeByteArray.h> +#include <Swiften/Base/SafeString.h> +#include <Swiften/Base/Concat.h> namespace Swift { AuthRequestSerializer::AuthRequestSerializer() { } -std::string AuthRequestSerializer::serialize(boost::shared_ptr<Element> element) const { +SafeString AuthRequestSerializer::serialize(boost::shared_ptr<Element> element) const { boost::shared_ptr<AuthRequest> authRequest(boost::dynamic_pointer_cast<AuthRequest>(element)); - std::string value; - boost::optional<ByteArray> message = authRequest->getMessage(); + SafeString value; + boost::optional<SafeByteArray> message = authRequest->getMessage(); if (message) { - if ((*message).isEmpty()) { + if ((*message).empty()) { value = "="; } else { value = Base64::encode(*message); } } - return "<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"" + authRequest->getMechanism() + "\">" + value + "</auth>"; + return concat(SafeString("<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"" + authRequest->getMechanism() + "\">"), value, SafeString("</auth>")); } } |