diff options
Diffstat (limited to 'qpid/cpp')
-rw-r--r-- | qpid/cpp/src/qpid/acl/Acl.cpp | 61 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/acl/Acl.h | 11 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/acl/management-schema.xml | 2 |
3 files changed, 66 insertions, 8 deletions
diff --git a/qpid/cpp/src/qpid/acl/Acl.cpp b/qpid/cpp/src/qpid/acl/Acl.cpp index 982b9e3bb0..f9c307c7d3 100644 --- a/qpid/cpp/src/qpid/acl/Acl.cpp +++ b/qpid/cpp/src/qpid/acl/Acl.cpp @@ -24,6 +24,7 @@ #include "qpid/Options.h" #include "qpid/shared_ptr.h" #include "qpid/log/Logger.h" +#include "qpid/management/PackageACL.h" #include <map> @@ -33,12 +34,28 @@ namespace qpid { namespace acl { using namespace std; +using qpid::management::ManagementAgent; +using qpid::management::ManagementObject; +using qpid::management::Manageable; +using qpid::management::Args; Acl::Acl (AclValues& av, broker::Broker& b): aclValues(av), broker(&b), transferAcl(false) { - if (!readAclFile()) throw Exception("Could not read ACL file"); - QPID_LOG(info, "ACL Plugin loaded"); + + ManagementAgent* agent = ManagementAgent::Singleton::getInstance(); + + if (agent != 0){ + management::PackageACL packageInit(agent); + mgmtObject = new management::Acl (agent, this, broker); + agent->addObject (mgmtObject); + } + if (!readAclFile()){ + throw Exception("Could not read ACL file"); + if (mgmtObject!=0) mgmtObject->set_enforcingAcl(0); + } + QPID_LOG(info, "ACL Plugin loaded"); + if (mgmtObject!=0) mgmtObject->set_enforcingAcl(1); } bool Acl::authorise(const std::string& id, const Action& action, const ObjectType& objType, const std::string& name, std::map<Property, std::string>* params) @@ -74,10 +91,16 @@ using namespace std; case ALLOW: return true; case DENY: + if (mgmtObject!=0) mgmtObject->inc_aclDenyCount(); return false; case DENYLOG: + if (mgmtObject!=0) mgmtObject->inc_aclDenyCount(); default: QPID_LOG(info, "ACL Deny id:" << id << " action:" << AclHelper::getActionStr(action) << " ObjectType:" << AclHelper::getObjectTypeStr(objType) << " Name:" << name); + if (mgmtObject!=0){ + framing::FieldTable _params; + mgmtObject->event_aclEvent(1, id, AclHelper::getActionStr(action),AclHelper::getObjectTypeStr(objType),name, _params); + } return false; } return false; @@ -92,16 +115,44 @@ using namespace std; bool Acl::readAclFile(std::string& aclFile) { boost::shared_ptr<AclData> d(new AclData); AclReader ar; - if (ar.read(aclFile, d)) + if (ar.read(aclFile, d)){ + mgmtObject->event_fileNotLoaded("","See log for file load reason failure"); return false; - + } + data = d; transferAcl = data->transferAcl; // any transfer ACL + if (mgmtObject!=0){ + mgmtObject->set_transferAcl(transferAcl?1:0); + mgmtObject->set_policyFile(aclFile); + sys::AbsTime now = sys::AbsTime::now(); + int64_t ns = sys::Duration(now); + mgmtObject->set_lastAclLoad(ns); + mgmtObject->event_fileLoaded(""); + } return true; } Acl::~Acl(){} + ManagementObject* Acl::GetManagementObject(void) const + { + return (ManagementObject*) mgmtObject; + } + + Manageable::status_t Acl::ManagementMethod (uint32_t methodId, Args& /*args*/, string&) + { + Manageable::status_t status = Manageable::STATUS_UNKNOWN_METHOD; + QPID_LOG (debug, "Queue::ManagementMethod [id=" << methodId << "]"); + + switch (methodId) + { + case management::Acl::METHOD_RELOADACLFILE : + readAclFile(); + status = Manageable::STATUS_OK; + break; + } - + return status; +} }} // namespace qpid::acl diff --git a/qpid/cpp/src/qpid/acl/Acl.h b/qpid/cpp/src/qpid/acl/Acl.h index 67051d6392..22450709d9 100644 --- a/qpid/cpp/src/qpid/acl/Acl.h +++ b/qpid/cpp/src/qpid/acl/Acl.h @@ -26,6 +26,9 @@ #include "qpid/shared_ptr.h" #include "qpid/RefCounted.h" #include "qpid/broker/AclModule.h" +#include "qpid/management/Manageable.h" +#include "qpid/management/Acl.h" + #include <map> #include <string> @@ -45,7 +48,7 @@ struct AclValues { }; -class Acl : public broker::AclModule, public RefCounted +class Acl : public broker::AclModule, public RefCounted, public management::Manageable { private: @@ -53,6 +56,7 @@ private: broker::Broker* broker; bool transferAcl; boost::shared_ptr<AclData> data; + management::Acl* mgmtObject; // mgnt owns lifecycle public: @@ -70,7 +74,10 @@ public: private: bool result(const AclResult& aclreslt, const std::string& id, const Action& action, const ObjectType& objType, const std::string& name); bool readAclFile(); - bool readAclFile(std::string& aclFile); + bool readAclFile(std::string& aclFile); + virtual qpid::management::ManagementObject* GetManagementObject(void) const; + virtual management::Manageable::status_t ManagementMethod (uint32_t methodId, management::Args& args, std::string& text); + }; diff --git a/qpid/cpp/src/qpid/acl/management-schema.xml b/qpid/cpp/src/qpid/acl/management-schema.xml index 4f633f6a06..ebd1eb2a53 100644 --- a/qpid/cpp/src/qpid/acl/management-schema.xml +++ b/qpid/cpp/src/qpid/acl/management-schema.xml @@ -16,7 +16,7 @@ * limitations under the License. --> - <class name="plugin"> + <class name="acl"> <property name="brokerRef" type="objId" references="qpid.Broker" access="RO" index="y" parentRef="y"/> <property name="policyFile" type="sstr" access="RO" desc="Name of the policy file"/> <property name="enforcingAcl" type="bool" access="RO" desc="Currently Enforcing ACL"/> |