diff options
-rw-r--r-- | src/Client/InformationManager.cpp | 3 | ||||
-rw-r--r-- | src/Common/ClientConnection.h | 5 | ||||
-rw-r--r-- | src/Common/Connection.h | 3 | ||||
-rw-r--r-- | src/Common/RequestHandlers/FSInfoRequestHandler.cpp | 3 | ||||
-rw-r--r-- | src/Common/RequestHandlers/SimpleRequestHandler.cpp | 2 | ||||
-rw-r--r-- | src/Common/RequestHandlers/SimpleRequestHandlerGroup.cpp | 2 | ||||
-rw-r--r-- | src/Common/RequestHandlers/StatusRequestHandler.cpp | 3 | ||||
-rw-r--r-- | src/Daemon/RequestHandlers/CommandRequestHandler.cpp | 3 | ||||
-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 |
13 files changed, 39 insertions, 42 deletions
diff --git a/src/Client/InformationManager.cpp b/src/Client/InformationManager.cpp index 108a2a5..6ac2647 100644 --- a/src/Client/InformationManager.cpp +++ b/src/Client/InformationManager.cpp @@ -28,7 +28,8 @@ namespace Mad { namespace Client { void InformationManager::DaemonStateUpdateRequestHandler::handleRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret) { - // TODO Require authentication + if(!getConnection()->isAuthenticated()) + throw(Core::Exception(Core::Exception::PERMISSION)); InformationManager *informationManager = dynamic_cast<Application&>(*getApplication()).getInformationManager(); diff --git a/src/Common/ClientConnection.h b/src/Common/ClientConnection.h index a02c461..7bdceba 100644 --- a/src/Common/ClientConnection.h +++ b/src/Common/ClientConnection.h @@ -54,6 +54,11 @@ class MAD_COMMON_EXPORT ClientConnection : public Connection { void waitWhileConnected() const; virtual bool disconnect(); + + virtual bool isAuthenticated() const { + return true; + } + //virtual void* getCertificate(size_t *size) const; //virtual void* getPeerCertificate(size_t *size) const; }; diff --git a/src/Common/Connection.h b/src/Common/Connection.h index bcf6c44..2a04de0 100644 --- a/src/Common/Connection.h +++ b/src/Common/Connection.h @@ -62,6 +62,9 @@ class MAD_COMMON_EXPORT Connection : private boost::noncopyable { virtual bool disconnect() = 0; + + virtual bool isAuthenticated() const = 0; + //virtual void* getCertificate(size_t *size) const = 0; //virtual void* getPeerCertificate(size_t *size) const = 0; }; diff --git a/src/Common/RequestHandlers/FSInfoRequestHandler.cpp b/src/Common/RequestHandlers/FSInfoRequestHandler.cpp index 8af1ed3..a416af4 100644 --- a/src/Common/RequestHandlers/FSInfoRequestHandler.cpp +++ b/src/Common/RequestHandlers/FSInfoRequestHandler.cpp @@ -25,7 +25,8 @@ namespace Common { namespace RequestHandlers { void FSInfoRequestHandler::handleRequest(boost::shared_ptr<const Common::XmlPacket> /*packet*/, Common::XmlPacket *ret) { - // TODO Require authentication + if(!getConnection()->isAuthenticated()) + throw(Core::Exception(Core::Exception::PERMISSION)); std::vector<SystemManager::FSInfo> fsInfo; getApplication()->getSystemManager()->getFSInfo(&fsInfo); diff --git a/src/Common/RequestHandlers/SimpleRequestHandler.cpp b/src/Common/RequestHandlers/SimpleRequestHandler.cpp index 84258a6..789db9e 100644 --- a/src/Common/RequestHandlers/SimpleRequestHandler.cpp +++ b/src/Common/RequestHandlers/SimpleRequestHandler.cpp @@ -39,8 +39,6 @@ void SimpleRequestHandler::handlePacket(boost::shared_ptr<const XmlPacket> packe return; } - // TODO Require authentication - XmlPacket ret; try { diff --git a/src/Common/RequestHandlers/SimpleRequestHandlerGroup.cpp b/src/Common/RequestHandlers/SimpleRequestHandlerGroup.cpp index f084ac1..261950d 100644 --- a/src/Common/RequestHandlers/SimpleRequestHandlerGroup.cpp +++ b/src/Common/RequestHandlers/SimpleRequestHandlerGroup.cpp @@ -40,8 +40,6 @@ void SimpleRequestHandlerGroup::GroupRequestHandler::handlePacket(boost::shared_ return; } - // TODO Require authentication - XmlPacket ret; try { diff --git a/src/Common/RequestHandlers/StatusRequestHandler.cpp b/src/Common/RequestHandlers/StatusRequestHandler.cpp index 18b8868..e5d87da 100644 --- a/src/Common/RequestHandlers/StatusRequestHandler.cpp +++ b/src/Common/RequestHandlers/StatusRequestHandler.cpp @@ -25,7 +25,8 @@ namespace Common { namespace RequestHandlers { void StatusRequestHandler::handleRequest(boost::shared_ptr<const Common::XmlPacket> /*packet*/, Common::XmlPacket *ret) { - // TODO Require authentication + if(!getConnection()->isAuthenticated()) + throw(Core::Exception(Core::Exception::PERMISSION)); ret->setType("OK"); diff --git a/src/Daemon/RequestHandlers/CommandRequestHandler.cpp b/src/Daemon/RequestHandlers/CommandRequestHandler.cpp index 9be8a5b..6c245f9 100644 --- a/src/Daemon/RequestHandlers/CommandRequestHandler.cpp +++ b/src/Daemon/RequestHandlers/CommandRequestHandler.cpp @@ -25,7 +25,8 @@ namespace Daemon { namespace RequestHandlers { void CommandRequestHandler::handleRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret) { - // TODO Require authentication + if(!getConnection()->isAuthenticated()) + throw(Core::Exception(Core::Exception::PERMISSION)); std::string command = packet->get<const std::string&>("command"); 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")); |