From da9a0f4e40899b18c7993256bb27f5f50bf874f7 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 5 Dec 2013 21:51:22 +0000 Subject: QPID-3981: Windows C++ Broker fails ACL self tests Most failures caused by a bug in NullAuthenticator, it was not adding the default realm to user IDs that didn't already have a realm. Copied from trunk r1548268 git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/0.26@1548313 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/qpid/broker/windows/SaslAuthenticator.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/qpid/cpp/src/qpid/broker/windows/SaslAuthenticator.cpp b/qpid/cpp/src/qpid/broker/windows/SaslAuthenticator.cpp index 98c7516ebe..814c236712 100644 --- a/qpid/cpp/src/qpid/broker/windows/SaslAuthenticator.cpp +++ b/qpid/cpp/src/qpid/broker/windows/SaslAuthenticator.cpp @@ -43,6 +43,7 @@ class NullAuthenticator : public SaslAuthenticator { qpid::broker::amqp_0_10::Connection& connection; framing::AMQP_ClientProxy::Connection client; + string realm; public: NullAuthenticator(qpid::broker::amqp_0_10::Connection& connection); ~NullAuthenticator(); @@ -92,7 +93,8 @@ std::auto_ptr SaslAuthenticator::createAuthenticator(qpid::br } } -NullAuthenticator::NullAuthenticator(qpid::broker::amqp_0_10::Connection& c) : connection(c), client(c.getOutput()) {} +NullAuthenticator::NullAuthenticator(qpid::broker::amqp_0_10::Connection& c) : + connection(c), client(c.getOutput()), realm("@"+c.getBroker().getOptions().realm) {} NullAuthenticator::~NullAuthenticator() {} void NullAuthenticator::getMechanisms(Array& mechanisms) @@ -101,6 +103,13 @@ void NullAuthenticator::getMechanisms(Array& mechanisms) mechanisms.add(boost::shared_ptr(new Str16Value("PLAIN"))); } +namespace { +bool endsWith(const std::string& str, const std::string& ending) { + return (ending.size() <= str.size()) && + (str.compare(str.size() - ending.size(), ending.size(), ending) == 0); +} +} + void NullAuthenticator::start(const string& mechanism, const string* response) { QPID_LOG(warning, "SASL: No Authentication Performed"); @@ -110,6 +119,7 @@ void NullAuthenticator::start(const string& mechanism, const string* response) string::size_type i = temp.find((char)0); string uid = temp.substr(0, i); string pwd = temp.substr(i + 1); + if (!endsWith(uid, realm)) uid += realm; connection.setUserId(uid); } } else { -- cgit v1.2.1