Back to index

nordugrid-arc-nox  1.1.0~rc6
PDP.h
Go to the documentation of this file.
00001 #ifndef __ARC_SEC_PDP_H__
00002 #define __ARC_SEC_PDP_H__
00003 
00004 #include <string>
00005 #include <arc/message/Message.h>
00006 #include <arc/loader/Plugin.h>
00007 #include <arc/ArcConfig.h>
00008 #include <arc/Logger.h>
00009 
00010 namespace ArcSec {
00011   //AuthzRequest, AuthzRequestSection, internal structure for request context 
00019   typedef struct {
00020     std::string value;
00021     std::string id;
00022     std::string type;
00023     std::string issuer;
00024   } AuthzRequestSection;
00025   typedef struct {
00026     std::list<ArcSec::AuthzRequestSection> subject;
00027     std::list<ArcSec::AuthzRequestSection> resource;
00028     std::list<ArcSec::AuthzRequestSection> action;
00029     std::list<ArcSec::AuthzRequestSection> context;
00030   } AuthzRequest;
00031 
00032   class PDPConfigContext:public Arc::MessageContextElement {
00033    private:
00034     std::list<ArcSec::AuthzRequest> request;
00035     std::list<std::string> policylocation;
00036     
00037    public:
00038     PDPConfigContext() {};
00039     PDPConfigContext(std::list<ArcSec::AuthzRequest> req, std::string& policy) {request = req; policylocation.push_back(policy); };
00040     PDPConfigContext(std::list<ArcSec::AuthzRequest> req, std::list<std::string> policy) {request = req; policylocation = policy; };
00041     void AddRequestItem(ArcSec::AuthzRequest requestitem) { request.push_back(requestitem); };
00042     void SetRequestItem(ArcSec::AuthzRequest requestitem) { 
00043       while(!(request.empty())) { request.pop_back(); }
00044       request.push_back(requestitem); 
00045     };
00046     void SetRequestItem(std::list<ArcSec::AuthzRequest> req) { 
00047       while(!(request.empty())) { request.pop_back(); }
00048       request = req;
00049     };
00050     int RequestItemSize() { return (int)(request.size()); };
00051     ArcSec::AuthzRequest& GetRequestItem(int n) { 
00052       std::list<ArcSec::AuthzRequest>::iterator it, ret;
00053       it = request.begin();
00054       for(int i = 0; i<=n; i++) {ret = it; it++;}
00055       return (*ret); 
00056     };
00057     void AddPolicyLocation(std::string& policy) { policylocation.push_back(policy); };
00058     void SetPolicyLocation(std::list<std::string> policy) { 
00059       std::list<std::string>::iterator it1 = policylocation.begin();
00060       std::list<std::string>::iterator it2 = policylocation.end(); 
00061       policylocation.erase(it1, it2); 
00062       policylocation = policy; 
00063     };
00064     void SetPolicyLocation(std::string& policy) { 
00065       std::list<std::string>::iterator it1 = policylocation.begin();
00066       std::list<std::string>::iterator it2 = policylocation.end();  
00067       policylocation.erase(it1, it2);
00068       policylocation.push_back(policy); 
00069     };
00070     std::list<std::string>& GetPolicyLocation() { return policylocation; }; 
00071     virtual ~PDPConfigContext(void) {
00072       while(!(request.empty())) { request.pop_back(); }
00073     };
00074   };
00075 
00077 
00082   class PDP: public Arc::Plugin {
00083    public:
00084     PDP(Arc::Config* cfg) { if(cfg) id_=(std::string)(cfg->Attribute("id")); };
00085     virtual ~PDP() {};
00086     virtual bool isPermitted(Arc::Message *msg) const = 0;
00087     void SetId(std::string& id) { id_ = id; };
00088     std::string GetId() { return id_; };
00089 
00090    protected:
00091     std::string id_;
00092     static Arc::Logger logger;
00093   };
00094 
00095   #define PDPPluginKind ("HED:PDP")
00096 
00097   class PDPPluginArgument: public Arc::PluginArgument {
00098    private:
00099     Arc::Config* config_;
00100    public:
00101     PDPPluginArgument(Arc::Config* config):config_(config) { };
00102     virtual ~PDPPluginArgument(void) { };
00103     operator Arc::Config* (void) { return config_; };
00104   };
00105 
00106 } // namespace ArcSec
00107 
00108 #endif /* __ARC_SEC_PDP_H__ */