Back to index

nordugrid-arc-nox  1.1.0~rc6
AttributeSelector.cpp
Go to the documentation of this file.
00001 #ifdef HAVE_CONFIG_H
00002 #include <config.h>
00003 #endif
00004 
00005 #include "XACMLEvaluationCtx.h"
00006 #include "AttributeSelector.h"
00007 
00008 using namespace Arc;
00009 using namespace ArcSec;
00010 
00011 AttributeSelector::AttributeSelector(Arc::XMLNode& node, AttributeFactory* attr_factory) : present(false), 
00012     attrfactory(attr_factory) {
00013   std::string tp = (std::string)(node.Attribute("DataType"));
00014   if(tp.empty()) {std::cerr<<"Required DataType does not exist in AttributeSelector"<<std::endl; exit(0);}
00015 
00016   type = tp;
00017 
00018 #if 0
00019   size_t found = tp.find_last_of("#");
00020   if(found!=std::string::npos) {
00021     type = tp.substr(found+1);
00022   }
00023   else {
00024     found=tp.find_last_of(":"); //urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name
00025     type = tp.substr(found+1);
00026   }
00027 #endif
00028 
00029   reqctxpath = (std::string)(node.Attribute("RequestContextPath"));
00030   if(reqctxpath.empty()) {std::cerr<<"Required RequestContextPath does not exist in AttributeSelector"<<std::endl; exit(0);} 
00031 
00032 std::cout<<"=====!!!!!  "<<reqctxpath<<std::endl;
00033 
00034   
00035   std::string must = node.Attribute("MustBePresent");
00036   if(!must.empty()) present = true;
00037 
00038   //get the <Policy> node
00039   //TODO: need to duplicate node maybe
00040   policyroot = node.GetRoot(); 
00041 
00042 }
00043 
00044 AttributeSelector::~AttributeSelector() {
00045 }
00046 
00047 std::list<AttributeValue*> AttributeSelector::evaluate(EvaluationCtx* ctx) {
00048   std::list<AttributeValue*> res;
00049   res = ctx->getAttributes(reqctxpath, policyroot, type, attrfactory);
00050   
00051   if(present && (res.size() ==0)) {
00052     //std::cerr<<"AttributeSelector requires at least one attributes from request's"<<target<<std::endl;
00053   }
00054 
00055   return res;
00056 }
00057 
00058