summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Serializer')
-rw-r--r--Swiften/Serializer/AuthChallengeSerializer.cpp17
-rw-r--r--Swiften/Serializer/AuthChallengeSerializer.h15
-rw-r--r--Swiften/Serializer/AuthResponseSerializer.cpp17
-rw-r--r--Swiften/Serializer/AuthResponseSerializer.h15
-rw-r--r--Swiften/Serializer/XMPPSerializer.cpp4
5 files changed, 68 insertions, 0 deletions
diff --git a/Swiften/Serializer/AuthChallengeSerializer.cpp b/Swiften/Serializer/AuthChallengeSerializer.cpp
new file mode 100644
index 0000000..152607d
--- /dev/null
+++ b/Swiften/Serializer/AuthChallengeSerializer.cpp
@@ -0,0 +1,17 @@
+#include "Swiften/Serializer/AuthChallengeSerializer.h"
+
+#include "Swiften/Elements/AuthChallenge.h"
+#include "Swiften/StringCodecs/Base64.h"
+
+namespace Swift {
+
+AuthChallengeSerializer::AuthChallengeSerializer() {
+}
+
+String AuthChallengeSerializer::serialize(boost::shared_ptr<Element> element) const {
+ boost::shared_ptr<AuthChallenge> authRequest(boost::dynamic_pointer_cast<AuthChallenge>(element));
+ String value = (authRequest->getValue().isEmpty() ? "=" : Base64::encode(authRequest->getValue()));
+ return "<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + value + "</challenge>";
+}
+
+}
diff --git a/Swiften/Serializer/AuthChallengeSerializer.h b/Swiften/Serializer/AuthChallengeSerializer.h
new file mode 100644
index 0000000..010d9a9
--- /dev/null
+++ b/Swiften/Serializer/AuthChallengeSerializer.h
@@ -0,0 +1,15 @@
+#pragma once
+
+#include <boost/shared_ptr.hpp>
+
+#include "Swiften/Elements/AuthChallenge.h"
+#include "Swiften/Serializer/GenericElementSerializer.h"
+
+namespace Swift {
+ class AuthChallengeSerializer : public GenericElementSerializer<AuthChallenge> {
+ public:
+ AuthChallengeSerializer();
+
+ virtual String serialize(boost::shared_ptr<Element> element) const;
+ };
+}
diff --git a/Swiften/Serializer/AuthResponseSerializer.cpp b/Swiften/Serializer/AuthResponseSerializer.cpp
new file mode 100644
index 0000000..2348a3d
--- /dev/null
+++ b/Swiften/Serializer/AuthResponseSerializer.cpp
@@ -0,0 +1,17 @@
+#include "Swiften/Serializer/AuthResponseSerializer.h"
+
+#include "Swiften/Elements/AuthResponse.h"
+#include "Swiften/StringCodecs/Base64.h"
+
+namespace Swift {
+
+AuthResponseSerializer::AuthResponseSerializer() {
+}
+
+String AuthResponseSerializer::serialize(boost::shared_ptr<Element> element) const {
+ boost::shared_ptr<AuthResponse> authRequest(boost::dynamic_pointer_cast<AuthResponse>(element));
+ String value = (authRequest->getValue().isEmpty() ? "=" : Base64::encode(authRequest->getValue()));
+ return "<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + value + "</response>";
+}
+
+}
diff --git a/Swiften/Serializer/AuthResponseSerializer.h b/Swiften/Serializer/AuthResponseSerializer.h
new file mode 100644
index 0000000..8d47291
--- /dev/null
+++ b/Swiften/Serializer/AuthResponseSerializer.h
@@ -0,0 +1,15 @@
+#pragma once
+
+#include <boost/shared_ptr.hpp>
+
+#include "Swiften/Elements/AuthResponse.h"
+#include "Swiften/Serializer/GenericElementSerializer.h"
+
+namespace Swift {
+ class AuthResponseSerializer : public GenericElementSerializer<AuthResponse> {
+ public:
+ AuthResponseSerializer();
+
+ virtual String serialize(boost::shared_ptr<Element> element) const;
+ };
+}
diff --git a/Swiften/Serializer/XMPPSerializer.cpp b/Swiften/Serializer/XMPPSerializer.cpp
index 660bb37..082cdf3 100644
--- a/Swiften/Serializer/XMPPSerializer.cpp
+++ b/Swiften/Serializer/XMPPSerializer.cpp
@@ -11,6 +11,8 @@
#include "Swiften/Serializer/AuthRequestSerializer.h"
#include "Swiften/Serializer/AuthFailureSerializer.h"
#include "Swiften/Serializer/AuthSuccessSerializer.h"
+#include "Swiften/Serializer/AuthChallengeSerializer.h"
+#include "Swiften/Serializer/AuthResponseSerializer.h"
#include "Swiften/Serializer/StartTLSRequestSerializer.h"
#include "Swiften/Serializer/StartTLSFailureSerializer.h"
#include "Swiften/Serializer/TLSProceedSerializer.h"
@@ -29,6 +31,8 @@ XMPPSerializer::XMPPSerializer(PayloadSerializerCollection* payloadSerializers)
serializers_.push_back(boost::shared_ptr<ElementSerializer>(new AuthRequestSerializer()));
serializers_.push_back(boost::shared_ptr<ElementSerializer>(new AuthFailureSerializer()));
serializers_.push_back(boost::shared_ptr<ElementSerializer>(new AuthSuccessSerializer()));
+ serializers_.push_back(boost::shared_ptr<ElementSerializer>(new AuthChallengeSerializer()));
+ serializers_.push_back(boost::shared_ptr<ElementSerializer>(new AuthResponseSerializer()));
serializers_.push_back(boost::shared_ptr<ElementSerializer>(new StartTLSRequestSerializer()));
serializers_.push_back(boost::shared_ptr<ElementSerializer>(new StartTLSFailureSerializer()));
serializers_.push_back(boost::shared_ptr<ElementSerializer>(new TLSProceedSerializer()));