Changeset - 996a48005b0d
[Not reviewed]
0 2 0
HanzZ - 14 years ago 2012-04-09 09:27:26
hanzz.k@gmail.com
more fixes
2 files changed with 11 insertions and 14 deletions:
0 comments (0 inline, 0 general)
spectrum_manager/src/main.cpp
Show inline comments
 
@@ -301,25 +301,25 @@ static void ask_local_servers(ManagerConfig *config, Swift::BoostNetworkFactorie
 
			std::cerr << "Config directory " << CONFIG_STRING(config, "service.config_directory") << " does not exist\n";
 
			exit(7);
 
		}
 
 
		directory_iterator end_itr;
 
		for (directory_iterator itr(p); itr != end_itr; ++itr) {
 
			if (is_regular(itr->path()) && extension(itr->path()) == ".cfg") {
 
				Config cfg;
 
				if (cfg.load(itr->path().string()) == false) {
 
					std::cerr << "Can't load config file " << itr->path().string() << ". Skipping...\n";
 
				}
 
 
				if (CONFIG_STRING(&cfg, "service.admin_jid").empty() || CONFIG_STRING(&cfg, "service.admin_password").empty()) {
 
				if (CONFIG_VECTOR(&cfg, "service.admin_jid").empty() || CONFIG_STRING(&cfg, "service.admin_password").empty()) {
 
					std::cerr << itr->path().string() << ": service.admin_jid or service.admin_password empty. This server can't be queried over XMPP.\n";
 
				}
 
 
				finished++;
 
				Swift::Client *client = new Swift::Client(CONFIG_VECTOR(&cfg, "service.admin_jid")[0], CONFIG_STRING(&cfg, "service.admin_password"), &networkFactories);
 
				client->setAlwaysTrustCertificates();
 
				client->onConnected.connect(boost::bind(&handleConnected, client, CONFIG_STRING(&cfg, "service.jid")));
 
				client->onDisconnected.connect(bind(&handleDisconnected, client, _1, CONFIG_STRING(&cfg, "service.jid")));
 
				client->onMessageReceived.connect(bind(&handleMessageReceived, client, _1, CONFIG_STRING(&cfg, "service.jid")));
 
				Swift::ClientOptions opt;
 
				opt.allowPLAINWithoutTLS = true;
 
				client->connect(opt);
src/userregistry.cpp
Show inline comments
 
@@ -29,37 +29,34 @@ namespace Transport {
 

	
 
DEFINE_LOGGER(logger, "UserRegistry");
 

	
 
UserRegistry::UserRegistry(Config *cfg, Swift::NetworkFactories *factories) {
 
	config = cfg;
 
	m_removeTimer = factories->getTimerFactory()->createTimer(1);
 
	m_inRemoveLater = false;
 
}
 

	
 
UserRegistry::~UserRegistry() { m_removeTimer->stop(); }
 

	
 
void UserRegistry::isValidUserPassword(const Swift::JID& user, Swift::ServerFromClientSession *session, const Swift::SafeByteArray& password) {
 

	
 
//	if (!CONFIG_STRING(config, "service.admin_jid").empty() ) {
 
		std::vector<std::string> const &x = CONFIG_VECTOR(config,"service.admin_jid");
 
		if (std::find(x.begin(), x.end(), user.toBare().toString()) != x.end()) {
 
		    if (Swift::safeByteArrayToString(password) == CONFIG_STRING(config, "service.admin_password")) {
 
			session->handlePasswordValid();
 
		    }
 
		    else {
 
			session->handlePasswordInvalid();
 
		    }
 
		    return;
 
	    }
 
//	}
 
	std::vector<std::string> const &x = CONFIG_VECTOR(config,"service.admin_jid");
 
	if (std::find(x.begin(), x.end(), user.toBare().toString()) != x.end()) {
 
		if (Swift::safeByteArrayToString(password) == CONFIG_STRING(config, "service.admin_password")) {
 
		session->handlePasswordValid();
 
		}
 
		else {
 
		session->handlePasswordInvalid();
 
		}
 
		return;
 
	}
 
	std::string key = user.toBare().toString();
 

	
 
	// Users try to connect twice
 
	if (users.find(key) != users.end()) {
 
		// Kill the first session
 
		LOG4CXX_INFO(logger, key << ": Removing previous session and making this one active");
 
		Swift::ServerFromClientSession *tmp = users[key].session;
 
		users[key].session = session;
 
		tmp->handlePasswordInvalid();
 
	}
 

	
 
	LOG4CXX_INFO(logger, key << ": Connecting this user to find if password is valid");
0 comments (0 inline, 0 general)