Changeset - 81f72c8e5521
[Not reviewed]
Merge
0 5 0
Jan Kaluza - 13 years ago 2012-04-09 07:17:32
hanzz.k@gmail.com
Merge pull request #6 from askovpen/master

#258
4 files changed with 23 insertions and 14 deletions:
0 comments (0 inline, 0 general)
src/admininterface.cpp
Show inline comments
 
@@ -59,11 +59,13 @@ void AdminInterface::handleMessageReceived(Swift::Message::ref message) {
 
	if (!message->getTo().getNode().empty())
 
		return;
 

	
 
	if (message->getFrom().toBare().toString() != CONFIG_STRING(m_component->getConfig(), "service.admin_jid")) {
 
		LOG4CXX_WARN(logger, "Message not from admin user, but from " << message->getFrom().toBare().toString());
 
		return;
 
	std::vector<std::string> const &x = CONFIG_VECTOR(m_component->getConfig(),"service.admin_jid");
 
	if (std::find(x.begin(), x.end(), message->getFrom().toBare().toString()) == x.end()) {
 
	    LOG4CXX_WARN(logger, "Message not from admin user, but from " << message->getFrom().toBare().toString());
 
	    return;
 
	
 
	}
 

	
 
	
 
	// Ignore empty messages
 
	if (message->getBody().empty()) {
 
		return;
src/config.cpp
Show inline comments
 
@@ -77,7 +77,7 @@ bool Config::load(std::istream &ifs, boost::program_options::options_description
 
		("service.backend_port", value<std::string>()->default_value("0"), "Port to bind backend server to")
 
		("service.cert", value<std::string>()->default_value(""), "PKCS#12 Certificate.")
 
		("service.cert_password", value<std::string>()->default_value(""), "PKCS#12 Certificate password.")
 
		("service.admin_jid", value<std::string>()->default_value(""), "Administrator jid.")
 
		("service.admin_jid", value<std::vector<std::string> >()->multitoken(), "Administrator jid.")
 
		("service.admin_password", value<std::string>()->default_value(""), "Administrator password.")
 
		("service.reuse_old_backends", value<bool>()->default_value(true), "True if Spectrum should use old backends which were full in the past.")
 
		("service.idle_reconnect_time", value<int>()->default_value(0), "Time in seconds after which idle users are reconnected to let their backend die.")
src/usermanager.cpp
Show inline comments
 
@@ -150,7 +150,10 @@ void UserManager::handlePresence(Swift::Presence::ref presence) {
 
	// Create user class if it's not there
 
	if (!user) {
 
		// Admin user is not legacy network user, so do not create User class instance for him
 
		if (m_component->inServerMode() && CONFIG_STRING(m_component->getConfig(), "service.admin_jid") == presence->getFrom().toBare().toString()) {
 
		if (m_component->inServerMode()) {
 
		    std::vector<std::string> const &x = CONFIG_VECTOR(m_component->getConfig(),"service.admin_jid");
 
		    if (std::find(x.begin(), x.end(), presence->getFrom().toBare().toString()) != x.end()) {
 
		
 
			// Send admin contact to the user.
 
			Swift::RosterPayload::ref payload = Swift::RosterPayload::ref(new Swift::RosterPayload());
 
			Swift::RosterItemPayload item;
 
@@ -167,6 +170,7 @@ void UserManager::handlePresence(Swift::Presence::ref presence) {
 
			response->setFrom(m_component->getJID());
 
			m_component->getStanzaChannel()->sendPresence(response);
 
			return;
 
		    }
 
		}
 

	
 
		// No user and unavailable presence -> answer with unavailable
src/userregistry.cpp
Show inline comments
 
@@ -38,16 +38,19 @@ UserRegistry::UserRegistry(Config *cfg, Swift::NetworkFactories *factories) {
 
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() && user.toBare().toString() == CONFIG_STRING(config, "service.admin_jid")) {
 
		if (Swift::safeByteArrayToString(password) == CONFIG_STRING(config, "service.admin_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 {
 
		    }
 
		    else {
 
			session->handlePasswordInvalid();
 
		}
 
		return;
 
	}
 

	
 
		    }
 
		    return;
 
	    }
 
//	}
 
	std::string key = user.toBare().toString();
 

	
 
	// Users try to connect twice
0 comments (0 inline, 0 general)