summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2013-12-05 21:51:22 +0000
committerAlan Conway <aconway@apache.org>2013-12-05 21:51:22 +0000
commitda9a0f4e40899b18c7993256bb27f5f50bf874f7 (patch)
tree8b4f1ac6b19c2345d0abee4e3189d542ec441d5a
parent75c84610b4683b429e384ddb34c44ca737fbbbf2 (diff)
downloadqpid-python-da9a0f4e40899b18c7993256bb27f5f50bf874f7.tar.gz
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
-rw-r--r--qpid/cpp/src/qpid/broker/windows/SaslAuthenticator.cpp12
1 files changed, 11 insertions, 1 deletions
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> 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<FieldValue>(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 {