summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swift/Controllers/MainController.cpp1
-rw-r--r--Swiften/Client/Client.cpp3
-rw-r--r--Swiften/Client/ClientError.h1
-rw-r--r--Swiften/Client/ClientSession.cpp18
-rw-r--r--Swiften/Client/ClientSession.h1
-rw-r--r--Swiften/Elements/AuthSuccess.h12
-rw-r--r--Swiften/Parser/AuthSuccessParser.cpp24
-rw-r--r--Swiften/Parser/AuthSuccessParser.h16
-rw-r--r--Swiften/Parser/SConscript1
-rw-r--r--Swiften/SConscript1
-rw-r--r--Swiften/Serializer/AuthSuccessSerializer.cpp17
-rw-r--r--Swiften/Serializer/AuthSuccessSerializer.h13
12 files changed, 86 insertions, 22 deletions
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp
index 2ae110b..f05d42d 100644
--- a/Swift/Controllers/MainController.cpp
+++ b/Swift/Controllers/MainController.cpp
@@ -234,96 +234,97 @@ void MainController::handleInputNotIdle() {
queuedPresence_ = preIdlePresence_;
}
}
void MainController::handleIncomingPresence(boost::shared_ptr<Presence> presence) {
//FIXME: subscribe, subscribed
rosterController_->handleIncomingPresence(presence);
}
void MainController::handleLoginRequest(const String &username, const String &password, const String& certificateFile, bool remember) {
loginWindow_->setMessage("");
ProfileSettingsProvider* profileSettings = new ProfileSettingsProvider(username, settings_);
profileSettings->storeString("jid", username);
profileSettings->storeString("certificate", certificateFile);
profileSettings->storeString("pass", remember ? password : "");
loginWindow_->addAvailableAccount(profileSettings->getStringSetting("jid"), profileSettings->getStringSetting("pass"), profileSettings->getStringSetting("certificate"));
delete profileSettings;
jid_ = JID(username);
password_ = password;
certificateFile_ = certificateFile;
performLoginFromCachedCredentials();
}
void MainController::performLoginFromCachedCredentials() {
if (!client_) {
client_ = new Swift::Client(jid_, password_);
//client_->onDataRead.connect(&printIncomingData);
//client_->onDataWritten.connect(&printOutgoingData);
if (!certificateFile_.isEmpty()) {
client_->setCertificate(certificateFile_);
}
client_->onError.connect(boost::bind(&MainController::handleError, this, _1));
client_->onConnected.connect(boost::bind(&MainController::handleConnected, this));
client_->onMessageReceived.connect(boost::bind(&MainController::handleIncomingMessage, this, _1));
}
client_->connect();
}
void MainController::handleError(const ClientError& error) {
String message;
switch(error.getType()) {
case ClientError::UnknownError: message = "Unknown Error"; break;
case ClientError::DomainNameResolveError: message = "Unable to find server"; break;
case ClientError::ConnectionError: message = "Error connecting to server"; break;
case ClientError::ConnectionReadError: message = "Error while receiving server data"; break;
case ClientError::ConnectionWriteError: message = "Error while sending data to the server"; break;
case ClientError::XMLError: message = "Error parsing server data"; break;
case ClientError::AuthenticationFailedError: message = "Login/password invalid"; break;
+ case ClientError::ServerVerificationFailedError: message = "Server verification failed"; break;
case ClientError::NoSupportedAuthMechanismsError: message = "Authentication mechanisms not supported"; break;
case ClientError::UnexpectedElementError: message = "Unexpected response"; break;
case ClientError::ResourceBindError: message = "Error binding resource"; break;
case ClientError::SessionStartError: message = "Error starting session"; break;
case ClientError::TLSError: message = "Encryption error"; break;
case ClientError::ClientCertificateLoadError: message = "Error loading certificate (Invalid password?)"; break;
case ClientError::ClientCertificateError: message = "Certificate not authorized"; break;
}
if (!rosterController_) { //hasn't been logged in yet
signOut();
loginWindow_->setMessage(message);
}
logout();
if (rosterController_) {
//reconnectAfterError();
}
}
void MainController::handleCancelLoginRequest() {
signOut();
}
void MainController::signOut() {
logout();
idleDetector_->onInputIdle.connect(boost::bind(&MainController::handleInputIdle, this));
idleDetector_->onInputNotIdle.connect(boost::bind(&MainController::handleInputNotIdle, this));
loginWindow_->loggedOut();
foreach (JIDChatControllerPair controllerPair, chatControllers_) {
delete controllerPair.second;
}
chatControllers_.clear();
foreach (JIDMUCControllerPair controllerPair, mucControllers_) {
delete controllerPair.second;
}
mucControllers_.clear();
delete rosterController_;
rosterController_ = NULL;
resetClient();
}
void MainController::logout() {
if (client_ && client_->isAvailable()) {
client_->disconnect();
}
if (rosterController_) {
rosterController_->getWindow()->setMyStatusType(StatusShow::None);
rosterController_->getWindow()->setMyStatusText("");
}
diff --git a/Swiften/Client/Client.cpp b/Swiften/Client/Client.cpp
index 2bd039a..874e23b 100644
--- a/Swiften/Client/Client.cpp
+++ b/Swiften/Client/Client.cpp
@@ -96,96 +96,99 @@ void Client::sendIQ(boost::shared_ptr<IQ> iq) {
send(iq);
}
void Client::sendMessage(boost::shared_ptr<Message> message) {
send(message);
}
void Client::sendPresence(boost::shared_ptr<Presence> presence) {
send(presence);
}
String Client::getNewIQID() {
return idGenerator_.generateID();
}
void Client::handleElement(boost::shared_ptr<Element> element) {
boost::shared_ptr<Message> message = boost::dynamic_pointer_cast<Message>(element);
if (message) {
onMessageReceived(message);
return;
}
boost::shared_ptr<Presence> presence = boost::dynamic_pointer_cast<Presence>(element);
if (presence) {
onPresenceReceived(presence);
return;
}
boost::shared_ptr<IQ> iq = boost::dynamic_pointer_cast<IQ>(element);
if (iq) {
onIQReceived(iq);
return;
}
}
void Client::setCertificate(const String& certificate) {
certificate_ = certificate;
}
void Client::handleSessionFinished(boost::shared_ptr<Error> error) {
closeConnection();
if (error) {
ClientError clientError;
if (boost::shared_ptr<ClientSession::Error> actualError = boost::dynamic_pointer_cast<ClientSession::Error>(error)) {
switch(actualError->type) {
case ClientSession::Error::AuthenticationFailedError:
clientError = ClientError(ClientError::AuthenticationFailedError);
break;
+ case ClientSession::Error::ServerVerificationFailedError:
+ clientError = ClientError(ClientError::ServerVerificationFailedError);
+ break;
case ClientSession::Error::NoSupportedAuthMechanismsError:
clientError = ClientError(ClientError::NoSupportedAuthMechanismsError);
break;
case ClientSession::Error::UnexpectedElementError:
clientError = ClientError(ClientError::UnexpectedElementError);
break;
case ClientSession::Error::ResourceBindError:
clientError = ClientError(ClientError::ResourceBindError);
break;
case ClientSession::Error::SessionStartError:
clientError = ClientError(ClientError::SessionStartError);
break;
case ClientSession::Error::TLSError:
clientError = ClientError(ClientError::TLSError);
break;
case ClientSession::Error::TLSClientCertificateError:
clientError = ClientError(ClientError::ClientCertificateError);
break;
}
}
else if (boost::shared_ptr<SessionStream::Error> actualError = boost::dynamic_pointer_cast<SessionStream::Error>(error)) {
switch(actualError->type) {
case SessionStream::Error::ParseError:
clientError = ClientError(ClientError::XMLError);
break;
case SessionStream::Error::TLSError:
clientError = ClientError(ClientError::TLSError);
break;
case SessionStream::Error::InvalidTLSCertificateError:
clientError = ClientError(ClientError::ClientCertificateLoadError);
break;
case SessionStream::Error::ConnectionReadError:
clientError = ClientError(ClientError::ConnectionReadError);
break;
case SessionStream::Error::ConnectionWriteError:
clientError = ClientError(ClientError::ConnectionWriteError);
break;
}
}
onError(clientError);
}
session_.reset();
}
void Client::handleNeedCredentials() {
session_->sendCredentials(password_);
}
diff --git a/Swiften/Client/ClientError.h b/Swiften/Client/ClientError.h
index d4f280c..55c57fc 100644
--- a/Swiften/Client/ClientError.h
+++ b/Swiften/Client/ClientError.h
@@ -1,30 +1,31 @@
#pragma once
namespace Swift {
class ClientError {
public:
enum Type {
UnknownError,
DomainNameResolveError,
ConnectionError,
ConnectionReadError,
ConnectionWriteError,
XMLError,
AuthenticationFailedError,
+ ServerVerificationFailedError,
NoSupportedAuthMechanismsError,
UnexpectedElementError,
ResourceBindError,
SessionStartError,
TLSError,
ClientCertificateLoadError,
ClientCertificateError
};
ClientError(Type type = UnknownError) : type_(type) {}
Type getType() const { return type_; }
private:
Type type_;
};
}
diff --git a/Swiften/Client/ClientSession.cpp b/Swiften/Client/ClientSession.cpp
index fb80754..960af70 100644
--- a/Swiften/Client/ClientSession.cpp
+++ b/Swiften/Client/ClientSession.cpp
@@ -85,104 +85,108 @@ void ClientSession::handleElement(boost::shared_ptr<Element> element) {
authenticator = new SCRAMSHA1ClientAuthenticator("ClientNonce");
state = WaitingForCredentials;
onNeedCredentials();
}
else if (streamFeatures->hasAuthenticationMechanism("PLAIN")) {
authenticator = new PLAINClientAuthenticator();
state = WaitingForCredentials;
onNeedCredentials();
}
else {
finishSession(Error::NoSupportedAuthMechanismsError);
}
}
else {
// Start the session
stream->setWhitespacePingEnabled(true);
if (streamFeatures->hasSession()) {
needSessionStart = true;
}
if (streamFeatures->hasResourceBind()) {
state = BindingResource;
boost::shared_ptr<ResourceBind> resourceBind(new ResourceBind());
if (!localJID.getResource().isEmpty()) {
resourceBind->setResource(localJID.getResource());
}
stream->writeElement(IQ::createRequest(IQ::Set, JID(), "session-bind", resourceBind));
}
else if (needSessionStart) {
sendSessionStart();
}
else {
state = Initialized;
onInitialized();
}
}
}
else if (AuthChallenge* challenge = dynamic_cast<AuthChallenge*>(element.get())) {
checkState(Authenticating);
assert(authenticator);
if (authenticator->setChallenge(challenge->getValue())) {
stream->writeElement(boost::shared_ptr<AuthResponse>(new AuthResponse(authenticator->getResponse())));
}
else {
finishSession(Error::AuthenticationFailedError);
}
}
- else if (dynamic_cast<AuthSuccess*>(element.get())) {
- // TODO: Check success data with authenticator
+ else if (AuthSuccess* authSuccess = dynamic_cast<AuthSuccess*>(element.get())) {
checkState(Authenticating);
- state = WaitingForStreamStart;
- delete authenticator;
- authenticator = NULL;
- stream->resetXMPPParser();
- sendStreamHeader();
+ if (!authenticator->setChallenge(authSuccess->getValue())) {
+ finishSession(Error::ServerVerificationFailedError);
+ }
+ else {
+ state = WaitingForStreamStart;
+ delete authenticator;
+ authenticator = NULL;
+ stream->resetXMPPParser();
+ sendStreamHeader();
+ }
}
else if (dynamic_cast<AuthFailure*>(element.get())) {
delete authenticator;
authenticator = NULL;
finishSession(Error::AuthenticationFailedError);
}
else if (dynamic_cast<TLSProceed*>(element.get())) {
checkState(WaitingForEncrypt);
state = Encrypting;
stream->addTLSEncryption();
}
else if (dynamic_cast<StartTLSFailure*>(element.get())) {
finishSession(Error::TLSError);
}
else if (IQ* iq = dynamic_cast<IQ*>(element.get())) {
if (state == BindingResource) {
boost::shared_ptr<ResourceBind> resourceBind(iq->getPayload<ResourceBind>());
if (iq->getType() == IQ::Error && iq->getID() == "session-bind") {
finishSession(Error::ResourceBindError);
}
else if (!resourceBind) {
finishSession(Error::UnexpectedElementError);
}
else if (iq->getType() == IQ::Result) {
localJID = resourceBind->getJID();
if (!localJID.isValid()) {
finishSession(Error::ResourceBindError);
}
if (needSessionStart) {
sendSessionStart();
}
else {
state = Initialized;
}
}
else {
finishSession(Error::UnexpectedElementError);
}
}
else if (state == StartingSession) {
if (iq->getType() == IQ::Result) {
state = Initialized;
onInitialized();
}
else if (iq->getType() == IQ::Error) {
finishSession(Error::SessionStartError);
}
else {
diff --git a/Swiften/Client/ClientSession.h b/Swiften/Client/ClientSession.h
index f3bc119..5e5acbc 100644
--- a/Swiften/Client/ClientSession.h
+++ b/Swiften/Client/ClientSession.h
@@ -1,84 +1,85 @@
#pragma once
#include <boost/signal.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include "Swiften/Base/Error.h"
#include "Swiften/Session/SessionStream.h"
#include "Swiften/Session/BasicSessionStream.h"
#include "Swiften/Base/String.h"
#include "Swiften/JID/JID.h"
#include "Swiften/Elements/Element.h"
namespace Swift {
class ClientAuthenticator;
class ClientSession : public boost::enable_shared_from_this<ClientSession> {
public:
enum State {
Initial,
WaitingForStreamStart,
Negotiating,
Compressing,
WaitingForEncrypt,
Encrypting,
WaitingForCredentials,
Authenticating,
BindingResource,
StartingSession,
Initialized,
Finished
};
struct Error : public Swift::Error {
enum Type {
AuthenticationFailedError,
+ ServerVerificationFailedError,
NoSupportedAuthMechanismsError,
UnexpectedElementError,
ResourceBindError,
SessionStartError,
TLSClientCertificateError,
TLSError,
} type;
Error(Type type) : type(type) {}
};
static boost::shared_ptr<ClientSession> create(const JID& jid, boost::shared_ptr<SessionStream> stream) {
return boost::shared_ptr<ClientSession>(new ClientSession(jid, stream));
}
State getState() const {
return state;
}
void start();
void finish();
void sendCredentials(const String& password);
void sendElement(boost::shared_ptr<Element> element);
public:
boost::signal<void ()> onNeedCredentials;
boost::signal<void ()> onInitialized;
boost::signal<void (boost::shared_ptr<Swift::Error>)> onFinished;
boost::signal<void (boost::shared_ptr<Element>)> onElementReceived;
private:
ClientSession(
const JID& jid,
boost::shared_ptr<SessionStream>);
void finishSession(Error::Type error);
void finishSession(boost::shared_ptr<Swift::Error> error);
JID getRemoteJID() const {
return JID("", localJID.getDomain());
}
void sendStreamHeader();
void sendSessionStart();
void handleElement(boost::shared_ptr<Element>);
void handleStreamStart(const ProtocolHeader&);
void handleStreamError(boost::shared_ptr<Swift::Error>);
diff --git a/Swiften/Elements/AuthSuccess.h b/Swiften/Elements/AuthSuccess.h
index da4d798..1db1729 100644
--- a/Swiften/Elements/AuthSuccess.h
+++ b/Swiften/Elements/AuthSuccess.h
@@ -1,10 +1,22 @@
#pragma once
#include "Swiften/Elements/Element.h"
+#include "Swiften/Base/ByteArray.h"
namespace Swift {
class AuthSuccess : public Element {
public:
AuthSuccess() {}
+
+ const ByteArray& getValue() const {
+ return value;
+ }
+
+ void setValue(const ByteArray& value) {
+ this->value = value;
+ }
+
+ private:
+ ByteArray value;
};
}
diff --git a/Swiften/Parser/AuthSuccessParser.cpp b/Swiften/Parser/AuthSuccessParser.cpp
new file mode 100644
index 0000000..2dc2aa2
--- /dev/null
+++ b/Swiften/Parser/AuthSuccessParser.cpp
@@ -0,0 +1,24 @@
+#include "Swiften/Parser/AuthSuccessParser.h"
+#include "Swiften/StringCodecs/Base64.h"
+
+namespace Swift {
+
+AuthSuccessParser::AuthSuccessParser() : GenericElementParser<AuthSuccess>(), depth(0) {
+}
+
+void AuthSuccessParser::handleStartElement(const String&, const String&, const AttributeMap&) {
+ ++depth;
+}
+
+void AuthSuccessParser::handleEndElement(const String&, const String&) {
+ --depth;
+ if (depth == 0) {
+ getElementGeneric()->setValue(Base64::decode(text));
+ }
+}
+
+void AuthSuccessParser::handleCharacterData(const String& text) {
+ this->text += text;
+}
+
+}
diff --git a/Swiften/Parser/AuthSuccessParser.h b/Swiften/Parser/AuthSuccessParser.h
index bb6515d..5d987c5 100644
--- a/Swiften/Parser/AuthSuccessParser.h
+++ b/Swiften/Parser/AuthSuccessParser.h
@@ -1,14 +1,20 @@
-#ifndef SWIFTEN_AUTHSUCCESSPARSER_H
-#define SWIFTEN_AUTHSUCCESSPARSER_H
+#pragma once
#include "Swiften/Parser/GenericElementParser.h"
#include "Swiften/Elements/AuthSuccess.h"
+#include "Swiften/Base/String.h"
namespace Swift {
class AuthSuccessParser : public GenericElementParser<AuthSuccess> {
public:
- AuthSuccessParser() : GenericElementParser<AuthSuccess>() {}
+ AuthSuccessParser();
+
+ virtual void handleStartElement(const String&, const String& ns, const AttributeMap&);
+ virtual void handleEndElement(const String&, const String& ns);
+ virtual void handleCharacterData(const String&);
+
+ private:
+ int depth;
+ String text;
};
}
-
-#endif
diff --git a/Swiften/Parser/SConscript b/Swiften/Parser/SConscript
index d04712c..1e1dcd8 100644
--- a/Swiften/Parser/SConscript
+++ b/Swiften/Parser/SConscript
@@ -1,56 +1,57 @@
Import("swiften_env")
myenv = swiften_env.Clone()
myenv.MergeFlags(swiften_env["BOOST_FLAGS"])
myenv.MergeFlags(swiften_env.get("LIBXML_FLAGS", ""))
myenv.MergeFlags(swiften_env.get("EXPAT_FLAGS", ""))
sources = [
"AuthRequestParser.cpp",
"AuthChallengeParser.cpp",
+ "AuthSuccessParser.cpp",
"AuthResponseParser.cpp",
"CompressParser.cpp",
"ElementParser.cpp",
"IQParser.cpp",
"MessageParser.cpp",
"PayloadParser.cpp",
"PayloadParserFactory.cpp",
"PayloadParserFactoryCollection.cpp",
"PayloadParsers/BodyParser.cpp",
"PayloadParsers/DiscoInfoParser.cpp",
"PayloadParsers/ErrorParser.cpp",
"PayloadParsers/FullPayloadParserFactoryCollection.cpp",
"PayloadParsers/PriorityParser.cpp",
"PayloadParsers/PrivateStorageParser.cpp",
"PayloadParsers/RawXMLPayloadParser.cpp",
"PayloadParsers/ResourceBindParser.cpp",
"PayloadParsers/RosterParser.cpp",
"PayloadParsers/SecurityLabelParser.cpp",
"PayloadParsers/SecurityLabelsCatalogParser.cpp",
"PayloadParsers/SoftwareVersionParser.cpp",
"PayloadParsers/StorageParser.cpp",
"PayloadParsers/StatusParser.cpp",
"PayloadParsers/StatusShowParser.cpp",
"PayloadParsers/VCardParser.cpp",
"PayloadParsers/VCardUpdateParser.cpp",
"PlatformXMLParserFactory.cpp",
"PresenceParser.cpp",
"SerializingParser.cpp",
"StanzaParser.cpp",
"StreamFeaturesParser.cpp",
"XMLParser.cpp",
"XMLParserClient.cpp",
"XMLParserFactory.cpp",
"XMPPParser.cpp",
"XMPPParserClient.cpp",
]
if myenv.get("HAVE_EXPAT", 0) :
myenv.Append(CPPDEFINES = "HAVE_EXPAT")
sources += ["ExpatParser.cpp"]
if myenv.get("HAVE_LIBXML", 0) :
myenv.Append(CPPDEFINES = "HAVE_LIBXML")
sources += ["LibXMLParser.cpp"]
objects = myenv.StaticObject(sources)
swiften_env.Append(SWIFTEN_OBJECTS = [objects])
diff --git a/Swiften/SConscript b/Swiften/SConscript
index 6189b2e..9742768 100644
--- a/Swiften/SConscript
+++ b/Swiften/SConscript
@@ -1,93 +1,94 @@
Import("env")
env["SWIFTEN_FLAGS"] = {
"LIBPATH": [Dir(".")],
"LIBS": ["Swiften"]
}
swiften_env = env.Clone()
swiften_env.MergeFlags(swiften_env["BOOST_FLAGS"])
Export("swiften_env")
# TODO: Move all this to a submodule SConscript
myenv = swiften_env.Clone()
myenv.MergeFlags(myenv["ZLIB_FLAGS"])
myenv.MergeFlags(myenv["OPENSSL_FLAGS"])
sources = [
"Avatars/AvatarFileStorage.cpp",
"Avatars/AvatarManager.cpp",
"Avatars/AvatarStorage.cpp",
"Client/Client.cpp",
"Client/ClientSession.cpp",
"Compress/ZLibCodecompressor.cpp",
"Disco/CapsInfoGenerator.cpp",
"Elements/DiscoInfo.cpp",
"Elements/Element.cpp",
"Elements/IQ.cpp",
"Elements/MUCPayload.cpp",
"Elements/Payload.cpp",
"Elements/RosterPayload.cpp",
"Elements/Stanza.cpp",
"MUC/MUC.cpp",
"MUC/MUCOccupant.cpp",
"MUC/MUCRegistry.cpp",
"Notifier/Notifier.cpp",
"Presence/PresenceOracle.cpp",
"Queries/IQChannel.cpp",
"Queries/IQHandler.cpp",
"Queries/IQRouter.cpp",
"Queries/Request.cpp",
"Queries/Responders/DiscoInfoResponder.cpp",
"Queries/Responders/SoftwareVersionResponder.cpp",
"Roster/ContactRosterItem.cpp",
"Roster/Roster.cpp",
"Roster/XMPPRoster.cpp",
"Serializer/AuthRequestSerializer.cpp",
+ "Serializer/AuthSuccessSerializer.cpp",
"Serializer/AuthChallengeSerializer.cpp",
"Serializer/AuthResponseSerializer.cpp",
"Serializer/CompressRequestSerializer.cpp",
"Serializer/ElementSerializer.cpp",
"Serializer/MessageSerializer.cpp",
"Serializer/PayloadSerializer.cpp",
"Serializer/PayloadSerializerCollection.cpp",
"Serializer/PayloadSerializers/CapsInfoSerializer.cpp",
"Serializer/PayloadSerializers/DiscoInfoSerializer.cpp",
"Serializer/PayloadSerializers/ErrorSerializer.cpp",
"Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp",
"Serializer/PayloadSerializers/MUCPayloadSerializer.cpp",
"Serializer/PayloadSerializers/ResourceBindSerializer.cpp",
"Serializer/PayloadSerializers/RosterSerializer.cpp",
"Serializer/PayloadSerializers/SecurityLabelSerializer.cpp",
"Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.cpp",
"Serializer/PayloadSerializers/SoftwareVersionSerializer.cpp",
"Serializer/PayloadSerializers/VCardSerializer.cpp",
"Serializer/PayloadSerializers/VCardUpdateSerializer.cpp",
"Serializer/PayloadSerializers/StorageSerializer.cpp",
"Serializer/PayloadSerializers/PrivateStorageSerializer.cpp",
"Serializer/PresenceSerializer.cpp",
"Serializer/StanzaSerializer.cpp",
"Serializer/StreamFeaturesSerializer.cpp",
"Serializer/XML/XMLElement.cpp",
"Serializer/XML/XMLNode.cpp",
"Serializer/XMPPSerializer.cpp",
"Server/ServerFromClientSession.cpp",
"Server/ServerSession.cpp",
"Server/ServerStanzaRouter.cpp",
"Server/SimpleUserRegistry.cpp",
"Server/UserRegistry.cpp",
"Session/Session.cpp",
"Session/SessionStream.cpp",
"Session/BasicSessionStream.cpp",
"StringCodecs/Base64.cpp",
"StringCodecs/SHA1.cpp",
"StringCodecs/HMACSHA1.cpp",
"StringCodecs/PBKDF2.cpp",
]
# "Notifier/GrowlNotifier.cpp",
if myenv.get("HAVE_OPENSSL", 0) :
sources += ["TLS/OpenSSL/OpenSSLContext.cpp"]
SConscript(dirs = [
"Base",
"StringPrep",
diff --git a/Swiften/Serializer/AuthSuccessSerializer.cpp b/Swiften/Serializer/AuthSuccessSerializer.cpp
new file mode 100644
index 0000000..6d7f195
--- /dev/null
+++ b/Swiften/Serializer/AuthSuccessSerializer.cpp
@@ -0,0 +1,17 @@
+#include "Swiften/Serializer/AuthSuccessSerializer.h"
+
+#include "Swiften/Elements/AuthSuccess.h"
+#include "Swiften/StringCodecs/Base64.h"
+
+namespace Swift {
+
+AuthSuccessSerializer::AuthSuccessSerializer() {
+}
+
+String AuthSuccessSerializer::serialize(boost::shared_ptr<Element> element) const {
+ boost::shared_ptr<AuthSuccess> authRequest(boost::dynamic_pointer_cast<AuthSuccess>(element));
+ String value = (authRequest->getValue().isEmpty() ? "=" : Base64::encode(authRequest->getValue()));
+ return "<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" + value + "</challenge>";
+}
+
+}
diff --git a/Swiften/Serializer/AuthSuccessSerializer.h b/Swiften/Serializer/AuthSuccessSerializer.h
index 1fdc3ab..6ced772 100644
--- a/Swiften/Serializer/AuthSuccessSerializer.h
+++ b/Swiften/Serializer/AuthSuccessSerializer.h
@@ -1,22 +1,15 @@
-#ifndef SWIFTEN_AuthSuccessSerializer_H
-#define SWIFTEN_AuthSuccessSerializer_H
+#pragma once
#include <boost/shared_ptr.hpp>
#include "Swiften/Elements/AuthSuccess.h"
#include "Swiften/Serializer/GenericElementSerializer.h"
-#include "Swiften/Serializer/XML/XMLElement.h"
namespace Swift {
class AuthSuccessSerializer : public GenericElementSerializer<AuthSuccess> {
public:
- AuthSuccessSerializer() : GenericElementSerializer<AuthSuccess>() {
- }
+ AuthSuccessSerializer();
- virtual String serialize(boost::shared_ptr<Element>) const {
- return XMLElement("success", "urn:ietf:params:xml:ns:xmpp-sasl").serialize();
- }
+ virtual String serialize(boost::shared_ptr<Element> element) const;
};
}
-
-#endif