summaryrefslogtreecommitdiffstats
path: root/src/Common/AuthManager.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common/AuthManager.h')
-rw-r--r--src/Common/AuthManager.h44
1 files changed, 15 insertions, 29 deletions
diff --git a/src/Common/AuthManager.h b/src/Common/AuthManager.h
index 65e1fd3..e45762a 100644
--- a/src/Common/AuthManager.h
+++ b/src/Common/AuthManager.h
@@ -22,14 +22,13 @@
#include "export.h"
-#include "AuthBackend.h"
#include "AuthContext.h"
#include <Core/Exception.h>
-#include <vector>
+#include <map>
+#include <set>
-#include <boost/cstdint.hpp>
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
@@ -40,43 +39,30 @@ namespace Common {
class Application;
+class AuthBackend;
+class AuthProvider;
+
class MAD_COMMON_EXPORT AuthManager : private boost::noncopyable {
private:
friend class Application;
- class DenyBackend : public AuthBackend {
- private:
- const static std::vector<std::string> methods;
-
- protected:
- virtual const std::vector<std::string>& getMethods() const {
- return methods;
- }
-
- virtual const std::vector<std::string>& getSubMethods(const std::string& /*method*/) const throw(Core::Exception) {
- throw Core::Exception(Core::Exception::NOT_IMPLEMENTED);
- }
+ boost::shared_ptr<AuthProvider> provider;
- virtual boost::shared_ptr<AuthContext> authenticate(const std::string& /*method*/, const std::string& /*subMethod*/,
- const std::string& /*user*/, const std::vector<boost::uint8_t>& /*data*/, std::vector<boost::uint8_t>& /*response*/,
- boost::shared_ptr<AuthContext> /*context*/) throw(Core::Exception) {
- throw Core::Exception(Core::Exception::NOT_IMPLEMENTED);
- }
- };
-
- boost::shared_ptr<DenyBackend> denyBackend;
-
- boost::shared_ptr<AuthBackend> backend;
+ std::set<std::string> methods;
+ std::map<std::string, boost::shared_ptr<AuthBackend> > backends;
boost::shared_mutex mutex;
- AuthManager() : denyBackend(new DenyBackend), backend(denyBackend) {}
+ AuthManager() {}
public:
- void registerBackend(boost::shared_ptr<AuthBackend> newBackend);
- void unregisterBackend(boost::shared_ptr<AuthBackend> oldBackend);
+ void setProvider(boost::shared_ptr<AuthProvider> newProvider);
+ void unsetProvider(boost::shared_ptr<AuthProvider> oldProvider);
+
+ void registerBackend(boost::shared_ptr<AuthBackend> backend);
+ void unregisterBackend(boost::shared_ptr<AuthBackend> backend);
- std::vector<std::string> getMethods();
+ std::set<std::string> getMethods();
std::vector<std::string> getSubMethods(const std::string &method) throw(Core::Exception);
boost::shared_ptr<AuthContext> authenticate(const std::string &method, const std::string &subMethod,