summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-06-24 00:04:28 +0200
committerMatthias Schiffer <matthias@gamezock.de>2009-06-24 00:04:28 +0200
commitdff7c00a0c2c3fcb64efd611d70398d711ad861b (patch)
tree93c1556c15987b37e8d2ba3421cb246006a02eac
parent02b9e16833acbdaa820bd3b8b64d652a41a8ff58 (diff)
downloadmad-dff7c00a0c2c3fcb64efd611d70398d711ad861b.tar
mad-dff7c00a0c2c3fcb64efd611d70398d711ad861b.zip
NetworkUserBackend implementiert
-rw-r--r--src/Client/CommandParser.cpp3
-rw-r--r--src/Client/UserCommands.cpp194
-rw-r--r--src/Client/UserCommands.h4
-rw-r--r--src/Common/Backends/CMakeLists.txt6
-rw-r--r--src/Common/Backends/NetworkUserBackend.cpp203
-rw-r--r--src/Common/Backends/NetworkUserBackend.h91
-rw-r--r--src/Common/CMakeLists.txt3
-rw-r--r--src/Common/Requests/CMakeLists.txt5
-rw-r--r--src/Common/Requests/GroupListRequest.h38
-rw-r--r--src/Common/Requests/GroupUserListRequest.cpp36
-rw-r--r--src/Common/Requests/GroupUserListRequest.h44
-rw-r--r--src/Common/Requests/UserGroupListRequest.cpp36
-rw-r--r--src/Common/Requests/UserGroupListRequest.h44
-rw-r--r--src/Common/Requests/UserInfoRequest.cpp36
-rw-r--r--src/Common/Requests/UserInfoRequest.h44
-rw-r--r--src/Common/Requests/UserListRequest.h38
-rw-r--r--src/Common/UserBackend.h16
-rw-r--r--src/Common/UserManager.cpp20
-rw-r--r--src/Common/UserManager.h18
-rw-r--r--src/Server/RequestHandlers/UserRequestHandlerGroup.cpp42
-rw-r--r--src/Server/RequestHandlers/UserRequestHandlerGroup.h2
-rw-r--r--src/madc.cpp7
-rw-r--r--src/modules/UserBackendMysql/UserBackendMysql.cpp36
-rw-r--r--src/modules/UserBackendMysql/UserBackendMysql.h18
24 files changed, 498 insertions, 486 deletions
diff --git a/src/Client/CommandParser.cpp b/src/Client/CommandParser.cpp
index f231082..842be7f 100644
--- a/src/Client/CommandParser.cpp
+++ b/src/Client/CommandParser.cpp
@@ -43,10 +43,11 @@ const CommandParser::Command CommandParser::commands[] = {
{{"reboot", 0}, "reboot *|host...", "Reboot host", "Reboot hosts. * will reboot all hosts.", &SystemCommands::rebootCommand},
{{"shutdown", "halt", 0}, "shutdown *|host...", "Shut hosts down", "Shut hosts down. * will shut down all hosts.", &SystemCommands::shutdownCommand},
{{"status", "st", 0}, "status [host]", "Display status information", "Display host status information. If no host is given, display server status information.", &SystemCommands::statusCommand},
- {{"user_info", "user", 0}, "user_info uid", "Search for a user id", "Search for a user id.", &UserCommands::userInfoCommand},
{{"list_users", "users", 0}, "list_users", "Show the user account database", "Show the user account database.", &UserCommands::listUsersCommand},
+ {{"user_info", "user", 0}, "user_info uid|name", "Search for a user id", "Search for a user.", &UserCommands::userInfoCommand},
{{"list_user_groups", "user_groups", 0}, "list_user_groups uid", "List user's groups", "List the groups that the user is member of.", &UserCommands::listUserGroupsCommand},
{{"list_groups", "groups", 0}, "list_groups", "Show the user group database", "Show the user group database.", &UserCommands::listGroupsCommand},
+ {{"group_info", "group", 0}, "group_info gid|name", "Search for a group id", "Search for a group.", &UserCommands::groupInfoCommand},
{{"list_group_users", "group_users", 0}, "list_group_users gid", "List group's users", "List the users that are members of the group.", &UserCommands::listGroupUsersCommand},
{{"exit", "quit", 0}, "exit", "Close the connection and quit the client", "Close the connection and quit the client.", &CommandParser::exitCommand},
{{0}, 0, 0, 0, 0}
diff --git a/src/Client/UserCommands.cpp b/src/Client/UserCommands.cpp
index de5b7ea..fec2a33 100644
--- a/src/Client/UserCommands.cpp
+++ b/src/Client/UserCommands.cpp
@@ -23,11 +23,7 @@
#include <Common/RequestManager.h>
-#include <Common/Requests/GroupListRequest.h>
-#include <Common/Requests/GroupUserListRequest.h>
-#include <Common/Requests/UserInfoRequest.h>
-#include <Common/Requests/UserListRequest.h>
-#include <Common/Requests/UserGroupListRequest.h>
+#include <Common/UserManager.h>
#include <iostream>
@@ -35,6 +31,29 @@
namespace Mad {
namespace Client {
+void UserCommands::listUsersCommand(CommandParser *commandParser, const std::vector<std::string> &args _UNUSED_PARAMETER_) {
+ try {
+ boost::shared_ptr<const std::map<unsigned long, Common::UserInfo> > users = commandParser->application->getUserManager()->getUserList();
+
+ if(users->empty()) {
+ std::cout << "User list is empty." << std::endl;
+ }
+ else {
+ std::cout << "Found " << users->size() << " user" << (users->size()==1 ? "" : "s") << ":" << std::endl;
+
+ for(std::map<unsigned long, Common::UserInfo>::const_iterator user = users->begin(); user != users->end(); ++user) {
+ std::cout << " " << user->second.getUid() << ", " << user->second.getGid() << ", "
+ << user->second.getUsername() << ", " << user->second.getFullName() << std::endl;
+ }
+ }
+
+ std::cout << std::endl;
+ }
+ catch(Core::Exception e) {
+ std::cerr << "An error occurred during your request: " << e.strerror() << "." << std::endl;
+ }
+}
+
void UserCommands::userInfoCommand(CommandParser *commandParser, const std::vector<std::string> &args) {
if(args.size() == 1) {
std::cerr << args[0] << ": No user id given." << std::endl;
@@ -47,58 +66,23 @@ void UserCommands::userInfoCommand(CommandParser *commandParser, const std::vect
return;
}
- char *endptr;
- unsigned long uid = std::strtoul(args[1].c_str(), &endptr, 10);
- if(args[1].empty() || *endptr != '\0') {
- std::cerr << args[0] << ": Unable to parse user id." << std::endl;
- commandParser->printUsage("user_info");
- return;
- }
-
- boost::shared_ptr<Common::Requests::UserInfoRequest> request(new Common::Requests::UserInfoRequest(commandParser->application, uid));
- commandParser->application->getRequestManager()->sendRequest(commandParser->connection, request);
- request->wait();
-
- std::pair<boost::shared_ptr<const Common::XmlPacket>, Core::Exception> result = request->getResult();
-
- if(!result.first || result.second) {
- std::cerr << "An error occurred during your request: " << result.second.strerror() << "." << std::endl;
- }
- else {
- const Common::XmlPacket &packet = *result.first;
-
- std::cout << " " << packet.get<unsigned long>("uid") << ", " << packet.get<unsigned long>("gid") << ", "
- << packet.get<const std::string&>("username") << ", " << packet.get<const std::string&>("fullName") << std::endl << std::endl;
- }
-}
-
-void UserCommands::listUsersCommand(CommandParser *commandParser, const std::vector<std::string> &args _UNUSED_PARAMETER_) {
- boost::shared_ptr<Common::Requests::UserListRequest> request(new Common::Requests::UserListRequest(commandParser->application));
-
- commandParser->application->getRequestManager()->sendRequest(commandParser->connection, request);
- request->wait();
-
- std::pair<boost::shared_ptr<const Common::XmlPacket>, Core::Exception> result = request->getResult();
-
- if(!result.first || result.second) {
- std::cerr << "An error occurred during your request: " << result.second.strerror() << "." << std::endl;
- }
- else {
- const Common::XmlPacket::List *users = result.first->getList("users");
-
- if(!users || users->isEmpty()) {
- std::cout << "User list is empty." << std::endl;
- }
- else {
- std::cout << "Found " << users->getSize() << " user" << (users->getSize()==1 ? "" : "s") << ":" << std::endl;
+ try {
+ char *endptr;
+ unsigned long uid = std::strtoul(args[1].c_str(), &endptr, 10);
+ boost::shared_ptr<const Common::UserInfo> userInfo;
- for(Common::XmlPacket::List::const_iterator user = users->begin(); user != users->end(); ++user)
- std::cout << " " << user->get<unsigned long>("uid") << ", " << user->get<unsigned long>("gid")
- << ", " << user->get<const std::string&>("username") << ", " << user->get<const std::string&>("fullName") << std::endl;
+ if(args[1].empty() || *endptr != '\0') {
+ userInfo = commandParser->application->getUserManager()->getUserInfoByName(args[1]);
}
+ else
+ userInfo = commandParser->application->getUserManager()->getUserInfo(uid);
- std::cout << std::endl;
+ std::cout << " " << userInfo->getUid() << ", " << userInfo->getGid() << ", "
+ << userInfo->getUsername() << ", " << userInfo->getFullName() << std::endl << std::endl;
+ }
+ catch(Core::Exception e) {
+ std::cerr << "An error occurred during your request: " << e.strerror() << "." << std::endl;
}
}
@@ -122,59 +106,77 @@ void UserCommands::listUserGroupsCommand(CommandParser *commandParser, const std
return;
}
- boost::shared_ptr<Common::Requests::UserGroupListRequest> request(new Common::Requests::UserGroupListRequest(commandParser->application, uid));
- commandParser->application->getRequestManager()->sendRequest(commandParser->connection, request);
- request->wait();
+ try {
+ boost::shared_ptr<const std::set<unsigned long> > groups = commandParser->application->getUserManager()->getUserGroupList(uid);
- std::pair<boost::shared_ptr<const Common::XmlPacket>, Core::Exception> result = request->getResult();
-
- if(!result.first || result.second) {
- std::cerr << "An error occurred during your request: " << result.second.strerror() << "." << std::endl;
- }
- else {
- const Common::XmlPacket::List *groups = result.first->getList("groups");
-
- if(!groups || groups->isEmpty()) {
+ if(groups->empty()) {
std::cout << "The user isn't member of any group." << std::endl;
}
else {
- std::cout << "User is member of " << groups->getSize() << " group" << (groups->getSize()==1 ? "" : "s") << ":" << std::endl;
+ std::cout << "User is member of " << groups->size() << " group" << (groups->size()==1 ? "" : "s") << ":" << std::endl;
- for(Common::XmlPacket::List::const_iterator group = groups->begin(); group != groups->end(); ++group)
- std::cout << " " << group->get<unsigned long>("gid") << std::endl;
+ for(std::set<unsigned long>::const_iterator group = groups->begin(); group != groups->end(); ++group)
+ std::cout << " " << *group << std::endl;
}
std::cout << std::endl;
}
+ catch(Core::Exception e) {
+ std::cerr << "An error occurred during your request: " << e.strerror() << "." << std::endl;
+ }
}
void UserCommands::listGroupsCommand(CommandParser *commandParser, const std::vector<std::string> &args _UNUSED_PARAMETER_) {
- boost::shared_ptr<Common::Requests::GroupListRequest> request(new Common::Requests::GroupListRequest(commandParser->application));
+ try {
+ boost::shared_ptr<const std::map<unsigned long, Common::GroupInfo> > groups = commandParser->application->getUserManager()->getGroupList();
- commandParser->application->getRequestManager()->sendRequest(commandParser->connection, request);
- request->wait();
+ if(groups->empty()) {
+ std::cout << "Group list is empty." << std::endl;
+ }
+ else {
+ std::cout << "Found " << groups->size() << " group" << (groups->size()==1 ? "" : "s") << ":" << std::endl;
- std::pair<boost::shared_ptr<const Common::XmlPacket>, Core::Exception> result = request->getResult();
+ for(std::map<unsigned long, Common::GroupInfo>::const_iterator group = groups->begin(); group != groups->end(); ++group) {
+ std::cout << " " << group->second.getGid() << ", " << group->second.getName() << std::endl;
+ }
+ }
- if(!result.first || result.second) {
- std::cerr << "An error occurred during your request: " << result.second.strerror() << "." << std::endl;
+ std::cout << std::endl;
+ }
+ catch(Core::Exception e) {
+ std::cerr << "An error occurred during your request: " << e.strerror() << "." << std::endl;
}
- else {
- const Common::XmlPacket::List *groups = result.first->getList("groups");
+}
- if(!groups || groups->isEmpty()) {
- std::cout << "Group list is empty." << std::endl;
- }
- else {
- std::cout << "Found " << groups->getSize() << " group" << (groups->getSize()==1 ? "" : "s") << ":" << std::endl;
+void UserCommands::groupInfoCommand(CommandParser *commandParser, const std::vector<std::string> &args) {
+ if(args.size() == 1) {
+ std::cerr << args[0] << ": No group id given." << std::endl;
+ commandParser->printUsage("group_info");
+ return;
+ }
+ if(args.size() > 2) {
+ std::cerr << args[0] << ": Too many arguments." << std::endl;
+ commandParser->printUsage("group_info");
+ return;
+ }
+
+ try {
+ char *endptr;
+ unsigned long gid = std::strtoul(args[1].c_str(), &endptr, 10);
+ boost::shared_ptr<const Common::GroupInfo> groupInfo;
- for(Common::XmlPacket::List::const_iterator group = groups->begin(); group != groups->end(); ++group)
- std::cout << " " << group->get<unsigned long>("gid") << ", " << group->get<const std::string&>("name") << std::endl;
+ if(args[1].empty() || *endptr != '\0') {
+ groupInfo = commandParser->application->getUserManager()->getGroupInfoByName(args[1]);
}
+ else
+ groupInfo = commandParser->application->getUserManager()->getGroupInfo(gid);
- std::cout << std::endl;
+ std::cout << " " << groupInfo->getGid() << ", " << groupInfo->getName() << std::endl << std::endl;
+ }
+ catch(Core::Exception e) {
+ std::cerr << "An error occurred during your request: " << e.strerror() << "." << std::endl;
}
}
@@ -198,31 +200,25 @@ void UserCommands::listGroupUsersCommand(CommandParser *commandParser, const std
return;
}
- boost::shared_ptr<Common::Requests::GroupUserListRequest> request(new Common::Requests::GroupUserListRequest(commandParser->application, gid));
- commandParser->application->getRequestManager()->sendRequest(commandParser->connection, request);
- request->wait();
+ try {
+ boost::shared_ptr<const std::set<unsigned long> > users = commandParser->application->getUserManager()->getGroupUserList(gid);
- std::pair<boost::shared_ptr<const Common::XmlPacket>, Core::Exception> result = request->getResult();
-
- if(!result.first || result.second) {
- std::cerr << "An error occurred during your request: " << result.second.strerror() << "." << std::endl;
- }
- else {
- const Common::XmlPacket::List *users = result.first->getList("users");
-
- if(!users || users->isEmpty()) {
+ if(users->empty()) {
std::cout << "The group doesn't have any members." << std::endl;
}
else {
- std::cout << "The group has " << users->getSize() << " member" << (users->getSize()==1 ? "" : "s") << ":" << std::endl;
+ std::cout << "The group has " << users->size() << " member" << (users->size()==1 ? "" : "s") << ":" << std::endl;
- for(Common::XmlPacket::List::const_iterator user = users->begin(); user != users->end(); ++user)
- std::cout << " " << user->get<unsigned long>("uid") << std::endl;
+ for(std::set<unsigned long>::const_iterator user = users->begin(); user != users->end(); ++user)
+ std::cout << " " << *user << std::endl;
}
std::cout << std::endl;
}
+ catch(Core::Exception e) {
+ std::cerr << "An error occurred during your request: " << e.strerror() << "." << std::endl;
+ }
}
}
diff --git a/src/Client/UserCommands.h b/src/Client/UserCommands.h
index f3dd31c..0f56a40 100644
--- a/src/Client/UserCommands.h
+++ b/src/Client/UserCommands.h
@@ -33,10 +33,12 @@ class UserCommands {
UserCommands();
public:
- static void userInfoCommand(CommandParser *commandParser, const std::vector<std::string> &args);
static void listUsersCommand(CommandParser *commandParser, const std::vector<std::string> &args);
+ static void userInfoCommand(CommandParser *commandParser, const std::vector<std::string> &args);
static void listUserGroupsCommand(CommandParser *commandParser, const std::vector<std::string> &args);
+
static void listGroupsCommand(CommandParser *commandParser, const std::vector<std::string> &args);
+ static void groupInfoCommand(CommandParser *commandParser, const std::vector<std::string> &args);
static void listGroupUsersCommand(CommandParser *commandParser, const std::vector<std::string> &args);
};
diff --git a/src/Common/Backends/CMakeLists.txt b/src/Common/Backends/CMakeLists.txt
new file mode 100644
index 0000000..4d9d30e
--- /dev/null
+++ b/src/Common/Backends/CMakeLists.txt
@@ -0,0 +1,6 @@
+include_directories(${INCLUDES})
+
+add_library(Backends STATIC
+ NetworkUserBackend.cpp NetworkUserBackend.h
+)
+target_link_libraries(Backends Common)
diff --git a/src/Common/Backends/NetworkUserBackend.cpp b/src/Common/Backends/NetworkUserBackend.cpp
new file mode 100644
index 0000000..81fc94a
--- /dev/null
+++ b/src/Common/Backends/NetworkUserBackend.cpp
@@ -0,0 +1,203 @@
+/*
+ * NetworkUserBackend.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 "NetworkUserBackend.h"
+#include "../RequestManager.h"
+
+namespace Mad {
+namespace Common {
+namespace Backends {
+
+void NetworkUserBackend::IdUserRequest::sendRequest() {
+ Common::XmlPacket packet;
+ packet.setType(type);
+ packet.set(idType, id);
+
+ sendPacket(packet);
+}
+
+void NetworkUserBackend::NameUserRequest::sendRequest() {
+ Common::XmlPacket packet;
+ packet.setType(type);
+ packet.set("name", name);
+
+ sendPacket(packet);
+}
+
+boost::shared_ptr<const std::map<unsigned long, UserInfo> > NetworkUserBackend::getUserList() throw(Core::Exception) {
+ boost::shared_ptr<SimpleUserRequest> request(new SimpleUserRequest(application, "ListUsers"));
+ application->getRequestManager()->sendRequest(connection, request);
+ request->wait();
+
+ std::pair<boost::shared_ptr<const XmlPacket>, Core::Exception> result = request->getResult();
+ if(!result.first || result.second)
+ throw result.second;
+
+ boost::shared_ptr<std::map<unsigned long, UserInfo> > userList(new std::map<unsigned long, UserInfo>);
+
+ const XmlPacket::List *users = result.first->getList("users");
+ if(users) {
+ for(XmlPacket::List::const_iterator user = users->begin(); user != users->end(); ++user) {
+ UserInfo userInfo(user->get<unsigned long>("uid"), user->get<const std::string&>("username"));
+ userInfo.setGid(user->get<unsigned long>("gid"));
+ userInfo.setFullName(user->get<const std::string&>("fullName"));
+
+ userList->insert(std::make_pair(userInfo.getUid(), userInfo));
+ }
+ }
+
+ return userList;
+}
+
+boost::shared_ptr<const UserInfo> NetworkUserBackend::getUserInfo(unsigned long uid) throw(Core::Exception) {
+ boost::shared_ptr<IdUserRequest> request(new IdUserRequest(application, "GetUserInfo", "uid", uid));
+ application->getRequestManager()->sendRequest(connection, request);
+ request->wait();
+
+ std::pair<boost::shared_ptr<const XmlPacket>, Core::Exception> result = request->getResult();
+ if(!result.first || result.second)
+ throw result.second;
+
+ boost::shared_ptr<UserInfo> userInfo(new UserInfo(result.first->get<unsigned long>("uid"), result.first->get<const std::string&>("username")));
+ userInfo->setGid(result.first->get<unsigned long>("gid"));
+ userInfo->setFullName(result.first->get<const std::string&>("fullName"));
+
+ return userInfo;
+}
+
+boost::shared_ptr<const UserInfo> NetworkUserBackend::getUserInfoByName(const std::string &name) throw(Core::Exception) {
+ boost::shared_ptr<NameUserRequest> request(new NameUserRequest(application, "GetUserInfo", name));
+ application->getRequestManager()->sendRequest(connection, request);
+ request->wait();
+
+ std::pair<boost::shared_ptr<const XmlPacket>, Core::Exception> result = request->getResult();
+ if(!result.first || result.second)
+ throw result.second;
+
+ boost::shared_ptr<UserInfo> userInfo(new UserInfo(result.first->get<unsigned long>("uid"), result.first->get<const std::string&>("username")));
+ userInfo->setGid(result.first->get<unsigned long>("gid"));
+ userInfo->setFullName(result.first->get<const std::string&>("fullName"));
+
+ return userInfo;
+}
+
+boost::shared_ptr<const std::set<unsigned long> > NetworkUserBackend::getUserGroupList(unsigned long uid) throw(Core::Exception) {
+ boost::shared_ptr<IdUserRequest> request(new IdUserRequest(application, "ListUserGroups", "uid", uid));
+ application->getRequestManager()->sendRequest(connection, request);
+ request->wait();
+
+ std::pair<boost::shared_ptr<const XmlPacket>, Core::Exception> result = request->getResult();
+ if(!result.first || result.second)
+ throw result.second;
+
+ boost::shared_ptr<std::set<unsigned long> > groupList(new std::set<unsigned long>);
+
+ const XmlPacket::List *groups = result.first->getList("groups");
+ if(groups) {
+ for(XmlPacket::List::const_iterator group = groups->begin(); group != groups->end(); ++group)
+ groupList->insert(group->get<unsigned long>("gid"));
+ }
+
+ return groupList;
+}
+
+boost::shared_ptr<const std::map<unsigned long, GroupInfo> > NetworkUserBackend::getGroupList() throw(Core::Exception) {
+ boost::shared_ptr<SimpleUserRequest> request(new SimpleUserRequest(application, "ListGroups"));
+ application->getRequestManager()->sendRequest(connection, request);
+ request->wait();
+
+ std::pair<boost::shared_ptr<const XmlPacket>, Core::Exception> result = request->getResult();
+ if(!result.first || result.second)
+ throw result.second;
+
+ boost::shared_ptr<std::map<unsigned long, GroupInfo> > groupList(new std::map<unsigned long, GroupInfo>);
+
+ const XmlPacket::List *groups = result.first->getList("groups");
+ if(groups) {
+ for(XmlPacket::List::const_iterator group = groups->begin(); group != groups->end(); ++group) {
+ GroupInfo groupInfo(group->get<unsigned long>("gid"), group->get<const std::string&>("name"));
+ groupList->insert(std::make_pair(groupInfo.getGid(), groupInfo));
+ }
+ }
+
+ return groupList;
+}
+
+boost::shared_ptr<const GroupInfo> NetworkUserBackend::getGroupInfo(unsigned long gid) throw(Core::Exception) {
+ boost::shared_ptr<IdUserRequest> request(new IdUserRequest(application, "GetGroupInfo", "gid", gid));
+ application->getRequestManager()->sendRequest(connection, request);
+ request->wait();
+
+ std::pair<boost::shared_ptr<const XmlPacket>, Core::Exception> result = request->getResult();
+ if(!result.first || result.second)
+ throw result.second;
+
+ boost::shared_ptr<GroupInfo> groupInfo(new GroupInfo(result.first->get<unsigned long>("gid"), result.first->get<const std::string&>("name")));
+
+ return groupInfo;
+}
+
+boost::shared_ptr<const GroupInfo> NetworkUserBackend::getGroupInfoByName(const std::string &name) throw(Core::Exception) {
+ boost::shared_ptr<NameUserRequest> request(new NameUserRequest(application, "GetGroupInfo", name));
+ application->getRequestManager()->sendRequest(connection, request);
+ request->wait();
+
+ std::pair<boost::shared_ptr<const XmlPacket>, Core::Exception> result = request->getResult();
+ if(!result.first || result.second)
+ throw result.second;
+
+ boost::shared_ptr<GroupInfo> groupInfo(new GroupInfo(result.first->get<unsigned long>("gid"), result.first->get<const std::string&>("name")));
+
+ return groupInfo;
+}
+
+boost::shared_ptr<const std::set<unsigned long> > NetworkUserBackend::getGroupUserList(unsigned long gid) throw(Core::Exception) {
+ boost::shared_ptr<IdUserRequest> request(new IdUserRequest(application, "ListGroupUsers", "gid", gid));
+ application->getRequestManager()->sendRequest(connection, request);
+ request->wait();
+
+ std::pair<boost::shared_ptr<const XmlPacket>, Core::Exception> result = request->getResult();
+ if(!result.first || result.second)
+ throw result.second;
+
+ boost::shared_ptr<std::set<unsigned long> > userList(new std::set<unsigned long>);
+
+ const XmlPacket::List *users = result.first->getList("users");
+ if(users) {
+ for(XmlPacket::List::const_iterator user = users->begin(); user != users->end(); ++user) {
+ userList->insert(user->get<unsigned long>("uid"));
+ }
+ }
+
+ return userList;
+}
+
+
+/*void NetworkUserBackend::setPassword(unsigned long uid, const std::string &password) throw(Core::Exception) {
+
+}*/
+
+
+/*void NetworkUserBackend::addUser(const UserInfo &userInfo) throw(Core::Exception) {
+
+}*/
+
+}
+}
+}
diff --git a/src/Common/Backends/NetworkUserBackend.h b/src/Common/Backends/NetworkUserBackend.h
new file mode 100644
index 0000000..c569ab6
--- /dev/null
+++ b/src/Common/Backends/NetworkUserBackend.h
@@ -0,0 +1,91 @@
+/*
+ * NetworkUserBackend.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_COMMON_BACKENDS_NETWORKUSERBACKEND_H_
+#define MAD_COMMON_BACKENDS_NETWORKUSERBACKEND_H_
+
+#include "../UserBackend.h"
+#include "../Requests/SimpleRequest.h"
+
+namespace Mad {
+namespace Common {
+namespace Backends {
+
+class NetworkUserBackend : public UserBackend {
+ private:
+ class SimpleUserRequest : public Requests::SimpleRequest {
+ public:
+ SimpleUserRequest(Application *application, const std::string &type) : SimpleRequest(application, type) {}
+ };
+
+ class IdUserRequest : public Request {
+ private:
+ std::string type;
+ std::string idType;
+ unsigned long id;
+
+
+ protected:
+ virtual void sendRequest();
+
+ public:
+ IdUserRequest(Application *application, const std::string &type0, const std::string &idType0, unsigned long id0)
+ : Request(application), type(type0), idType(idType0), id(id0) {}
+ };
+
+ class NameUserRequest : public Request {
+ private:
+ std::string type;
+ std::string name;
+
+
+ protected:
+ virtual void sendRequest();
+
+ public:
+ NameUserRequest(Application *application, const std::string &type0, const std::string &name0)
+ : Request(application), type(type0), name(name0) {}
+ };
+
+ Application *application;
+ Connection *connection;
+
+ protected:
+ virtual boost::shared_ptr<const std::map<unsigned long, UserInfo> > getUserList() throw(Core::Exception);
+ virtual boost::shared_ptr<const UserInfo> getUserInfo(unsigned long uid) throw(Core::Exception);
+ virtual boost::shared_ptr<const UserInfo> getUserInfoByName(const std::string &name) throw(Core::Exception);
+ virtual boost::shared_ptr<const std::set<unsigned long> > getUserGroupList(unsigned long uid) throw(Core::Exception);
+
+ virtual boost::shared_ptr<const std::map<unsigned long, GroupInfo> > getGroupList() throw(Core::Exception);
+ virtual boost::shared_ptr<const GroupInfo> getGroupInfo(unsigned long gid) throw(Core::Exception);
+ virtual boost::shared_ptr<const GroupInfo> getGroupInfoByName(const std::string &name) throw(Core::Exception);
+ virtual boost::shared_ptr<const std::set<unsigned long> > getGroupUserList(unsigned long gid) throw(Core::Exception);
+
+ //virtual void setPassword(unsigned long uid, const std::string &password) throw(Core::Exception);
+ //virtual void addUser(const UserInfo &userInfo) throw(Core::Exception);
+
+ public:
+ NetworkUserBackend(Application *application0, Connection *connection0) : application(application0), connection(connection0) {}
+};
+
+}
+}
+}
+
+#endif /* MAD_COMMON_BACKENDS_NETWORKUSERBACKEND_H_ */
diff --git a/src/Common/CMakeLists.txt b/src/Common/CMakeLists.txt
index 3ec77c4..7201ed5 100644
--- a/src/Common/CMakeLists.txt
+++ b/src/Common/CMakeLists.txt
@@ -1,3 +1,4 @@
+add_subdirectory(Backends)
add_subdirectory(RequestHandlers)
add_subdirectory(Requests)
@@ -25,4 +26,4 @@ add_library(Common
UserManager.cpp UserManager.h
XmlPacket.cpp XmlPacket.h
)
-target_link_libraries(Common RequestHandlers Requests Net ${LIBXML2_LIBRARIES} ${LTDL_LIBRARIES})
+target_link_libraries(Common Backends RequestHandlers Requests Net ${LIBXML2_LIBRARIES} ${LTDL_LIBRARIES})
diff --git a/src/Common/Requests/CMakeLists.txt b/src/Common/Requests/CMakeLists.txt
index b6ff90c..d80b0fa 100644
--- a/src/Common/Requests/CMakeLists.txt
+++ b/src/Common/Requests/CMakeLists.txt
@@ -3,13 +3,8 @@ include_directories(${INCLUDES})
add_library(Requests STATIC
DisconnectRequest.cpp DisconnectRequest.h
FSInfoRequest.h
- GroupListRequest.h
- GroupUserListRequest.cpp GroupUserListRequest.h
IdentifyRequest.cpp IdentifyRequest.h
SimpleRequest.cpp SimpleRequest.h
StatusRequest.h
- UserGroupListRequest.cpp UserGroupListRequest.h
- UserInfoRequest.cpp UserInfoRequest.h
- UserListRequest.h
)
target_link_libraries(Requests ${KRB5_LIBRARIES})
diff --git a/src/Common/Requests/GroupListRequest.h b/src/Common/Requests/GroupListRequest.h
deleted file mode 100644
index f8760ca..0000000
--- a/src/Common/Requests/GroupListRequest.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * GroupListRequest.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_COMMON_REQUESTS_GROUPLISTREQUEST_H_
-#define MAD_COMMON_REQUESTS_GROUPLISTREQUEST_H_
-
-#include "SimpleRequest.h"
-
-namespace Mad {
-namespace Common {
-namespace Requests {
-
-class GroupListRequest : public SimpleRequest {
- public:
- GroupListRequest(Application *application) : SimpleRequest(application, "ListGroups") {}
-};
-
-}
-}
-}
-
-#endif /* MAD_COMMON_REQUESTS_GROUPLISTREQUEST_H_ */
diff --git a/src/Common/Requests/GroupUserListRequest.cpp b/src/Common/Requests/GroupUserListRequest.cpp
deleted file mode 100644
index 87ab1b5..0000000
--- a/src/Common/Requests/GroupUserListRequest.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * GroupUserListRequest.cpp
- *
- * 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/>.
- */
-
-#include "GroupUserListRequest.h"
-
-namespace Mad {
-namespace Common {
-namespace Requests {
-
-void GroupUserListRequest::sendRequest() {
- Common::XmlPacket packet;
- packet.setType("ListGroupUsers");
- packet.set("gid", gid);
-
- sendPacket(packet);
-}
-
-}
-}
-}
diff --git a/src/Common/Requests/GroupUserListRequest.h b/src/Common/Requests/GroupUserListRequest.h
deleted file mode 100644
index f95cd3b..0000000
--- a/src/Common/Requests/GroupUserListRequest.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * GroupUserListRequest.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_COMMON_REQUESTS_GROUPUSERLISTREQUEST_H_
-#define MAD_COMMON_REQUESTS_GROUPUSERLISTREQUEST_H_
-
-#include "../Request.h"
-
-namespace Mad {
-namespace Common {
-namespace Requests {
-
-class GroupUserListRequest : public Request {
- private:
- unsigned long gid;
-
- protected:
- virtual void sendRequest();
-
- public:
- GroupUserListRequest(Application *application, unsigned long gid0) : Request(application), gid(gid0) {}
-};
-
-}
-}
-}
-
-#endif /* MAD_COMMON_REQUESTS_GROUPUSERLISTREQUEST_H_ */
diff --git a/src/Common/Requests/UserGroupListRequest.cpp b/src/Common/Requests/UserGroupListRequest.cpp
deleted file mode 100644
index 0c1a72f..0000000
--- a/src/Common/Requests/UserGroupListRequest.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * UserGroupListRequest.cpp
- *
- * 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/>.
- */
-
-#include "UserGroupListRequest.h"
-
-namespace Mad {
-namespace Common {
-namespace Requests {
-
-void UserGroupListRequest::sendRequest() {
- Common::XmlPacket packet;
- packet.setType("ListUserGroups");
- packet.set("uid", uid);
-
- sendPacket(packet);
-}
-
-}
-}
-}
diff --git a/src/Common/Requests/UserGroupListRequest.h b/src/Common/Requests/UserGroupListRequest.h
deleted file mode 100644
index 4cd27b6..0000000
--- a/src/Common/Requests/UserGroupListRequest.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * UserGroupListRequest.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_COMMON_REQUESTS_USERGROUPLISTREQUEST_H_
-#define MAD_COMMON_REQUESTS_USERGROUPLISTREQUEST_H_
-
-#include "../Request.h"
-
-namespace Mad {
-namespace Common {
-namespace Requests {
-
-class UserGroupListRequest : public Request {
- private:
- unsigned long uid;
-
- protected:
- virtual void sendRequest();
-
- public:
- UserGroupListRequest(Application *application, unsigned long uid0) : Request(application), uid(uid0) {}
-};
-
-}
-}
-}
-
-#endif /* MAD_COMMON_REQUESTS_USERGROUPLISTREQUEST_H_ */
diff --git a/src/Common/Requests/UserInfoRequest.cpp b/src/Common/Requests/UserInfoRequest.cpp
deleted file mode 100644
index b4b6940..0000000
--- a/src/Common/Requests/UserInfoRequest.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * UserInfoRequest.cpp
- *
- * 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/>.
- */
-
-#include "UserInfoRequest.h"
-
-namespace Mad {
-namespace Common {
-namespace Requests {
-
-void UserInfoRequest::sendRequest() {
- Common::XmlPacket packet;
- packet.setType("GetUserInfo");
- packet.set("uid", uid);
-
- sendPacket(packet);
-}
-
-}
-}
-}
diff --git a/src/Common/Requests/UserInfoRequest.h b/src/Common/Requests/UserInfoRequest.h
deleted file mode 100644
index 7b4b2fc..0000000
--- a/src/Common/Requests/UserInfoRequest.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * UserInfoRequest.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_COMMON_REQUESTS_USERINFOREQUEST_H_
-#define MAD_COMMON_REQUESTS_USERINFOREQUEST_H_
-
-#include "../Request.h"
-
-namespace Mad {
-namespace Common {
-namespace Requests {
-
-class UserInfoRequest : public Request {
- private:
- unsigned long uid;
-
- protected:
- virtual void sendRequest();
-
- public:
- UserInfoRequest(Application *application, unsigned long uid0) : Request(application), uid(uid0) {}
-};
-
-}
-}
-}
-
-#endif /* MAD_COMMON_REQUESTS_USERINFOREQUEST_H_ */
diff --git a/src/Common/Requests/UserListRequest.h b/src/Common/Requests/UserListRequest.h
deleted file mode 100644
index 9196166..0000000
--- a/src/Common/Requests/UserListRequest.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * UserListRequest.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_COMMON_REQUESTS_USERLISTREQUEST_H_
-#define MAD_COMMON_REQUESTS_USERLISTREQUEST_H_
-
-#include "SimpleRequest.h"
-
-namespace Mad {
-namespace Common {
-namespace Requests {
-
-class UserListRequest : public SimpleRequest {
- public:
- UserListRequest(Application *application) : SimpleRequest(application, "ListUsers") {}
-};
-
-}
-}
-}
-
-#endif /* MAD_COMMON_REQUESTS_USERLISTREQUEST_H_ */
diff --git a/src/Common/UserBackend.h b/src/Common/UserBackend.h
index 16db16c..8375551 100644
--- a/src/Common/UserBackend.h
+++ b/src/Common/UserBackend.h
@@ -45,36 +45,36 @@ class UserBackend {
UserBackend() {}
- virtual boost::shared_ptr<std::map<unsigned long, UserInfo> > getUserList() throw(Core::Exception) {
+ virtual boost::shared_ptr<const std::map<unsigned long, UserInfo> > getUserList() throw(Core::Exception) {
throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED));
}
- virtual boost::shared_ptr<UserInfo> getUserInfo(unsigned long uid _UNUSED_PARAMETER_) throw(Core::Exception) {
+ virtual boost::shared_ptr<const UserInfo> getUserInfo(unsigned long uid _UNUSED_PARAMETER_) throw(Core::Exception) {
throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED));
}
- virtual boost::shared_ptr<UserInfo> getUserInfoByName(const std::string &name _UNUSED_PARAMETER_) throw(Core::Exception) {
+ virtual boost::shared_ptr<const 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) {
+ virtual boost::shared_ptr<const 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, GroupInfo> > getGroupList() throw(Core::Exception) {
+ virtual boost::shared_ptr<const std::map<unsigned long, GroupInfo> > getGroupList() throw(Core::Exception) {
throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED));
}
- virtual std::string getGroupName(unsigned long gid _UNUSED_PARAMETER_) throw(Core::Exception) {
+ virtual boost::shared_ptr<const GroupInfo> getGroupInfo(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) {
+ virtual boost::shared_ptr<const GroupInfo> getGroupInfoByName(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) {
+ virtual boost::shared_ptr<const std::set<unsigned long> > getGroupUserList(unsigned long gid _UNUSED_PARAMETER_) throw(Core::Exception) {
throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED));
}
diff --git a/src/Common/UserManager.cpp b/src/Common/UserManager.cpp
index 6f5f548..66cbbf4 100644
--- a/src/Common/UserManager.cpp
+++ b/src/Common/UserManager.cpp
@@ -31,7 +31,7 @@ bool UserManager::Compare::operator() (boost::shared_ptr<UserBackend> b1, boost:
}
-boost::shared_ptr<std::map<unsigned long, UserInfo> > UserManager::getUserList() throw(Core::Exception) {
+boost::shared_ptr<const std::map<unsigned long, 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) {
@@ -47,7 +47,7 @@ boost::shared_ptr<std::map<unsigned long, UserInfo> > UserManager::getUserList()
throw e;
}
-boost::shared_ptr<UserInfo> UserManager::getUserInfo(unsigned long uid) throw(Core::Exception) {
+boost::shared_ptr<const 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) {
@@ -63,7 +63,7 @@ boost::shared_ptr<UserInfo> UserManager::getUserInfo(unsigned long uid) throw(Co
throw e;
}
-boost::shared_ptr<UserInfo> UserManager::getUserInfoByName(const std::string &name) throw(Core::Exception) {
+boost::shared_ptr<const 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) {
@@ -79,7 +79,7 @@ boost::shared_ptr<UserInfo> UserManager::getUserInfoByName(const std::string &na
throw e;
}
-boost::shared_ptr<std::set<unsigned long> > UserManager::getUserGroupList(unsigned long uid) throw(Core::Exception) {
+boost::shared_ptr<const 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) {
@@ -95,7 +95,7 @@ boost::shared_ptr<std::set<unsigned long> > UserManager::getUserGroupList(unsign
throw e;
}
-boost::shared_ptr<std::map<unsigned long, GroupInfo> > UserManager::getGroupList() throw(Core::Exception) {
+boost::shared_ptr<const std::map<unsigned long, 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) {
@@ -111,12 +111,12 @@ boost::shared_ptr<std::map<unsigned long, GroupInfo> > UserManager::getGroupList
throw e;
}
-std::string UserManager::getGroupName(unsigned long gid) throw(Core::Exception) {
+boost::shared_ptr<const GroupInfo> UserManager::getGroupInfo(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);
+ return (*backend)->getGroupInfo(gid);
}
catch(Core::Exception e2) {
if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED)
@@ -127,12 +127,12 @@ std::string UserManager::getGroupName(unsigned long gid) throw(Core::Exception)
throw e;
}
-unsigned long UserManager::getGroupId(const std::string &name) throw(Core::Exception) {
+boost::shared_ptr<const GroupInfo> UserManager::getGroupInfoByName(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);
+ return (*backend)->getGroupInfoByName(name);
}
catch(Core::Exception e2) {
if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED)
@@ -143,7 +143,7 @@ unsigned long UserManager::getGroupId(const std::string &name) throw(Core::Excep
throw e;
}
-boost::shared_ptr<std::set<unsigned long> > UserManager::getGroupUserList(unsigned long gid) throw(Core::Exception) {
+boost::shared_ptr<const 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) {
diff --git a/src/Common/UserManager.h b/src/Common/UserManager.h
index bdf39c1..215fde8 100644
--- a/src/Common/UserManager.h
+++ b/src/Common/UserManager.h
@@ -58,15 +58,15 @@ class UserManager : boost::noncopyable {
backends.erase(backend);
}
- boost::shared_ptr<std::map<unsigned long, UserInfo> > getUserList() throw(Core::Exception);
- boost::shared_ptr<UserInfo> getUserInfo(unsigned long uid) throw(Core::Exception);
- boost::shared_ptr<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, 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);
+ boost::shared_ptr<const std::map<unsigned long, UserInfo> > getUserList() throw(Core::Exception);
+ boost::shared_ptr<const UserInfo> getUserInfo(unsigned long uid) throw(Core::Exception);
+ boost::shared_ptr<const UserInfo> getUserInfoByName(const std::string &name) throw(Core::Exception);
+ boost::shared_ptr<const std::set<unsigned long> > getUserGroupList(unsigned long uid) throw(Core::Exception);
+
+ boost::shared_ptr<const std::map<unsigned long, GroupInfo> > getGroupList() throw(Core::Exception);
+ boost::shared_ptr<const GroupInfo> getGroupInfo(unsigned long gid) throw(Core::Exception);
+ boost::shared_ptr<const GroupInfo> getGroupInfoByName(const std::string &name) throw(Core::Exception);
+ boost::shared_ptr<const std::set<unsigned long> > getGroupUserList(unsigned long gid) throw(Core::Exception);
void setPassword(unsigned long uid, const std::string &password) throw(Core::Exception);
diff --git a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp
index 6378e08..31d2c16 100644
--- a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp
+++ b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp
@@ -27,12 +27,12 @@ namespace RequestHandlers {
void UserRequestHandlerGroup::handleUserListRequest(boost::shared_ptr<const Common::XmlPacket> packet _UNUSED_PARAMETER_, Common::XmlPacket *ret,
Common::Connection *connection _UNUSED_PARAMETER_) {
- boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > info = application->getUserManager()->getUserList();
+ boost::shared_ptr<const std::map<unsigned long, Common::UserInfo> > info = application->getUserManager()->getUserList();
ret->setType("OK");
Common::XmlPacket::List *list = ret->createList("users");
- for(std::map<unsigned long, Common::UserInfo>::iterator user = info->begin(); user != info->end(); ++user) {
+ for(std::map<unsigned long, Common::UserInfo>::const_iterator user = info->begin(); user != info->end(); ++user) {
Common::XmlPacket::List::iterator entry = list->addEntry();
entry->set("uid", user->second.getUid());
@@ -44,7 +44,13 @@ void UserRequestHandlerGroup::handleUserListRequest(boost::shared_ptr<const Comm
void UserRequestHandlerGroup::handleUserInfoRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret,
Common::Connection *connection _UNUSED_PARAMETER_) {
- boost::shared_ptr<Common::UserInfo> info = application->getUserManager()->getUserInfo(packet->get<unsigned long>("uid"));
+ boost::shared_ptr<const Common::UserInfo> info;
+
+ unsigned long uid = packet->get<unsigned long>("uid");
+ if(uid)
+ info = application->getUserManager()->getUserInfo(uid);
+ else
+ info = application->getUserManager()->getUserInfoByName(packet->get<const std::string&>("name"));
ret->setType("OK");
@@ -56,12 +62,12 @@ void UserRequestHandlerGroup::handleUserInfoRequest(boost::shared_ptr<const Comm
void UserRequestHandlerGroup::handleUserGroupListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret,
Common::Connection *connection _UNUSED_PARAMETER_) {
- boost::shared_ptr<std::set<unsigned long> > groups = application->getUserManager()->getUserGroupList(packet->get<unsigned long>("uid"));
+ boost::shared_ptr<const std::set<unsigned long> > groups = application->getUserManager()->getUserGroupList(packet->get<unsigned long>("uid"));
ret->setType("OK");
Common::XmlPacket::List *list = ret->createList("groups");
- for(std::set<unsigned long>::iterator group = groups->begin(); group != groups->end(); ++group) {
+ for(std::set<unsigned long>::const_iterator group = groups->begin(); group != groups->end(); ++group) {
Common::XmlPacket::List::iterator entry = list->addEntry();
entry->set("gid", *group);
@@ -70,12 +76,12 @@ void UserRequestHandlerGroup::handleUserGroupListRequest(boost::shared_ptr<const
void UserRequestHandlerGroup::handleGroupListRequest(boost::shared_ptr<const Common::XmlPacket> packet _UNUSED_PARAMETER_, Common::XmlPacket *ret,
Common::Connection *connection _UNUSED_PARAMETER_) {
- boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > info = application->getUserManager()->getGroupList();
+ boost::shared_ptr<const std::map<unsigned long, Common::GroupInfo> > info = application->getUserManager()->getGroupList();
ret->setType("OK");
Common::XmlPacket::List *list = ret->createList("groups");
- for(std::map<unsigned long, Common::GroupInfo>::iterator group = info->begin(); group != info->end(); ++group) {
+ for(std::map<unsigned long, Common::GroupInfo>::const_iterator group = info->begin(); group != info->end(); ++group) {
Common::XmlPacket::List::iterator entry = list->addEntry();
entry->set("gid", group->second.getGid());
@@ -83,14 +89,30 @@ void UserRequestHandlerGroup::handleGroupListRequest(boost::shared_ptr<const Com
}
}
+void UserRequestHandlerGroup::handleGroupInfoRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret,
+ Common::Connection *connection _UNUSED_PARAMETER_) {
+ boost::shared_ptr<const Common::GroupInfo> info;
+
+ unsigned long gid = packet->get<unsigned long>("gid");
+ if(gid)
+ info = application->getUserManager()->getGroupInfo(gid);
+ else
+ info = application->getUserManager()->getGroupInfoByName(packet->get<const std::string&>("name"));
+
+ ret->setType("OK");
+
+ ret->set("gid", info->getGid());
+ ret->set("name", info->getName());
+}
+
void UserRequestHandlerGroup::handleGroupUserListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret,
Common::Connection *connection _UNUSED_PARAMETER_) {
- boost::shared_ptr<std::set<unsigned long> > users = application->getUserManager()->getGroupUserList(packet->get<unsigned long>("gid"));
+ boost::shared_ptr<const std::set<unsigned long> > users = application->getUserManager()->getGroupUserList(packet->get<unsigned long>("gid"));
ret->setType("OK");
Common::XmlPacket::List *list = ret->createList("users");
- for(std::set<unsigned long>::iterator user = users->begin(); user != users->end(); ++user) {
+ for(std::set<unsigned long>::const_iterator user = users->begin(); user != users->end(); ++user) {
Common::XmlPacket::List::iterator entry = list->addEntry();
entry->set("uid", *user);
@@ -101,7 +123,9 @@ UserRequestHandlerGroup::UserRequestHandlerGroup(Application *application0) : ap
registerHandler("ListUsers", boost::bind(&UserRequestHandlerGroup::handleUserListRequest, this, _1, _2, _3));
registerHandler("GetUserInfo", boost::bind(&UserRequestHandlerGroup::handleUserInfoRequest, this, _1, _2, _3));
registerHandler("ListUserGroups", boost::bind(&UserRequestHandlerGroup::handleUserGroupListRequest, this, _1, _2, _3));
+
registerHandler("ListGroups", boost::bind(&UserRequestHandlerGroup::handleGroupListRequest, this, _1, _2, _3));
+ registerHandler("GetGroupInfo", boost::bind(&UserRequestHandlerGroup::handleGroupInfoRequest, this, _1, _2, _3));
registerHandler("ListGroupUsers", boost::bind(&UserRequestHandlerGroup::handleGroupUserListRequest, this, _1, _2, _3));
}
diff --git a/src/Server/RequestHandlers/UserRequestHandlerGroup.h b/src/Server/RequestHandlers/UserRequestHandlerGroup.h
index 2a17a9a..744f895 100644
--- a/src/Server/RequestHandlers/UserRequestHandlerGroup.h
+++ b/src/Server/RequestHandlers/UserRequestHandlerGroup.h
@@ -36,7 +36,9 @@ class UserRequestHandlerGroup : public Common::RequestHandlers::SimpleRequestHan
void handleUserListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection);
void handleUserInfoRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection);
void handleUserGroupListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection);
+
void handleGroupListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection);
+ void handleGroupInfoRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection);
void handleGroupUserListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret, Common::Connection *connection);
public:
diff --git a/src/madc.cpp b/src/madc.cpp
index 55c2be7..a0cfb61 100644
--- a/src/madc.cpp
+++ b/src/madc.cpp
@@ -20,6 +20,8 @@
#include "Core/ConfigManager.h"
#include "Common/ClientConnection.h"
+#include "Common/UserManager.h"
+#include "Common/Backends/NetworkUserBackend.h"
#include "Common/RequestManager.h"
#include "Common/Requests/IdentifyRequest.h"
@@ -77,6 +79,9 @@ int main(int argc, char *argv[]) {
std::cerr << " done." << std::endl << std::endl;
+ boost::shared_ptr<Common::Backends::NetworkUserBackend> networkUserBackend(new Common::Backends::NetworkUserBackend(&application, connection));
+ application.getUserManager()->registerBackend(networkUserBackend);
+
Client::CommandParser commandParser(&application, connection);
while(connection->isConnected() && !commandParser.willDisconnect()) {
@@ -94,6 +99,8 @@ int main(int argc, char *argv[]) {
connection->waitWhileConnected();
+ application.getUserManager()->unregisterBackend(networkUserBackend);
+
application.getRequestManager()->unregisterConnection(connection);
}
catch(Core::Exception &e) {
diff --git a/src/modules/UserBackendMysql/UserBackendMysql.cpp b/src/modules/UserBackendMysql/UserBackendMysql.cpp
index 904c9a6..e6e6dda 100644
--- a/src/modules/UserBackendMysql/UserBackendMysql.cpp
+++ b/src/modules/UserBackendMysql/UserBackendMysql.cpp
@@ -129,14 +129,14 @@ void UserBackendMysql::configFinished() {
}
-boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > UserBackendMysql::getUserList() throw(Core::Exception) {
+boost::shared_ptr<const std::map<unsigned long, Common::UserInfo> > UserBackendMysql::getUserList() throw(Core::Exception) {
application->getThreadManager()->detach();
if(!mysql || mysql_ping(mysql))
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
mysql_real_query(mysql, queryListUsers.c_str(), queryListUsers.length());
- MYSQL_RES *result = mysql_use_result(mysql);
+ MYSQL_RES *result = mysql_store_result(mysql);
if(!result || mysql_num_fields(result) < 4)
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
@@ -155,7 +155,7 @@ boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > UserBackendMysql::
return users;
}
-boost::shared_ptr<Common::UserInfo> UserBackendMysql::getUserInfo(unsigned long uid) throw(Core::Exception) {
+boost::shared_ptr<const Common::UserInfo> UserBackendMysql::getUserInfo(unsigned long uid) throw(Core::Exception) {
application->getThreadManager()->detach();
if(!mysql || mysql_ping(mysql))
@@ -171,7 +171,7 @@ boost::shared_ptr<Common::UserInfo> UserBackendMysql::getUserInfo(unsigned long
query = boost::regex_replace(query, boost::regex("\\{UID\\}"), tmp.str(), boost::match_default);
mysql_real_query(mysql, query.c_str(), query.length());
- MYSQL_RES *result = mysql_use_result(mysql);
+ MYSQL_RES *result = mysql_store_result(mysql);
if(!result || mysql_num_fields(result) < 4)
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
@@ -192,7 +192,7 @@ boost::shared_ptr<Common::UserInfo> UserBackendMysql::getUserInfo(unsigned long
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
}
-boost::shared_ptr<Common::UserInfo> UserBackendMysql::getUserInfoByName(const std::string &name) throw(Core::Exception) {
+boost::shared_ptr<const Common::UserInfo> UserBackendMysql::getUserInfoByName(const std::string &name) throw(Core::Exception) {
application->getThreadManager()->detach();
if(!mysql || mysql_ping(mysql))
@@ -205,7 +205,7 @@ boost::shared_ptr<Common::UserInfo> UserBackendMysql::getUserInfoByName(const st
std::string query = boost::regex_replace(queryUserByName, boost::regex("\\{USER\\}"), "\""+std::string(escapedName.get())+"\"", boost::match_default);
mysql_real_query(mysql, query.c_str(), query.length());
- MYSQL_RES *result = mysql_use_result(mysql);
+ MYSQL_RES *result = mysql_store_result(mysql);
if(!result || mysql_num_fields(result) < 4)
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
@@ -226,7 +226,7 @@ boost::shared_ptr<Common::UserInfo> UserBackendMysql::getUserInfoByName(const st
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
}
-boost::shared_ptr<std::set<unsigned long> > UserBackendMysql::getUserGroupList(unsigned long uid) throw(Core::Exception) {
+boost::shared_ptr<const std::set<unsigned long> > UserBackendMysql::getUserGroupList(unsigned long uid) throw(Core::Exception) {
application->getThreadManager()->detach();
if(!mysql || mysql_ping(mysql))
@@ -240,7 +240,7 @@ boost::shared_ptr<std::set<unsigned long> > UserBackendMysql::getUserGroupList(u
std::string query = boost::regex_replace(queryListUserGroups, boost::regex("\\{UID\\}"), tmp.str(), boost::match_default);
mysql_real_query(mysql, query.c_str(), query.length());
- MYSQL_RES *result = mysql_use_result(mysql);
+ MYSQL_RES *result = mysql_store_result(mysql);
if(!result || mysql_num_fields(result) < 1)
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
@@ -254,14 +254,14 @@ boost::shared_ptr<std::set<unsigned long> > UserBackendMysql::getUserGroupList(u
}
-boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > UserBackendMysql::getGroupList() throw(Core::Exception) {
+boost::shared_ptr<const std::map<unsigned long, Common::GroupInfo> > UserBackendMysql::getGroupList() throw(Core::Exception) {
application->getThreadManager()->detach();
if(!mysql || mysql_ping(mysql))
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
mysql_real_query(mysql, queryListGroups.c_str(), queryListGroups.length());
- MYSQL_RES *result = mysql_use_result(mysql);
+ MYSQL_RES *result = mysql_store_result(mysql);
if(!result || mysql_num_fields(result) < 2)
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
@@ -277,7 +277,7 @@ boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > UserBackendMysql:
return groups;
}
-std::string UserBackendMysql::getGroupName(unsigned long gid) throw(Core::Exception) {
+boost::shared_ptr<const Common::GroupInfo> UserBackendMysql::getGroupInfo(unsigned long gid) throw(Core::Exception) {
application->getThreadManager()->detach();
if(!mysql || mysql_ping(mysql))
@@ -293,7 +293,7 @@ std::string UserBackendMysql::getGroupName(unsigned long gid) throw(Core::Except
query = boost::regex_replace(query, boost::regex("\\{GID\\}"), tmp.str(), boost::match_default);
mysql_real_query(mysql, query.c_str(), query.length());
- MYSQL_RES *result = mysql_use_result(mysql);
+ MYSQL_RES *result = mysql_store_result(mysql);
if(!result || mysql_num_fields(result) < 2)
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
@@ -301,12 +301,12 @@ std::string UserBackendMysql::getGroupName(unsigned long gid) throw(Core::Except
MYSQL_ROW row = mysql_fetch_row(result);
if(row)
- return row[1];
+ return boost::shared_ptr<Common::GroupInfo>(new Common::GroupInfo(strtoul(row[0], 0, 10), row[1]));
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
}
-unsigned long UserBackendMysql::getGroupId(const std::string &name) throw(Core::Exception) {
+boost::shared_ptr<const Common::GroupInfo> UserBackendMysql::getGroupInfoByName(const std::string &name) throw(Core::Exception) {
application->getThreadManager()->detach();
if(!mysql || mysql_ping(mysql))
@@ -319,7 +319,7 @@ unsigned long UserBackendMysql::getGroupId(const std::string &name) throw(Core::
std::string query = boost::regex_replace(queryGroupByName, boost::regex("\\{GROUP\\}"), "\""+std::string(escapedName.get())+"\"", boost::match_default);
mysql_real_query(mysql, query.c_str(), query.length());
- MYSQL_RES *result = mysql_use_result(mysql);
+ MYSQL_RES *result = mysql_store_result(mysql);
if(!result || mysql_num_fields(result) < 2)
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
@@ -327,12 +327,12 @@ unsigned long UserBackendMysql::getGroupId(const std::string &name) throw(Core::
MYSQL_ROW row = mysql_fetch_row(result);
if(row)
- return strtoul(row[0], 0, 10);
+ return boost::shared_ptr<Common::GroupInfo>(new Common::GroupInfo(strtoul(row[0], 0, 10), row[1]));
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
}
-boost::shared_ptr<std::set<unsigned long> > UserBackendMysql::getGroupUserList(unsigned long gid) throw(Core::Exception) {
+boost::shared_ptr<const std::set<unsigned long> > UserBackendMysql::getGroupUserList(unsigned long gid) throw(Core::Exception) {
application->getThreadManager()->detach();
if(!mysql || mysql_ping(mysql))
@@ -346,7 +346,7 @@ boost::shared_ptr<std::set<unsigned long> > UserBackendMysql::getGroupUserList(u
std::string query = boost::regex_replace(queryListGroupUsers, boost::regex("\\{GID\\}"), tmp.str(), boost::match_default);
mysql_real_query(mysql, query.c_str(), query.length());
- MYSQL_RES *result = mysql_use_result(mysql);
+ MYSQL_RES *result = mysql_store_result(mysql);
if(!result || mysql_num_fields(result) < 1)
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
diff --git a/src/modules/UserBackendMysql/UserBackendMysql.h b/src/modules/UserBackendMysql/UserBackendMysql.h
index 77f0700..7832e95 100644
--- a/src/modules/UserBackendMysql/UserBackendMysql.h
+++ b/src/modules/UserBackendMysql/UserBackendMysql.h
@@ -50,15 +50,15 @@ class UserBackendMysql : public Common::UserBackend, private Core::Configurable
virtual bool handleConfigEntry(const Core::ConfigEntry &entry, bool);
virtual void configFinished();
- virtual boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > getUserList() throw(Core::Exception);
- virtual boost::shared_ptr<Common::UserInfo> getUserInfo(unsigned long uid) throw(Core::Exception);
- virtual boost::shared_ptr<Common::UserInfo> getUserInfoByName(const std::string &name) throw(Core::Exception);
- virtual boost::shared_ptr<std::set<unsigned long> > getUserGroupList(unsigned long uid) throw(Core::Exception);
-
- virtual boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > getGroupList() throw(Core::Exception);
- virtual std::string getGroupName(unsigned long gid) throw(Core::Exception);
- virtual unsigned long getGroupId(const std::string &name) throw(Core::Exception);
- virtual boost::shared_ptr<std::set<unsigned long> > getGroupUserList(unsigned long gid) throw(Core::Exception);
+ virtual boost::shared_ptr<const std::map<unsigned long, Common::UserInfo> > getUserList() throw(Core::Exception);
+ virtual boost::shared_ptr<const Common::UserInfo> getUserInfo(unsigned long uid) throw(Core::Exception);
+ virtual boost::shared_ptr<const Common::UserInfo> getUserInfoByName(const std::string &name) throw(Core::Exception);
+ virtual boost::shared_ptr<const std::set<unsigned long> > getUserGroupList(unsigned long uid) throw(Core::Exception);
+
+ virtual boost::shared_ptr<const std::map<unsigned long, Common::GroupInfo> > getGroupList() throw(Core::Exception);
+ virtual boost::shared_ptr<const Common::GroupInfo> getGroupInfo(unsigned long gid) throw(Core::Exception);
+ virtual boost::shared_ptr<const Common::GroupInfo> getGroupInfoByName(const std::string &name) throw(Core::Exception);
+ virtual boost::shared_ptr<const std::set<unsigned long> > getGroupUserList(unsigned long gid) throw(Core::Exception);
public:
UserBackendMysql(Common::Application *application0) : application(application0), port(0), mysql(0) {