summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/broker/SaslAuthenticator.cpp
diff options
context:
space:
mode:
authorStephen D. Huston <shuston@apache.org>2008-10-16 22:32:31 +0000
committerStephen D. Huston <shuston@apache.org>2008-10-16 22:32:31 +0000
commitbf54dc92bf7d46862cbef3113314b7b16797d92e (patch)
treef4eb32ed0c3fd37e9b64eda78ebf3250d3814444 /cpp/src/qpid/broker/SaslAuthenticator.cpp
parent18afe1de9b0f1082013569566192c460ec163290 (diff)
downloadqpid-python-bf54dc92bf7d46862cbef3113314b7b16797d92e.tar.gz
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
Diffstat (limited to 'cpp/src/qpid/broker/SaslAuthenticator.cpp')
-rw-r--r--cpp/src/qpid/broker/SaslAuthenticator.cpp40
1 files changed, 39 insertions, 1 deletions
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> SaslAuthenticator::createAuthenticator(Connection& c)