You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by cc...@apache.org on 2008/09/12 21:11:36 UTC

svn commit: r694778 - in /incubator/qpid/trunk/qpid/cpp/src/qpid/acl: Acl.cpp Acl.h management-schema.xml

Author: cctrieloff
Date: Fri Sep 12 12:11:35 2008
New Revision: 694778

URL: http://svn.apache.org/viewvc?rev=694778&view=rev
Log:
QPID-106

- Added mgnt schema
- Added ability to reload ACL file
- Added events for ACL deny
- Added stats for ACL.



Modified:
    incubator/qpid/trunk/qpid/cpp/src/qpid/acl/Acl.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/acl/Acl.h
    incubator/qpid/trunk/qpid/cpp/src/qpid/acl/management-schema.xml

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/acl/Acl.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/acl/Acl.cpp?rev=694778&r1=694777&r2=694778&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/acl/Acl.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/acl/Acl.cpp Fri Sep 12 12:11:35 2008
@@ -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 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 @@
 	  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 @@
    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

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/acl/Acl.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/acl/Acl.h?rev=694778&r1=694777&r2=694778&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/acl/Acl.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/acl/Acl.h Fri Sep 12 12:11:35 2008
@@ -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 @@
 };
 
 
-class Acl : public broker::AclModule, public RefCounted 
+class Acl : public broker::AclModule, public RefCounted, public management::Manageable
 {
 
 private:
@@ -53,6 +56,7 @@
    broker::Broker* broker;
    bool transferAcl;
    boost::shared_ptr<AclData> data;
+   management::Acl* mgmtObject; // mgnt owns lifecycle
 
 
 public:
@@ -70,7 +74,10 @@
 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);
+  
 };
 
 

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/acl/management-schema.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/acl/management-schema.xml?rev=694778&r1=694777&r2=694778&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/acl/management-schema.xml (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/acl/management-schema.xml Fri Sep 12 12:11:35 2008
@@ -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"/>