Author: rajith
Date: Mon Jan 11 19:26:11 2010
New Revision: 898021
URL: http://svn.apache.org/viewvc?rev=898021&view=rev
Log:
This further improves the fix made at rev 19819 in Qpid trunk for QPID-2175
The check is now done without creating any new strings to avoid extra
allocations.
Modified:
qpid/trunk/qpid/cpp/src/qpid/broker/SemanticState.cpp
qpid/trunk/qpid/cpp/src/qpid/broker/SemanticState.h
Modified: qpid/trunk/qpid/cpp/src/qpid/broker/SemanticState.cpp
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/SemanticState.cpp?rev=898021&r1=898020&r2=898021&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/SemanticState.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/SemanticState.cpp Mon Jan 11 19:26:11
2010
@@ -71,7 +71,8 @@
dtxSelected(false),
authMsg(getSession().getBroker().getOptions().auth &&
!getSession().getConnection().isFederationLink()),
userID(getSession().getConnection().getUserId()),
- defaultRealm(getSession().getBroker().getOptions().realm)
+
userName(getSession().getConnection().getUserId().substr(0,getSession().getConnection().getUserId().find('@'))),
+ isDefaultRealm(userID.find('@') != std::string::npos &&
getSession().getBroker().getOptions().realm ==
userID.substr(userID.find('@')+1,userID.size()))
{
acl = getSession().getBroker().getAcl();
}
@@ -429,8 +430,8 @@
/* verify the userid if specified: */
std::string id =
msg->hasProperties<MessageProperties>() ?
msg->getProperties<MessageProperties>()->getUserId() : nullstring;
-
- if (authMsg && !id.empty() && id != userID &&
id.append("@").append(defaultRealm) != userID)
+
+ if (authMsg && !id.empty() && !(id == userID || (isDefaultRealm && id ==
userName)))
{
QPID_LOG(debug, "authorised user id : " << userID << " but user id in
message declared as " << id);
throw UnauthorizedAccessException(QPID_MSG("authorised user id : " <<
userID << " but user id in message declared as " << id));
Modified: qpid/trunk/qpid/cpp/src/qpid/broker/SemanticState.h
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/SemanticState.h?rev=898021&r1=898020&r2=898021&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/SemanticState.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/SemanticState.h Mon Jan 11 19:26:11 2010
@@ -156,7 +156,8 @@
AclModule* acl;
const bool authMsg;
const string userID;
- const string defaultRealm;
+ const string userName;
+ const bool isDefaultRealm;
void route(boost::intrusive_ptr<Message> msg, Deliverable& strategy);
void checkDtxTimeout();
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:[email protected]