Back to index

nordugrid-arc-nox  1.1.0~rc6
XACMLCondition.cpp
Go to the documentation of this file.
00001 #ifdef HAVE_CONFIG_H
00002 #include <config.h>
00003 #endif
00004 
00005 #include <list>
00006 
00007 #include <arc/security/ArcPDP/attr/AttributeValue.h>
00008 
00009 #include "XACMLPolicy.h"
00010 #include "XACMLRule.h"
00011 #include "XACMLCondition.h"
00012 
00013 static Arc::Logger logger(Arc::Logger::rootLogger, "XACMLCondition");
00014 
00015 using namespace Arc;
00016 using namespace ArcSec;
00017 
00018 XACMLCondition::XACMLCondition(Arc::XMLNode& node, EvaluatorContext* ctx) : condition_node(node) {
00019   XMLNode cnd;
00020   std::string name;
00021   for(int i = 0;;i++ ) {
00022     cnd = node.Child(i);
00023     if(!cnd) break;
00024     name = cnd.Name();
00025     if(name == "Apply") {
00026       apply_list.push_back(new XACMLApply(cnd, ctx));
00027     }
00028   }
00029 }
00030 
00031 XACMLCondition::~XACMLCondition() {
00032   while(!(apply_list.empty())) {
00033     XACMLApply* apply = apply_list.back();
00034     apply_list.pop_back();
00035     delete apply;
00036   }
00037 }
00038 
00039 std::list<AttributeValue*> XACMLCondition::evaluate(EvaluationCtx* ctx) {
00040   std::list<AttributeValue*> res_list;
00041   std::list<XACMLApply*>::iterator i;
00042   for(i = apply_list.begin(); i!= apply_list.end(); i++) {
00043     res_list = (*i)->evaluate(ctx);
00044     if(!res_list.empty()) break;
00045     //Suppose only one <Apply/> exists under <Condition/>
00046     //TODO: process the situation about more than one <Apply/> exist under <Condition/>
00047   }
00048   return res_list;
00049 }
00050