From 82ef58fb3d0bdf6ce7d13f42cca30d03b24973c6 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 27 Aug 2009 17:27:58 +0200 Subject: =?UTF-8?q?AuthProvider=20hinzugef=C3=BCgt=20AuthBackendFile=20in?= =?UTF-8?q?=20AuthProviderFile=20und=20AuthBackendPassword=20aufgeteilt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/AuthBackendFile/AuthBackendFile.cpp | 108 --------------------- src/modules/AuthBackendFile/AuthBackendFile.h | 95 ------------------ src/modules/AuthBackendFile/CMakeLists.txt | 8 -- src/modules/AuthBackendFile/Module.cpp | 30 ------ src/modules/AuthBackendFile/Module.h | 52 ---------- .../AuthBackendPassword/AuthBackendPassword.cpp | 50 ++++++++++ .../AuthBackendPassword/AuthBackendPassword.h | 71 ++++++++++++++ src/modules/AuthBackendPassword/CMakeLists.txt | 8 ++ src/modules/AuthBackendPassword/Module.cpp | 30 ++++++ src/modules/AuthBackendPassword/Module.h | 52 ++++++++++ src/modules/AuthProviderFile/AuthProviderFile.cpp | 78 +++++++++++++++ src/modules/AuthProviderFile/AuthProviderFile.h | 80 +++++++++++++++ src/modules/AuthProviderFile/CMakeLists.txt | 8 ++ src/modules/AuthProviderFile/Module.cpp | 30 ++++++ src/modules/AuthProviderFile/Module.h | 52 ++++++++++ src/modules/CMakeLists.txt | 3 +- 16 files changed, 461 insertions(+), 294 deletions(-) delete mode 100644 src/modules/AuthBackendFile/AuthBackendFile.cpp delete mode 100644 src/modules/AuthBackendFile/AuthBackendFile.h delete mode 100644 src/modules/AuthBackendFile/CMakeLists.txt delete mode 100644 src/modules/AuthBackendFile/Module.cpp delete mode 100644 src/modules/AuthBackendFile/Module.h create mode 100644 src/modules/AuthBackendPassword/AuthBackendPassword.cpp create mode 100644 src/modules/AuthBackendPassword/AuthBackendPassword.h create mode 100644 src/modules/AuthBackendPassword/CMakeLists.txt create mode 100644 src/modules/AuthBackendPassword/Module.cpp create mode 100644 src/modules/AuthBackendPassword/Module.h create mode 100644 src/modules/AuthProviderFile/AuthProviderFile.cpp create mode 100644 src/modules/AuthProviderFile/AuthProviderFile.h create mode 100644 src/modules/AuthProviderFile/CMakeLists.txt create mode 100644 src/modules/AuthProviderFile/Module.cpp create mode 100644 src/modules/AuthProviderFile/Module.h (limited to 'src/modules') diff --git a/src/modules/AuthBackendFile/AuthBackendFile.cpp b/src/modules/AuthBackendFile/AuthBackendFile.cpp deleted file mode 100644 index b05b2db..0000000 --- a/src/modules/AuthBackendFile/AuthBackendFile.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * AuthBackendFile.cpp - * - * Copyright (C) 2009 Matthias Schiffer - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along - * with this program. If not, see . - */ - -#include "AuthBackendFile.h" -#include -#include - -#include - -#include - -namespace Mad { -namespace Modules { -namespace AuthBackendFile { - -void AuthBackendFile::readFile(const std::string &name) { - std::ifstream stream(name.c_str()); - if(!stream.good()) { - application->logf(Core::LoggerBase::LOG_WARNING, "AuthBackendFile: Can't read file '%s'.", name.c_str()); - return; - } - - while(stream.good() && !stream.eof()) { - std::string line; - std::getline(stream, line); - - if(line.empty()) - continue; - - static const boost::regex regex("([^:]+):(.+)", boost::regex_constants::perl); - boost::smatch match; - - if(!boost::regex_match(line, match, regex)) { - application->logf(Core::LoggerBase::LOG_WARNING, "AuthBackendFile: Malformed line in file '%s'.", name.c_str()); - continue; - } - - - userMap.insert(std::make_pair(match[1].str(), match[2].str())); - } -} - -bool AuthBackendFile::handleConfigEntry(const Core::ConfigEntry &entry, bool /*handled*/) { - if(!entry[0].getKey().matches("AuthBackendFile")) - return false; - - if(entry[1].empty()) - return true; - - if(entry[1].getKey().matches("File")) { - if(entry[2].empty()) { - readFile(entry[1][0]); - } - } - else if(!entry[2].empty()) - return false; - - return true; -} - -boost::shared_ptr AuthBackendFile::authenticate(const std::string &method, const std::string &subMethod, - const std::string &user, const std::vector &data, std::vector& /*response*/, - boost::shared_ptr context) throw(Core::Exception) { - if(method != "Password") - throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); - - if(context.get() != 0 && dynamic_cast(context.get()) == 0) - throw(Core::Exception(Core::Exception::INVALID_INPUT)); - - if(context.get() == 0) - context.reset(new AuthContextFile); - - std::map::iterator userIt = userMap.find(user); - if(userIt == userMap.end()) - throw(Core::Exception(Core::Exception::AUTHENTICATION)); - - if(subMethod == "Clear") { - if(userIt->second != std::string(data.begin(), data.end())) - throw(Core::Exception(Core::Exception::AUTHENTICATION)); - } - else { - if(!std::equal(data.begin(), data.end(), Common::Hash::hash(userIt->second, subMethod).begin())) - throw(Core::Exception(Core::Exception::AUTHENTICATION)); - } - - - return context; -} - -} -} -} diff --git a/src/modules/AuthBackendFile/AuthBackendFile.h b/src/modules/AuthBackendFile/AuthBackendFile.h deleted file mode 100644 index 8098817..0000000 --- a/src/modules/AuthBackendFile/AuthBackendFile.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * AuthBackendFile.h - * - * Copyright (C) 2008 Matthias Schiffer - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along - * with this program. If not, see . - */ - -#ifndef MAD_MODULES_AUTHBACKENDFILE_AUTHBACKENDFILE_H_ -#define MAD_MODULES_AUTHBACKENDFILE_AUTHBACKENDFILE_H_ - -#include "../export.h" - -#include -#include -#include -#include - -#include -#include - -namespace Mad { -namespace Modules { -namespace AuthBackendFile { - -class MAD_MODULE_EXPORT AuthBackendFile : public Common::AuthBackend, private Core::Configurable, private boost::noncopyable { - private: - class AuthContextFile : public Common::AuthContext { - protected: - virtual bool isAuthenticated() const { - return true; - } - }; - - void readFile(const std::string &name); - - Common::Application *application; - - std::vector methods; - std::vector subMethods; - - std::map userMap; - - protected: - virtual bool handleConfigEntry(const Core::ConfigEntry &entry, bool /*handled*/); - - virtual const std::vector& getMethods() const { - return methods; - } - - virtual const std::vector& getSubMethods(const std::string &method) const throw(Core::Exception) { - if(method != "Password") - throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); - - return subMethods; - } - - virtual boost::shared_ptr authenticate(const std::string &method, const std::string &subMethod, - const std::string &user, const std::vector &data, std::vector &response, - boost::shared_ptr context) throw(Core::Exception); - - public: - AuthBackendFile(Common::Application *application0) : application(application0) { - methods.push_back("Password"); - - const std::vector &hashList = Common::Hash::getHashList(); - if(hashList.empty()) - subMethods.push_back("Clear"); - else - subMethods.push_back(hashList.front()); - - application->getConfigManager()->registerConfigurable(this); - } - - virtual ~AuthBackendFile() { - application->getConfigManager()->unregisterConfigurable(this); - } -}; - -} -} -} - -#endif /* MAD_MODULES_AUTHBACKENDFILE_AUTHBACKENDFILE_H_ */ diff --git a/src/modules/AuthBackendFile/CMakeLists.txt b/src/modules/AuthBackendFile/CMakeLists.txt deleted file mode 100644 index 3afd71f..0000000 --- a/src/modules/AuthBackendFile/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -include_directories(${INCLUDES}) - -mad_module(AuthBackendFile - Module.cpp Module.h - AuthBackendFile.cpp AuthBackendFile.h -) - -mad_module_libraries(AuthBackendFile) diff --git a/src/modules/AuthBackendFile/Module.cpp b/src/modules/AuthBackendFile/Module.cpp deleted file mode 100644 index e5a9a18..0000000 --- a/src/modules/AuthBackendFile/Module.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Module.cpp - * - * Copyright (C) 2009 Matthias Schiffer - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along - * with this program. If not, see . - */ - -#include "../export.h" - -#include "Module.h" - -extern "C" { - -MAD_MODULE_EXPORT Mad::Common::Module* AuthBackendFile_create(Mad::Common::Application *application) { - return new Mad::Modules::AuthBackendFile::Module(application); -} - -} diff --git a/src/modules/AuthBackendFile/Module.h b/src/modules/AuthBackendFile/Module.h deleted file mode 100644 index b0d14aa..0000000 --- a/src/modules/AuthBackendFile/Module.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Module.h - * - * Copyright (C) 2009 Matthias Schiffer - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along - * with this program. If not, see . - */ - -#ifndef MAD_MODULES_AUTHBACKENDFILE_MODULE_H_ -#define MAD_MODULES_AUTHBACKENDFILE_MODULE_H_ - -#include "AuthBackendFile.h" - -#include -#include - -namespace Mad { -namespace Modules { -namespace AuthBackendFile { - -class Module : public Common::Module { - private: - Common::Application *application; - - boost::shared_ptr backend; - - public: - Module(Common::Application *application0) : application(application0), backend(new AuthBackendFile(application)) { - application->getAuthManager()->registerBackend(backend); - } - - virtual ~Module() { - application->getAuthManager()->unregisterBackend(backend); - } -}; - -} -} -} - -#endif /* MAD_MODULES_AUTHBACKENDFILE_MODULE_H_ */ diff --git a/src/modules/AuthBackendPassword/AuthBackendPassword.cpp b/src/modules/AuthBackendPassword/AuthBackendPassword.cpp new file mode 100644 index 0000000..7e5aca9 --- /dev/null +++ b/src/modules/AuthBackendPassword/AuthBackendPassword.cpp @@ -0,0 +1,50 @@ +/* + * AuthBackendPassword.cpp + * + * Copyright (C) 2009 Matthias Schiffer + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with this program. If not, see . + */ + +#include "AuthBackendPassword.h" + +namespace Mad { +namespace Modules { +namespace AuthBackendPassword { + +const std::string AuthBackendPassword::methodName = "Password"; + +boost::shared_ptr AuthBackendPassword::authenticate(boost::shared_ptr provider, const std::string &subMethod, + const std::string &user, const std::vector &data, std::vector& /*response*/, + boost::shared_ptr context) throw(Core::Exception) { + if(context.get() != 0 && dynamic_cast(context.get()) == 0) + throw(Core::Exception(Core::Exception::INVALID_INPUT)); + + std::vector allowedMethods = getSubMethods(provider); + if(std::find(allowedMethods.begin(), allowedMethods.end(), subMethod) == allowedMethods.end()) + throw(Core::Exception(Core::Exception::INVALID_INPUT)); + + if(context.get() == 0) + context.reset(new AuthContextPassword); + + if(!provider->checkPassword(user, data, subMethod)) + throw(Core::Exception(Core::Exception::AUTHENTICATION)); + + + return context; +} + +} +} +} diff --git a/src/modules/AuthBackendPassword/AuthBackendPassword.h b/src/modules/AuthBackendPassword/AuthBackendPassword.h new file mode 100644 index 0000000..ac100c1 --- /dev/null +++ b/src/modules/AuthBackendPassword/AuthBackendPassword.h @@ -0,0 +1,71 @@ +/* + * AuthBackendPassword.h + * + * Copyright (C) 2008 Matthias Schiffer + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with this program. If not, see . + */ + +#ifndef MAD_MODULES_AUTHBACKENDPASSWORD_AUTHBACKENDPASSWORD_H_ +#define MAD_MODULES_AUTHBACKENDPASSWORD_AUTHBACKENDPASSWORD_H_ + +#include "../export.h" + +#include +#include +#include +#include + +namespace Mad { +namespace Modules { +namespace AuthBackendPassword { + +class MAD_MODULE_EXPORT AuthBackendPassword : public Common::AuthBackend, private boost::noncopyable { + private: + class AuthContextPassword : public Common::AuthContext { + protected: + virtual bool isAuthenticated() const { + return true; + } + }; + + Common::Application *application; + + static const std::string methodName; + + protected: + virtual const std::string& getMethodName() const { + return methodName; + } + + virtual std::vector getSubMethods(boost::shared_ptr provider) const { + std::vector ret; + ret.push_back(provider->getHashes().front()); + + return ret; + } + + virtual boost::shared_ptr authenticate(boost::shared_ptr provider, const std::string &subMethod, + const std::string &user, const std::vector &data, std::vector &response, + boost::shared_ptr context) throw(Core::Exception); + + public: + AuthBackendPassword(Common::Application *application0) : application(application0) {} +}; + +} +} +} + +#endif /* MAD_MODULES_AUTHBACKENDPASSWORD_AUTHBACKENDPASSWORD_H_ */ diff --git a/src/modules/AuthBackendPassword/CMakeLists.txt b/src/modules/AuthBackendPassword/CMakeLists.txt new file mode 100644 index 0000000..cad37a2 --- /dev/null +++ b/src/modules/AuthBackendPassword/CMakeLists.txt @@ -0,0 +1,8 @@ +include_directories(${INCLUDES}) + +mad_module(AuthBackendPassword + Module.cpp Module.h + AuthBackendPassword.cpp AuthBackendPassword.h +) + +mad_module_libraries(AuthBackendPassword) diff --git a/src/modules/AuthBackendPassword/Module.cpp b/src/modules/AuthBackendPassword/Module.cpp new file mode 100644 index 0000000..a46f6f6 --- /dev/null +++ b/src/modules/AuthBackendPassword/Module.cpp @@ -0,0 +1,30 @@ +/* + * Module.cpp + * + * Copyright (C) 2009 Matthias Schiffer + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with this program. If not, see . + */ + +#include "../export.h" + +#include "Module.h" + +extern "C" { + +MAD_MODULE_EXPORT Mad::Common::Module* AuthBackendPassword_create(Mad::Common::Application *application) { + return new Mad::Modules::AuthBackendPassword::Module(application); +} + +} diff --git a/src/modules/AuthBackendPassword/Module.h b/src/modules/AuthBackendPassword/Module.h new file mode 100644 index 0000000..e0a462e --- /dev/null +++ b/src/modules/AuthBackendPassword/Module.h @@ -0,0 +1,52 @@ +/* + * Module.h + * + * Copyright (C) 2009 Matthias Schiffer + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with this program. If not, see . + */ + +#ifndef MAD_MODULES_AUTHBACKENDPASSWORD_MODULE_H_ +#define MAD_MODULES_AUTHBACKENDPASSWORD_MODULE_H_ + +#include "AuthBackendPassword.h" + +#include +#include + +namespace Mad { +namespace Modules { +namespace AuthBackendPassword { + +class Module : public Common::Module { + private: + Common::Application *application; + + boost::shared_ptr backend; + + public: + Module(Common::Application *application0) : application(application0), backend(new AuthBackendPassword(application)) { + application->getAuthManager()->registerBackend(backend); + } + + virtual ~Module() { + application->getAuthManager()->unregisterBackend(backend); + } +}; + +} +} +} + +#endif /* MAD_MODULES_AUTHBACKENDPASSWORD_MODULE_H_ */ diff --git a/src/modules/AuthProviderFile/AuthProviderFile.cpp b/src/modules/AuthProviderFile/AuthProviderFile.cpp new file mode 100644 index 0000000..ce575cd --- /dev/null +++ b/src/modules/AuthProviderFile/AuthProviderFile.cpp @@ -0,0 +1,78 @@ +/* + * AuthBackendFile.cpp + * + * Copyright (C) 2009 Matthias Schiffer + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with this program. If not, see . + */ + +#include "AuthProviderFile.h" +#include + +#include + +#include + +namespace Mad { +namespace Modules { +namespace AuthProviderFile { + +void AuthProviderFile::readFile(const std::string &name) { + std::ifstream stream(name.c_str()); + if(!stream.good()) { + application->logf(Core::LoggerBase::LOG_WARNING, "AuthProviderFile: Can't read file '%s'.", name.c_str()); + return; + } + + while(stream.good() && !stream.eof()) { + std::string line; + std::getline(stream, line); + + if(line.empty()) + continue; + + static const boost::regex regex("([^:]+):(.+)", boost::regex_constants::perl); + boost::smatch match; + + if(!boost::regex_match(line, match, regex)) { + application->logf(Core::LoggerBase::LOG_WARNING, "AuthProviderFile: Malformed line in file '%s'.", name.c_str()); + continue; + } + + + userMap.insert(std::make_pair(match[1].str(), match[2].str())); + } +} + +bool AuthProviderFile::handleConfigEntry(const Core::ConfigEntry &entry, bool /*handled*/) { + if(!entry[0].getKey().matches("AuthProviderFile")) + return false; + + if(entry[1].empty()) + return true; + + if(entry[1].getKey().matches("File")) { + if(entry[2].empty()) { + readFile(entry[1][0]); + } + } + else if(!entry[2].empty()) + return false; + + return true; +} + +} +} +} diff --git a/src/modules/AuthProviderFile/AuthProviderFile.h b/src/modules/AuthProviderFile/AuthProviderFile.h new file mode 100644 index 0000000..da0c8cd --- /dev/null +++ b/src/modules/AuthProviderFile/AuthProviderFile.h @@ -0,0 +1,80 @@ +/* + * AuthProviderFile.h + * + * Copyright (C) 2008 Matthias Schiffer + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with this program. If not, see . + */ + +#ifndef MAD_MODULES_AUTHPROVIDERFILE_AUTHPROVIDERFILE_H_ +#define MAD_MODULES_AUTHPROVIDERFILE_AUTHPROVIDERFILE_H_ + +#include "../export.h" + +#include +#include +#include + +#include +#include + +namespace Mad { +namespace Modules { +namespace AuthProviderFile { + +class MAD_MODULE_EXPORT AuthProviderFile : public Common::AuthProvider, private Core::Configurable, private boost::noncopyable { + private: + void readFile(const std::string &name); + + Common::Application *application; + + std::map userMap; + + std::vector hashes; + + protected: + virtual bool handleConfigEntry(const Core::ConfigEntry &entry, bool /*handled*/); + + virtual const std::vector& getHashes() const { + return hashes; + } + + virtual std::vector getPassword(const std::string &user, const std::string &hash) throw(Core::Exception) { + std::map::iterator userIt = userMap.find(user); + if(userIt == userMap.end()) + return std::vector(); + + if(hash == "Clear") + return std::vector(userIt->second.begin(), userIt->second.end()); + else + return Common::Hash::hash(std::vector(userIt->second.begin(), userIt->second.end()), hash); + } + + public: + AuthProviderFile(Common::Application *application0) : application(application0), hashes(Common::Hash::getHashList()) { + hashes.push_back("Clear"); + + application->getConfigManager()->registerConfigurable(this); + } + + virtual ~AuthProviderFile() { + application->getConfigManager()->unregisterConfigurable(this); + } +}; + +} +} +} + +#endif /* MAD_MODULES_AUTHPROVIDERFILE_AUTHPROVIDERFILE_H_ */ diff --git a/src/modules/AuthProviderFile/CMakeLists.txt b/src/modules/AuthProviderFile/CMakeLists.txt new file mode 100644 index 0000000..609357a --- /dev/null +++ b/src/modules/AuthProviderFile/CMakeLists.txt @@ -0,0 +1,8 @@ +include_directories(${INCLUDES}) + +mad_module(AuthProviderFile + Module.cpp Module.h + AuthProviderFile.cpp AuthProviderFile.h +) + +mad_module_libraries(AuthProviderFile) diff --git a/src/modules/AuthProviderFile/Module.cpp b/src/modules/AuthProviderFile/Module.cpp new file mode 100644 index 0000000..aa84d22 --- /dev/null +++ b/src/modules/AuthProviderFile/Module.cpp @@ -0,0 +1,30 @@ +/* + * Module.cpp + * + * Copyright (C) 2009 Matthias Schiffer + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with this program. If not, see . + */ + +#include "../export.h" + +#include "Module.h" + +extern "C" { + +MAD_MODULE_EXPORT Mad::Common::Module* AuthProviderFile_create(Mad::Common::Application *application) { + return new Mad::Modules::AuthProviderFile::Module(application); +} + +} diff --git a/src/modules/AuthProviderFile/Module.h b/src/modules/AuthProviderFile/Module.h new file mode 100644 index 0000000..772a83b --- /dev/null +++ b/src/modules/AuthProviderFile/Module.h @@ -0,0 +1,52 @@ +/* + * Module.h + * + * Copyright (C) 2009 Matthias Schiffer + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with this program. If not, see . + */ + +#ifndef MAD_MODULES_AUTHPROVIDERFILE_MODULE_H_ +#define MAD_MODULES_AUTHPROVIDERFILE_MODULE_H_ + +#include "AuthProviderFile.h" + +#include +#include + +namespace Mad { +namespace Modules { +namespace AuthProviderFile { + +class Module : public Common::Module { + private: + Common::Application *application; + + boost::shared_ptr provider; + + public: + Module(Common::Application *application0) : application(application0), provider(new AuthProviderFile(application)) { + application->getAuthManager()->setProvider(provider); + } + + virtual ~Module() { + application->getAuthManager()->unsetProvider(provider); + } +}; + +} +} +} + +#endif /* MAD_MODULES_AUTHPROVIDERFILE_MODULE_H_ */ diff --git a/src/modules/CMakeLists.txt b/src/modules/CMakeLists.txt index e5890f4..0e198f8 100644 --- a/src/modules/CMakeLists.txt +++ b/src/modules/CMakeLists.txt @@ -33,7 +33,8 @@ macro(mad_module_libraries name) endif(WITH_${upper_name}) endmacro(mad_module_libraries) -add_subdirectory(AuthBackendFile) +add_subdirectory(AuthBackendPassword) +add_subdirectory(AuthProviderFile) add_subdirectory(FileLogger) if(UNIX) -- cgit v1.2.3