From c964aa2708ed2839ded3c35eed7338f3e81f568f Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 24 Aug 2009 04:47:54 +0200 Subject: =?UTF-8?q?Authentifikation:=20=C3=9Cbertrage=20Passw=C3=B6rter=20?= =?UTF-8?q?gehasht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Common/AuthBackend.h | 5 +++-- src/Common/AuthManager.cpp | 12 +++++++++--- src/Common/AuthManager.h | 14 ++++++++++---- src/Common/CMakeLists.txt | 1 + src/Common/Hash.h | 4 ++++ 5 files changed, 27 insertions(+), 9 deletions(-) (limited to 'src/Common') 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& getMethods() const = 0; + virtual const std::vector& getSubMethods(const std::string &method) const throw(Core::Exception) = 0; - virtual boost::shared_ptr authenticate(const std::string& /*method*/, const std::string& /*user*/, - const std::vector& /*data*/, std::vector& /*response*/, + 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) = 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 AuthManager::getMethods() { return backend->getMethods(); } -boost::shared_ptr AuthManager::authenticate(const std::string &method, const std::string &user, const std::vector &data, - std::vector &response, boost::shared_ptr context) throw(Core::Exception) { +std::vector AuthManager::getSubMethods(const std::string &method) throw(Core::Exception) { + boost::shared_lock lock(mutex); + + return backend->getSubMethods(method); +} + +boost::shared_ptr AuthManager::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) { boost::lock_guard 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 authenticate(const std::string& /*method*/, const std::string& /*user*/, - const std::vector& /*data*/, std::vector& /*response*/, + virtual const std::vector& getSubMethods(const std::string& /*method*/) const throw(Core::Exception) { + throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); + } + + 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) { throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); } @@ -73,9 +77,11 @@ class MAD_COMMON_EXPORT AuthManager : private boost::noncopyable { void unregisterBackend(boost::shared_ptr oldBackend); std::vector getMethods(); + std::vector getSubMethods(const std::string &method) throw(Core::Exception); - boost::shared_ptr authenticate(const std::string &method, const std::string &user, const std::vector &data, - std::vector &response, boost::shared_ptr context = boost::shared_ptr()) throw(Core::Exception); + 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 = boost::shared_ptr()) 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 hash(const std::vector &in, unsigned int method) throw (Core::Exception); static std::vector hash(const std::vector &in, const std::string &method) throw (Core::Exception) { -- cgit v1.2.3