From 804cfbdaf19ee803f362b6aa4c35696ca4e850c3 Mon Sep 17 00:00:00 2001 From: "Carl C. Trieloff" Date: Tue, 2 Sep 2008 21:49:55 +0000 Subject: QPID-107 Implementation for ACL for C++ broker git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@691396 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/acl/AclReader.h | 90 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 80 insertions(+), 10 deletions(-) (limited to 'cpp/src/qpid/acl/AclReader.h') diff --git a/cpp/src/qpid/acl/AclReader.h b/cpp/src/qpid/acl/AclReader.h index 783b70d98a..c6e7770311 100644 --- a/cpp/src/qpid/acl/AclReader.h +++ b/cpp/src/qpid/acl/AclReader.h @@ -21,23 +21,93 @@ */ #include +#include +#include #include #include +#include "qpid/acl/AclData.h" +#include "qpid/broker/AclModule.h" + namespace qpid { namespace acl { -struct AclData { - bool lc; // Line continue flag - AclData() : lc(false) {} -}; - class AclReader { -public: - static int read(const std::string& fn, boost::shared_ptr d); -private: - static void processLine(char* line, boost::shared_ptr d); - static int tokenizeLine(char* line, std::vector& toks); + typedef std::set nameSet; + typedef nameSet::const_iterator nsCitr; + typedef boost::shared_ptr nameSetPtr; + + typedef std::pair groupPair; + typedef std::map groupMap; + typedef groupMap::const_iterator gmCitr; + typedef std::pair gmRes; + + typedef std::pair propNvPair; + typedef std::map propMap; + typedef propMap::const_iterator pmCitr; + + class aclRule { + public: + enum objectStatus {NONE, VALUE, ALL}; + AclResult res; + nameSet names; + bool actionAll; // True if action is set to keyword "all" + Action action; // Ignored if action is set to keyword "all" + objectStatus objStatus; + ObjectType object; // Ignored for all status values except VALUE + propMap props; + public: + aclRule(const AclResult r, const std::string n, const groupMap& groups); // action = "all" + aclRule(const AclResult r, const std::string n, const groupMap& groups, const Action a); + void setObjectType(const ObjectType o); + void setObjectTypeAll(); + bool addProperty(const Property p, const std::string v); + bool validate(const AclHelper::objectMapPtr& validationMap); + std::string toString(); // debug aid + private: + void processName(const std::string& name, const groupMap& groups); + }; + typedef boost::shared_ptr aclRulePtr; + typedef std::vector ruleList; + typedef ruleList::const_iterator rlCitr; + + typedef std::vector tokList; + typedef tokList::const_iterator tlCitr; + + typedef std::set keywordSet; + typedef keywordSet::const_iterator ksCitr; + typedef std::pair nvPair; // Name-Value pair + + std::string fileName; + int lineNumber; + bool contFlag; + std::string groupName; + nameSet names; + groupMap groups; + ruleList rules; + AclHelper::objectMapPtr validationMap; + + public: + AclReader(); + virtual ~AclReader(); + int read(const std::string& fn, boost::shared_ptr d); + + private: + bool processLine(char* line); + void loadDecisionData( boost::shared_ptr d); + int tokenize(char* line, tokList& toks); + + bool processGroupLine(tokList& toks, const bool cont); + gmCitr addGroup(const std::string& groupName); + void addName(const std::string& name, nameSetPtr groupNameSet); + void addName(const std::string& name); + void printNames() const; // debug aid + + bool processAclLine(tokList& toks); + void printRules() const; // debug aid + + static bool checkName(const std::string& name); + static nvPair splitNameValuePair(const std::string& nvpString); }; }} // namespace qpid::acl -- cgit v1.2.1