diff options
Diffstat (limited to 'src/Server')
-rw-r--r-- | src/Server/ConnectionManager.cpp | 8 | ||||
-rw-r--r-- | src/Server/ConnectionManager.h | 6 | ||||
-rw-r--r-- | src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp | 14 |
3 files changed, 19 insertions, 9 deletions
diff --git a/src/Server/ConnectionManager.cpp b/src/Server/ConnectionManager.cpp index c49e7e8..b9490bc 100644 --- a/src/Server/ConnectionManager.cpp +++ b/src/Server/ConnectionManager.cpp @@ -58,11 +58,11 @@ bool ConnectionManager::ServerConnection::disconnect() { } boost::shared_ptr<const Common::AuthContext> ConnectionManager::ServerConnection::authenticate(const std::string &method, - const std::string &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response) { + const std::string &subMethod, const std::string &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response) { if(!isIdentified()) type = CLIENT; - authContext = application->getAuthManager()->authenticate(method, user, data, response, authContext); + authContext = application->getAuthManager()->authenticate(method, subMethod, user, data, response, authContext); return authContext; } @@ -294,7 +294,7 @@ void ConnectionManager::identifyDaemonConnection(Common::Connection *con, const } boost::shared_ptr<const Common::AuthContext> ConnectionManager::authenticateConnection(Common::Connection *con, const std::string &method, - const std::string &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response) { + const std::string &subMethod, const std::string &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response) { // TODO Logging ServerConnection *connection = dynamic_cast<ServerConnection*>(con); @@ -305,7 +305,7 @@ boost::shared_ptr<const Common::AuthContext> ConnectionManager::authenticateConn if(!connection->isIdentified()) connection->identify(); - return connection->authenticate(method, user, data, response); + return connection->authenticate(method, subMethod, user, data, response); } std::vector<Common::HostInfo> ConnectionManager::getDaemonList() const { diff --git a/src/Server/ConnectionManager.h b/src/Server/ConnectionManager.h index 067ce28..9638f38 100644 --- a/src/Server/ConnectionManager.h +++ b/src/Server/ConnectionManager.h @@ -101,8 +101,8 @@ class MAD_SERVER_EXPORT ConnectionManager : public Core::Configurable, private b return (authContext.get() != 0 && authContext->isAuthenticated()); } - boost::shared_ptr<const Common::AuthContext> authenticate(const std::string &method, const std::string &user, - const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response); + boost::shared_ptr<const Common::AuthContext> authenticate(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); }; friend class Application; @@ -142,7 +142,7 @@ class MAD_SERVER_EXPORT ConnectionManager : public Core::Configurable, private b void identifyDaemonConnection(Common::Connection *con, const std::string &name) throw (Core::Exception); - boost::shared_ptr<const Common::AuthContext> authenticateConnection(Common::Connection *con, const std::string &method, + 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; diff --git a/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp b/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp index 37e2e79..7607171 100644 --- a/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp @@ -43,6 +43,15 @@ void ConnectionRequestHandlerGroup::handleAuthMethodRequest(boost::shared_ptr<co Common::XmlPacket::List::iterator entry = list->addEntry(); entry->set("name", *method); + Common::XmlPacket::List *subList = entry->createList("subMethods"); + + const std::vector<std::string> &subMethods = application->getAuthManager()->getSubMethods(*method); + + for(std::vector<std::string>::const_iterator subMethod = subMethods.begin(); subMethod != subMethods.end(); ++subMethod) { + Common::XmlPacket::List::iterator subEntry = subList->addEntry(); + + subEntry->set("name", *subMethod); + } } } @@ -50,8 +59,9 @@ void ConnectionRequestHandlerGroup::handleAuthRequest(boost::shared_ptr<const Co std::vector<boost::uint8_t> response; boost::shared_ptr<const Common::AuthContext> authContext = application->getConnectionManager()->authenticateConnection(connection, - packet->get<const std::string&>("method"), packet->get<const std::string&>("user"), - packet->get<const std::vector<boost::uint8_t>&>("data"), response); + packet->get<const std::string&>("method"), packet->get<const std::string&>("subMethod"), + packet->get<const std::string&>("user"), packet->get<const std::vector<boost::uint8_t>&>("data"), + response); if(!response.empty()) ret->set("data", response); |