summaryrefslogtreecommitdiffstats
path: root/src/Common
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common')
-rw-r--r--src/Common/AuthBackend.h5
-rw-r--r--src/Common/AuthManager.cpp12
-rw-r--r--src/Common/AuthManager.h14
-rw-r--r--src/Common/CMakeLists.txt1
-rw-r--r--src/Common/Hash.h4
5 files changed, 27 insertions, 9 deletions
diff --git a/src/Common/AuthBackend.h b/src/Common/AuthBackend.h
index 53c7769..d916d1d 100644
--- a/src/Common/AuthBackend.h
+++ b/src/Common/AuthBackend.h
@@ -38,9 +38,10 @@ class AuthBackend {
friend class AuthManager;
virtual const std::vector<std::string>& getMethods() const = 0;
+ virtual const std::vector<std::string>& getSubMethods(const std::string &method) const throw(Core::Exception) = 0;
- virtual boost::shared_ptr<AuthContext> authenticate(const std::string& /*method*/, const std::string& /*user*/,
- const std::vector<boost::uint8_t>& /*data*/, std::vector<boost::uint8_t>& /*response*/,
+ 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) = 0;
public:
diff --git a/src/Common/AuthManager.cpp b/src/Common/AuthManager.cpp
index ffb8453..82fbda5 100644
--- a/src/Common/AuthManager.cpp
+++ b/src/Common/AuthManager.cpp
@@ -45,13 +45,19 @@ std::vector<std::string> AuthManager::getMethods() {
return backend->getMethods();
}
-boost::shared_ptr<AuthContext> AuthManager::authenticate(const std::string &method, 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) {
+std::vector<std::string> AuthManager::getSubMethods(const std::string &method) throw(Core::Exception) {
+ boost::shared_lock<boost::shared_mutex> lock(mutex);
+
+ return backend->getSubMethods(method);
+}
+
+boost::shared_ptr<AuthContext> AuthManager::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) {
boost::lock_guard<boost::shared_mutex> lock(mutex);
response.clear();
- return backend->authenticate(method, user, data, response, context);
+ return backend->authenticate(method, subMethod, user, data, response, context);
}
}
diff --git a/src/Common/AuthManager.h b/src/Common/AuthManager.h
index 1516526..65e1fd3 100644
--- a/src/Common/AuthManager.h
+++ b/src/Common/AuthManager.h
@@ -53,8 +53,12 @@ class MAD_COMMON_EXPORT AuthManager : private boost::noncopyable {
return methods;
}
- virtual boost::shared_ptr<AuthContext> authenticate(const std::string& /*method*/, const std::string& /*user*/,
- const std::vector<boost::uint8_t>& /*data*/, std::vector<boost::uint8_t>& /*response*/,
+ virtual const std::vector<std::string>& getSubMethods(const std::string& /*method*/) const throw(Core::Exception) {
+ throw Core::Exception(Core::Exception::NOT_IMPLEMENTED);
+ }
+
+ 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);
}
@@ -73,9 +77,11 @@ class MAD_COMMON_EXPORT AuthManager : private boost::noncopyable {
void unregisterBackend(boost::shared_ptr<AuthBackend> oldBackend);
std::vector<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 &user, const std::vector<boost::uint8_t> &data,
- std::vector<boost::uint8_t> &response, boost::shared_ptr<AuthContext> context = boost::shared_ptr<AuthContext>()) throw(Core::Exception);
+ 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 = boost::shared_ptr<AuthContext>()) throw(Core::Exception);
};
}
diff --git a/src/Common/CMakeLists.txt b/src/Common/CMakeLists.txt
index 129c7de..e370c54 100644
--- a/src/Common/CMakeLists.txt
+++ b/src/Common/CMakeLists.txt
@@ -11,6 +11,7 @@ mad_library(Common
RequestHandlers/SimpleRequestHandlerGroup.cpp RequestHandlers/SimpleRequestHandlerGroup.h
RequestHandlers/StatusRequestHandler.cpp RequestHandlers/StatusRequestHandler.h
+ Requests/AuthMethodRequest.h
Requests/DisconnectRequest.cpp Requests/DisconnectRequest.h
Requests/FSInfoRequest.h
Requests/IdentifyRequest.cpp Requests/IdentifyRequest.h
diff --git a/src/Common/Hash.h b/src/Common/Hash.h
index 69b3318..06562e2 100644
--- a/src/Common/Hash.h
+++ b/src/Common/Hash.h
@@ -66,6 +66,10 @@ class MAD_COMMON_EXPORT Hash {
return hashes.getList();
}
+ static bool isHashSupported(const std::string &method) {
+ return (hashes.getMap().find(method) != hashes.getMap().end());
+ }
+
static std::vector<boost::uint8_t> hash(const std::vector<boost::uint8_t> &in, unsigned int method) throw (Core::Exception);
static std::vector<boost::uint8_t> hash(const std::vector<boost::uint8_t> &in, const std::string &method) throw (Core::Exception) {