diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2009-05-29 18:02:12 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2009-05-29 18:02:12 +0200 |
commit | cb8e66c1b1f1c8076053d71347d0b1f96ca0bca1 (patch) | |
tree | e8340c2830b5d4614cfb44bbb309003a3eb6525c /src/Server/RequestHandlers | |
parent | 9bb64c7c90e6481ed3689a2b9380496da4ce09ff (diff) | |
download | mad-cb8e66c1b1f1c8076053d71347d0b1f96ca0bca1.tar mad-cb8e66c1b1f1c8076053d71347d0b1f96ca0bca1.zip |
Requests UserGroupList und GroupUserList implementiert
Diffstat (limited to 'src/Server/RequestHandlers')
5 files changed, 234 insertions, 2 deletions
diff --git a/src/Server/RequestHandlers/CMakeLists.txt b/src/Server/RequestHandlers/CMakeLists.txt index 9215348..fe4e71d 100644 --- a/src/Server/RequestHandlers/CMakeLists.txt +++ b/src/Server/RequestHandlers/CMakeLists.txt @@ -3,8 +3,8 @@ include_directories(${INCLUDES}) add_library(ServerRequestHandlers DaemonCommandRequestHandler.cpp DaemonFSInfoRequestHandler.cpp DaemonListRequestHandler.cpp DaemonStatusRequestHandler.cpp - GroupListRequestHandler.cpp IdentifyRequestHandler.cpp - LogRequestHandler.cpp UserInfoRequestHandler.cpp + GroupListRequestHandler.cpp GroupUserListRequestHandler.cpp IdentifyRequestHandler.cpp + LogRequestHandler.cpp UserGroupListRequestHandler.cpp UserInfoRequestHandler.cpp UserListRequestHandler.cpp ) target_link_libraries(ServerRequestHandlers Server ${KRB5_LIBRARIES}) diff --git a/src/Server/RequestHandlers/GroupUserListRequestHandler.cpp b/src/Server/RequestHandlers/GroupUserListRequestHandler.cpp new file mode 100644 index 0000000..df1253a --- /dev/null +++ b/src/Server/RequestHandlers/GroupUserListRequestHandler.cpp @@ -0,0 +1,74 @@ +/* + * GroupUserListRequestHandler.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 "GroupUserListRequestHandler.h" +#include "../UserManager.h" +#include <Net/Exception.h> +#include <Common/Logger.h> + +namespace Mad { +namespace Server { +namespace RequestHandlers { + +void GroupUserListRequestHandler::handlePacket(const Common::XmlPacket &packet) { + if(packet.getType() != "ListGroupUsers") { + Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet."); + + Common::XmlPacket ret; + ret.setType("Error"); + ret.add("ErrorCode", Net::Exception::UNEXPECTED_PACKET); + + sendPacket(ret); + + signalFinished()(); + return; + } + + // TODO Require authentication + + Common::XmlPacket ret; + + try { + boost::shared_ptr<std::set<unsigned long> > users = UserManager::get()->getGroupUserList((unsigned long)packet["gid"]); + + ret.setType("OK"); + ret.addList("users"); + + for(std::set<unsigned long>::iterator user = users->begin(); user != users->end(); ++user) { + ret["users"].addEntry(); + Common::XmlPacket::Entry &entry = ret["users"].back(); + + entry.add("uid", *user); + } + } + catch(Net::Exception e) { + ret.setType("Error"); + ret.add("ErrorCode", e.getErrorCode()); + ret.add("SubCode", e.getSubCode()); + ret.add("SubSubCode", e.getSubSubCode()); + ret.add("Where", e.getWhere()); + } + + sendPacket(ret); + signalFinished()(); +} + +} +} +} diff --git a/src/Server/RequestHandlers/GroupUserListRequestHandler.h b/src/Server/RequestHandlers/GroupUserListRequestHandler.h new file mode 100644 index 0000000..5e50961 --- /dev/null +++ b/src/Server/RequestHandlers/GroupUserListRequestHandler.h @@ -0,0 +1,42 @@ +/* + * GroupUserListRequestHandler.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_REQUESTHANDLERS_GROUPUSERLISTREQUESTHANDLER_H_ +#define MAD_SERVER_REQUESTHANDLERS_GROUPUSERLISTREQUESTHANDLER_H_ + +#include <Common/RequestHandler.h> + +namespace Mad { +namespace Server { +namespace RequestHandlers { + +class GroupUserListRequestHandler : public Common::RequestHandler { + protected: + virtual void handlePacket(const Common::XmlPacket &packet); + + public: + GroupUserListRequestHandler(Common::Connection *connection, uint16_t requestId) + : RequestHandler(connection, requestId) {} +}; + +} +} +} + +#endif /* MAD_SERVER_REQUESTHANDLERS_GROUPUSERLISTREQUESTHANDLER_H_ */ diff --git a/src/Server/RequestHandlers/UserGroupListRequestHandler.cpp b/src/Server/RequestHandlers/UserGroupListRequestHandler.cpp new file mode 100644 index 0000000..e127649 --- /dev/null +++ b/src/Server/RequestHandlers/UserGroupListRequestHandler.cpp @@ -0,0 +1,74 @@ +/* + * UserGroupListRequestHandler.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 "UserGroupListRequestHandler.h" +#include "../UserManager.h" +#include <Net/Exception.h> +#include <Common/Logger.h> + +namespace Mad { +namespace Server { +namespace RequestHandlers { + +void UserGroupListRequestHandler::handlePacket(const Common::XmlPacket &packet) { + if(packet.getType() != "ListUserGroups") { + Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet."); + + Common::XmlPacket ret; + ret.setType("Error"); + ret.add("ErrorCode", Net::Exception::UNEXPECTED_PACKET); + + sendPacket(ret); + + signalFinished()(); + return; + } + + // TODO Require authentication + + Common::XmlPacket ret; + + try { + boost::shared_ptr<std::set<unsigned long> > groups = UserManager::get()->getUserGroupList((unsigned long)packet["uid"]); + + ret.setType("OK"); + ret.addList("groups"); + + for(std::set<unsigned long>::iterator group = groups->begin(); group != groups->end(); ++group) { + ret["groups"].addEntry(); + Common::XmlPacket::Entry &entry = ret["groups"].back(); + + entry.add("gid", *group); + } + } + catch(Net::Exception e) { + ret.setType("Error"); + ret.add("ErrorCode", e.getErrorCode()); + ret.add("SubCode", e.getSubCode()); + ret.add("SubSubCode", e.getSubSubCode()); + ret.add("Where", e.getWhere()); + } + + sendPacket(ret); + signalFinished()(); +} + +} +} +} diff --git a/src/Server/RequestHandlers/UserGroupListRequestHandler.h b/src/Server/RequestHandlers/UserGroupListRequestHandler.h new file mode 100644 index 0000000..8e2add0 --- /dev/null +++ b/src/Server/RequestHandlers/UserGroupListRequestHandler.h @@ -0,0 +1,42 @@ +/* + * UserGroupListRequestHandler.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_REQUESTHANDLERS_USERGROUPLISTREQUESTHANDLER_H_ +#define MAD_SERVER_REQUESTHANDLERS_USERGROUPLISTREQUESTHANDLER_H_ + +#include <Common/RequestHandler.h> + +namespace Mad { +namespace Server { +namespace RequestHandlers { + +class UserGroupListRequestHandler : public Common::RequestHandler { + protected: + virtual void handlePacket(const Common::XmlPacket &packet); + + public: + UserGroupListRequestHandler(Common::Connection *connection, uint16_t requestId) + : RequestHandler(connection, requestId) {} +}; + +} +} +} + +#endif /* MAD_SERVER_REQUESTHANDLERS_USERGROUPLISTREQUESTHANDLER_H_ */ |