Back to index

nordugrid-arc-nox  1.1.0~rc6
Evaluator.h
Go to the documentation of this file.
00001 #ifndef __ARC_SEC_EVALUATOR_H__
00002 #define __ARC_SEC_EVALUATOR_H__
00003 
00004 #include <list>
00005 #include <fstream>
00006 #include <arc/XMLNode.h>
00007 #include <arc/Logger.h>
00008 #include <arc/security/ClassLoader.h>
00009 #include <arc/security/ArcPDP/Source.h>
00010 
00011 #include "fn/FnFactory.h"
00012 #include "attr/AttributeFactory.h"
00013 #include "alg/AlgFactory.h"
00014 #include "Request.h"
00015 #include "Response.h"
00016 
00017 namespace ArcSec {
00018 
00019 typedef enum {
00023   EvaluatorFailsOnDeny,
00025   EvaluatorStopsOnDeny,
00027   EvaluatorStopsOnPermit,
00029   EvaluatorStopsNever
00030 } EvaluatorCombiningAlg;
00031 
00033 class Evaluator : public Arc::LoadableClass {
00034 protected:
00035   static Arc::Logger logger;
00036 public:
00037   Evaluator (Arc::XMLNode*) {};
00038   Evaluator (const char *) {};
00039   virtual ~Evaluator() {};
00040 
00043   virtual Response* evaluate(Request* request) = 0;
00044 
00046   virtual Response* evaluate(const Source& request) = 0;
00047 
00051   virtual Response* evaluate(Request* request, const Source& policy) = 0;
00052 
00056   virtual Response* evaluate(const Source& request, const Source& policy) = 0;
00057 
00061   virtual Response* evaluate(Request* request, Policy* policyobj) = 0;
00062 
00066   virtual Response* evaluate(const Source& request, Policy* policyobj) = 0;
00067 
00069   virtual AttributeFactory* getAttrFactory () = 0;
00070 
00072   virtual FnFactory* getFnFactory () = 0;
00073 
00075   virtual AlgFactory* getAlgFactory () = 0;
00076 
00078   virtual void addPolicy(const Source& policy,const std::string& id = "") = 0;
00079 
00083   virtual void addPolicy(Policy* policy,const std::string& id = "") = 0;
00084 
00086   virtual void setCombiningAlg(EvaluatorCombiningAlg alg) = 0;
00087 
00089   virtual void setCombiningAlg(CombiningAlg* alg = NULL) = 0;
00090 
00092   virtual const char* getName(void) const = 0;
00093 protected:
00097   virtual Response* evaluate(EvaluationCtx* ctx) = 0;
00098 
00099 private:
00101   virtual void parsecfg(Arc::XMLNode& cfg) = 0;
00102 };
00103 
00105 class EvaluatorContext {
00106   private:
00107     Evaluator* evaluator;
00108   public:
00109     EvaluatorContext(Evaluator* evaluator) : evaluator(evaluator) {};
00110     ~EvaluatorContext() {};
00111    public:
00113     operator AttributeFactory*()    { return evaluator->getAttrFactory(); };
00115     operator FnFactory*()        { return evaluator->getFnFactory(); };
00117     operator AlgFactory*() { return evaluator->getAlgFactory(); };
00118   };
00119 } // namespace ArcSec
00120 
00121 #endif /* __ARC_SEC_EVALUATOR_H__ */