summaryrefslogtreecommitdiffstats
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/AuthBackendChallengeResponse/AuthBackendChallengeResponse.cpp8
-rw-r--r--src/modules/AuthBackendChallengeResponse/AuthBackendChallengeResponse.h12
-rw-r--r--src/modules/AuthBackendPassword/AuthBackendPassword.cpp8
-rw-r--r--src/modules/AuthBackendPassword/AuthBackendPassword.h12
-rw-r--r--src/modules/AuthProviderFile/AuthProviderFile.cpp42
-rw-r--r--src/modules/AuthProviderFile/AuthProviderFile.h14
-rw-r--r--src/modules/StorageBackendFile/StorageBackendFile.cpp32
-rw-r--r--src/modules/StorageBackendFile/StorageBackendFile.h18
-rw-r--r--src/modules/UserConfigBackendHome/UserConfigBackendHome.cpp22
-rw-r--r--src/modules/UserConfigBackendHome/UserConfigBackendHome.h4
-rw-r--r--src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.cpp10
-rw-r--r--src/modules/UserDBBackendMysql/UserDBBackendMysql.cpp68
-rw-r--r--src/modules/UserDBBackendMysql/UserDBBackendMysql.h34
13 files changed, 145 insertions, 139 deletions
diff --git a/src/modules/AuthBackendChallengeResponse/AuthBackendChallengeResponse.cpp b/src/modules/AuthBackendChallengeResponse/AuthBackendChallengeResponse.cpp
index fc6bd47..0785b7d 100644
--- a/src/modules/AuthBackendChallengeResponse/AuthBackendChallengeResponse.cpp
+++ b/src/modules/AuthBackendChallengeResponse/AuthBackendChallengeResponse.cpp
@@ -27,7 +27,7 @@ namespace Mad {
namespace Modules {
namespace AuthBackendChallengeResponse {
-const std::string AuthBackendChallengeResponse::methodName = "Challenge-Response";
+const Core::String AuthBackendChallengeResponse::methodName = "Challenge-Response";
AuthBackendChallengeResponse::AuthContextChallengeResponse::AuthContextChallengeResponse(AuthBackendChallengeResponse *backend) : authenticated(false) {
challenge.reserve(32);
@@ -38,13 +38,13 @@ AuthBackendChallengeResponse::AuthContextChallengeResponse::AuthContextChallenge
challenge.push_back(backend->randomGenerator());
}
-boost::shared_ptr<Common::AuthContext> AuthBackendChallengeResponse::authenticate(boost::shared_ptr<Common::AuthProvider> provider, const std::string &subMethod,
- const std::string &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response,
+boost::shared_ptr<Common::AuthContext> AuthBackendChallengeResponse::authenticate(boost::shared_ptr<Common::AuthProvider> provider, const Core::String &subMethod,
+ const Core::String &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response,
boost::shared_ptr<Common::AuthContext> context) throw(Core::Exception) {
if(context && dynamic_cast<AuthContextChallengeResponse*>(context.get()) == 0)
throw(Core::Exception(Core::Exception::INVALID_INPUT));
- std::vector<std::string> allowedMethods = getSubMethods(provider);
+ std::vector<Core::String> allowedMethods = getSubMethods(provider);
if(std::find(allowedMethods.begin(), allowedMethods.end(), subMethod) == allowedMethods.end())
throw(Core::Exception(Core::Exception::INVALID_INPUT));
diff --git a/src/modules/AuthBackendChallengeResponse/AuthBackendChallengeResponse.h b/src/modules/AuthBackendChallengeResponse/AuthBackendChallengeResponse.h
index dc1b60a..0d69eba 100644
--- a/src/modules/AuthBackendChallengeResponse/AuthBackendChallengeResponse.h
+++ b/src/modules/AuthBackendChallengeResponse/AuthBackendChallengeResponse.h
@@ -56,7 +56,7 @@ class MAD_MODULE_EXPORT AuthBackendChallengeResponse : public Common::AuthBacken
}
};
- static const std::string methodName;
+ static const Core::String methodName;
Common::Application *application;
@@ -68,19 +68,19 @@ class MAD_MODULE_EXPORT AuthBackendChallengeResponse : public Common::AuthBacken
protected:
- virtual const std::string& getMethodName() const {
+ virtual const Core::String& getMethodName() const {
return methodName;
}
- virtual std::vector<std::string> getSubMethods(boost::shared_ptr<Common::AuthProvider> provider) const {
- std::vector<std::string> ret;
+ virtual std::vector<Core::String> getSubMethods(boost::shared_ptr<Common::AuthProvider> provider) const {
+ std::vector<Core::String> ret;
ret.push_back(provider->getHashes().front());
return ret;
}
- virtual boost::shared_ptr<Common::AuthContext> authenticate(boost::shared_ptr<Common::AuthProvider> provider, const std::string &subMethod,
- const std::string &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response,
+ virtual boost::shared_ptr<Common::AuthContext> authenticate(boost::shared_ptr<Common::AuthProvider> provider, const Core::String &subMethod,
+ const Core::String &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response,
boost::shared_ptr<Common::AuthContext> context) throw(Core::Exception);
public:
diff --git a/src/modules/AuthBackendPassword/AuthBackendPassword.cpp b/src/modules/AuthBackendPassword/AuthBackendPassword.cpp
index 1b38002..9701f04 100644
--- a/src/modules/AuthBackendPassword/AuthBackendPassword.cpp
+++ b/src/modules/AuthBackendPassword/AuthBackendPassword.cpp
@@ -23,15 +23,15 @@ namespace Mad {
namespace Modules {
namespace AuthBackendPassword {
-const std::string AuthBackendPassword::methodName = "Password";
+const Core::String AuthBackendPassword::methodName = "Password";
-boost::shared_ptr<Common::AuthContext> AuthBackendPassword::authenticate(boost::shared_ptr<Common::AuthProvider> provider, const std::string &subMethod,
- const std::string &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t>& /*response*/,
+boost::shared_ptr<Common::AuthContext> AuthBackendPassword::authenticate(boost::shared_ptr<Common::AuthProvider> provider, const Core::String &subMethod,
+ const Core::String &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t>& /*response*/,
boost::shared_ptr<Common::AuthContext> context) throw(Core::Exception) {
if(context && dynamic_cast<AuthContextPassword*>(context.get()) == 0)
throw(Core::Exception(Core::Exception::INVALID_INPUT));
- std::vector<std::string> allowedMethods = getSubMethods(provider);
+ std::vector<Core::String> allowedMethods = getSubMethods(provider);
if(std::find(allowedMethods.begin(), allowedMethods.end(), subMethod) == allowedMethods.end())
throw(Core::Exception(Core::Exception::INVALID_INPUT));
diff --git a/src/modules/AuthBackendPassword/AuthBackendPassword.h b/src/modules/AuthBackendPassword/AuthBackendPassword.h
index ac100c1..aed11e8 100644
--- a/src/modules/AuthBackendPassword/AuthBackendPassword.h
+++ b/src/modules/AuthBackendPassword/AuthBackendPassword.h
@@ -42,22 +42,22 @@ class MAD_MODULE_EXPORT AuthBackendPassword : public Common::AuthBackend, privat
Common::Application *application;
- static const std::string methodName;
+ static const Core::String methodName;
protected:
- virtual const std::string& getMethodName() const {
+ virtual const Core::String& getMethodName() const {
return methodName;
}
- virtual std::vector<std::string> getSubMethods(boost::shared_ptr<Common::AuthProvider> provider) const {
- std::vector<std::string> ret;
+ virtual std::vector<Core::String> getSubMethods(boost::shared_ptr<Common::AuthProvider> provider) const {
+ std::vector<Core::String> ret;
ret.push_back(provider->getHashes().front());
return ret;
}
- virtual boost::shared_ptr<Common::AuthContext> authenticate(boost::shared_ptr<Common::AuthProvider> provider, const std::string &subMethod,
- const std::string &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response,
+ virtual boost::shared_ptr<Common::AuthContext> authenticate(boost::shared_ptr<Common::AuthProvider> provider, const Core::String &subMethod,
+ const Core::String &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response,
boost::shared_ptr<Common::AuthContext> context) throw(Core::Exception);
public:
diff --git a/src/modules/AuthProviderFile/AuthProviderFile.cpp b/src/modules/AuthProviderFile/AuthProviderFile.cpp
index b1e1e52..b006cdc 100644
--- a/src/modules/AuthProviderFile/AuthProviderFile.cpp
+++ b/src/modules/AuthProviderFile/AuthProviderFile.cpp
@@ -54,17 +54,19 @@ void AuthProviderFile::readFile(const std::string &name) {
continue;
}
- std::string password = match[2].str();
+ Core::String password = match[2].str().c_str();
+
+ if(filehash.isEmpty()) {
+ std::string utf8pass = password.extractUTF8();
- if(filehash.empty()) {
boost::lock_guard<boost::mutex> lock(mutex);
- userMap.insert(std::make_pair(match[1].str(), std::vector<boost::uint8_t>(password.begin(), password.end())));
+ userMap.insert(std::make_pair(match[1].str().c_str(), std::vector<boost::uint8_t>(utf8pass.begin(), utf8pass.end())));
}
else {
std::vector<boost::uint8_t> data;
- data.reserve(password.size()/2);
+ data.reserve(password.length()/2);
- for(size_t c = 0; c < password.size()-1; c += 2) {
+ for(boost::int32_t c = 0; c < password.length()-1; c += 2) {
char buffer[3] = {password[c], password[c+1], 0};
unsigned char byte;
@@ -79,7 +81,7 @@ void AuthProviderFile::readFile(const std::string &name) {
if(!data.empty()) {
boost::lock_guard<boost::mutex> lock(mutex);
- userMap.insert(std::make_pair(match[1].str(), data));
+ userMap.insert(std::make_pair(match[1].str().c_str(), data));
}
}
}
@@ -94,15 +96,15 @@ bool AuthProviderFile::handleConfigEntry(const Core::ConfigEntry &entry, bool /*
if(entry[1].getKey().matches("Hash")) {
if(entry[2].isEmpty()) {
- filehash = entry[1][0].extract();
+ filehash = entry[1][0];
if(!Common::Hash::isHashSupported(filehash))
- application->logf(Core::Logger::LOG_WARNING, "AuthProviderFile: Unsupported hash '%s'", filehash.c_str());
+ application->logf(Core::Logger::LOG_WARNING, "AuthProviderFile: Unsupported hash '%s'", filehash.extract().c_str());
}
}
else if(entry[1].getKey().matches("File")) {
if(entry[2].isEmpty()) {
- files.push_back(entry[1][0].extract());
+ files.push_back(entry[1][0]);
}
}
else if(!entry[2].isEmpty())
@@ -112,9 +114,9 @@ bool AuthProviderFile::handleConfigEntry(const Core::ConfigEntry &entry, bool /*
}
void AuthProviderFile::configFinished() {
- if(filehash.empty() || boost::algorithm::to_lower_copy(filehash) == "clear") {
+ if(filehash.isEmpty() || filehash.matches("clear")) {
hashes = Common::Hash::getHashList();
- filehash.clear();
+ filehash.remove();
}
else {
hashes.clear();
@@ -123,12 +125,12 @@ void AuthProviderFile::configFinished() {
hashes.push_back("Clear");
- for(std::vector<std::string>::iterator file = files.begin(); file != files.end(); ++file)
- readFile(*file);
+ for(std::vector<Core::String>::iterator file = files.begin(); file != files.end(); ++file)
+ readFile(file->extract());
}
-bool AuthProviderFile::checkPassword(const std::string &user, const std::vector<boost::uint8_t> &data, const std::string &hash) throw(Core::Exception) {
- if((hash.empty() || boost::algorithm::to_lower_copy(hash) == "clear") && !filehash.empty()) {
+bool AuthProviderFile::checkPassword(const Core::String &user, const std::vector<boost::uint8_t> &data, const Core::String &hash) throw(Core::Exception) {
+ if((hash.isEmpty() || hash.matches("clear")) && !filehash.isEmpty()) {
std::vector<boost::uint8_t> password = getPassword(user, filehash);
std::vector<boost::uint8_t> hashdata = Common::Hash::hash(data, filehash);
@@ -140,20 +142,20 @@ bool AuthProviderFile::checkPassword(const std::string &user, const std::vector<
}
}
-std::vector<boost::uint8_t> AuthProviderFile::getPassword(const std::string &user, const std::string &hash) throw(Core::Exception) {
+std::vector<boost::uint8_t> AuthProviderFile::getPassword(const Core::String &user, const Core::String &hash) throw(Core::Exception) {
boost::lock_guard<boost::mutex> lock(mutex);
- std::map<std::string, std::vector<boost::uint8_t> >::iterator userIt = userMap.find(user);
+ std::map<Core::String, std::vector<boost::uint8_t> >::iterator userIt = userMap.find(user);
if(userIt == userMap.end())
return std::vector<boost::uint8_t>();
- if(filehash.empty()) {
- if(boost::algorithm::to_lower_copy(hash) == "clear")
+ if(filehash.isEmpty()) {
+ if(hash.matches("clear"))
return userIt->second;
else
return Common::Hash::hash(userIt->second, hash);
}
- else if(boost::algorithm::to_lower_copy(filehash) == boost::algorithm::to_lower_copy(hash)) {
+ else if(filehash.matches(hash)) {
return userIt->second;
}
else
diff --git a/src/modules/AuthProviderFile/AuthProviderFile.h b/src/modules/AuthProviderFile/AuthProviderFile.h
index 63f3d28..6ca907f 100644
--- a/src/modules/AuthProviderFile/AuthProviderFile.h
+++ b/src/modules/AuthProviderFile/AuthProviderFile.h
@@ -42,23 +42,23 @@ class MAD_MODULE_EXPORT AuthProviderFile : public Common::AuthProvider, private
boost::mutex mutex;
- std::map<std::string, std::vector<boost::uint8_t> > userMap;
+ std::map<Core::String, std::vector<boost::uint8_t> > userMap;
- std::vector<std::string> files;
- std::string filehash;
+ std::vector<Core::String> files;
+ Core::String filehash;
- std::vector<std::string> hashes;
+ std::vector<Core::String> hashes;
protected:
virtual bool handleConfigEntry(const Core::ConfigEntry &entry, bool /*handled*/);
virtual void configFinished();
- virtual const std::vector<std::string>& getHashes() const {
+ virtual const std::vector<Core::String>& getHashes() const {
return hashes;
}
- virtual bool checkPassword(const std::string &user, const std::vector<boost::uint8_t> &data, const std::string &hash) throw(Core::Exception);
- virtual std::vector<boost::uint8_t> getPassword(const std::string &user, const std::string &hash) throw(Core::Exception);
+ virtual bool checkPassword(const Core::String &user, const std::vector<boost::uint8_t> &data, const Core::String &hash) throw(Core::Exception);
+ virtual std::vector<boost::uint8_t> getPassword(const Core::String &user, const Core::String &hash) throw(Core::Exception);
public:
AuthProviderFile(Common::Application *application0) : application(application0) {
diff --git a/src/modules/StorageBackendFile/StorageBackendFile.cpp b/src/modules/StorageBackendFile/StorageBackendFile.cpp
index aae7e03..0affc2c 100644
--- a/src/modules/StorageBackendFile/StorageBackendFile.cpp
+++ b/src/modules/StorageBackendFile/StorageBackendFile.cpp
@@ -62,29 +62,29 @@ void StorageBackendFile::configFinished() {
configured = true;
}
-boost::filesystem::path StorageBackendFile::getFileName(const std::string &type, const std::string &name) {
+boost::filesystem::path StorageBackendFile::getFileName(const Core::String &type, const Core::String &name) {
boost::filesystem::path path(storageRoot);
- path /= type;
- path /= (name + ".xml");
+ path /= type.extract();
+ path /= Core::String(name + ".xml").extract();
return path;
}
-std::set<std::string> StorageBackendFile::listTypes() throw (Core::Exception) {
+std::set<Core::String> StorageBackendFile::listTypes() throw (Core::Exception) {
boost::shared_lock<boost::shared_mutex> lock(mutex);
if(!configured)
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
- std::set<std::string> ret;
+ std::set<Core::String> ret;
try {
for(boost::filesystem::directory_iterator it(storageRoot); it != boost::filesystem::directory_iterator(); ++it) {
boost::filesystem::path path = *it;
if(boost::filesystem::is_directory(path))
- ret.insert(path.filename());
+ ret.insert(path.filename().c_str());
}
}
catch(...) {} // Don't throw if we can't iterate over the dirs
@@ -92,23 +92,23 @@ std::set<std::string> StorageBackendFile::listTypes() throw (Core::Exception) {
return ret;
}
-std::set<std::string> StorageBackendFile::list(const std::string &type) throw (Core::Exception) {
+std::set<Core::String> StorageBackendFile::list(const Core::String &type) throw (Core::Exception) {
boost::shared_lock<boost::shared_mutex> lock(mutex);
if(!configured)
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
- std::set<std::string> ret;
+ std::set<Core::String> ret;
boost::filesystem::path path(storageRoot);
- path /= type;
+ path /= type.extract();
try {
for(boost::filesystem::directory_iterator it(path); it != boost::filesystem::directory_iterator(); ++it) {
boost::filesystem::path filePath = *it;
if(boost::filesystem::is_regular_file(filePath) && filePath.extension() == ".xml")
- ret.insert(filePath.replace_extension().filename());
+ ret.insert(filePath.replace_extension().filename().c_str());
}
}
catch(...) {} // Don't throw if we can't iterate over the dirs
@@ -117,7 +117,7 @@ std::set<std::string> StorageBackendFile::list(const std::string &type) throw (C
}
-bool StorageBackendFile::exists(const std::string &type, const std::string &name) throw (Core::Exception) {
+bool StorageBackendFile::exists(const Core::String &type, const Core::String &name) throw (Core::Exception) {
boost::shared_lock<boost::shared_mutex> lock(mutex);
if(!configured)
@@ -128,7 +128,7 @@ bool StorageBackendFile::exists(const std::string &type, const std::string &name
return boost::filesystem::is_regular_file(path);
}
-void StorageBackendFile::store(const std::string &type, const std::string &name, const Common::XmlData *data) throw (Core::Exception) {
+void StorageBackendFile::store(const Core::String &type, const Core::String &name, const Common::XmlData *data) throw (Core::Exception) {
boost::lock_guard<boost::shared_mutex> lock(mutex);
if(!configured)
@@ -140,7 +140,7 @@ void StorageBackendFile::store(const std::string &type, const std::string &name,
data->toFile(path.file_string());
}
-boost::shared_ptr<Common::XmlData> StorageBackendFile::load(const std::string &type, const std::string &name) throw (Core::Exception) {
+boost::shared_ptr<Common::XmlData> StorageBackendFile::load(const Core::String &type, const Core::String &name) throw (Core::Exception) {
boost::shared_lock<boost::shared_mutex> lock(mutex);
if(!configured)
@@ -153,7 +153,7 @@ boost::shared_ptr<Common::XmlData> StorageBackendFile::load(const std::string &t
return boost::shared_ptr<Common::XmlData>(new Common::XmlData(path.file_string()));
}
-void StorageBackendFile::copy(const std::string &type, const std::string &name, const std::string &newName) throw (Core::Exception) {
+void StorageBackendFile::copy(const Core::String &type, const Core::String &name, const Core::String &newName) throw (Core::Exception) {
boost::lock_guard<boost::shared_mutex> lock(mutex);
if(!configured)
@@ -164,7 +164,7 @@ void StorageBackendFile::copy(const std::string &type, const std::string &name,
boost::filesystem::copy_file(path, newPath);
}
-void StorageBackendFile::rename(const std::string &type, const std::string &name, const std::string &newName) throw (Core::Exception) {
+void StorageBackendFile::rename(const Core::String &type, const Core::String &name, const Core::String &newName) throw (Core::Exception) {
boost::lock_guard<boost::shared_mutex> lock(mutex);
if(!configured)
@@ -175,7 +175,7 @@ void StorageBackendFile::rename(const std::string &type, const std::string &name
boost::filesystem::rename(path, newPath);
}
-void StorageBackendFile::remove(const std::string &type, const std::string &name) throw (Core::Exception) {
+void StorageBackendFile::remove(const Core::String &type, const Core::String &name) throw (Core::Exception) {
boost::lock_guard<boost::shared_mutex> lock(mutex);
if(!configured)
diff --git a/src/modules/StorageBackendFile/StorageBackendFile.h b/src/modules/StorageBackendFile/StorageBackendFile.h
index 9994500..f38e674 100644
--- a/src/modules/StorageBackendFile/StorageBackendFile.h
+++ b/src/modules/StorageBackendFile/StorageBackendFile.h
@@ -42,23 +42,23 @@ class StorageBackendFile : public Common::StorageBackend, private Core::Configur
boost::shared_mutex mutex;
- boost::filesystem::path getFileName(const std::string &type, const std::string &name);
+ boost::filesystem::path getFileName(const Core::String &type, const Core::String &name);
protected:
virtual bool handleConfigEntry(const Core::ConfigEntry &entry, bool handled);
virtual void configFinished();
- virtual std::set<std::string> listTypes() throw (Core::Exception);
- virtual std::set<std::string> list(const std::string &type) throw (Core::Exception);
+ virtual std::set<Core::String> listTypes() throw (Core::Exception);
+ virtual std::set<Core::String> list(const Core::String &type) throw (Core::Exception);
- virtual bool exists(const std::string &type, const std::string &name) throw (Core::Exception);
+ virtual bool exists(const Core::String &type, const Core::String &name) throw (Core::Exception);
- virtual void store(const std::string &type, const std::string &name, const Common::XmlData *data) throw (Core::Exception);
- virtual boost::shared_ptr<Common::XmlData> load(const std::string &type, const std::string &name) throw (Core::Exception);
+ virtual void store(const Core::String &type, const Core::String &name, const Common::XmlData *data) throw (Core::Exception);
+ virtual boost::shared_ptr<Common::XmlData> load(const Core::String &type, const Core::String &name) throw (Core::Exception);
- virtual void copy(const std::string &type, const std::string &name, const std::string &newName) throw (Core::Exception);
- virtual void rename(const std::string &type, const std::string &name, const std::string &newName) throw (Core::Exception);
- virtual void remove(const std::string &type, const std::string &name) throw (Core::Exception);
+ virtual void copy(const Core::String &type, const Core::String &name, const Core::String &newName) throw (Core::Exception);
+ virtual void rename(const Core::String &type, const Core::String &name, const Core::String &newName) throw (Core::Exception);
+ virtual void remove(const Core::String &type, const Core::String &name) throw (Core::Exception);
public:
StorageBackendFile(Common::Application *application0) : application(application0), configured(false) {
diff --git a/src/modules/UserConfigBackendHome/UserConfigBackendHome.cpp b/src/modules/UserConfigBackendHome/UserConfigBackendHome.cpp
index d47e03b..e1db3b9 100644
--- a/src/modules/UserConfigBackendHome/UserConfigBackendHome.cpp
+++ b/src/modules/UserConfigBackendHome/UserConfigBackendHome.cpp
@@ -35,11 +35,11 @@ bool UserConfigBackendHome::handleConfigEntry(const Core::ConfigEntry &entry, bo
if(entry[0].getKey().matches("UserManager")) {
if(entry[1].getKey().matches("Skeleton")) {
if(entry[2].isEmpty())
- skeleton = entry[1][0].extract();
+ skeleton = entry[1][0];
}
else if(entry[1].getKey().matches("HomeDir")) {
if(entry[2].isEmpty())
- homeDir = entry[1][0].extract();
+ homeDir = entry[1][0];
}
else if(entry[1].getKey().matches("UserDirMode")) {
if(entry[2].isEmpty()) {
@@ -104,8 +104,8 @@ void UserConfigBackendHome::migrateOwner(const std::string &path, const Common::
}
void UserConfigBackendHome::addUser(const Common::UserInfo &userInfo) throw(Core::Exception) {
- boost::filesystem::path path(homeDir);
- path /= userInfo.getUsername();
+ boost::filesystem::path path(homeDir.extract());
+ path /= userInfo.getUsername().extract();
boost::filesystem::create_directories(path);
@@ -118,7 +118,7 @@ void UserConfigBackendHome::addUser(const Common::UserInfo &userInfo) throw(Core
// TODO Error
}
- boost::filesystem::path skeletonPath(skeleton);
+ boost::filesystem::path skeletonPath(skeleton.extract());
if(!boost::filesystem::is_directory(skeletonPath))
return;
@@ -161,11 +161,11 @@ void UserConfigBackendHome::addUser(const Common::UserInfo &userInfo) throw(Core
}
void UserConfigBackendHome::updateUser(const Common::UserInfo &oldUserInfo, const Common::UserInfo &userInfo) throw(Core::Exception) {
- boost::filesystem::path oldPath(homeDir);
- oldPath /= oldUserInfo.getUsername();
+ boost::filesystem::path oldPath(homeDir.extract());
+ oldPath /= oldUserInfo.getUsername().extract();
- boost::filesystem::path path(homeDir);
- path /= userInfo.getUsername();
+ boost::filesystem::path path(homeDir.extract());
+ path /= userInfo.getUsername().extract();
if(oldPath != path) {
try {
@@ -202,8 +202,8 @@ void UserConfigBackendHome::updateUser(const Common::UserInfo &oldUserInfo, cons
}
void UserConfigBackendHome::deleteUser(const Common::UserInfo &userInfo) throw(Core::Exception) {
- boost::filesystem::path path(homeDir);
- path /= userInfo.getUsername();
+ boost::filesystem::path path(homeDir.extract());
+ path /= userInfo.getUsername().extract();
boost::filesystem::remove_all(path);
}
diff --git a/src/modules/UserConfigBackendHome/UserConfigBackendHome.h b/src/modules/UserConfigBackendHome/UserConfigBackendHome.h
index f115d9e..e82795c 100644
--- a/src/modules/UserConfigBackendHome/UserConfigBackendHome.h
+++ b/src/modules/UserConfigBackendHome/UserConfigBackendHome.h
@@ -36,8 +36,8 @@ class UserConfigBackendHome : public Common::UserConfigBackend, private Core::Co
private:
Common::Application *application;
- std::string skeleton;
- std::string homeDir;
+ Core::String skeleton;
+ Core::String homeDir;
unsigned long dirMode;
boost::mutex mutex;
diff --git a/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.cpp b/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.cpp
index 475a689..7d53e55 100644
--- a/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.cpp
+++ b/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.cpp
@@ -133,7 +133,9 @@ void UserConfigBackendKrb5::configFinished() {
void UserConfigBackendKrb5::checkUserInfo(const Common::UserInfo &userInfo) throw(Core::Exception) {
- if(std::strcspn(userInfo.getUsername().c_str(), "/@") != userInfo.getUsername().length())
+ std::string username = userInfo.getUsername().extract();
+
+ if(std::strcspn(username.c_str(), "/@") != username.length())
throw Core::Exception(Core::Exception::INVALID_INPUT);
}
@@ -145,7 +147,7 @@ void UserConfigBackendKrb5::addUser(const Common::UserInfo &userInfo) throw(Core
if(!context || !handle)
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
- std::string princStr = userInfo.getUsername() + "@" + realm;
+ std::string princStr = userInfo.getUsername().extract() + "@" + realm;
kadm5_principal_ent_rec princ;
@@ -228,7 +230,7 @@ void UserConfigBackendKrb5::deleteUser(const Common::UserInfo &userInfo) throw(C
if(!context || !handle)
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
- std::string princStr = userInfo.getUsername() + "@" + realm;
+ std::string princStr = userInfo.getUsername().extract() + "@" + realm;
krb5_principal princ;
krb5_error_code err = krb5_parse_name(context, princStr.c_str(), &princ);
@@ -261,7 +263,7 @@ void UserConfigBackendKrb5::setPassword(const Common::UserInfo &userInfo, const
if(!context || !handle)
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
- std::string princStr = userInfo.getUsername() + "@" + realm;
+ std::string princStr = userInfo.getUsername().extract() + "@" + realm;
krb5_principal princ;
krb5_error_code err = krb5_parse_name(context, princStr.c_str(), &princ);
diff --git a/src/modules/UserDBBackendMysql/UserDBBackendMysql.cpp b/src/modules/UserDBBackendMysql/UserDBBackendMysql.cpp
index 7e7711a..46f9d12 100644
--- a/src/modules/UserDBBackendMysql/UserDBBackendMysql.cpp
+++ b/src/modules/UserDBBackendMysql/UserDBBackendMysql.cpp
@@ -27,6 +27,7 @@
#include <boost/bind.hpp>
#include <boost/regex.hpp>
#include <boost/thread/locks.hpp>
+#include <boost/variant/get.hpp>
#include <mysql/mysqld_error.h>
@@ -34,7 +35,7 @@ namespace Mad {
namespace Modules {
namespace UserDBBackendMysql {
-const std::string UserDBBackendMysql::name("UserDBBackendMysql");
+const Core::String UserDBBackendMysql::name("UserDBBackendMysql");
bool UserDBBackendMysql::handleConfigEntry(const Core::ConfigEntry &entry, bool /*handled*/) {
if(!entry[0].getKey().matches("UserManager"))
@@ -48,19 +49,19 @@ bool UserDBBackendMysql::handleConfigEntry(const Core::ConfigEntry &entry, bool
if(entry[2].getKey().matches("Host")) {
if(entry[3].isEmpty())
- host = entry[2][0].extract();
+ host = entry[2][0];
}
else if(entry[2].getKey().matches("Username")) {
if(entry[3].isEmpty())
- username = entry[2][0].extract();
+ username = entry[2][0];
}
else if(entry[2].getKey().matches("Password")) {
if(entry[3].isEmpty())
- passwd = entry[2][0].extract();
+ passwd = entry[2][0];
}
else if(entry[2].getKey().matches("Database")) {
if(entry[3].isEmpty())
- db = entry[2][0].extract();
+ db = entry[2][0];
}
else if(entry[2].getKey().matches("Port")) {
if(entry[3].isEmpty()) {
@@ -77,76 +78,76 @@ bool UserDBBackendMysql::handleConfigEntry(const Core::ConfigEntry &entry, bool
}
else if(entry[2].getKey().matches("UnixSocket")) {
if(entry[3].isEmpty())
- unixSocket = entry[2][0].extract();
+ unixSocket = entry[2][0];
}
else if(entry[2].getKey().matches("Queries")) {
if(entry[3].getKey().matches("ListUsers")) {
if(entry[4].isEmpty())
- queryListUsers = entry[3][0].extract();
+ queryListUsers = entry[3][0];
}
else if(entry[3].getKey().matches("ListGroups")) {
if(entry[4].isEmpty())
- queryListGroups = entry[3][0].extract();
+ queryListGroups = entry[3][0];
}
else if(entry[3].getKey().matches("ListUserGroups")) {
if(entry[4].isEmpty())
- queryListUserGroups = entry[3][0].extract();
+ queryListUserGroups = entry[3][0];
}
else if(entry[3].getKey().matches("ListGroupUsers")) {
if(entry[4].isEmpty())
- queryListGroupUsers = entry[3][0].extract();
+ queryListGroupUsers = entry[3][0];
}
else if(entry[3].getKey().matches("UserById")) {
if(entry[4].isEmpty())
- queryUserById = entry[3][0].extract();
+ queryUserById = entry[3][0];
}
else if(entry[3].getKey().matches("UserByName")) {
if(entry[4].isEmpty())
- queryUserByName = entry[3][0].extract();
+ queryUserByName = entry[3][0];
}
else if(entry[3].getKey().matches("GroupById")) {
if(entry[4].isEmpty())
- queryGroupById = entry[3][0].extract();
+ queryGroupById = entry[3][0];
}
else if(entry[3].getKey().matches("GroupByName")) {
if(entry[4].isEmpty())
- queryGroupByName = entry[3][0].extract();
+ queryGroupByName = entry[3][0];
}
else if(entry[3].getKey().matches("UserGroupTable")) {
if(entry[4].isEmpty())
- queryUserGroupTable = entry[3][0].extract();
+ queryUserGroupTable = entry[3][0];
}
else if(entry[3].getKey().matches("AddUser")) {
if(entry[4].isEmpty())
- queryAddUser = entry[3][0].extract();
+ queryAddUser = entry[3][0];
}
else if(entry[3].getKey().matches("UpdateUser")) {
if(entry[4].isEmpty())
- queryUpdateUser = entry[3][0].extract();
+ queryUpdateUser = entry[3][0];
}
else if(entry[3].getKey().matches("DeleteUser")) {
if(entry[4].isEmpty())
- queryDeleteUser = entry[3][0].extract();
+ queryDeleteUser = entry[3][0];
}
else if(entry[3].getKey().matches("AddGroup")) {
if(entry[4].isEmpty())
- queryAddGroup = entry[3][0].extract();
+ queryAddGroup = entry[3][0];
}
else if(entry[3].getKey().matches("UpdateGroup")) {
if(entry[4].isEmpty())
- queryUpdateGroup = entry[3][0].extract();
+ queryUpdateGroup = entry[3][0];
}
else if(entry[3].getKey().matches("DeleteGroup")) {
if(entry[4].isEmpty())
- queryDeleteGroup = entry[3][0].extract();
+ queryDeleteGroup = entry[3][0];
}
else if(entry[3].getKey().matches("AddUserToGroup")) {
if(entry[4].isEmpty())
- queryAddUserToGroup = entry[3][0].extract();
+ queryAddUserToGroup = entry[3][0];
}
else if(entry[3].getKey().matches("DeleteUserFromGroup")) {
if(entry[4].isEmpty())
- queryDeleteUserFromGroup = entry[3][0].extract();
+ queryDeleteUserFromGroup = entry[3][0];
}
else if(!entry[3].isEmpty())
return false;
@@ -158,32 +159,33 @@ bool UserDBBackendMysql::handleConfigEntry(const Core::ConfigEntry &entry, bool
}
void UserDBBackendMysql::configFinished() {
- if(db.empty()) {
+ if(db.isEmpty()) {
application->log(Core::Logger::LOG_ERROR, "UserDBBackendMysql: No database name given");
return;
}
boost::lock_guard<boost::mutex> lock(mutex);
mysql = mysql_init(0);
- mysql_real_connect(mysql, host.c_str(), username.c_str(), passwd.c_str(), db.c_str(), port, unixSocket.empty() ? 0 : unixSocket.c_str(), 0);
+ mysql_real_connect(mysql, host.extract().c_str(), username.extract().c_str(), passwd.extract().c_str(),
+ db.extract().c_str(), port, unixSocket.isEmpty() ? 0 : unixSocket.extract().c_str(), 0);
}
-UserDBBackendMysql::Result UserDBBackendMysql::query(const std::string &query, const ArgumentMap &args) throw(Core::Exception) {
+UserDBBackendMysql::Result UserDBBackendMysql::query(const Core::String &query, const ArgumentMap &args) throw(Core::Exception) {
if(!mysql || mysql_ping(mysql))
throw Core::Exception(Core::Exception::NOT_AVAILABLE);
+ std::string queryStr = query.extract();
+
if(args.empty()) {
- mysql_real_query(mysql, query.c_str(), query.length());
+ mysql_real_query(mysql, queryStr.c_str(), queryStr.length());
}
else {
- std::string queryStr = query;
-
for(ArgumentMap::const_iterator arg = args.begin(); arg != args.end(); ++arg) {
std::string argStr;
try {
- argStr = boost::get<std::string>(arg->second);
+ argStr = boost::get<Core::String>(arg->second).extract();
}
catch(...) {
std::ostringstream stream;
@@ -194,7 +196,7 @@ UserDBBackendMysql::Result UserDBBackendMysql::query(const std::string &query, c
boost::scoped_array<char> escaped(new char[argStr.length()*2+1]);
mysql_real_escape_string(mysql, escaped.get(), argStr.c_str(), argStr.length());
- queryStr = boost::regex_replace(queryStr, boost::regex("\\{" + arg->first + "\\}"), "\"" + std::string(escaped.get()) + "\"", boost::match_default);
+ queryStr = boost::regex_replace(queryStr, boost::regex("\\{" + arg->first.extract() + "\\}"), "\"" + std::string(escaped.get()) + "\"", boost::match_default);
}
mysql_real_query(mysql, queryStr.c_str(), queryStr.length());
@@ -273,7 +275,7 @@ boost::shared_ptr<const Common::UserInfo> UserDBBackendMysql::getUserInfo(unsign
throw Core::Exception(Core::Exception::NOT_FOUND);
}
-boost::shared_ptr<const Common::UserInfo> UserDBBackendMysql::getUserInfoByName(const std::string &name, boost::posix_time::ptime *timestamp) throw(Core::Exception) {
+boost::shared_ptr<const Common::UserInfo> UserDBBackendMysql::getUserInfoByName(const Core::String &name, boost::posix_time::ptime *timestamp) throw(Core::Exception) {
application->getThreadManager()->detach();
boost::unique_lock<boost::mutex> lock(mutex);
@@ -400,7 +402,7 @@ boost::shared_ptr<const Common::GroupInfo> UserDBBackendMysql::getGroupInfo(unsi
throw Core::Exception(Core::Exception::NOT_FOUND);
}
-boost::shared_ptr<const Common::GroupInfo> UserDBBackendMysql::getGroupInfoByName(const std::string &name, boost::posix_time::ptime *timestamp) throw(Core::Exception) {
+boost::shared_ptr<const Common::GroupInfo> UserDBBackendMysql::getGroupInfoByName(const Core::String &name, boost::posix_time::ptime *timestamp) throw(Core::Exception) {
application->getThreadManager()->detach();
boost::unique_lock<boost::mutex> lock(mutex);
diff --git a/src/modules/UserDBBackendMysql/UserDBBackendMysql.h b/src/modules/UserDBBackendMysql/UserDBBackendMysql.h
index 959e133..9351ca1 100644
--- a/src/modules/UserDBBackendMysql/UserDBBackendMysql.h
+++ b/src/modules/UserDBBackendMysql/UserDBBackendMysql.h
@@ -29,7 +29,7 @@
#include <mysql/mysql.h>
#include <boost/thread/mutex.hpp>
-#include <boost/variant.hpp>
+#include <boost/variant/variant.hpp>
namespace Mad {
namespace Modules {
@@ -37,14 +37,14 @@ namespace UserDBBackendMysql {
class UserDBBackendMysql : public Common::UserDBBackend, private Core::Configurable, private boost::noncopyable {
private:
- typedef std::map<std::string, boost::variant<std::string, unsigned long> > ArgumentMap;
+ typedef std::map<Core::String, boost::variant<Core::String, unsigned long> > ArgumentMap;
class Result;
- Result query(const std::string &query, const ArgumentMap &args = ArgumentMap()) throw(Core::Exception);
+ Result query(const Core::String &query, const ArgumentMap &args = ArgumentMap()) throw(Core::Exception);
class Result {
private:
- friend Result UserDBBackendMysql::query(const std::string &query, const ArgumentMap &args) throw(Core::Exception);
+ friend Result UserDBBackendMysql::query(const Core::String &query, const ArgumentMap &args) throw(Core::Exception);
boost::shared_ptr<MYSQL_RES> result;
@@ -84,21 +84,21 @@ class UserDBBackendMysql : public Common::UserDBBackend, private Core::Configura
}
};
- static const std::string name;
+ static const Core::String name;
Common::Application *application;
- std::string host, username, passwd, db, unixSocket;
+ Core::String host, username, passwd, db, unixSocket;
uint16_t port;
- std::string queryListUsers, queryListGroups;
- std::string queryListUserGroups, queryListGroupUsers;
- std::string queryUserById, queryUserByName;
- std::string queryGroupById, queryGroupByName;
- std::string queryUserGroupTable;
- std::string queryAddUser, queryUpdateUser, queryDeleteUser;
- std::string queryAddGroup, queryUpdateGroup, queryDeleteGroup;
- std::string queryAddUserToGroup, queryDeleteUserFromGroup;
+ Core::String queryListUsers, queryListGroups;
+ Core::String queryListUserGroups, queryListGroupUsers;
+ Core::String queryUserById, queryUserByName;
+ Core::String queryGroupById, queryGroupByName;
+ Core::String queryUserGroupTable;
+ Core::String queryAddUser, queryUpdateUser, queryDeleteUser;
+ Core::String queryAddGroup, queryUpdateGroup, queryDeleteGroup;
+ Core::String queryAddUserToGroup, queryDeleteUserFromGroup;
MYSQL *mysql;
@@ -112,12 +112,12 @@ class UserDBBackendMysql : public Common::UserDBBackend, private Core::Configura
virtual boost::shared_ptr<const std::map<unsigned long, Common::UserInfo> > getUserList(boost::posix_time::ptime *timestamp) throw(Core::Exception);
virtual boost::shared_ptr<const Common::UserInfo> getUserInfo(unsigned long uid, boost::posix_time::ptime *timestamp) throw(Core::Exception);
- virtual boost::shared_ptr<const Common::UserInfo> getUserInfoByName(const std::string &name, boost::posix_time::ptime *timestamp) throw(Core::Exception);
+ virtual boost::shared_ptr<const Common::UserInfo> getUserInfoByName(const Core::String &name, boost::posix_time::ptime *timestamp) throw(Core::Exception);
virtual boost::shared_ptr<const std::set<unsigned long> > getUserGroupList(unsigned long uid, boost::posix_time::ptime *timestamp) throw(Core::Exception);
virtual boost::shared_ptr<const std::map<unsigned long, Common::GroupInfo> > getGroupList(boost::posix_time::ptime *timestamp) throw(Core::Exception);
virtual boost::shared_ptr<const Common::GroupInfo> getGroupInfo(unsigned long gid, boost::posix_time::ptime *timestamp) throw(Core::Exception);
- virtual boost::shared_ptr<const Common::GroupInfo> getGroupInfoByName(const std::string &name, boost::posix_time::ptime *timestamp) throw(Core::Exception);
+ virtual boost::shared_ptr<const Common::GroupInfo> getGroupInfoByName(const Core::String &name, boost::posix_time::ptime *timestamp) throw(Core::Exception);
virtual boost::shared_ptr<const std::set<unsigned long> > getGroupUserList(unsigned long gid, boost::posix_time::ptime *timestamp) throw(Core::Exception);
virtual boost::shared_ptr<const std::multimap<unsigned long, unsigned long> > getFullUserGroupList(boost::posix_time::ptime *timestamp) throw(Core::Exception);
@@ -147,7 +147,7 @@ class UserDBBackendMysql : public Common::UserDBBackend, private Core::Configura
}
}
- virtual const std::string& getName() {
+ virtual const Core::String& getName() {
return name;
}
};