diff options
Diffstat (limited to 'src/Server')
-rw-r--r-- | src/Server/ConnectionManager.cpp | 9 | ||||
-rw-r--r-- | src/Server/ConnectionManager.h | 4 | ||||
-rw-r--r-- | src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp | 2 | ||||
-rw-r--r-- | src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp | 6 | ||||
-rw-r--r-- | src/Server/RequestHandlers/UserRequestHandlerGroup.cpp | 36 |
5 files changed, 23 insertions, 34 deletions
diff --git a/src/Server/ConnectionManager.cpp b/src/Server/ConnectionManager.cpp index cb7376c..4867464 100644 --- a/src/Server/ConnectionManager.cpp +++ b/src/Server/ConnectionManager.cpp @@ -324,14 +324,5 @@ std::vector<Common::HostInfo> ConnectionManager::getDaemonList() const { return ret; } -bool ConnectionManager::isAuthenticated(Common::Connection *con) const { - ServerConnection *connection = dynamic_cast<ServerConnection*>(con); - - if(!connection) - throw Core::Exception(Core::Exception::INVALID_INPUT); - - return connection->isAuthenticated(); -} - } } diff --git a/src/Server/ConnectionManager.h b/src/Server/ConnectionManager.h index 057e73e..099072c 100644 --- a/src/Server/ConnectionManager.h +++ b/src/Server/ConnectionManager.h @@ -97,7 +97,7 @@ class MAD_SERVER_EXPORT ConnectionManager : public Core::Configurable, private b hostInfo = info; } - bool isAuthenticated() const { + virtual bool isAuthenticated() const { return (authContext.get() != 0 && authContext->isAuthenticated()); } @@ -145,8 +145,6 @@ class MAD_SERVER_EXPORT ConnectionManager : public Core::Configurable, private b boost::shared_ptr<const Common::AuthContext> authenticateConnection(Common::Connection *con, const std::string &method, const std::string &subMethod, const std::string &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response); - bool isAuthenticated(Common::Connection *con) const; - std::vector<Common::HostInfo> getDaemonList() const; }; diff --git a/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp b/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp index 2a091e6..2171deb 100644 --- a/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp @@ -74,7 +74,7 @@ void ConnectionRequestHandlerGroup::handleAuthRequest(boost::shared_ptr<const Co void ConnectionRequestHandlerGroup::handleDaemonListRequest(boost::shared_ptr<const Common::XmlPacket> /*packet*/, Common::XmlPacket *ret, Common::Connection *connection) { - if(!application->getConnectionManager()->isAuthenticated(connection)) + if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); ret->setType("OK"); diff --git a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp index ee79ff2..35e167e 100644 --- a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp @@ -44,12 +44,12 @@ void DaemonRequestHandlerGroup::DaemonRequestHandler::handlePacket(boost::shared return; } - ConnectionManager *connectionManager = dynamic_cast<Application&>(*getApplication()).getConnectionManager(); - - if(!connectionManager->isAuthenticated(getConnection())) + if(!getConnection()->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); try { + ConnectionManager *connectionManager = dynamic_cast<Application&>(*getApplication()).getConnectionManager(); + boost::shared_ptr<Common::Connection> daemonCon = connectionManager->getDaemonConnection(packet->get<const std::string&>("daemon")); boost::shared_ptr<Common::Request> request; diff --git a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp index ea6f6c1..d5f97a9 100644 --- a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp @@ -31,7 +31,7 @@ namespace RequestHandlers { void UserRequestHandlerGroup::handleUserListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection) { - if(!application->getConnectionManager()->isAuthenticated(connection)) + if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); @@ -67,7 +67,7 @@ void UserRequestHandlerGroup::handleUserListRequest(boost::shared_ptr<const Comm void UserRequestHandlerGroup::handleUserInfoRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection) { - if(!application->getConnectionManager()->isAuthenticated(connection)) + if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); @@ -103,7 +103,7 @@ void UserRequestHandlerGroup::handleUserInfoRequest(boost::shared_ptr<const Comm void UserRequestHandlerGroup::handleUserGroupListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection) { - if(!application->getConnectionManager()->isAuthenticated(connection)) + if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); @@ -136,7 +136,7 @@ void UserRequestHandlerGroup::handleUserGroupListRequest(boost::shared_ptr<const void UserRequestHandlerGroup::handleGroupListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection) { - if(!application->getConnectionManager()->isAuthenticated(connection)) + if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); @@ -170,7 +170,7 @@ void UserRequestHandlerGroup::handleGroupListRequest(boost::shared_ptr<const Com void UserRequestHandlerGroup::handleGroupInfoRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection) { - if(!application->getConnectionManager()->isAuthenticated(connection)) + if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); @@ -204,7 +204,7 @@ void UserRequestHandlerGroup::handleGroupInfoRequest(boost::shared_ptr<const Com void UserRequestHandlerGroup::handleGroupUserListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection) { - if(!application->getConnectionManager()->isAuthenticated(connection)) + if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); @@ -235,7 +235,7 @@ void UserRequestHandlerGroup::handleGroupUserListRequest(boost::shared_ptr<const void UserRequestHandlerGroup::handleFullUserGroupListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection) { - if(!application->getConnectionManager()->isAuthenticated(connection)) + if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); @@ -270,7 +270,7 @@ void UserRequestHandlerGroup::handleFullUserGroupListRequest(boost::shared_ptr<c void UserRequestHandlerGroup::handleUserInfoCheckRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection) { - if(!application->getConnectionManager()->isAuthenticated(connection)) + if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); Common::UserInfo userInfo(packet->get<unsigned long>("uid"), packet->get<const std::string&>("username")); @@ -284,7 +284,7 @@ void UserRequestHandlerGroup::handleUserInfoCheckRequest(boost::shared_ptr<const void UserRequestHandlerGroup::handleUserAddRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection) { - if(!application->getConnectionManager()->isAuthenticated(connection)) + if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); Common::UserInfo userInfo(packet->get<unsigned long>("uid"), packet->get<const std::string&>("username")); @@ -298,7 +298,7 @@ void UserRequestHandlerGroup::handleUserAddRequest(boost::shared_ptr<const Commo void UserRequestHandlerGroup::handleUserUpdateRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection) { - if(!application->getConnectionManager()->isAuthenticated(connection)) + if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); Common::UserInfo userInfo(packet->get<unsigned long>("uid"), packet->get<const std::string&>("username")); @@ -312,7 +312,7 @@ void UserRequestHandlerGroup::handleUserUpdateRequest(boost::shared_ptr<const Co void UserRequestHandlerGroup::handleUserDeleteRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection) { - if(!application->getConnectionManager()->isAuthenticated(connection)) + if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); application->getUserManager()->deleteUser(packet->get<unsigned long>("uid")); @@ -323,7 +323,7 @@ void UserRequestHandlerGroup::handleUserDeleteRequest(boost::shared_ptr<const Co void UserRequestHandlerGroup::handleGroupInfoCheckRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection) { - if(!application->getConnectionManager()->isAuthenticated(connection)) + if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); application->getUserManager()->checkGroupInfo(Common::GroupInfo(packet->get<unsigned long>("gid"), packet->get<const std::string&>("name"))); @@ -333,7 +333,7 @@ void UserRequestHandlerGroup::handleGroupInfoCheckRequest(boost::shared_ptr<cons void UserRequestHandlerGroup::handleGroupAddRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection) { - if(!application->getConnectionManager()->isAuthenticated(connection)) + if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); application->getUserManager()->addGroup(Common::GroupInfo(packet->get<unsigned long>("gid"), packet->get<const std::string&>("name"))); @@ -343,7 +343,7 @@ void UserRequestHandlerGroup::handleGroupAddRequest(boost::shared_ptr<const Comm void UserRequestHandlerGroup::handleGroupUpdateRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection) { - if(!application->getConnectionManager()->isAuthenticated(connection)) + if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); application->getUserManager()->updateGroup(packet->get<unsigned long>("origGid"), @@ -354,7 +354,7 @@ void UserRequestHandlerGroup::handleGroupUpdateRequest(boost::shared_ptr<const C void UserRequestHandlerGroup::handleGroupDeleteRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection) { - if(!application->getConnectionManager()->isAuthenticated(connection)) + if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); application->getUserManager()->deleteGroup(packet->get<unsigned long>("gid")); @@ -365,7 +365,7 @@ void UserRequestHandlerGroup::handleGroupDeleteRequest(boost::shared_ptr<const C void UserRequestHandlerGroup::handleAddUserToGroupRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection) { - if(!application->getConnectionManager()->isAuthenticated(connection)) + if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); application->getUserManager()->addUserToGroup(packet->get<unsigned long>("uid"), packet->get<unsigned long>("gid")); @@ -375,7 +375,7 @@ void UserRequestHandlerGroup::handleAddUserToGroupRequest(boost::shared_ptr<cons void UserRequestHandlerGroup::handleDeleteUserFromGroupRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection) { - if(!application->getConnectionManager()->isAuthenticated(connection)) + if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); application->getUserManager()->deleteUserFromGroup(packet->get<unsigned long>("uid"), packet->get<unsigned long>("gid")); @@ -385,7 +385,7 @@ void UserRequestHandlerGroup::handleDeleteUserFromGroupRequest(boost::shared_ptr void UserRequestHandlerGroup::handlePasswordSetRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection) { - if(!application->getConnectionManager()->isAuthenticated(connection)) + if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); application->getUserManager()->setPassword(packet->get<unsigned long>("uid"), packet->get<const std::string&>("password")); |