summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Base/SConscript1
-rw-r--r--Swiften/Base/SafeByteArray.cpp5
-rw-r--r--Swiften/Base/SafeByteArray.h4
-rw-r--r--Swiften/Base/SafeString.cpp17
-rw-r--r--Swiften/Base/SafeString.h75
-rw-r--r--Swiften/Client/Client.h2
-rw-r--r--Swiften/Client/ClientSession.cpp3
-rw-r--r--Swiften/Client/ClientSession.h3
-rw-r--r--Swiften/Client/ClientXMLTracer.cpp2
-rw-r--r--Swiften/Client/CoreClient.cpp4
-rw-r--r--Swiften/Client/CoreClient.h6
-rw-r--r--Swiften/Client/UnitTest/ClientSessionTest.cpp11
-rw-r--r--Swiften/Examples/BenchTool/BenchTool.cpp2
-rw-r--r--Swiften/IDN/StringPrep.cpp12
-rw-r--r--Swiften/IDN/StringPrep.h4
-rw-r--r--Swiften/SASL/ClientAuthenticator.h7
-rw-r--r--Swiften/SASL/DIGESTMD5ClientAuthenticator.cpp2
-rw-r--r--Swiften/SASL/PLAINClientAuthenticator.cpp2
-rw-r--r--Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp2
-rw-r--r--Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp4
-rw-r--r--Swiften/SASL/UnitTest/PLAINClientAuthenticatorTest.cpp4
-rw-r--r--Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp38
-rw-r--r--Swiften/Serializer/AuthChallengeSerializer.cpp4
-rw-r--r--Swiften/Serializer/AuthChallengeSerializer.h2
-rw-r--r--Swiften/Serializer/AuthFailureSerializer.h4
-rw-r--r--Swiften/Serializer/AuthRequestSerializer.cpp9
-rw-r--r--Swiften/Serializer/AuthRequestSerializer.h2
-rw-r--r--Swiften/Serializer/AuthResponseSerializer.cpp9
-rw-r--r--Swiften/Serializer/AuthResponseSerializer.h2
-rw-r--r--Swiften/Serializer/AuthSuccessSerializer.cpp4
-rw-r--r--Swiften/Serializer/AuthSuccessSerializer.h2
-rw-r--r--Swiften/Serializer/ComponentHandshakeSerializer.cpp4
-rw-r--r--Swiften/Serializer/ComponentHandshakeSerializer.h2
-rw-r--r--Swiften/Serializer/CompressFailureSerializer.h4
-rw-r--r--Swiften/Serializer/CompressRequestSerializer.cpp4
-rw-r--r--Swiften/Serializer/CompressRequestSerializer.h2
-rw-r--r--Swiften/Serializer/ElementSerializer.h4
-rw-r--r--Swiften/Serializer/EnableStreamManagementSerializer.h4
-rw-r--r--Swiften/Serializer/GenericElementSerializer.h2
-rw-r--r--Swiften/Serializer/StanzaAckRequestSerializer.h4
-rw-r--r--Swiften/Serializer/StanzaAckSerializer.h4
-rw-r--r--Swiften/Serializer/StanzaSerializer.cpp4
-rw-r--r--Swiften/Serializer/StanzaSerializer.h2
-rw-r--r--Swiften/Serializer/StartTLSFailureSerializer.h4
-rw-r--r--Swiften/Serializer/StartTLSRequestSerializer.h4
-rw-r--r--Swiften/Serializer/StreamErrorSerializer.cpp4
-rw-r--r--Swiften/Serializer/StreamErrorSerializer.h2
-rw-r--r--Swiften/Serializer/StreamFeaturesSerializer.cpp4
-rw-r--r--Swiften/Serializer/StreamFeaturesSerializer.h2
-rw-r--r--Swiften/Serializer/StreamManagementEnabledSerializer.cpp4
-rw-r--r--Swiften/Serializer/StreamManagementEnabledSerializer.h2
-rw-r--r--Swiften/Serializer/StreamManagementFailedSerializer.h4
-rw-r--r--Swiften/Serializer/StreamResumeSerializer.cpp4
-rw-r--r--Swiften/Serializer/StreamResumeSerializer.h2
-rw-r--r--Swiften/Serializer/StreamResumedSerializer.cpp4
-rw-r--r--Swiften/Serializer/StreamResumedSerializer.h2
-rw-r--r--Swiften/Serializer/TLSProceedSerializer.h4
-rw-r--r--Swiften/Serializer/UnitTest/AuthChallengeSerializerTest.cpp6
-rw-r--r--Swiften/Serializer/UnitTest/AuthRequestSerializerTest.cpp6
-rw-r--r--Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp6
-rw-r--r--Swiften/Serializer/UnitTest/AuthSuccessSerializerTest.cpp6
-rw-r--r--Swiften/Serializer/UnitTest/StreamFeaturesSerializerTest.cpp2
-rw-r--r--Swiften/Serializer/XMPPSerializer.cpp4
-rw-r--r--Swiften/Serializer/XMPPSerializer.h2
-rw-r--r--Swiften/StreamStack/XMPPLayer.cpp2
-rw-r--r--Swiften/StringCodecs/Base64.cpp5
-rw-r--r--Swiften/StringCodecs/Base64.h2
-rw-r--r--Swiften/TLS/OpenSSL/OpenSSLContext.cpp2
-rw-r--r--Swiften/TLS/PKCS12Certificate.h8
69 files changed, 137 insertions, 248 deletions
diff --git a/Swiften/Base/SConscript b/Swiften/Base/SConscript
index ab78639..3279c22 100644
--- a/Swiften/Base/SConscript
+++ b/Swiften/Base/SConscript
@@ -7,7 +7,6 @@ objects = swiften_env.SwiftenObject([
"Log.cpp",
"Paths.cpp",
"String.cpp",
- "SafeString.cpp",
"IDGenerator.cpp",
"sleep.cpp",
])
diff --git a/Swiften/Base/SafeByteArray.cpp b/Swiften/Base/SafeByteArray.cpp
index e09a285..848b6d8 100644
--- a/Swiften/Base/SafeByteArray.cpp
+++ b/Swiften/Base/SafeByteArray.cpp
@@ -5,7 +5,6 @@
*/
#include <Swiften/Base/SafeByteArray.h>
-#include <Swiften/Base/SafeString.h>
using namespace Swift;
@@ -20,8 +19,4 @@ SafeByteArray createSafeByteArray(const char* c) {
return data;
}
-SafeByteArray createSafeByteArray(const SafeString& s) {
- return SafeByteArray(s.begin(), s.end());
-}
-
}
diff --git a/Swiften/Base/SafeByteArray.h b/Swiften/Base/SafeByteArray.h
index 2f3fbfa..032a6d5 100644
--- a/Swiften/Base/SafeByteArray.h
+++ b/Swiften/Base/SafeByteArray.h
@@ -12,8 +12,6 @@
#include <Swiften/Base/ByteArray.h>
namespace Swift {
- class SafeString;
-
typedef std::vector<unsigned char, SafeAllocator<unsigned char> > SafeByteArray;
inline SafeByteArray createSafeByteArray(const ByteArray& a) {
@@ -38,8 +36,6 @@ namespace Swift {
return SafeByteArray(c, c + n);
}
- SafeByteArray createSafeByteArray(const SafeString& s);
-
/* WARNING! This breaks the safety of the data in the safe byte array.
* Do not use in modes that require data safety. */
inline std::string safeByteArrayToString(const SafeByteArray& b) {
diff --git a/Swiften/Base/SafeString.cpp b/Swiften/Base/SafeString.cpp
deleted file mode 100644
index 2abcdb0..0000000
--- a/Swiften/Base/SafeString.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright (c) 2011 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#include <Swiften/Base/SafeString.h>
-
-#include <algorithm>
-
-using namespace Swift;
-
-SafeString::SafeString(const char* rawData) {
- for (const char* c = rawData; *c; ++c) {
- data.push_back(*c);
- }
-}
diff --git a/Swiften/Base/SafeString.h b/Swiften/Base/SafeString.h
deleted file mode 100644
index d549bd1..0000000
--- a/Swiften/Base/SafeString.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2011 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#pragma once
-
-#include <vector>
-#include <string>
-
-#include <Swiften/Base/SafeAllocator.h>
-
-namespace Swift {
- class SafeString {
- public:
- typedef std::vector<char, SafeAllocator<char> > Data;
- typedef Data::iterator Iterator;
- typedef Data::const_iterator ConstIterator;
-
- SafeString() {
- }
-
- SafeString(const std::string& s) : data(s.begin(), s.end()) {
- }
-
- SafeString(const char*);
-
- SafeString(const char* begin, const char* end) : data(begin, end) {
- }
-
- std::string toString() const {
- return data.empty() ? std::string() : std::string(&data[0], data.size());
- }
-
- void resize(size_t n) {
- data.resize(n);
- }
-
- char& operator[](size_t n) {
- return data[n];
- }
-
- Iterator begin() {
- return data.begin();
- }
-
- Iterator end() {
- return data.end();
- }
-
- ConstIterator begin() const {
- return data.begin();
- }
-
- ConstIterator end() const {
- return data.end();
- }
-
- size_t size() const {
- return data.size();
- }
-
- void clear() {
- data.clear();
- }
-
- bool operator==(const SafeString& o) const {
- return data == o.data;
- }
-
- private:
- std::vector<char, SafeAllocator<char> > data;
- };
-};
diff --git a/Swiften/Client/Client.h b/Swiften/Client/Client.h
index bee9d5c..08289a5 100644
--- a/Swiften/Client/Client.h
+++ b/Swiften/Client/Client.h
@@ -8,6 +8,8 @@
#include <Swiften/Client/CoreClient.h>
+#include <Swiften/Base/SafeString.h>
+
namespace Swift {
class SoftwareVersionResponder;
class BlindCertificateTrustChecker;
diff --git a/Swiften/Client/ClientSession.cpp b/Swiften/Client/ClientSession.cpp
index 57d9c12..8945e9a 100644
--- a/Swiften/Client/ClientSession.cpp
+++ b/Swiften/Client/ClientSession.cpp
@@ -12,7 +12,6 @@
#include <boost/uuid/uuid_generators.hpp>
#include <boost/smart_ptr/make_shared.hpp>
-#include <Swiften/Base/SafeString.h>
#include <Swiften/Elements/ProtocolHeader.h>
#include <Swiften/Elements/StreamFeatures.h>
#include <Swiften/Elements/StreamError.h>
@@ -339,7 +338,7 @@ bool ClientSession::checkState(State state) {
return true;
}
-void ClientSession::sendCredentials(const SafeString& password) {
+void ClientSession::sendCredentials(const SafeByteArray& password) {
assert(WaitingForCredentials);
state = Authenticating;
authenticator->setCredentials(localJID.getNode(), password);
diff --git a/Swiften/Client/ClientSession.h b/Swiften/Client/ClientSession.h
index 246388a..ace9868 100644
--- a/Swiften/Client/ClientSession.h
+++ b/Swiften/Client/ClientSession.h
@@ -21,7 +21,6 @@
namespace Swift {
class ClientAuthenticator;
class CertificateTrustChecker;
- class SafeString;
class ClientSession : public boost::enable_shared_from_this<ClientSession> {
public:
@@ -105,7 +104,7 @@ namespace Swift {
return getState() == Finished;
}
- void sendCredentials(const SafeString& password);
+ void sendCredentials(const SafeByteArray& password);
void sendStanza(boost::shared_ptr<Stanza>);
void setCertificateTrustChecker(CertificateTrustChecker* checker) {
diff --git a/Swiften/Client/ClientXMLTracer.cpp b/Swiften/Client/ClientXMLTracer.cpp
index 441da9b..c1e398d 100644
--- a/Swiften/Client/ClientXMLTracer.cpp
+++ b/Swiften/Client/ClientXMLTracer.cpp
@@ -9,8 +9,6 @@
#include <iostream>
#include <boost/bind.hpp>
-#include <Swiften/Base/SafeString.h>
-
namespace Swift {
ClientXMLTracer::ClientXMLTracer(CoreClient* client) {
diff --git a/Swiften/Client/CoreClient.cpp b/Swiften/Client/CoreClient.cpp
index 9eec7ca..a2708c5 100644
--- a/Swiften/Client/CoreClient.cpp
+++ b/Swiften/Client/CoreClient.cpp
@@ -28,7 +28,7 @@
namespace Swift {
-CoreClient::CoreClient(const JID& jid, const SafeString& password, NetworkFactories* networkFactories) : jid_(jid), password_(password), networkFactories(networkFactories), disconnectRequested_(false), certificateTrustChecker(NULL) {
+CoreClient::CoreClient(const JID& jid, const SafeByteArray& password, NetworkFactories* networkFactories) : jid_(jid), password_(password), networkFactories(networkFactories), disconnectRequested_(false), certificateTrustChecker(NULL) {
stanzaChannel_ = new ClientSessionStanzaChannel();
stanzaChannel_->onMessageReceived.connect(boost::bind(&CoreClient::handleMessageReceived, this, _1));
stanzaChannel_->onPresenceReceived.connect(boost::bind(&CoreClient::handlePresenceReceived, this, _1));
@@ -101,7 +101,7 @@ void CoreClient::handleConnectorFinished(boost::shared_ptr<Connection> connectio
assert(!sessionStream_);
sessionStream_ = boost::make_shared<BasicSessionStream>(ClientStreamType, connection_, getPayloadParserFactories(), getPayloadSerializers(), tlsFactories->getTLSContextFactory(), networkFactories->getTimerFactory());
if (!certificate_.empty()) {
- sessionStream_->setTLSCertificate(PKCS12Certificate(certificate_, password_.toString()));
+ sessionStream_->setTLSCertificate(PKCS12Certificate(certificate_, password_));
}
sessionStream_->onDataRead.connect(boost::bind(&CoreClient::handleDataRead, this, _1));
sessionStream_->onDataWritten.connect(boost::bind(&CoreClient::handleDataWritten, this, _1));
diff --git a/Swiften/Client/CoreClient.h b/Swiften/Client/CoreClient.h
index 841c32c..16813de 100644
--- a/Swiften/Client/CoreClient.h
+++ b/Swiften/Client/CoreClient.h
@@ -14,7 +14,6 @@
#include <Swiften/JID/JID.h>
#include <Swiften/Client/ClientError.h>
#include <Swiften/Client/ClientOptions.h>
-#include <Swiften/Base/SafeString.h>
#include <Swiften/Base/SafeByteArray.h>
namespace Swift {
@@ -35,7 +34,6 @@ namespace Swift {
class CertificateTrustChecker;
class NetworkFactories;
class ClientSessionStanzaChannel;
- class SafeString;
/**
* The central class for communicating with an XMPP server.
@@ -53,7 +51,7 @@ namespace Swift {
* Constructs a client for the given JID with the given password.
* The given eventLoop will be used to post events to.
*/
- CoreClient(const JID& jid, const SafeString& password, NetworkFactories* networkFactories);
+ CoreClient(const JID& jid, const SafeByteArray& password, NetworkFactories* networkFactories);
~CoreClient();
void setCertificate(const std::string& certificate);
@@ -204,7 +202,7 @@ namespace Swift {
private:
JID jid_;
- SafeString password_;
+ SafeByteArray password_;
NetworkFactories* networkFactories;
ClientSessionStanzaChannel* stanzaChannel_;
IQRouter* iqRouter_;
diff --git a/Swiften/Client/UnitTest/ClientSessionTest.cpp b/Swiften/Client/UnitTest/ClientSessionTest.cpp
index 6918be8..8fc869b 100644
--- a/Swiften/Client/UnitTest/ClientSessionTest.cpp
+++ b/Swiften/Client/UnitTest/ClientSessionTest.cpp
@@ -11,7 +11,6 @@
#include <boost/optional.hpp>
#include <boost/smart_ptr/make_shared.hpp>
-#include <Swiften/Base/SafeString.h>
#include <Swiften/Session/SessionStream.h>
#include <Swiften/Client/ClientSession.h>
#include <Swiften/Elements/Message.h>
@@ -182,7 +181,7 @@ class ClientSessionTest : public CppUnit::TestFixture {
server->sendStreamFeaturesWithPLAINAuthentication();
CPPUNIT_ASSERT(needCredentials);
CPPUNIT_ASSERT_EQUAL(ClientSession::WaitingForCredentials, session->getState());
- session->sendCredentials("mypass");
+ session->sendCredentials(createSafeByteArray("mypass"));
server->receiveAuthRequest("PLAIN");
server->sendAuthSuccess();
server->receiveStreamStart();
@@ -198,7 +197,7 @@ class ClientSessionTest : public CppUnit::TestFixture {
server->sendStreamFeaturesWithPLAINAuthentication();
CPPUNIT_ASSERT(needCredentials);
CPPUNIT_ASSERT_EQUAL(ClientSession::WaitingForCredentials, session->getState());
- session->sendCredentials("mypass");
+ session->sendCredentials(createSafeByteArray("mypass"));
server->receiveAuthRequest("PLAIN");
server->sendAuthFailure();
@@ -238,7 +237,7 @@ class ClientSessionTest : public CppUnit::TestFixture {
server->receiveStreamStart();
server->sendStreamStart();
server->sendStreamFeaturesWithPLAINAuthentication();
- session->sendCredentials("mypass");
+ session->sendCredentials(createSafeByteArray("mypass"));
server->receiveAuthRequest("PLAIN");
server->sendAuthSuccess();
server->receiveStreamStart();
@@ -262,7 +261,7 @@ class ClientSessionTest : public CppUnit::TestFixture {
server->receiveStreamStart();
server->sendStreamStart();
server->sendStreamFeaturesWithPLAINAuthentication();
- session->sendCredentials("mypass");
+ session->sendCredentials(createSafeByteArray("mypass"));
server->receiveAuthRequest("PLAIN");
server->sendAuthSuccess();
server->receiveStreamStart();
@@ -305,7 +304,7 @@ class ClientSessionTest : public CppUnit::TestFixture {
server->receiveStreamStart();
server->sendStreamStart();
server->sendStreamFeaturesWithPLAINAuthentication();
- session->sendCredentials("mypass");
+ session->sendCredentials(createSafeByteArray("mypass"));
server->receiveAuthRequest("PLAIN");
server->sendAuthSuccess();
server->receiveStreamStart();
diff --git a/Swiften/Examples/BenchTool/BenchTool.cpp b/Swiften/Examples/BenchTool/BenchTool.cpp
index a440148..ba6cf84 100644
--- a/Swiften/Examples/BenchTool/BenchTool.cpp
+++ b/Swiften/Examples/BenchTool/BenchTool.cpp
@@ -46,7 +46,7 @@ int main(int, char**) {
BlindCertificateTrustChecker trustChecker;
std::vector<CoreClient*> clients;
for (int i = 0; i < numberOfInstances; ++i) {
- CoreClient* client = new Swift::CoreClient(JID(jid), std::string(pass), &networkFactories);
+ CoreClient* client = new Swift::CoreClient(JID(jid), createSafeByteArray(std::string(pass)), &networkFactories);
client->setCertificateTrustChecker(&trustChecker);
client->onConnected.connect(&handleConnected);
clients.push_back(client);
diff --git a/Swiften/IDN/StringPrep.cpp b/Swiften/IDN/StringPrep.cpp
index f8ebb2c..140e130 100644
--- a/Swiften/IDN/StringPrep.cpp
+++ b/Swiften/IDN/StringPrep.cpp
@@ -28,14 +28,14 @@ using namespace Swift;
}
template<typename StringType, typename ContainerType>
- StringType getStringPrepared(const StringType& s, StringPrep::Profile profile) {
+ ContainerType getStringPrepared(const StringType& s, StringPrep::Profile profile) {
ContainerType input(s.begin(), s.end());
input.resize(MAX_STRINGPREP_SIZE);
if (stringprep(&input[0], MAX_STRINGPREP_SIZE, static_cast<Stringprep_profile_flags>(0), getLibIDNProfile(profile)) == 0) {
- return StringType(&input[0]);
+ return input;
}
else {
- return StringType();
+ return ContainerType();
}
}
}
@@ -43,11 +43,11 @@ using namespace Swift;
namespace Swift {
std::string StringPrep::getPrepared(const std::string& s, Profile profile) {
- return getStringPrepared< std::string, std::vector<char> >(s, profile);
+ return std::string(vecptr(getStringPrepared< std::string, std::vector<char> >(s, profile)));
}
-SafeString StringPrep::getPrepared(const SafeString& s, Profile profile) {
- return getStringPrepared<SafeString, std::vector<char, SafeAllocator<char> > >(s, profile);
+SafeByteArray StringPrep::getPrepared(const SafeByteArray& s, Profile profile) {
+ return createSafeByteArray(reinterpret_cast<const char*>(vecptr(getStringPrepared<SafeByteArray, std::vector<char, SafeAllocator<char> > >(s, profile))));
}
}
diff --git a/Swiften/IDN/StringPrep.h b/Swiften/IDN/StringPrep.h
index fc75118..dc8fadc 100644
--- a/Swiften/IDN/StringPrep.h
+++ b/Swiften/IDN/StringPrep.h
@@ -7,7 +7,7 @@
#pragma once
#include <string>
-#include <Swiften/Base/SafeString.h>
+#include <Swiften/Base/SafeByteArray.h>
namespace Swift {
class StringPrep {
@@ -20,6 +20,6 @@ namespace Swift {
};
static std::string getPrepared(const std::string& s, Profile profile);
- static SafeString getPrepared(const SafeString& s, Profile profile);
+ static SafeByteArray getPrepared(const SafeByteArray& s, Profile profile);
};
}
diff --git a/Swiften/SASL/ClientAuthenticator.h b/Swiften/SASL/ClientAuthenticator.h
index 6557b9a..8710ac8 100644
--- a/Swiften/SASL/ClientAuthenticator.h
+++ b/Swiften/SASL/ClientAuthenticator.h
@@ -10,7 +10,6 @@
#include <string>
#include <vector>
-#include <Swiften/Base/SafeString.h>
#include <Swiften/Base/SafeByteArray.h>
#include <Swiften/Base/ByteArray.h>
@@ -24,7 +23,7 @@ namespace Swift {
return name;
}
- void setCredentials(const std::string& authcid, const SafeString& password, const std::string& authzid = std::string()) {
+ void setCredentials(const std::string& authcid, const SafeByteArray& password, const std::string& authzid = std::string()) {
this->authcid = authcid;
this->password = password;
this->authzid = authzid;
@@ -41,14 +40,14 @@ namespace Swift {
return authzid;
}
- const SafeString& getPassword() const {
+ const SafeByteArray& getPassword() const {
return password;
}
private:
std::string name;
std::string authcid;
- SafeString password;
+ SafeByteArray password;
std::string authzid;
};
}
diff --git a/Swiften/SASL/DIGESTMD5ClientAuthenticator.cpp b/Swiften/SASL/DIGESTMD5ClientAuthenticator.cpp
index ffa098c..5e78ee2 100644
--- a/Swiften/SASL/DIGESTMD5ClientAuthenticator.cpp
+++ b/Swiften/SASL/DIGESTMD5ClientAuthenticator.cpp
@@ -34,7 +34,7 @@ boost::optional<SafeByteArray> DIGESTMD5ClientAuthenticator::getResponse() const
// Compute the response value
ByteArray A1 = concat(
MD5::getHash(
- createSafeByteArray(concat(SafeString(getAuthenticationID().c_str()), SafeString(":"), SafeString(realm.c_str()), SafeString(":"), getPassword()))),
+ concat(createSafeByteArray(getAuthenticationID().c_str()), createSafeByteArray(":"), createSafeByteArray(realm.c_str()), createSafeByteArray(":"), getPassword())),
createByteArray(":"), createByteArray(*challenge.getValue("nonce")), createByteArray(":"), createByteArray(cnonce));
if (!getAuthorizationID().empty()) {
append(A1, createByteArray(":" + getAuthenticationID()));
diff --git a/Swiften/SASL/PLAINClientAuthenticator.cpp b/Swiften/SASL/PLAINClientAuthenticator.cpp
index 17f880a..7872174 100644
--- a/Swiften/SASL/PLAINClientAuthenticator.cpp
+++ b/Swiften/SASL/PLAINClientAuthenticator.cpp
@@ -13,7 +13,7 @@ PLAINClientAuthenticator::PLAINClientAuthenticator() : ClientAuthenticator("PLAI
}
boost::optional<SafeByteArray> PLAINClientAuthenticator::getResponse() const {
- return concat(createSafeByteArray(getAuthorizationID()), createSafeByteArray('\0'), createSafeByteArray(getAuthenticationID()), createSafeByteArray('\0'), createSafeByteArray(getPassword()));
+ return concat(createSafeByteArray(getAuthorizationID()), createSafeByteArray('\0'), createSafeByteArray(getAuthenticationID()), createSafeByteArray('\0'), getPassword());
}
bool PLAINClientAuthenticator::setChallenge(const boost::optional<ByteArray>&) {
diff --git a/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp b/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp
index a9855a5..1d0ad70 100644
--- a/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp
+++ b/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp
@@ -100,7 +100,7 @@ bool SCRAMSHA1ClientAuthenticator::setChallenge(const boost::optional<ByteArray>
}
// Compute all the values needed for the server signature
- saltedPassword = PBKDF2::encode(createSafeByteArray(StringPrep::getPrepared(getPassword(), StringPrep::SASLPrep)), salt, iterations);
+ saltedPassword = PBKDF2::encode(StringPrep::getPrepared(getPassword(), StringPrep::SASLPrep), salt, iterations);
authMessage = concat(getInitialBareClientMessage(), createByteArray(","), initialServerMessage, createByteArray(","), getFinalMessageWithoutProof());
ByteArray serverKey = HMACSHA1::getResult(saltedPassword, createByteArray("Server Key"));
serverSignature = HMACSHA1::getResult(serverKey, authMessage);
diff --git a/Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp b/Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp
index e5f26ae..38bab15 100644
--- a/Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp
+++ b/Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp
@@ -32,7 +32,7 @@ class DIGESTMD5ClientAuthenticatorTest : public CppUnit::TestFixture {
void testGetResponse() {
DIGESTMD5ClientAuthenticator testling("xmpp.example.com", "abcdefgh");
- testling.setCredentials("user", "pass", "");
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
testling.setChallenge(createByteArray(
"realm=\"example.com\","
"nonce=\"O6skKPuaCZEny3hteI19qXMBXSadoWs840MchORo\","
@@ -46,7 +46,7 @@ class DIGESTMD5ClientAuthenticatorTest : public CppUnit::TestFixture {
void testGetResponse_WithAuthorizationID() {
DIGESTMD5ClientAuthenticator testling("xmpp.example.com", "abcdefgh");
- testling.setCredentials("user", "pass", "myauthzid");
+ testling.setCredentials("user", createSafeByteArray("pass"), "myauthzid");
testling.setChallenge(createByteArray(
"realm=\"example.com\","
"nonce=\"O6skKPuaCZEny3hteI19qXMBXSadoWs840MchORo\","
diff --git a/Swiften/SASL/UnitTest/PLAINClientAuthenticatorTest.cpp b/Swiften/SASL/UnitTest/PLAINClientAuthenticatorTest.cpp
index d6c4188..3416923 100644
--- a/Swiften/SASL/UnitTest/PLAINClientAuthenticatorTest.cpp
+++ b/Swiften/SASL/UnitTest/PLAINClientAuthenticatorTest.cpp
@@ -22,7 +22,7 @@ class PLAINClientAuthenticatorTest : public CppUnit::TestFixture {
void testGetResponse_WithoutAuthzID() {
PLAINClientAuthenticator testling;
- testling.setCredentials("user", "pass");
+ testling.setCredentials("user", createSafeByteArray("pass"));
CPPUNIT_ASSERT_EQUAL(*testling.getResponse(), createSafeByteArray("\0user\0pass", 10));
}
@@ -30,7 +30,7 @@ class PLAINClientAuthenticatorTest : public CppUnit::TestFixture {
void testGetResponse_WithAuthzID() {
PLAINClientAuthenticator testling;
- testling.setCredentials("user", "pass", "authz");
+ testling.setCredentials("user", createSafeByteArray("pass"), "authz");
CPPUNIT_ASSERT_EQUAL(*testling.getResponse(), createSafeByteArray("authz\0user\0pass", 15));
}
diff --git a/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp b/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp
index 6db51fb..f0ca01c 100644
--- a/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp
+++ b/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp
@@ -43,7 +43,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture {
void testGetInitialResponse() {
SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH");
- testling.setCredentials("user", "pass", "");
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
SafeByteArray response = *testling.getResponse();
@@ -52,7 +52,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture {
void testGetInitialResponse_UsernameHasSpecialChars() {
SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH");
- testling.setCredentials(",us=,er=", "pass", "");
+ testling.setCredentials(",us=,er=", createSafeByteArray("pass"), "");
SafeByteArray response = *testling.getResponse();
@@ -61,7 +61,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture {
void testGetInitialResponse_WithAuthorizationID() {
SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH");
- testling.setCredentials("user", "pass", "auth");
+ testling.setCredentials("user", createSafeByteArray("pass"), "auth");
SafeByteArray response = *testling.getResponse();
@@ -70,7 +70,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture {
void testGetInitialResponse_WithAuthorizationIDWithSpecialChars() {
SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH");
- testling.setCredentials("user", "pass", "a=u,th");
+ testling.setCredentials("user", createSafeByteArray("pass"), "a=u,th");
SafeByteArray response = *testling.getResponse();
@@ -80,7 +80,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture {
void testGetInitialResponse_WithoutChannelBindingWithTLSChannelBindingData() {
SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH", false);
testling.setTLSChannelBindingData(createByteArray("xyza"));
- testling.setCredentials("user", "pass", "");
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
SafeByteArray response = *testling.getResponse();
@@ -90,7 +90,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture {
void testGetInitialResponse_WithChannelBindingWithTLSChannelBindingData() {
SCRAMSHA1ClientAuthenticator testling("abcdefghABCDEFGH", true);
testling.setTLSChannelBindingData(createByteArray("xyza"));
- testling.setCredentials("user", "pass", "");
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
SafeByteArray response = *testling.getResponse();
@@ -99,7 +99,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture {
void testGetFinalResponse() {
SCRAMSHA1ClientAuthenticator testling("abcdefgh");
- testling.setCredentials("user", "pass", "");
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
SafeByteArray response = *testling.getResponse();
@@ -109,7 +109,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture {
void testGetFinalResponse_WithoutChannelBindingWithTLSChannelBindingData() {
SCRAMSHA1ClientAuthenticator testling("abcdefgh", false);
- testling.setCredentials("user", "pass", "");
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
testling.setTLSChannelBindingData(createByteArray("xyza"));
testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
@@ -120,7 +120,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture {
void testGetFinalResponse_WithChannelBindingWithTLSChannelBindingData() {
SCRAMSHA1ClientAuthenticator testling("abcdefgh", true);
- testling.setCredentials("user", "pass", "");
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
testling.setTLSChannelBindingData(createByteArray("xyza"));
testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
@@ -131,7 +131,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture {
void testSetFinalChallenge() {
SCRAMSHA1ClientAuthenticator testling("abcdefgh");
- testling.setCredentials("user", "pass", "");
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
bool result = testling.setChallenge(createByteArray("v=Dd+Q20knZs9jeeK0pi1Mx1Se+yo="));
@@ -141,7 +141,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture {
void testSetChallenge() {
SCRAMSHA1ClientAuthenticator testling("abcdefgh");
- testling.setCredentials("user", "pass", "");
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
bool result = testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
@@ -150,7 +150,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture {
void testSetChallenge_InvalidClientNonce() {
SCRAMSHA1ClientAuthenticator testling("abcdefgh");
- testling.setCredentials("user", "pass", "");
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
bool result = testling.setChallenge(createByteArray("r=abcdefgiABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
@@ -159,7 +159,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture {
void testSetChallenge_OnlyClientNonce() {
SCRAMSHA1ClientAuthenticator testling("abcdefgh");
- testling.setCredentials("user", "pass", "");
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
bool result = testling.setChallenge(createByteArray("r=abcdefgh,s=MTIzNDU2NzgK,i=4096"));
@@ -168,7 +168,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture {
void testSetChallenge_InvalidIterations() {
SCRAMSHA1ClientAuthenticator testling("abcdefgh");
- testling.setCredentials("user", "pass", "");
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
bool result = testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=bla"));
@@ -177,7 +177,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture {
void testSetChallenge_MissingIterations() {
SCRAMSHA1ClientAuthenticator testling("abcdefgh");
- testling.setCredentials("user", "pass", "");
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
bool result = testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK"));
@@ -186,7 +186,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture {
void testSetChallenge_ZeroIterations() {
SCRAMSHA1ClientAuthenticator testling("abcdefgh");
- testling.setCredentials("user", "pass", "");
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
bool result = testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=0"));
@@ -195,7 +195,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture {
void testSetChallenge_NegativeIterations() {
SCRAMSHA1ClientAuthenticator testling("abcdefgh");
- testling.setCredentials("user", "pass", "");
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
bool result = testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=-1"));
@@ -204,7 +204,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture {
void testSetFinalChallenge_InvalidChallenge() {
SCRAMSHA1ClientAuthenticator testling("abcdefgh");
- testling.setCredentials("user", "pass", "");
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
bool result = testling.setChallenge(createByteArray("v=e26kI69ICb6zosapLLxrER/631A="));
@@ -213,7 +213,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture {
void testGetResponseAfterFinalChallenge() {
SCRAMSHA1ClientAuthenticator testling("abcdefgh");
- testling.setCredentials("user", "pass", "");
+ testling.setCredentials("user", createSafeByteArray("pass"), "");
testling.setChallenge(createByteArray("r=abcdefghABCDEFGH,s=MTIzNDU2NzgK,i=4096"));
testling.setChallenge(createByteArray("v=Dd+Q20knZs9jeeK0pi1Mx1Se+yo="));
diff --git a/Swiften/Serializer/AuthChallengeSerializer.cpp b/Swiften/Serializer/AuthChallengeSerializer.cpp
index 445059d..1ddc165 100644
--- a/Swiften/Serializer/AuthChallengeSerializer.cpp
+++ b/Swiften/Serializer/AuthChallengeSerializer.cpp
@@ -15,7 +15,7 @@ namespace Swift {
AuthChallengeSerializer::AuthChallengeSerializer() {
}
-SafeString AuthChallengeSerializer::serialize(boost::shared_ptr<Element> element) const {
+SafeByteArray AuthChallengeSerializer::serialize(boost::shared_ptr<Element> element) const {
boost::shared_ptr<AuthChallenge> authChallenge(boost::dynamic_pointer_cast<AuthChallenge>(element));
std::string value;
boost::optional<std::vector<unsigned char> > message = authChallenge->getValue();
@@ -27,7 +27,7 @@ SafeString AuthChallengeSerializer::serialize(boost::shared_ptr<Element> element
value = Base64::encode(ByteArray(*message));
}
}
- return "<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + value + "</challenge>";
+ return createSafeByteArray("<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + value + "</challenge>");
}
}
diff --git a/Swiften/Serializer/AuthChallengeSerializer.h b/Swiften/Serializer/AuthChallengeSerializer.h
index 6254fac..d485473 100644
--- a/Swiften/Serializer/AuthChallengeSerializer.h
+++ b/Swiften/Serializer/AuthChallengeSerializer.h
@@ -16,6 +16,6 @@ namespace Swift {
public:
AuthChallengeSerializer();
- virtual SafeString serialize(boost::shared_ptr<Element> element) const;
+ virtual SafeByteArray serialize(boost::shared_ptr<Element> element) const;
};
}
diff --git a/Swiften/Serializer/AuthFailureSerializer.h b/Swiften/Serializer/AuthFailureSerializer.h
index 5f01f09..090f0c4 100644
--- a/Swiften/Serializer/AuthFailureSerializer.h
+++ b/Swiften/Serializer/AuthFailureSerializer.h
@@ -18,8 +18,8 @@ namespace Swift {
AuthFailureSerializer() : GenericElementSerializer<AuthFailure>() {
}
- virtual SafeString serialize(boost::shared_ptr<Element>) const {
- return XMLElement("failure", "urn:ietf:params:xml:ns:xmpp-sasl").serialize();
+ virtual SafeByteArray serialize(boost::shared_ptr<Element>) const {
+ return createSafeByteArray(XMLElement("failure", "urn:ietf:params:xml:ns:xmpp-sasl").serialize());
}
};
}
diff --git a/Swiften/Serializer/AuthRequestSerializer.cpp b/Swiften/Serializer/AuthRequestSerializer.cpp
index e38dc85..7f25c93 100644
--- a/Swiften/Serializer/AuthRequestSerializer.cpp
+++ b/Swiften/Serializer/AuthRequestSerializer.cpp
@@ -9,7 +9,6 @@
#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 {
@@ -17,19 +16,19 @@ namespace Swift {
AuthRequestSerializer::AuthRequestSerializer() {
}
-SafeString AuthRequestSerializer::serialize(boost::shared_ptr<Element> element) const {
+SafeByteArray AuthRequestSerializer::serialize(boost::shared_ptr<Element> element) const {
boost::shared_ptr<AuthRequest> authRequest(boost::dynamic_pointer_cast<AuthRequest>(element));
- SafeString value;
+ SafeByteArray value;
boost::optional<SafeByteArray> message = authRequest->getMessage();
if (message) {
if ((*message).empty()) {
- value = "=";
+ value = createSafeByteArray("=");
}
else {
value = Base64::encode(*message);
}
}
- return concat(SafeString("<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"" + authRequest->getMechanism() + "\">"), value, SafeString("</auth>"));
+ return concat(createSafeByteArray("<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"" + authRequest->getMechanism() + "\">"), value, createSafeByteArray("</auth>"));
}
}
diff --git a/Swiften/Serializer/AuthRequestSerializer.h b/Swiften/Serializer/AuthRequestSerializer.h
index 0d812d6..add7983 100644
--- a/Swiften/Serializer/AuthRequestSerializer.h
+++ b/Swiften/Serializer/AuthRequestSerializer.h
@@ -16,6 +16,6 @@ namespace Swift {
public:
AuthRequestSerializer();
- virtual SafeString serialize(boost::shared_ptr<Element> element) const;
+ virtual SafeByteArray serialize(boost::shared_ptr<Element> element) const;
};
}
diff --git a/Swiften/Serializer/AuthResponseSerializer.cpp b/Swiften/Serializer/AuthResponseSerializer.cpp
index 5b166b7..86b7fbe 100644
--- a/Swiften/Serializer/AuthResponseSerializer.cpp
+++ b/Swiften/Serializer/AuthResponseSerializer.cpp
@@ -9,7 +9,6 @@
#include <Swiften/Elements/AuthResponse.h>
#include <Swiften/StringCodecs/Base64.h>
#include <Swiften/Base/SafeByteArray.h>
-#include <Swiften/Base/SafeString.h>
#include <Swiften/Base/Concat.h>
namespace Swift {
@@ -17,19 +16,19 @@ namespace Swift {
AuthResponseSerializer::AuthResponseSerializer() {
}
-SafeString AuthResponseSerializer::serialize(boost::shared_ptr<Element> element) const {
+SafeByteArray AuthResponseSerializer::serialize(boost::shared_ptr<Element> element) const {
boost::shared_ptr<AuthResponse> authResponse(boost::dynamic_pointer_cast<AuthResponse>(element));
- SafeString value;
+ SafeByteArray value;
boost::optional<SafeByteArray> message = authResponse->getValue();
if (message) {
if ((*message).empty()) {
- value = "=";
+ value = createSafeByteArray("=");
}
else {
value = Base64::encode(*message);
}
}
- return concat(SafeString("<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"), value, SafeString("</response>"));
+ return concat(createSafeByteArray("<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"), value, createSafeByteArray("</response>"));
}
}
diff --git a/Swiften/Serializer/AuthResponseSerializer.h b/Swiften/Serializer/AuthResponseSerializer.h
index bb4866f..495f8cc 100644
--- a/Swiften/Serializer/AuthResponseSerializer.h
+++ b/Swiften/Serializer/AuthResponseSerializer.h
@@ -16,6 +16,6 @@ namespace Swift {
public:
AuthResponseSerializer();
- virtual SafeString serialize(boost::shared_ptr<Element> element) const;
+ virtual SafeByteArray serialize(boost::shared_ptr<Element> element) const;
};
}
diff --git a/Swiften/Serializer/AuthSuccessSerializer.cpp b/Swiften/Serializer/AuthSuccessSerializer.cpp
index b7cae47..26b58c3 100644
--- a/Swiften/Serializer/AuthSuccessSerializer.cpp
+++ b/Swiften/Serializer/AuthSuccessSerializer.cpp
@@ -15,7 +15,7 @@ namespace Swift {
AuthSuccessSerializer::AuthSuccessSerializer() {
}
-SafeString AuthSuccessSerializer::serialize(boost::shared_ptr<Element> element) const {
+SafeByteArray AuthSuccessSerializer::serialize(boost::shared_ptr<Element> element) const {
boost::shared_ptr<AuthSuccess> authSuccess(boost::dynamic_pointer_cast<AuthSuccess>(element));
std::string value;
boost::optional<std::vector<unsigned char> > message = authSuccess->getValue();
@@ -27,7 +27,7 @@ SafeString AuthSuccessSerializer::serialize(boost::shared_ptr<Element> element)
value = Base64::encode(ByteArray(*message));
}
}
- return "<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + value + "</success>";
+ return createSafeByteArray("<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + value + "</success>");
}
}
diff --git a/Swiften/Serializer/AuthSuccessSerializer.h b/Swiften/Serializer/AuthSuccessSerializer.h
index 5516c0d..8163d16 100644
--- a/Swiften/Serializer/AuthSuccessSerializer.h
+++ b/Swiften/Serializer/AuthSuccessSerializer.h
@@ -16,6 +16,6 @@ namespace Swift {
public:
AuthSuccessSerializer();
- virtual SafeString serialize(boost::shared_ptr<Element> element) const;
+ virtual SafeByteArray serialize(boost::shared_ptr<Element> element) const;
};
}
diff --git a/Swiften/Serializer/ComponentHandshakeSerializer.cpp b/Swiften/Serializer/ComponentHandshakeSerializer.cpp
index c60492d..e7837d3 100644
--- a/Swiften/Serializer/ComponentHandshakeSerializer.cpp
+++ b/Swiften/Serializer/ComponentHandshakeSerializer.cpp
@@ -13,9 +13,9 @@ namespace Swift {
ComponentHandshakeSerializer::ComponentHandshakeSerializer() {
}
-SafeString ComponentHandshakeSerializer::serialize(boost::shared_ptr<Element> element) const {
+SafeByteArray ComponentHandshakeSerializer::serialize(boost::shared_ptr<Element> element) const {
boost::shared_ptr<ComponentHandshake> handshake(boost::dynamic_pointer_cast<ComponentHandshake>(element));
- return "<handshake>" + handshake->getData() + "</handshake>";
+ return createSafeByteArray("<handshake>" + handshake->getData() + "</handshake>");
}
}
diff --git a/Swiften/Serializer/ComponentHandshakeSerializer.h b/Swiften/Serializer/ComponentHandshakeSerializer.h
index 2d5970e..1145ed9 100644
--- a/Swiften/Serializer/ComponentHandshakeSerializer.h
+++ b/Swiften/Serializer/ComponentHandshakeSerializer.h
@@ -16,6 +16,6 @@ namespace Swift {
public:
ComponentHandshakeSerializer();
- virtual SafeString serialize(boost::shared_ptr<Element> element) const;
+ virtual SafeByteArray serialize(boost::shared_ptr<Element> element) const;
};
}
diff --git a/Swiften/Serializer/CompressFailureSerializer.h b/Swiften/Serializer/CompressFailureSerializer.h
index 3446670..27a638f 100644
--- a/Swiften/Serializer/CompressFailureSerializer.h
+++ b/Swiften/Serializer/CompressFailureSerializer.h
@@ -18,8 +18,8 @@ namespace Swift {
CompressFailureSerializer() : GenericElementSerializer<CompressFailure>() {
}
- virtual SafeString serialize(boost::shared_ptr<Element>) const {
- return XMLElement("failure", "http://jabber.org/protocol/compress").serialize();
+ virtual SafeByteArray serialize(boost::shared_ptr<Element>) const {
+ return createSafeByteArray(XMLElement("failure", "http://jabber.org/protocol/compress").serialize());
}
};
}
diff --git a/Swiften/Serializer/CompressRequestSerializer.cpp b/Swiften/Serializer/CompressRequestSerializer.cpp
index 8dc4e50..c6d4627 100644
--- a/Swiften/Serializer/CompressRequestSerializer.cpp
+++ b/Swiften/Serializer/CompressRequestSerializer.cpp
@@ -13,9 +13,9 @@ namespace Swift {
CompressRequestSerializer::CompressRequestSerializer() {
}
-SafeString CompressRequestSerializer::serialize(boost::shared_ptr<Element> element) const {
+SafeByteArray CompressRequestSerializer::serialize(boost::shared_ptr<Element> element) const {
boost::shared_ptr<CompressRequest> compressRequest(boost::dynamic_pointer_cast<CompressRequest>(element));
- return "<compress xmlns='http://jabber.org/protocol/compress'><method>" + compressRequest->getMethod() + "</method></compress>";
+ return createSafeByteArray("<compress xmlns='http://jabber.org/protocol/compress'><method>" + compressRequest->getMethod() + "</method></compress>");
}
bool CompressRequestSerializer::canSerialize(boost::shared_ptr<Element> element) const {
diff --git a/Swiften/Serializer/CompressRequestSerializer.h b/Swiften/Serializer/CompressRequestSerializer.h
index cd06e1a..4d68c98 100644
--- a/Swiften/Serializer/CompressRequestSerializer.h
+++ b/Swiften/Serializer/CompressRequestSerializer.h
@@ -15,7 +15,7 @@ namespace Swift {
public:
CompressRequestSerializer();
- virtual SafeString serialize(boost::shared_ptr<Element> element) const;
+ virtual SafeByteArray serialize(boost::shared_ptr<Element> element) const;
virtual bool canSerialize(boost::shared_ptr<Element> element) const;
};
}
diff --git a/Swiften/Serializer/ElementSerializer.h b/Swiften/Serializer/ElementSerializer.h
index 7109f96..ba59106 100644
--- a/Swiften/Serializer/ElementSerializer.h
+++ b/Swiften/Serializer/ElementSerializer.h
@@ -8,15 +8,15 @@
#include <boost/shared_ptr.hpp>
-#include <Swiften/Base/SafeString.h>
#include <Swiften/Elements/Element.h>
+#include <Swiften/Base/SafeByteArray.h>
namespace Swift {
class ElementSerializer {
public:
virtual ~ElementSerializer();
- virtual SafeString serialize(boost::shared_ptr<Element> element) const = 0;
+ virtual SafeByteArray serialize(boost::shared_ptr<Element> element) const = 0;
virtual bool canSerialize(boost::shared_ptr<Element> element) const = 0;
};
}
diff --git a/Swiften/Serializer/EnableStreamManagementSerializer.h b/Swiften/Serializer/EnableStreamManagementSerializer.h
index 35df0c1..384753b 100644
--- a/Swiften/Serializer/EnableStreamManagementSerializer.h
+++ b/Swiften/Serializer/EnableStreamManagementSerializer.h
@@ -18,8 +18,8 @@ namespace Swift {
EnableStreamManagementSerializer() : GenericElementSerializer<EnableStreamManagement>() {
}
- virtual SafeString serialize(boost::shared_ptr<Element>) const {
- return XMLElement("enable", "urn:xmpp:sm:2").serialize();
+ virtual SafeByteArray serialize(boost::shared_ptr<Element>) const {
+ return createSafeByteArray(XMLElement("enable", "urn:xmpp:sm:2").serialize());
}
};
}
diff --git a/Swiften/Serializer/GenericElementSerializer.h b/Swiften/Serializer/GenericElementSerializer.h
index c8abdf3..e56f156 100644
--- a/Swiften/Serializer/GenericElementSerializer.h
+++ b/Swiften/Serializer/GenericElementSerializer.h
@@ -14,7 +14,7 @@ namespace Swift {
template<typename T>
class GenericElementSerializer : public ElementSerializer {
public:
- virtual SafeString serialize(boost::shared_ptr<Element> element) const = 0;
+ virtual SafeByteArray serialize(boost::shared_ptr<Element> element) const = 0;
virtual bool canSerialize(boost::shared_ptr<Element> element) const {
return boost::dynamic_pointer_cast<T>(element);
diff --git a/Swiften/Serializer/StanzaAckRequestSerializer.h b/Swiften/Serializer/StanzaAckRequestSerializer.h
index dbcb27a..fff2a83 100644
--- a/Swiften/Serializer/StanzaAckRequestSerializer.h
+++ b/Swiften/Serializer/StanzaAckRequestSerializer.h
@@ -18,8 +18,8 @@ namespace Swift {
StanzaAckRequestSerializer() : GenericElementSerializer<StanzaAckRequest>() {
}
- virtual SafeString serialize(boost::shared_ptr<Element>) const {
- return XMLElement("r", "urn:xmpp:sm:2").serialize();
+ virtual SafeByteArray serialize(boost::shared_ptr<Element>) const {
+ return createSafeByteArray(XMLElement("r", "urn:xmpp:sm:2").serialize());
}
};
}
diff --git a/Swiften/Serializer/StanzaAckSerializer.h b/Swiften/Serializer/StanzaAckSerializer.h
index 91bbb8d..ea1e8ad 100644
--- a/Swiften/Serializer/StanzaAckSerializer.h
+++ b/Swiften/Serializer/StanzaAckSerializer.h
@@ -19,12 +19,12 @@ namespace Swift {
StanzaAckSerializer() : GenericElementSerializer<StanzaAck>() {
}
- virtual SafeString serialize(boost::shared_ptr<Element> element) const {
+ virtual SafeByteArray serialize(boost::shared_ptr<Element> element) const {
StanzaAck::ref stanzaAck(boost::dynamic_pointer_cast<StanzaAck>(element));
assert(stanzaAck->isValid());
XMLElement result("a", "urn:xmpp:sm:2");
result.setAttribute("h", std::string(boost::lexical_cast<std::string>(stanzaAck->getHandledStanzasCount())));
- return result.serialize();
+ return createSafeByteArray(result.serialize());
}
};
}
diff --git a/Swiften/Serializer/StanzaSerializer.cpp b/Swiften/Serializer/StanzaSerializer.cpp
index c34ecae..9a4fd2c 100644
--- a/Swiften/Serializer/StanzaSerializer.cpp
+++ b/Swiften/Serializer/StanzaSerializer.cpp
@@ -22,7 +22,7 @@ namespace Swift {
StanzaSerializer::StanzaSerializer(const std::string& tag, PayloadSerializerCollection* payloadSerializers) : tag_(tag), payloadSerializers_(payloadSerializers) {
}
-SafeString StanzaSerializer::serialize(boost::shared_ptr<Element> element) const {
+SafeByteArray StanzaSerializer::serialize(boost::shared_ptr<Element> element) const {
boost::shared_ptr<Stanza> stanza(boost::dynamic_pointer_cast<Stanza>(element));
XMLElement stanzaElement(tag_);
@@ -51,7 +51,7 @@ SafeString StanzaSerializer::serialize(boost::shared_ptr<Element> element) const
stanzaElement.addNode(boost::shared_ptr<XMLNode>(new XMLRawTextNode(serializedPayloads)));
}
- return stanzaElement.serialize();
+ return createSafeByteArray(stanzaElement.serialize());
}
}
diff --git a/Swiften/Serializer/StanzaSerializer.h b/Swiften/Serializer/StanzaSerializer.h
index 5726562..db18aa2 100644
--- a/Swiften/Serializer/StanzaSerializer.h
+++ b/Swiften/Serializer/StanzaSerializer.h
@@ -18,7 +18,7 @@ namespace Swift {
public:
StanzaSerializer(const std::string& tag, PayloadSerializerCollection* payloadSerializers);
- virtual SafeString serialize(boost::shared_ptr<Element>) const;
+ virtual SafeByteArray serialize(boost::shared_ptr<Element>) const;
virtual void setStanzaSpecificAttributes(boost::shared_ptr<Element>, XMLElement&) const = 0;
private:
diff --git a/Swiften/Serializer/StartTLSFailureSerializer.h b/Swiften/Serializer/StartTLSFailureSerializer.h
index 6f3f24c..779be92 100644
--- a/Swiften/Serializer/StartTLSFailureSerializer.h
+++ b/Swiften/Serializer/StartTLSFailureSerializer.h
@@ -18,8 +18,8 @@ namespace Swift {
StartTLSFailureSerializer() : GenericElementSerializer<StartTLSFailure>() {
}
- virtual SafeString serialize(boost::shared_ptr<Element>) const {
- return XMLElement("failure", "urn:ietf:params:xml:ns:xmpp-tls").serialize();
+ virtual SafeByteArray serialize(boost::shared_ptr<Element>) const {
+ return createSafeByteArray(XMLElement("failure", "urn:ietf:params:xml:ns:xmpp-tls").serialize());
}
};
}
diff --git a/Swiften/Serializer/StartTLSRequestSerializer.h b/Swiften/Serializer/StartTLSRequestSerializer.h
index d5fa046..df914ce 100644
--- a/Swiften/Serializer/StartTLSRequestSerializer.h
+++ b/Swiften/Serializer/StartTLSRequestSerializer.h
@@ -18,8 +18,8 @@ namespace Swift {
StartTLSRequestSerializer() : GenericElementSerializer<StartTLSRequest>() {
}
- virtual SafeString serialize(boost::shared_ptr<Element>) const {
- return XMLElement("starttls", "urn:ietf:params:xml:ns:xmpp-tls").serialize();
+ virtual SafeByteArray serialize(boost::shared_ptr<Element>) const {
+ return createSafeByteArray(XMLElement("starttls", "urn:ietf:params:xml:ns:xmpp-tls").serialize());
}
};
}
diff --git a/Swiften/Serializer/StreamErrorSerializer.cpp b/Swiften/Serializer/StreamErrorSerializer.cpp
index e95ee37..b3d62a0 100644
--- a/Swiften/Serializer/StreamErrorSerializer.cpp
+++ b/Swiften/Serializer/StreamErrorSerializer.cpp
@@ -15,7 +15,7 @@ namespace Swift {
StreamErrorSerializer::StreamErrorSerializer() : GenericElementSerializer<StreamError>() {
}
-SafeString StreamErrorSerializer::serialize(boost::shared_ptr<Element> element) const {
+SafeByteArray StreamErrorSerializer::serialize(boost::shared_ptr<Element> element) const {
StreamError::ref error = boost::dynamic_pointer_cast<StreamError>(element);
XMLElement errorElement("error", "http://etherx.jabber.org/streams");
@@ -53,7 +53,7 @@ SafeString StreamErrorSerializer::serialize(boost::shared_ptr<Element> element)
errorElement.addNode(boost::make_shared<XMLElement>("text", "urn:ietf:params:xml:ns:xmpp-streams", error->getText()));
}
- return errorElement.serialize();
+ return createSafeByteArray(errorElement.serialize());
}
}
diff --git a/Swiften/Serializer/StreamErrorSerializer.h b/Swiften/Serializer/StreamErrorSerializer.h
index 2115324..bdaa831 100644
--- a/Swiften/Serializer/StreamErrorSerializer.h
+++ b/Swiften/Serializer/StreamErrorSerializer.h
@@ -14,6 +14,6 @@ namespace Swift {
public:
StreamErrorSerializer();
- virtual SafeString serialize(boost::shared_ptr<Element> error) const;
+ virtual SafeByteArray serialize(boost::shared_ptr<Element> error) const;
};
}
diff --git a/Swiften/Serializer/StreamFeaturesSerializer.cpp b/Swiften/Serializer/StreamFeaturesSerializer.cpp
index 3c500e3..fb7bb8c 100644
--- a/Swiften/Serializer/StreamFeaturesSerializer.cpp
+++ b/Swiften/Serializer/StreamFeaturesSerializer.cpp
@@ -17,7 +17,7 @@ namespace Swift {
StreamFeaturesSerializer::StreamFeaturesSerializer() {
}
-SafeString StreamFeaturesSerializer::serialize(boost::shared_ptr<Element> element) const {
+SafeByteArray StreamFeaturesSerializer::serialize(boost::shared_ptr<Element> element) const {
boost::shared_ptr<StreamFeatures> streamFeatures(boost::dynamic_pointer_cast<StreamFeatures>(element));
XMLElement streamFeaturesElement("stream:features");
@@ -54,7 +54,7 @@ SafeString StreamFeaturesSerializer::serialize(boost::shared_ptr<Element> elemen
if (streamFeatures->hasRosterVersioning()) {
streamFeaturesElement.addNode(boost::make_shared<XMLElement>("ver", "urn:xmpp:features:rosterver"));
}
- return streamFeaturesElement.serialize();
+ return createSafeByteArray(streamFeaturesElement.serialize());
}
}
diff --git a/Swiften/Serializer/StreamFeaturesSerializer.h b/Swiften/Serializer/StreamFeaturesSerializer.h
index 0e8a6d2..5ea3ab1 100644
--- a/Swiften/Serializer/StreamFeaturesSerializer.h
+++ b/Swiften/Serializer/StreamFeaturesSerializer.h
@@ -16,6 +16,6 @@ namespace Swift {
public:
StreamFeaturesSerializer();
- virtual SafeString serialize(boost::shared_ptr<Element> element) const;
+ virtual SafeByteArray serialize(boost::shared_ptr<Element> element) const;
};
}
diff --git a/Swiften/Serializer/StreamManagementEnabledSerializer.cpp b/Swiften/Serializer/StreamManagementEnabledSerializer.cpp
index c19b86f..b559721 100644
--- a/Swiften/Serializer/StreamManagementEnabledSerializer.cpp
+++ b/Swiften/Serializer/StreamManagementEnabledSerializer.cpp
@@ -16,7 +16,7 @@ using namespace Swift;
StreamManagementEnabledSerializer::StreamManagementEnabledSerializer() : GenericElementSerializer<StreamManagementEnabled>() {
}
-SafeString StreamManagementEnabledSerializer::serialize(boost::shared_ptr<Element> el) const {
+SafeByteArray StreamManagementEnabledSerializer::serialize(boost::shared_ptr<Element> el) const {
boost::shared_ptr<StreamManagementEnabled> e(boost::dynamic_pointer_cast<StreamManagementEnabled>(el));
XMLElement element("enabled", "urn:xmpp:sm:2");
if (!e->getResumeID().empty()) {
@@ -25,5 +25,5 @@ SafeString StreamManagementEnabledSerializer::serialize(boost::shared_ptr<Elemen
if (e->getResumeSupported()) {
element.setAttribute("resume", "true");
}
- return element.serialize();
+ return createSafeByteArray(element.serialize());
}
diff --git a/Swiften/Serializer/StreamManagementEnabledSerializer.h b/Swiften/Serializer/StreamManagementEnabledSerializer.h
index 0ea976a..5f28a2b 100644
--- a/Swiften/Serializer/StreamManagementEnabledSerializer.h
+++ b/Swiften/Serializer/StreamManagementEnabledSerializer.h
@@ -16,6 +16,6 @@ namespace Swift {
public:
StreamManagementEnabledSerializer();
- virtual SafeString serialize(boost::shared_ptr<Element>) const;
+ virtual SafeByteArray serialize(boost::shared_ptr<Element>) const;
};
}
diff --git a/Swiften/Serializer/StreamManagementFailedSerializer.h b/Swiften/Serializer/StreamManagementFailedSerializer.h
index 034366e..f3dcce0 100644
--- a/Swiften/Serializer/StreamManagementFailedSerializer.h
+++ b/Swiften/Serializer/StreamManagementFailedSerializer.h
@@ -18,8 +18,8 @@ namespace Swift {
StreamManagementFailedSerializer() : GenericElementSerializer<StreamManagementFailed>() {
}
- virtual SafeString serialize(boost::shared_ptr<Element>) const {
- return XMLElement("failed", "urn:xmpp:sm:2").serialize();
+ virtual SafeByteArray serialize(boost::shared_ptr<Element>) const {
+ return createSafeByteArray(XMLElement("failed", "urn:xmpp:sm:2").serialize());
}
};
}
diff --git a/Swiften/Serializer/StreamResumeSerializer.cpp b/Swiften/Serializer/StreamResumeSerializer.cpp
index 01877a9..e9e520d 100644
--- a/Swiften/Serializer/StreamResumeSerializer.cpp
+++ b/Swiften/Serializer/StreamResumeSerializer.cpp
@@ -17,12 +17,12 @@ using namespace Swift;
StreamResumeSerializer::StreamResumeSerializer() : GenericElementSerializer<StreamResume>() {
}
-SafeString StreamResumeSerializer::serialize(boost::shared_ptr<Element> el) const {
+SafeByteArray StreamResumeSerializer::serialize(boost::shared_ptr<Element> el) const {
boost::shared_ptr<StreamResume> e(boost::dynamic_pointer_cast<StreamResume>(el));
XMLElement element("resume", "urn:xmpp:sm:2");
element.setAttribute("previd", e->getResumeID());
if (e->getHandledStanzasCount()) {
element.setAttribute("h", boost::lexical_cast<std::string>(e->getHandledStanzasCount()));
}
- return element.serialize();
+ return createSafeByteArray(element.serialize());
}
diff --git a/Swiften/Serializer/StreamResumeSerializer.h b/Swiften/Serializer/StreamResumeSerializer.h
index 965485f..501d8b6 100644
--- a/Swiften/Serializer/StreamResumeSerializer.h
+++ b/Swiften/Serializer/StreamResumeSerializer.h
@@ -16,6 +16,6 @@ namespace Swift {
public:
StreamResumeSerializer();
- virtual SafeString serialize(boost::shared_ptr<Element>) const;
+ virtual SafeByteArray serialize(boost::shared_ptr<Element>) const;
};
}
diff --git a/Swiften/Serializer/StreamResumedSerializer.cpp b/Swiften/Serializer/StreamResumedSerializer.cpp
index 06006b8..7ae82d1 100644
--- a/Swiften/Serializer/StreamResumedSerializer.cpp
+++ b/Swiften/Serializer/StreamResumedSerializer.cpp
@@ -17,12 +17,12 @@ using namespace Swift;
StreamResumedSerializer::StreamResumedSerializer() : GenericElementSerializer<StreamResumed>() {
}
-SafeString StreamResumedSerializer::serialize(boost::shared_ptr<Element> el) const {
+SafeByteArray StreamResumedSerializer::serialize(boost::shared_ptr<Element> el) const {
boost::shared_ptr<StreamResumed> e(boost::dynamic_pointer_cast<StreamResumed>(el));
XMLElement element("resumed", "urn:xmpp:sm:2");
element.setAttribute("previd", e->getResumeID());
if (e->getHandledStanzasCount()) {
element.setAttribute("h", boost::lexical_cast<std::string>(e->getHandledStanzasCount()));
}
- return element.serialize();
+ return createSafeByteArray(element.serialize());
}
diff --git a/Swiften/Serializer/StreamResumedSerializer.h b/Swiften/Serializer/StreamResumedSerializer.h
index 24d5f86..7828694 100644
--- a/Swiften/Serializer/StreamResumedSerializer.h
+++ b/Swiften/Serializer/StreamResumedSerializer.h
@@ -16,6 +16,6 @@ namespace Swift {
public:
StreamResumedSerializer();
- virtual SafeString serialize(boost::shared_ptr<Element>) const;
+ virtual SafeByteArray serialize(boost::shared_ptr<Element>) const;
};
}
diff --git a/Swiften/Serializer/TLSProceedSerializer.h b/Swiften/Serializer/TLSProceedSerializer.h
index 95ee211..21a8420 100644
--- a/Swiften/Serializer/TLSProceedSerializer.h
+++ b/Swiften/Serializer/TLSProceedSerializer.h
@@ -18,8 +18,8 @@ namespace Swift {
TLSProceedSerializer() : GenericElementSerializer<TLSProceed>() {
}
- virtual SafeString serialize(boost::shared_ptr<Element>) const {
- return XMLElement("proceed", "urn:ietf:params:xml:ns:xmpp-tls").serialize();
+ virtual SafeByteArray serialize(boost::shared_ptr<Element>) const {
+ return createSafeByteArray(XMLElement("proceed", "urn:ietf:params:xml:ns:xmpp-tls").serialize());
}
};
}
diff --git a/Swiften/Serializer/UnitTest/AuthChallengeSerializerTest.cpp b/Swiften/Serializer/UnitTest/AuthChallengeSerializerTest.cpp
index 3dd922e..5fb0a4e 100644
--- a/Swiften/Serializer/UnitTest/AuthChallengeSerializerTest.cpp
+++ b/Swiften/Serializer/UnitTest/AuthChallengeSerializerTest.cpp
@@ -27,7 +27,7 @@ class AuthChallengeSerializerTest : public CppUnit::TestFixture {
boost::shared_ptr<AuthChallenge> authChallenge(new AuthChallenge());
authChallenge->setValue(createByteArray("foo"));
- CPPUNIT_ASSERT_EQUAL(SafeString(
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
"<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
"Zm9v"
"</challenge>"), testling.serialize(authChallenge));
@@ -37,7 +37,7 @@ class AuthChallengeSerializerTest : public CppUnit::TestFixture {
AuthChallengeSerializer testling;
boost::shared_ptr<AuthChallenge> authChallenge(new AuthChallenge());
- CPPUNIT_ASSERT_EQUAL(SafeString(
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
"<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
"</challenge>"), testling.serialize(authChallenge));
}
@@ -47,7 +47,7 @@ class AuthChallengeSerializerTest : public CppUnit::TestFixture {
boost::shared_ptr<AuthChallenge> authChallenge(new AuthChallenge());
authChallenge->setValue(std::vector<unsigned char>());
- CPPUNIT_ASSERT_EQUAL(SafeString(
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
"<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
"="
"</challenge>"), testling.serialize(authChallenge));
diff --git a/Swiften/Serializer/UnitTest/AuthRequestSerializerTest.cpp b/Swiften/Serializer/UnitTest/AuthRequestSerializerTest.cpp
index 4d4cf50..db36de7 100644
--- a/Swiften/Serializer/UnitTest/AuthRequestSerializerTest.cpp
+++ b/Swiften/Serializer/UnitTest/AuthRequestSerializerTest.cpp
@@ -27,7 +27,7 @@ class AuthRequestSerializerTest : public CppUnit::TestFixture {
boost::shared_ptr<AuthRequest> authRequest(new AuthRequest("PLAIN"));
authRequest->setMessage(createSafeByteArray("foo"));
- CPPUNIT_ASSERT_EQUAL(SafeString(
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
"<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">"
"Zm9v"
"</auth>"), testling.serialize(authRequest));
@@ -37,7 +37,7 @@ class AuthRequestSerializerTest : public CppUnit::TestFixture {
AuthRequestSerializer testling;
boost::shared_ptr<AuthRequest> authRequest(new AuthRequest("PLAIN"));
- CPPUNIT_ASSERT_EQUAL(SafeString(
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
"<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">"
"</auth>"), testling.serialize(authRequest));
}
@@ -47,7 +47,7 @@ class AuthRequestSerializerTest : public CppUnit::TestFixture {
boost::shared_ptr<AuthRequest> authRequest(new AuthRequest("PLAIN"));
authRequest->setMessage(SafeByteArray());
- CPPUNIT_ASSERT_EQUAL(SafeString(
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
"<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">"
"="
"</auth>"), testling.serialize(authRequest));
diff --git a/Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp b/Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp
index 6804559..4b846d7 100644
--- a/Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp
+++ b/Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp
@@ -27,7 +27,7 @@ class AuthResponseSerializerTest : public CppUnit::TestFixture {
boost::shared_ptr<AuthResponse> authResponse(new AuthResponse());
authResponse->setValue(createSafeByteArray("foo"));
- CPPUNIT_ASSERT_EQUAL(SafeString(
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
"<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
"Zm9v"
"</response>"), testling.serialize(authResponse));
@@ -37,7 +37,7 @@ class AuthResponseSerializerTest : public CppUnit::TestFixture {
AuthResponseSerializer testling;
boost::shared_ptr<AuthResponse> authResponse(new AuthResponse());
- CPPUNIT_ASSERT_EQUAL(SafeString(
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
"<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
"</response>"), testling.serialize(authResponse));
}
@@ -47,7 +47,7 @@ class AuthResponseSerializerTest : public CppUnit::TestFixture {
boost::shared_ptr<AuthResponse> authResponse(new AuthResponse());
authResponse->setValue(SafeByteArray());
- CPPUNIT_ASSERT_EQUAL(SafeString(
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
"<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
"="
"</response>"), testling.serialize(authResponse));
diff --git a/Swiften/Serializer/UnitTest/AuthSuccessSerializerTest.cpp b/Swiften/Serializer/UnitTest/AuthSuccessSerializerTest.cpp
index 0d9f103..86e01f5 100644
--- a/Swiften/Serializer/UnitTest/AuthSuccessSerializerTest.cpp
+++ b/Swiften/Serializer/UnitTest/AuthSuccessSerializerTest.cpp
@@ -27,7 +27,7 @@ class AuthSuccessSerializerTest : public CppUnit::TestFixture {
boost::shared_ptr<AuthSuccess> authSuccess(new AuthSuccess());
authSuccess->setValue(createByteArray("foo"));
- CPPUNIT_ASSERT_EQUAL(SafeString(
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
"<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
"Zm9v"
"</success>"), testling.serialize(authSuccess));
@@ -37,7 +37,7 @@ class AuthSuccessSerializerTest : public CppUnit::TestFixture {
AuthSuccessSerializer testling;
boost::shared_ptr<AuthSuccess> authSuccess(new AuthSuccess());
- CPPUNIT_ASSERT_EQUAL(SafeString(
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
"<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
"</success>"), testling.serialize(authSuccess));
}
@@ -47,7 +47,7 @@ class AuthSuccessSerializerTest : public CppUnit::TestFixture {
boost::shared_ptr<AuthSuccess> authSuccess(new AuthSuccess());
authSuccess->setValue(std::vector<unsigned char>());
- CPPUNIT_ASSERT_EQUAL(SafeString(
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
"<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
"="
"</success>"), testling.serialize(authSuccess));
diff --git a/Swiften/Serializer/UnitTest/StreamFeaturesSerializerTest.cpp b/Swiften/Serializer/UnitTest/StreamFeaturesSerializerTest.cpp
index c4826c2..0abb32c 100644
--- a/Swiften/Serializer/UnitTest/StreamFeaturesSerializerTest.cpp
+++ b/Swiften/Serializer/UnitTest/StreamFeaturesSerializerTest.cpp
@@ -36,7 +36,7 @@ class StreamFeaturesSerializerTest : public CppUnit::TestFixture
streamFeatures->setHasStreamManagement();
streamFeatures->setHasRosterVersioning();
- CPPUNIT_ASSERT_EQUAL(SafeString(
+ CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
"<stream:features>"
"<starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>"
"<compression xmlns=\"http://jabber.org/features/compress\">"
diff --git a/Swiften/Serializer/XMPPSerializer.cpp b/Swiften/Serializer/XMPPSerializer.cpp
index 054175d..389f7cc 100644
--- a/Swiften/Serializer/XMPPSerializer.cpp
+++ b/Swiften/Serializer/XMPPSerializer.cpp
@@ -83,14 +83,14 @@ std::string XMPPSerializer::serializeHeader(const ProtocolHeader& header) const
return result;
}
-SafeString XMPPSerializer::serializeElement(boost::shared_ptr<Element> element) const {
+SafeByteArray XMPPSerializer::serializeElement(boost::shared_ptr<Element> element) const {
std::vector< boost::shared_ptr<ElementSerializer> >::const_iterator i = std::find_if(serializers_.begin(), serializers_.end(), boost::bind(&ElementSerializer::canSerialize, _1, element));
if (i != serializers_.end()) {
return (*i)->serialize(element);
}
else {
std::cerr << "Could not find serializer for " << typeid(*(element.get())).name() << std::endl;
- return "";
+ return createSafeByteArray("");
}
}
diff --git a/Swiften/Serializer/XMPPSerializer.h b/Swiften/Serializer/XMPPSerializer.h
index 58274a8..8727f7a 100644
--- a/Swiften/Serializer/XMPPSerializer.h
+++ b/Swiften/Serializer/XMPPSerializer.h
@@ -24,7 +24,7 @@ namespace Swift {
XMPPSerializer(PayloadSerializerCollection*, StreamType type);
std::string serializeHeader(const ProtocolHeader&) const;
- SafeString serializeElement(boost::shared_ptr<Element> stanza) const;
+ SafeByteArray serializeElement(boost::shared_ptr<Element> stanza) const;
std::string serializeFooter() const;
private:
diff --git a/Swiften/StreamStack/XMPPLayer.cpp b/Swiften/StreamStack/XMPPLayer.cpp
index 1de3a2a..1dcd84f 100644
--- a/Swiften/StreamStack/XMPPLayer.cpp
+++ b/Swiften/StreamStack/XMPPLayer.cpp
@@ -37,7 +37,7 @@ void XMPPLayer::writeFooter() {
}
void XMPPLayer::writeElement(boost::shared_ptr<Element> element) {
- writeDataInternal(createSafeByteArray(xmppSerializer_->serializeElement(element)));
+ writeDataInternal(xmppSerializer_->serializeElement(element));
}
void XMPPLayer::writeData(const std::string& data) {
diff --git a/Swiften/StringCodecs/Base64.cpp b/Swiften/StringCodecs/Base64.cpp
index d8511b4..e4eaa4e 100644
--- a/Swiften/StringCodecs/Base64.cpp
+++ b/Swiften/StringCodecs/Base64.cpp
@@ -10,7 +10,6 @@
#include <Swiften/StringCodecs/Base64.h>
#include <Swiften/Base/Algorithm.h>
-#include <Swiften/Base/SafeString.h>
namespace Swift {
@@ -56,8 +55,8 @@ std::string Base64::encode(const ByteArray &s) {
return base64Encode<std::string, ByteArray>(s);
}
-SafeString Base64::encode(const SafeByteArray &s) {
- return base64Encode<SafeString, SafeByteArray>(s);
+SafeByteArray Base64::encode(const SafeByteArray &s) {
+ return base64Encode<SafeByteArray, SafeByteArray>(s);
}
ByteArray Base64::decode(const std::string& input) {
diff --git a/Swiften/StringCodecs/Base64.h b/Swiften/StringCodecs/Base64.h
index 00a290d..2d67971 100644
--- a/Swiften/StringCodecs/Base64.h
+++ b/Swiften/StringCodecs/Base64.h
@@ -16,7 +16,7 @@ namespace Swift {
class Base64 {
public:
static std::string encode(const ByteArray& s);
- static SafeString encode(const SafeByteArray& s);
+ static SafeByteArray encode(const SafeByteArray& s);
static ByteArray decode(const std::string &s);
};
diff --git a/Swiften/TLS/OpenSSL/OpenSSLContext.cpp b/Swiften/TLS/OpenSSL/OpenSSLContext.cpp
index 8d3970e..220e7f9 100644
--- a/Swiften/TLS/OpenSSL/OpenSSLContext.cpp
+++ b/Swiften/TLS/OpenSSL/OpenSSLContext.cpp
@@ -203,7 +203,7 @@ bool OpenSSLContext::setClientCertificate(const PKCS12Certificate& certificate)
X509 *certPtr = 0;
EVP_PKEY* privateKeyPtr = 0;
STACK_OF(X509)* caCertsPtr = 0;
- int result = PKCS12_parse(pkcs12.get(), certificate.getPassword().c_str(), &privateKeyPtr, &certPtr, &caCertsPtr);
+ int result = PKCS12_parse(pkcs12.get(), reinterpret_cast<const char*>(vecptr(certificate.getPassword())), &privateKeyPtr, &certPtr, &caCertsPtr);
if (result != 1) {
return false;
}
diff --git a/Swiften/TLS/PKCS12Certificate.h b/Swiften/TLS/PKCS12Certificate.h
index d4cb367..c0e01d0 100644
--- a/Swiften/TLS/PKCS12Certificate.h
+++ b/Swiften/TLS/PKCS12Certificate.h
@@ -6,14 +6,14 @@
#pragma once
-#include <Swiften/Base/ByteArray.h>
+#include <Swiften/Base/SafeByteArray.h>
namespace Swift {
class PKCS12Certificate {
public:
PKCS12Certificate() {}
- PKCS12Certificate(const std::string& filename, const std::string& password) : password_(password) {
+ PKCS12Certificate(const std::string& filename, const SafeByteArray& password) : password_(password) {
readByteArrayFromFile(data_, filename);
}
@@ -29,12 +29,12 @@ namespace Swift {
data_ = data;
}
- const std::string& getPassword() const {
+ const SafeByteArray& getPassword() const {
return password_;
}
private:
ByteArray data_;
- std::string password_;
+ SafeByteArray password_;
};
}