summaryrefslogtreecommitdiff
path: root/cpp/src/qpid
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2010-04-09 18:17:34 +0000
committerGordon Sim <gsim@apache.org>2010-04-09 18:17:34 +0000
commit86e70636779edaee5c0a26de5995a707ab2206f9 (patch)
tree32c5d697e73dfdc84859977043cd2196aefd20b7 /cpp/src/qpid
parent3e19793c8f5be1676ea6f7577196f1b01cadf685 (diff)
downloadqpid-python-86e70636779edaee5c0a26de5995a707ab2206f9.tar.gz
QPID-2497: added some verification that address options specified are valid
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@932536 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid')
-rw-r--r--cpp/src/qpid/client/amqp0_10/AddressResolution.cpp54
1 files changed, 51 insertions, 3 deletions
diff --git a/cpp/src/qpid/client/amqp0_10/AddressResolution.cpp b/cpp/src/qpid/client/amqp0_10/AddressResolution.cpp
index 43b581861f..8289242f09 100644
--- a/cpp/src/qpid/client/amqp0_10/AddressResolution.cpp
+++ b/cpp/src/qpid/client/amqp0_10/AddressResolution.cpp
@@ -45,6 +45,7 @@ namespace amqp0_10 {
using qpid::Exception;
using qpid::messaging::Address;
+using qpid::messaging::AddressError;
using qpid::messaging::MalformedAddress;
using qpid::messaging::ResolutionError;
using qpid::messaging::NotFound;
@@ -60,11 +61,21 @@ using namespace qpid::framing::message;
using namespace qpid::amqp_0_10;
using namespace boost::assign;
+class Verifier
+{
+ public:
+ Verifier();
+ void verify(const Address& address) const;
+ private:
+ Variant::Map defined;
+ void verify(const Variant::Map& allowed, const Variant::Map& actual) const;
+};
namespace{
+const Verifier verifier;
const Variant EMPTY_VARIANT;
const FieldTable EMPTY_FIELD_TABLE;
- const Variant::List EMPTY_LIST;
+const Variant::List EMPTY_LIST;
const std::string EMPTY_STRING;
//policy types
@@ -250,8 +261,6 @@ class QueueSink : public Queue, public MessageSink
void cancel(qpid::client::AsyncSession& session, const std::string& name);
private:
};
-
-
bool isQueue(qpid::client::Session session, const qpid::messaging::Address& address);
bool isTopic(qpid::client::Session session, const qpid::messaging::Address& address);
@@ -362,6 +371,7 @@ bool AddressResolution::is_reliable(const Address& address)
std::string checkAddressType(qpid::client::Session session, const Address& address)
{
+ verifier.verify(address);
if (address.getName().empty()) {
throw MalformedAddress("Name cannot be null");
}
@@ -910,4 +920,42 @@ void Node::convert(const Variant& options, FieldTable& arguments)
std::vector<std::string> Node::RECEIVER_MODES = list_of<std::string>(ALWAYS) (RECEIVER);
std::vector<std::string> Node::SENDER_MODES = list_of<std::string>(ALWAYS) (SENDER);
+Verifier::Verifier()
+{
+ defined["create"] = true;
+ defined["assert"] = true;
+ defined["delete"] = true;
+ defined["mode"] = true;
+ Variant::Map node;
+ node["type"] = true;
+ node["durable"] = true;
+ node["x-declare"] = true;
+ node["x-bindings"] = true;
+ defined["node"] = node;
+ Variant::Map link;
+ link["name"] = true;
+ link["durable"] = true;
+ link["reliable"] = true;
+ link["x-subscribe"] = true;
+ link["x-declare"] = true;
+ link["x-bindings"] = true;
+ defined["link"] = link;
+}
+void Verifier::verify(const Address& address) const
+{
+ verify(defined, address.getOptions());
+}
+
+void Verifier::verify(const Variant::Map& allowed, const Variant::Map& actual) const
+{
+ for (Variant::Map::const_iterator i = actual.begin(); i != actual.end(); ++i) {
+ Variant::Map::const_iterator option = allowed.find(i->first);
+ if (option == allowed.end()) {
+ throw AddressError((boost::format("Unrecognised option: %1%") % i->first).str());
+ } else if (option->second.getType() == qpid::types::VAR_MAP) {
+ verify(option->second.asMap(), i->second.asMap());
+ }
+ }
+}
+
}}} // namespace qpid::client::amqp0_10