From bf54dc92bf7d46862cbef3113314b7b16797d92e Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Thu, 16 Oct 2008 22:32:31 +0000 Subject: Make SaslAuthenticator reimplementable for schemes other than Cyrus, such as Windows; resolves QPID-1365 git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@705382 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/broker/SaslAuthenticator.cpp | 40 ++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'cpp/src/qpid/broker/SaslAuthenticator.cpp') diff --git a/cpp/src/qpid/broker/SaslAuthenticator.cpp b/cpp/src/qpid/broker/SaslAuthenticator.cpp index 136cf6f785..d0e0d5bead 100644 --- a/cpp/src/qpid/broker/SaslAuthenticator.cpp +++ b/cpp/src/qpid/broker/SaslAuthenticator.cpp @@ -19,7 +19,9 @@ * */ -#include "config.h" +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif #include "Connection.h" #include "qpid/log/Statement.h" @@ -66,10 +68,46 @@ public: void step(const std::string& response); }; +bool SaslAuthenticator::available(void) +{ + return true; +} + +// Initialize the SASL mechanism; throw if it fails. +void SaslAuthenticator::init(const std::string& saslName) +{ + int code = sasl_server_init(NULL, saslName.c_str()); + if (code != SASL_OK) { + // TODO: Figure out who owns the char* returned by + // sasl_errstring, though it probably does not matter much + throw Exception(sasl_errstring(code, NULL, NULL)); + } +} + +void SaslAuthenticator::fini(void) +{ + sasl_done(); +} + #else typedef NullAuthenticator CyrusAuthenticator; +bool SaslAuthenticator::available(void) +{ + return false; +} + +void SaslAuthenticator::init(const std::string& /*saslName*/) +{ + throw Exception("Requested authentication but SASL unavailable"); +} + +void SaslAuthenticator::fini(void) +{ + return; +} + #endif std::auto_ptr SaslAuthenticator::createAuthenticator(Connection& c) -- cgit v1.2.1