diff options
Diffstat (limited to 'src/Server')
-rw-r--r-- | src/Server/Application.cpp | 7 | ||||
-rw-r--r-- | src/Server/Application.h | 6 | ||||
-rw-r--r-- | src/Server/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/Server/RequestHandlers/UserRequestHandlerGroup.cpp | 2 | ||||
-rw-r--r-- | src/Server/UserBackend.h | 100 | ||||
-rw-r--r-- | src/Server/UserManager.cpp | 195 | ||||
-rw-r--r-- | src/Server/UserManager.h | 79 |
7 files changed, 2 insertions, 389 deletions
diff --git a/src/Server/Application.cpp b/src/Server/Application.cpp index 3414e53..dc9fa5f 100644 --- a/src/Server/Application.cpp +++ b/src/Server/Application.cpp @@ -19,18 +19,13 @@ #include "Application.h" #include "ConnectionManager.h" -#include "UserManager.h" namespace Mad { namespace Server { -Application::Application() : Common::Application(true), connectionManager(new ConnectionManager(this)), -userManager(new UserManager) { - -} +Application::Application() : Common::Application(true), connectionManager(new ConnectionManager(this)) {} Application::~Application() { - delete userManager; delete connectionManager; } diff --git a/src/Server/Application.h b/src/Server/Application.h index b62893b..600458f 100644 --- a/src/Server/Application.h +++ b/src/Server/Application.h @@ -26,12 +26,10 @@ namespace Mad { namespace Server { class ConnectionManager; -class UserManager; class Application : public Common::Application { private: ConnectionManager *connectionManager; - UserManager *userManager; public: Application(); @@ -40,10 +38,6 @@ class Application : public Common::Application { ConnectionManager* getConnectionManager() const { return connectionManager; } - - UserManager* getUserManager() const { - return userManager; - } }; } diff --git a/src/Server/CMakeLists.txt b/src/Server/CMakeLists.txt index b609de3..22a7826 100644 --- a/src/Server/CMakeLists.txt +++ b/src/Server/CMakeLists.txt @@ -6,7 +6,5 @@ include_directories(${INCLUDES}) add_library(Server Application.cpp Application.h ConnectionManager.cpp ConnectionManager.h - UserBackend.h - UserManager.cpp UserManager.h ) target_link_libraries(Server ServerRequestHandlers ServerRequests Common) diff --git a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp index 3aaa576..34fae36 100644 --- a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp @@ -19,7 +19,7 @@ #include "UserRequestHandlerGroup.h" #include "../Application.h" -#include "../UserManager.h" +#include <Common/UserManager.h> namespace Mad { namespace Server { diff --git a/src/Server/UserBackend.h b/src/Server/UserBackend.h deleted file mode 100644 index 4688bc7..0000000 --- a/src/Server/UserBackend.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * UserBackend.h - * - * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de> - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef MAD_SERVER_USERBACKEND_H_ -#define MAD_SERVER_USERBACKEND_H_ - -#include <config.h> - -#include <Core/Exception.h> - -#include <Common/UserInfo.h> -#include <Common/GroupInfo.h> - -#include <map> -#include <set> -#include <string> - -#include <boost/smart_ptr.hpp> - - -namespace Mad { -namespace Server { - -class UserManager; - -class UserBackend { - protected: - friend class UserManager; - - UserBackend() {} - - virtual boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > getUserList() throw(Core::Exception) { - throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); - } - - virtual boost::shared_ptr<Common::UserInfo> getUserInfo(unsigned long uid _UNUSED_PARAMETER_) throw(Core::Exception) { - throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); - } - - virtual boost::shared_ptr<Common::UserInfo> getUserInfoByName(const std::string &name _UNUSED_PARAMETER_) throw(Core::Exception) { - throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); - } - - virtual boost::shared_ptr<std::set<unsigned long> > getUserGroupList(unsigned long uid _UNUSED_PARAMETER_) throw(Core::Exception) { - throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); - } - - - virtual boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > getGroupList() throw(Core::Exception) { - throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); - } - - virtual std::string getGroupName(unsigned long gid _UNUSED_PARAMETER_) throw(Core::Exception) { - throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); - } - - virtual unsigned long getGroupId(const std::string &name _UNUSED_PARAMETER_) throw(Core::Exception) { - throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); - } - - virtual boost::shared_ptr<std::set<unsigned long> > getGroupUserList(unsigned long gid _UNUSED_PARAMETER_) throw(Core::Exception) { - throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); - } - - virtual void setPassword(unsigned long uid _UNUSED_PARAMETER_, const std::string &password _UNUSED_PARAMETER_) throw(Core::Exception) { - throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); - } - - virtual void addUser(const Common::UserInfo &userInfo _UNUSED_PARAMETER_) throw(Core::Exception) { - throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); - } - - virtual int getPriority() const { - return 0; - } - - public: - virtual ~UserBackend() {} -}; - -} -} - -#endif /* MAD_SERVER_USERBACKEND_H_ */ diff --git a/src/Server/UserManager.cpp b/src/Server/UserManager.cpp deleted file mode 100644 index 243457c..0000000 --- a/src/Server/UserManager.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/* - * UserManager.cpp - * - * Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de> - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "UserManager.h" -#include "UserBackend.h" - -namespace Mad { -namespace Server { - -bool UserManager::Compare::operator() (boost::shared_ptr<UserBackend> b1, boost::shared_ptr<UserBackend> b2) { - if(b1->getPriority() == b2->getPriority()) - return (b1.get() > b2.get()); - else - return (b1->getPriority() > b2->getPriority()); -} - - -boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > UserManager::getUserList() throw(Core::Exception) { - Core::Exception e(Core::Exception::NOT_IMPLEMENTED); - - for(std::set<boost::shared_ptr<UserBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { - try { - return (*backend)->getUserList(); - } - catch(Core::Exception e2) { - if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED) - e = e2; - } - } - - throw e; -} - -boost::shared_ptr<Common::UserInfo> UserManager::getUserInfo(unsigned long uid) throw(Core::Exception) { - Core::Exception e(Core::Exception::NOT_IMPLEMENTED); - - for(std::set<boost::shared_ptr<UserBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { - try { - return (*backend)->getUserInfo(uid); - } - catch(Core::Exception e2) { - if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED) - e = e2; - } - } - - throw e; -} - -boost::shared_ptr<Common::UserInfo> UserManager::getUserInfoByName(const std::string &name) throw(Core::Exception) { - Core::Exception e(Core::Exception::NOT_IMPLEMENTED); - - for(std::set<boost::shared_ptr<UserBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { - try { - return (*backend)->getUserInfoByName(name); - } - catch(Core::Exception e2) { - if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED) - e = e2; - } - } - - throw e; -} - -boost::shared_ptr<std::set<unsigned long> > UserManager::getUserGroupList(unsigned long uid) throw(Core::Exception) { - Core::Exception e(Core::Exception::NOT_IMPLEMENTED); - - for(std::set<boost::shared_ptr<UserBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { - try { - return (*backend)->getUserGroupList(uid); - } - catch(Core::Exception e2) { - if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED) - e = e2; - } - } - - throw e; -} - -boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > UserManager::getGroupList() throw(Core::Exception) { - Core::Exception e(Core::Exception::NOT_IMPLEMENTED); - - for(std::set<boost::shared_ptr<UserBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { - try { - return (*backend)->getGroupList(); - } - catch(Core::Exception e2) { - if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED) - e = e2; - } - } - - throw e; -} - -std::string UserManager::getGroupName(unsigned long gid) throw(Core::Exception) { - Core::Exception e(Core::Exception::NOT_IMPLEMENTED); - - for(std::set<boost::shared_ptr<UserBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { - try { - return (*backend)->getGroupName(gid); - } - catch(Core::Exception e2) { - if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED) - e = e2; - } - } - - throw e; -} - -unsigned long UserManager::getGroupId(const std::string &name) throw(Core::Exception) { - Core::Exception e(Core::Exception::NOT_IMPLEMENTED); - - for(std::set<boost::shared_ptr<UserBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { - try { - return (*backend)->getGroupId(name); - } - catch(Core::Exception e2) { - if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED) - e = e2; - } - } - - throw e; -} - -boost::shared_ptr<std::set<unsigned long> > UserManager::getGroupUserList(unsigned long gid) throw(Core::Exception) { - Core::Exception e(Core::Exception::NOT_IMPLEMENTED); - - for(std::set<boost::shared_ptr<UserBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { - try { - return (*backend)->getGroupUserList(gid); - } - catch(Core::Exception e2) { - if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED) - e = e2; - } - } - - throw e; -} - -void UserManager::setPassword(unsigned long uid, const std::string &password) throw(Core::Exception) { - Core::Exception e(Core::Exception::NOT_IMPLEMENTED); - - for(std::set<boost::shared_ptr<UserBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { - try { - return (*backend)->setPassword(uid, password); - } - catch(Core::Exception e2) { - if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED) - e = e2; - } - } - - throw e; -} - -void UserManager::addUser(const Common::UserInfo &userInfo) throw(Core::Exception) { - Core::Exception e(Core::Exception::NOT_IMPLEMENTED); - - for(std::set<boost::shared_ptr<UserBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { - try { - return (*backend)->addUser(userInfo); - } - catch(Core::Exception e2) { - if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED) - e = e2; - } - } - - throw e; -} - -} -} diff --git a/src/Server/UserManager.h b/src/Server/UserManager.h deleted file mode 100644 index 6d3c034..0000000 --- a/src/Server/UserManager.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * UserManager.h - * - * Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de> - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef MAD_SERVER_USERMANAGER_H_ -#define MAD_SERVER_USERMANAGER_H_ - -#include <Common/UserInfo.h> -#include <Common/GroupInfo.h> - -#include <Core/Exception.h> - -#include <map> -#include <set> - -#include <boost/smart_ptr.hpp> -#include <boost/noncopyable.hpp> - -namespace Mad { -namespace Server { - -class Application; -class UserBackend; - -class UserManager : boost::noncopyable { - private: - friend class Application; - - struct Compare { - bool operator() (boost::shared_ptr<UserBackend> b1, boost::shared_ptr<UserBackend> b2); - }; - - std::set<boost::shared_ptr<UserBackend>, Compare> backends; - - UserManager() {} - - public: - void registerBackend(boost::shared_ptr<UserBackend> backend) { - backends.insert(backend); - } - - void unregisterBackend(boost::shared_ptr<UserBackend> backend) { - backends.erase(backend); - } - - boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > getUserList() throw(Core::Exception); - boost::shared_ptr<Common::UserInfo> getUserInfo(unsigned long uid) throw(Core::Exception); - boost::shared_ptr<Common::UserInfo> getUserInfoByName(const std::string &name) throw(Core::Exception); - boost::shared_ptr<std::set<unsigned long> > getUserGroupList(unsigned long uid) throw(Core::Exception); - - boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > getGroupList() throw(Core::Exception); - std::string getGroupName(unsigned long gid) throw(Core::Exception); - unsigned long getGroupId(const std::string &name) throw(Core::Exception); - boost::shared_ptr<std::set<unsigned long> > getGroupUserList(unsigned long gid) throw(Core::Exception); - - void setPassword(unsigned long uid, const std::string &password) throw(Core::Exception); - - void addUser(const Common::UserInfo &userInfo) throw(Core::Exception); -}; - -} -} - -#endif /* MAD_SERVER_USERMANAGER_H_ */ |