From 37c8bed9a5f2ae9141c461202fec5baa6fa21389 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 19 Jun 2009 18:21:03 +0200 Subject: UserManager nach Common verschoben --- src/Server/Application.cpp | 7 +- src/Server/Application.h | 6 - src/Server/CMakeLists.txt | 2 - .../RequestHandlers/UserRequestHandlerGroup.cpp | 2 +- src/Server/UserBackend.h | 100 ----------- src/Server/UserManager.cpp | 195 --------------------- src/Server/UserManager.h | 79 --------- 7 files changed, 2 insertions(+), 389 deletions(-) delete mode 100644 src/Server/UserBackend.h delete mode 100644 src/Server/UserManager.cpp delete mode 100644 src/Server/UserManager.h (limited to 'src/Server') 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 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 - * - * 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 . - */ - -#ifndef MAD_SERVER_USERBACKEND_H_ -#define MAD_SERVER_USERBACKEND_H_ - -#include - -#include - -#include -#include - -#include -#include -#include - -#include - - -namespace Mad { -namespace Server { - -class UserManager; - -class UserBackend { - protected: - friend class UserManager; - - UserBackend() {} - - virtual boost::shared_ptr > getUserList() throw(Core::Exception) { - throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); - } - - virtual boost::shared_ptr getUserInfo(unsigned long uid _UNUSED_PARAMETER_) throw(Core::Exception) { - throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); - } - - virtual boost::shared_ptr getUserInfoByName(const std::string &name _UNUSED_PARAMETER_) throw(Core::Exception) { - throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); - } - - virtual boost::shared_ptr > getUserGroupList(unsigned long uid _UNUSED_PARAMETER_) throw(Core::Exception) { - throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); - } - - - virtual boost::shared_ptr > 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 > 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 - * - * 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 . - */ - -#include "UserManager.h" -#include "UserBackend.h" - -namespace Mad { -namespace Server { - -bool UserManager::Compare::operator() (boost::shared_ptr b1, boost::shared_ptr b2) { - if(b1->getPriority() == b2->getPriority()) - return (b1.get() > b2.get()); - else - return (b1->getPriority() > b2->getPriority()); -} - - -boost::shared_ptr > UserManager::getUserList() throw(Core::Exception) { - Core::Exception e(Core::Exception::NOT_IMPLEMENTED); - - for(std::set >::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 UserManager::getUserInfo(unsigned long uid) throw(Core::Exception) { - Core::Exception e(Core::Exception::NOT_IMPLEMENTED); - - for(std::set >::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 UserManager::getUserInfoByName(const std::string &name) throw(Core::Exception) { - Core::Exception e(Core::Exception::NOT_IMPLEMENTED); - - for(std::set >::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 > UserManager::getUserGroupList(unsigned long uid) throw(Core::Exception) { - Core::Exception e(Core::Exception::NOT_IMPLEMENTED); - - for(std::set >::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 > UserManager::getGroupList() throw(Core::Exception) { - Core::Exception e(Core::Exception::NOT_IMPLEMENTED); - - for(std::set >::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 >::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 >::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 > UserManager::getGroupUserList(unsigned long gid) throw(Core::Exception) { - Core::Exception e(Core::Exception::NOT_IMPLEMENTED); - - for(std::set >::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 >::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 >::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 - * - * 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 . - */ - -#ifndef MAD_SERVER_USERMANAGER_H_ -#define MAD_SERVER_USERMANAGER_H_ - -#include -#include - -#include - -#include -#include - -#include -#include - -namespace Mad { -namespace Server { - -class Application; -class UserBackend; - -class UserManager : boost::noncopyable { - private: - friend class Application; - - struct Compare { - bool operator() (boost::shared_ptr b1, boost::shared_ptr b2); - }; - - std::set, Compare> backends; - - UserManager() {} - - public: - void registerBackend(boost::shared_ptr backend) { - backends.insert(backend); - } - - void unregisterBackend(boost::shared_ptr backend) { - backends.erase(backend); - } - - boost::shared_ptr > getUserList() throw(Core::Exception); - boost::shared_ptr getUserInfo(unsigned long uid) throw(Core::Exception); - boost::shared_ptr getUserInfoByName(const std::string &name) throw(Core::Exception); - boost::shared_ptr > getUserGroupList(unsigned long uid) throw(Core::Exception); - - boost::shared_ptr > 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 > 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_ */ -- cgit v1.2.3