From 033145b65c543d1d6c0c05ee84c1031fcd5ba3c7 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 26 May 2009 16:13:27 +0200 Subject: UserBackend-Interface erweitert und im Mysql-Backend implementiert --- src/Server/UserBackend.h | 22 +++++++++++++ src/Server/UserManager.cpp | 80 ++++++++++++++++++++++++++++++++++++++++++++++ src/Server/UserManager.h | 5 +++ 3 files changed, 107 insertions(+) (limited to 'src/Server') diff --git a/src/Server/UserBackend.h b/src/Server/UserBackend.h index 2a51d1b..001ee49 100644 --- a/src/Server/UserBackend.h +++ b/src/Server/UserBackend.h @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -52,10 +53,31 @@ class UserBackend { throw(Net::Exception(Net::Exception::NOT_IMPLEMENTED)); } + virtual boost::shared_ptr getUserInfoByName(const std::string &name _UNUSED_PARAMETER_) throw(Net::Exception) { + throw(Net::Exception(Net::Exception::NOT_IMPLEMENTED)); + } + + virtual boost::shared_ptr > getUserGroups(unsigned long uid _UNUSED_PARAMETER_) throw(Net::Exception) { + throw(Net::Exception(Net::Exception::NOT_IMPLEMENTED)); + } + + virtual boost::shared_ptr > getGroupList() throw(Net::Exception) { throw(Net::Exception(Net::Exception::NOT_IMPLEMENTED)); } + virtual std::string getGroupName(unsigned long gid _UNUSED_PARAMETER_) throw(Net::Exception) { + throw(Net::Exception(Net::Exception::NOT_IMPLEMENTED)); + } + + virtual unsigned long getGroupId(const std::string &name _UNUSED_PARAMETER_) throw(Net::Exception) { + throw(Net::Exception(Net::Exception::NOT_IMPLEMENTED)); + } + + virtual boost::shared_ptr > getGroupUsers(unsigned long gid _UNUSED_PARAMETER_) throw(Net::Exception) { + throw(Net::Exception(Net::Exception::NOT_IMPLEMENTED)); + } + // TODO Better interface... virtual void setPassword(unsigned long uid _UNUSED_PARAMETER_, const std::string &password _UNUSED_PARAMETER_) throw(Net::Exception) { throw(Net::Exception(Net::Exception::NOT_IMPLEMENTED)); diff --git a/src/Server/UserManager.cpp b/src/Server/UserManager.cpp index 7101b2c..e38f458 100644 --- a/src/Server/UserManager.cpp +++ b/src/Server/UserManager.cpp @@ -66,6 +66,38 @@ boost::shared_ptr UserManager::getUserInfo(unsigned long uid) throw e; } +boost::shared_ptr UserManager::getUserInfoByName(const std::string &name) throw(Net::Exception) { + Net::Exception e(Net::Exception::NOT_IMPLEMENTED); + + for(std::set >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { + try { + return (*backend)->getUserInfoByName(name); + } + catch(Net::Exception e2) { + if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED) + e = e2; + } + } + + throw e; +} + +boost::shared_ptr > UserManager::getUserGroups(unsigned long uid) throw(Net::Exception) { + Net::Exception e(Net::Exception::NOT_IMPLEMENTED); + + for(std::set >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { + try { + return (*backend)->getUserGroups(uid); + } + catch(Net::Exception e2) { + if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED) + e = e2; + } + } + + throw e; +} + boost::shared_ptr > UserManager::getGroupList() throw(Net::Exception) { Net::Exception e(Net::Exception::NOT_IMPLEMENTED); @@ -82,6 +114,54 @@ boost::shared_ptr > UserManager::getG throw e; } +std::string UserManager::getGroupName(unsigned long gid) throw(Net::Exception) { + Net::Exception e(Net::Exception::NOT_IMPLEMENTED); + + for(std::set >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { + try { + return (*backend)->getGroupName(gid); + } + catch(Net::Exception e2) { + if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED) + e = e2; + } + } + + throw e; +} + +unsigned long UserManager::getGroupId(const std::string &name) throw(Net::Exception) { + Net::Exception e(Net::Exception::NOT_IMPLEMENTED); + + for(std::set >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { + try { + return (*backend)->getGroupId(name); + } + catch(Net::Exception e2) { + if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED) + e = e2; + } + } + + throw e; +} + +boost::shared_ptr > UserManager::getGroupUsers(unsigned long gid) throw(Net::Exception) { + Net::Exception e(Net::Exception::NOT_IMPLEMENTED); + + for(std::set >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { + try { + return (*backend)->getGroupUsers(gid); + } + catch(Net::Exception e2) { + if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED) + e = e2; + } + } + + throw e; +} + void UserManager::setPassword(unsigned long uid, const std::string &password) throw(Net::Exception) { Net::Exception e(Net::Exception::NOT_IMPLEMENTED); diff --git a/src/Server/UserManager.h b/src/Server/UserManager.h index 3377727..fe0ef3f 100644 --- a/src/Server/UserManager.h +++ b/src/Server/UserManager.h @@ -59,8 +59,13 @@ class UserManager : boost::noncopyable { boost::shared_ptr > getUserList() throw(Net::Exception); boost::shared_ptr getUserInfo(unsigned long uid) throw(Net::Exception); + boost::shared_ptr getUserInfoByName(const std::string &name) throw(Net::Exception); + boost::shared_ptr > getUserGroups(unsigned long uid) throw(Net::Exception); boost::shared_ptr > getGroupList() throw(Net::Exception); + std::string getGroupName(unsigned long gid) throw(Net::Exception); + unsigned long getGroupId(const std::string &name) throw(Net::Exception); + boost::shared_ptr > getGroupUsers(unsigned long gid) throw(Net::Exception); void setPassword(unsigned long uid, const std::string &password) throw(Net::Exception); -- cgit v1.2.3