summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2013-12-05 20:21:30 +0000
committerAlan Conway <aconway@apache.org>2013-12-05 20:21:30 +0000
commit8e9390e1d25393553fa8fc3cdc397e7fd37a01f9 (patch)
tree16737f5488ce36ad774792dc1a74aa9418d76ea0 /cpp/src
parentd81c1be4e69cba98c65fe1764e66b5b8066cd3ea (diff)
downloadqpid-python-8e9390e1d25393553fa8fc3cdc397e7fd37a01f9.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. This fixes 20 of the 23 failures for this test, 3 tests are still failing: 16: acl.ACLTests.test_connection_limits_by_ip_address ....................... fail 16: acl.ACLTests.test_connection_limits_cli_sets_all ........................ fail 16: acl.ACLTests.test_queue_per_user_quota .................................. fail git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1548268 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/qpid/broker/windows/SaslAuthenticator.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/cpp/src/qpid/broker/windows/SaslAuthenticator.cpp b/cpp/src/qpid/broker/windows/SaslAuthenticator.cpp
index 98c7516ebe..814c236712 100644
--- a/cpp/src/qpid/broker/windows/SaslAuthenticator.cpp
+++ b/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 {