diff options
| author | Remko Tronçon <git@el-tramo.be> | 2011-10-07 18:09:30 (GMT) |
|---|---|---|
| committer | Remko Tronçon <git@el-tramo.be> | 2011-10-07 18:09:30 (GMT) |
| commit | 6b98253a4127c975bd59b6a49ddb203337a8c32b (patch) | |
| tree | 546a24e1687f50e403215152d65e21971568f166 /Limber/Server/ServerFromClientSession.cpp | |
| parent | b2f58c4f3eb93e3a32062670df5eb6682aed273a (diff) | |
| download | swift-contrib-6b98253a4127c975bd59b6a49ddb203337a8c32b.zip swift-contrib-6b98253a4127c975bd59b6a49ddb203337a8c32b.tar.bz2 | |
Hoist XML parser factory creation out of Swiften.
Diffstat (limited to 'Limber/Server/ServerFromClientSession.cpp')
| -rw-r--r-- | Limber/Server/ServerFromClientSession.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Limber/Server/ServerFromClientSession.cpp b/Limber/Server/ServerFromClientSession.cpp index 3a37c65..fd361b7 100644 --- a/Limber/Server/ServerFromClientSession.cpp +++ b/Limber/Server/ServerFromClientSession.cpp @@ -1,67 +1,68 @@ /* * Copyright (c) 2010 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #include "Limber/Server/ServerFromClientSession.h" #include <boost/bind.hpp> #include "Swiften/Elements/ProtocolHeader.h" #include "Limber/Server/UserRegistry.h" #include "Swiften/Network/Connection.h" #include "Swiften/StreamStack/XMPPLayer.h" #include "Swiften/Elements/StreamFeatures.h" #include "Swiften/Elements/ResourceBind.h" #include "Swiften/Elements/StartSession.h" #include "Swiften/Elements/IQ.h" #include "Swiften/Elements/AuthSuccess.h" #include "Swiften/Elements/AuthFailure.h" #include "Swiften/Elements/AuthRequest.h" #include "Swiften/SASL/PLAINMessage.h" namespace Swift { ServerFromClientSession::ServerFromClientSession( const std::string& id, boost::shared_ptr<Connection> connection, PayloadParserFactoryCollection* payloadParserFactories, PayloadSerializerCollection* payloadSerializers, + XMLParserFactory* xmlParserFactory, UserRegistry* userRegistry) : - Session(connection, payloadParserFactories, payloadSerializers), + Session(connection, payloadParserFactories, payloadSerializers, xmlParserFactory), id_(id), userRegistry_(userRegistry), authenticated_(false), initialized(false), allowSASLEXTERNAL(false) { } void ServerFromClientSession::handleElement(boost::shared_ptr<Element> element) { if (isInitialized()) { onElementReceived(element); } else { if (AuthRequest* authRequest = dynamic_cast<AuthRequest*>(element.get())) { if (authRequest->getMechanism() == "PLAIN" || (allowSASLEXTERNAL && authRequest->getMechanism() == "EXTERNAL")) { if (authRequest->getMechanism() == "EXTERNAL") { getXMPPLayer()->writeElement(boost::shared_ptr<AuthSuccess>(new AuthSuccess())); authenticated_ = true; getXMPPLayer()->resetParser(); } else { PLAINMessage plainMessage(authRequest->getMessage() ? *authRequest->getMessage() : createSafeByteArray("")); if (userRegistry_->isValidUserPassword(JID(plainMessage.getAuthenticationID(), getLocalJID().getDomain()), plainMessage.getPassword())) { getXMPPLayer()->writeElement(boost::shared_ptr<AuthSuccess>(new AuthSuccess())); user_ = plainMessage.getAuthenticationID(); authenticated_ = true; getXMPPLayer()->resetParser(); } else { getXMPPLayer()->writeElement(boost::shared_ptr<AuthFailure>(new AuthFailure)); finishSession(AuthenticationFailedError); } } } else { |
Swift