summaryrefslogtreecommitdiffstats
path: root/src/Server
diff options
context:
space:
mode:
Diffstat (limited to 'src/Server')
-rw-r--r--src/Server/ConnectionManager.cpp14
-rw-r--r--src/Server/ConnectionManager.h2
-rw-r--r--src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp16
-rw-r--r--src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp4
-rw-r--r--src/Server/RequestHandlers/UserRequestHandlerGroup.cpp98
5 files changed, 27 insertions, 107 deletions
diff --git a/src/Server/ConnectionManager.cpp b/src/Server/ConnectionManager.cpp
index f09f9e3..25e088a 100644
--- a/src/Server/ConnectionManager.cpp
+++ b/src/Server/ConnectionManager.cpp
@@ -120,31 +120,31 @@ bool ConnectionManager::handleConfigEntry(const Core::ConfigEntry &entry, bool h
if(entry[0].getKey().matches("Listen") && entry[1].isEmpty()) {
try {
- listenerAddresses.push_back(parseAddress(entry[0][0].extract()));
+ listenerAddresses.push_back(parseAddress(entry[0][0].toString()));
}
catch(Core::Exception &e) {
- application->logf(Core::Logger::LOG_WARNING, "ConnectionManager: Invalid listen address '%s'", entry[0][0].extract().c_str());
+ application->logf(Core::Logger::LOG_WARNING, "ConnectionManager: Invalid listen address '%s'", entry[0][0].toLocale().c_str());
}
return true;
}
else if(entry[0].getKey().matches("X509TrustFile") && entry[1].isEmpty()) {
- x509TrustFile = entry[0][0].extract();
+ x509TrustFile = entry[0][0];
return true;
}
else if(entry[0].getKey().matches("X509CrlFile") && entry[1].isEmpty()) {
- x509CrlFile = entry[0][0].extract();
+ x509CrlFile = entry[0][0];
return true;
}
else if(entry[0].getKey().matches("X509CertFile") && entry[1].isEmpty()) {
- x509CertFile = entry[0][0].extract();
+ x509CertFile = entry[0][0];
return true;
}
else if(entry[0].getKey().matches("X509KeyFile") && entry[1].isEmpty()) {
- x509KeyFile = entry[0][0].extract();
+ x509KeyFile = entry[0][0];
return true;
}
@@ -156,7 +156,7 @@ bool ConnectionManager::handleConfigEntry(const Core::ConfigEntry &entry, bool h
return true;
}
else if(entry[1].getKey().matches("IpAddress") && entry[2].isEmpty()) {
- daemonInfo[entry[0][0]].setIP(entry[1][0].extract());
+ daemonInfo[entry[0][0]].setIP(entry[1][0].toString());
return true;
}
diff --git a/src/Server/ConnectionManager.h b/src/Server/ConnectionManager.h
index dab1892..7e9dab0 100644
--- a/src/Server/ConnectionManager.h
+++ b/src/Server/ConnectionManager.h
@@ -107,7 +107,7 @@ class MAD_SERVER_EXPORT ConnectionManager : public Core::Configurable, private b
Application *application;
- std::string x509TrustFile, x509CrlFile, x509CertFile, x509KeyFile;
+ Core::String x509TrustFile, x509CrlFile, x509CertFile, x509KeyFile;
std::vector<boost::asio::ip::tcp::endpoint> listenerAddresses;
std::list<boost::shared_ptr<Net::Listener> > listeners;
diff --git a/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp b/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp
index d446485..a1c492b 100644
--- a/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp
+++ b/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp
@@ -100,23 +100,13 @@ void ConnectionRequestHandlerGroup::handleIdentifyRequest(boost::shared_ptr<cons
void ConnectionRequestHandlerGroup::handleLogRequest(boost::shared_ptr<const Common::XmlData> packet, Common::XmlData *ret, Common::Connection *connection) {
// TODO Require authentication
- boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time);
-
- const Core::String &timestr = packet->get<const Core::String&>("timestamp");
- if(!timestr.isEmpty()) {
- try {
- timestamp = boost::posix_time::from_iso_string(timestr.extract());
- }
- catch(...) {}
- }
-
try {
application->getLogManager()->log(
static_cast<Core::Logger::MessageCategory>(packet->get<long>("category")),
static_cast<Core::Logger::MessageLevel>(packet->get<long>("level")),
- timestamp,
- packet->get<const Core::String&>("message").extract(),
- application->getConnectionManager()->getDaemonName(connection).extract());
+ packet->get<boost::posix_time::ptime>("timestamp"),
+ packet->get<const Core::String&>("message"),
+ application->getConnectionManager()->getDaemonName(connection));
}
catch(Core::Exception &e) {
application->logf(Core::Logger::LOG_ERROR, "Can't determine daemon name: %s", e.what());
diff --git a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp
index 8f6909e..c80f493 100644
--- a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp
+++ b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp
@@ -69,7 +69,7 @@ void DaemonRequestHandlerGroup::DaemonRequestHandler::handlePacket(boost::shared
ret.set("ErrorCode", e.getErrorCode());
ret.set("SubCode", e.getSubCode());
ret.set("SubSubCode", e.getSubSubCode());
- ret.set("Where", e.getWhere().c_str());
+ ret.set("Where", e.getWhere());
sendPacket(ret);
signalFinished();
@@ -83,7 +83,7 @@ void DaemonRequestHandlerGroup::DaemonRequestHandler::requestFinished(boost::sha
ret.set("ErrorCode", error.getErrorCode());
ret.set("SubCode", error.getSubCode());
ret.set("SubSubCode", error.getSubSubCode());
- ret.set("Where", error.getWhere().c_str());
+ ret.set("Where", error.getWhere());
sendPacket(ret);
}
diff --git a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp
index f43ec86..5a7e3f9 100644
--- a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp
+++ b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp
@@ -34,22 +34,12 @@ void UserRequestHandlerGroup::handleUserListRequest(boost::shared_ptr<const Comm
if(!connection->isAuthenticated())
throw(Core::Exception(Core::Exception::PERMISSION));
- boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time);
-
- const Core::String &timestr = packet->get<const Core::String&>("timestamp");
- if(!timestr.isEmpty()) {
- try {
- timestamp = boost::posix_time::from_iso_string(timestr.extract());
- }
- catch(...) {}
- }
+ boost::posix_time::ptime timestamp = packet->get<boost::posix_time::ptime>("timestamp");
boost::shared_ptr<const std::map<unsigned long, Common::UserInfo> > users = application->getUserManager()->getUserList(&timestamp);
ret->setType("OK");
-
- if(!timestamp.is_not_a_date_time())
- ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str());
+ ret->set("timestamp", timestamp);
if(users) {
Common::XmlData::List *list = ret->createList("users");
@@ -70,15 +60,7 @@ void UserRequestHandlerGroup::handleUserInfoRequest(boost::shared_ptr<const Comm
if(!connection->isAuthenticated())
throw(Core::Exception(Core::Exception::PERMISSION));
- boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time);
-
- const Core::String &timestr = packet->get<const Core::String&>("timestamp");
- if(!timestr.isEmpty()) {
- try {
- timestamp = boost::posix_time::from_iso_string(timestr.extract());
- }
- catch(...) {}
- }
+ boost::posix_time::ptime timestamp = packet->get<boost::posix_time::ptime>("timestamp");
boost::shared_ptr<const Common::UserInfo> info;
@@ -89,9 +71,7 @@ void UserRequestHandlerGroup::handleUserInfoRequest(boost::shared_ptr<const Comm
info = application->getUserManager()->getUserInfoByName(packet->get<const Core::String&>("name"), &timestamp);
ret->setType("OK");
-
- if(!timestamp.is_not_a_date_time())
- ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str());
+ ret->set("timestamp", timestamp);
if(info) {
ret->set("uid", info->getUid());
@@ -106,22 +86,12 @@ void UserRequestHandlerGroup::handleUserGroupListRequest(boost::shared_ptr<const
if(!connection->isAuthenticated())
throw(Core::Exception(Core::Exception::PERMISSION));
- boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time);
-
- const Core::String &timestr = packet->get<const Core::String&>("timestamp");
- if(!timestr.isEmpty()) {
- try {
- timestamp = boost::posix_time::from_iso_string(timestr.extract());
- }
- catch(...) {}
- }
+ boost::posix_time::ptime timestamp = packet->get<boost::posix_time::ptime>("timestamp");
boost::shared_ptr<const std::set<unsigned long> > groups = application->getUserManager()->getUserGroupList(packet->get<unsigned long>("uid"), &timestamp);
ret->setType("OK");
-
- if(!timestamp.is_not_a_date_time())
- ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str());
+ ret->set("timestamp", timestamp);
if(groups) {
Common::XmlData::List *list = ret->createList("groups");
@@ -139,22 +109,12 @@ void UserRequestHandlerGroup::handleGroupListRequest(boost::shared_ptr<const Com
if(!connection->isAuthenticated())
throw(Core::Exception(Core::Exception::PERMISSION));
- boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time);
-
- const Core::String &timestr = packet->get<const Core::String&>("timestamp");
- if(!timestr.isEmpty()) {
- try {
- timestamp = boost::posix_time::from_iso_string(timestr.extract());
- }
- catch(...) {}
- }
+ boost::posix_time::ptime timestamp = packet->get<boost::posix_time::ptime>("timestamp");
boost::shared_ptr<const std::map<unsigned long, Common::GroupInfo> > groups = application->getUserManager()->getGroupList(&timestamp);
ret->setType("OK");
-
- if(!timestamp.is_not_a_date_time())
- ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str());
+ ret->set("timestamp", timestamp);
if(groups) {
Common::XmlData::List *list = ret->createList("groups");
@@ -173,15 +133,7 @@ void UserRequestHandlerGroup::handleGroupInfoRequest(boost::shared_ptr<const Com
if(!connection->isAuthenticated())
throw(Core::Exception(Core::Exception::PERMISSION));
- boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time);
-
- const Core::String &timestr = packet->get<const Core::String&>("timestamp");
- if(!timestr.isEmpty()) {
- try {
- timestamp = boost::posix_time::from_iso_string(timestr.extract());
- }
- catch(...) {}
- }
+ boost::posix_time::ptime timestamp = packet->get<boost::posix_time::ptime>("timestamp");
boost::shared_ptr<const Common::GroupInfo> info;
@@ -192,9 +144,7 @@ void UserRequestHandlerGroup::handleGroupInfoRequest(boost::shared_ptr<const Com
info = application->getUserManager()->getGroupInfoByName(packet->get<const Core::String&>("name"), &timestamp);
ret->setType("OK");
-
- if(!timestamp.is_not_a_date_time())
- ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str());
+ ret->set("timestamp", timestamp);
if(info) {
ret->set("gid", info->getGid());
@@ -207,22 +157,12 @@ void UserRequestHandlerGroup::handleGroupUserListRequest(boost::shared_ptr<const
if(!connection->isAuthenticated())
throw(Core::Exception(Core::Exception::PERMISSION));
- boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time);
-
- const Core::String &timestr = packet->get<const Core::String&>("timestamp");
- if(!timestr.isEmpty()) {
- try {
- timestamp = boost::posix_time::from_iso_string(timestr.extract());
- }
- catch(...) {}
- }
+ boost::posix_time::ptime timestamp = packet->get<boost::posix_time::ptime>("timestamp");
boost::shared_ptr<const std::set<unsigned long> > users = application->getUserManager()->getGroupUserList(packet->get<unsigned long>("gid"), &timestamp);
ret->setType("OK");
-
- if(!timestamp.is_not_a_date_time())
- ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str());
+ ret->set("timestamp", timestamp);
Common::XmlData::List *list = ret->createList("users");
@@ -238,22 +178,12 @@ void UserRequestHandlerGroup::handleFullUserGroupListRequest(boost::shared_ptr<c
if(!connection->isAuthenticated())
throw(Core::Exception(Core::Exception::PERMISSION));
- boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time);
-
- const Core::String &timestr = packet->get<const Core::String&>("timestamp");
- if(!timestr.isEmpty()) {
- try {
- timestamp = boost::posix_time::from_iso_string(timestr.extract());
- }
- catch(...) {}
- }
+ boost::posix_time::ptime timestamp = packet->get<boost::posix_time::ptime>("timestamp");
boost::shared_ptr<const std::multimap<unsigned long, unsigned long> > userGroups = application->getUserManager()->getFullUserGroupList(&timestamp);
ret->setType("OK");
-
- if(!timestamp.is_not_a_date_time())
- ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str());
+ ret->set("timestamp", timestamp);
if(userGroups) {
Common::XmlData::List *list = ret->createList("userGroupList");