summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/acl/AclConnectionCounter.cpp
diff options
context:
space:
mode:
authorCharles E. Rolke <chug@apache.org>2012-08-10 17:19:51 +0000
committerCharles E. Rolke <chug@apache.org>2012-08-10 17:19:51 +0000
commit83cd0d00a444d1e1b5f8e15135bf377eba03388d (patch)
tree3e188ba92b1c822b06732b3bedfa8ee4a59a20e1 /cpp/src/qpid/acl/AclConnectionCounter.cpp
parenta4c9bc20238bf256b919c8ba5c32c8b056130041 (diff)
downloadqpid-python-83cd0d00a444d1e1b5f8e15135bf377eba03388d.tar.gz
QPID-4142 C++ Broker connection counting gets usernames confused
when various auth mechanism are used. The issue is that the connection's userId is changed as the auth progresses. Also, the shadowed connections change differently from the non-shadowed connections. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1371772 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/acl/AclConnectionCounter.cpp')
-rw-r--r--cpp/src/qpid/acl/AclConnectionCounter.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/cpp/src/qpid/acl/AclConnectionCounter.cpp b/cpp/src/qpid/acl/AclConnectionCounter.cpp
index 052fa3c222..8c6e3eef6e 100644
--- a/cpp/src/qpid/acl/AclConnectionCounter.cpp
+++ b/cpp/src/qpid/acl/AclConnectionCounter.cpp
@@ -296,6 +296,47 @@ bool ConnectionCounter::approveConnection(const broker::Connection& connection)
}
}
+
+//
+// setUserId
+// On cluster shadow connections, track a new user id for this connection.
+//
+void ConnectionCounter::setUserId(const broker::Connection& connection,
+ const std::string& username)
+{
+ Mutex::ScopedLock locker(dataLock);
+
+ connectCountsMap_t::iterator eRef = connectProgressMap.find(connection.getMgmtId());
+ if (eRef != connectProgressMap.end()) {
+ if ((*eRef).second == C_OPENED){
+ // Connection has been opened so that current user has been counted
+ if (connection.isShadow()) {
+ // This is a shadow connection and therefore receives userId changes
+ QPID_LOG(debug, "Changing User ID for cluster connection: "
+ << connection.getMgmtId() << ", old user:'" << connection.getUserId()
+ << "', new user:'" << username << "'");
+
+ // Decrement user in-use count for old userId
+ releaseLH(connectByNameMap,
+ connection.getUserId(),
+ nameLimit);
+ // Increment user in-use count for new userId
+ (void) countConnectionLH(connectByNameMap, username, nameLimit, false);
+ } else {
+ QPID_LOG(warning, "Changing User ID for non-cluster connections is not supported: "
+ << connection.getMgmtId() << ", old user " << connection.getUserId()
+ << ", new user " << username);
+ }
+ } else {
+ // connection exists but has not been opened.
+ // setUserId is called in normal course. The user gets counted when connection is opened.
+ }
+ } else {
+ // Connection does not exist.
+ }
+}
+
+
//
// getClientIp - given a connection's mgmtId return the client host part.
//