From 9991fae5ea4415b6ef760a4430658202b90264bc Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Wed, 2 Feb 2011 18:16:57 +0000 Subject: QPID-3032 - Modifications to the QMFv2 implementation: 1) Use the topic exchange as the base for direct and reply-to addresses. 2) Add a strict-security option to the Console and Agent APIs that narrows the messaging patterns used such that they can easily be controlled by broker ACL policy. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1066562 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qmf/Agent.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'cpp/src/qmf/Agent.cpp') diff --git a/cpp/src/qmf/Agent.cpp b/cpp/src/qmf/Agent.cpp index 3a385b3741..1b7d03968e 100644 --- a/cpp/src/qmf/Agent.cpp +++ b/cpp/src/qmf/Agent.cpp @@ -71,8 +71,8 @@ Schema Agent::getSchema(const SchemaId& s, Duration t) { return impl->getSchema( AgentImpl::AgentImpl(const std::string& n, uint32_t e, ConsoleSessionImpl& s) : - name(n), epoch(e), session(s), touched(true), untouchedCount(0), capability(0), - nextCorrelator(1), schemaCache(s.schemaCache) + name(n), directSubject(n), epoch(e), session(s), touched(true), untouchedCount(0), capability(0), + sender(session.directSender), nextCorrelator(1), schemaCache(s.schemaCache) { } @@ -83,6 +83,11 @@ void AgentImpl::setAttribute(const std::string& k, const qpid::types::Variant& v try { capability = v.asUint32(); } catch (std::exception&) {} + if (k == "_direct_subject") + try { + directSubject = v.asString(); + sender = session.topicSender; + } catch (std::exception&) {} } const Variant& AgentImpl::getAttribute(const string& k) const @@ -514,9 +519,10 @@ void AgentImpl::sendQuery(const Query& query, uint32_t correlator) msg.setReplyTo(session.replyAddress); msg.setCorrelationId(boost::lexical_cast(correlator)); - msg.setSubject(name); + msg.setSubject(directSubject); encode(QueryImplAccess::get(query).asMap(), msg); - session.directSender.send(msg); + if (sender.isValid()) + sender.send(msg); QPID_LOG(trace, "SENT QueryRequest to=" << name); } @@ -538,9 +544,10 @@ void AgentImpl::sendMethod(const string& method, const Variant::Map& args, const msg.setReplyTo(session.replyAddress); msg.setCorrelationId(boost::lexical_cast(correlator)); - msg.setSubject(name); + msg.setSubject(directSubject); encode(map, msg); - session.directSender.send(msg); + if (sender.isValid()) + sender.send(msg); QPID_LOG(trace, "SENT MethodRequest method=" << method << " to=" << name); } @@ -578,8 +585,9 @@ void AgentImpl::sendSchemaRequest(const SchemaId& id) Message msg; msg.setReplyTo(session.replyAddress); msg.setContent(content); - msg.setSubject(name); - session.directSender.send(msg); + msg.setSubject(directSubject); + if (sender.isValid()) + sender.send(msg); QPID_LOG(trace, "SENT V1SchemaRequest to=" << name); } -- cgit v1.2.1