Back to index

nordugrid-arc-nox  1.1.0~rc6
RequestAttribute.cpp
Go to the documentation of this file.
00001 #ifdef HAVE_CONFIG_H
00002 #include <config.h>
00003 #endif
00004 
00005 #include "RequestAttribute.h"
00006 
00007 using namespace Arc;
00008 using namespace ArcSec;
00009 
00010 Logger RequestAttribute::logger(Logger::rootLogger, "RequestAttribute");
00011 
00012 RequestAttribute::RequestAttribute(XMLNode& node, AttributeFactory* attrfactory) : attrval(NULL), attrfactory(attrfactory) {
00013   Arc::XMLNode nd;
00014 
00015   //Get the attribute of the node  
00016   id = (std::string)(node.Attribute("AttributeId")); 
00017   if(id.empty())
00018     id = (std::string)(node.Attribute("Id"));
00019 
00020   std::string tp = (std::string)(node.Attribute("Type"));
00021   if(tp.empty())
00022     tp = (std::string)(node.Attribute("DataType")); 
00023   std::size_t found = tp.find_last_of("#"); //http://www.w3.org/2001/XMLSchema#string
00024   if(found!=std::string::npos) {
00025     type = tp.substr(found+1);
00026   }
00027   else {
00028     found=tp.find_last_of(":"); //urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name
00029     type = tp.substr(found+1);
00030   }
00031 
00032   issuer = (std::string)(node.Attribute("Issuer"));
00033 
00034   //Create the attribute value object according to the data type
00035   attrval = attrfactory->createValue(node, type);
00036 
00037   logger.msg(VERBOSE, "Id= %s,Type= %s,Issuer= %s,Value= %s",id, type, issuer, attrval?attrval->encode():"");
00038 
00039   if(attrval == NULL)
00040     logger.msg(ERROR,"No Attribute exists, which can deal with type: %s", type);
00041 
00042   //Copy the node parameter into this->node_, for the usage in duplicate method 
00043   node.New(node_);
00044 
00045 /*
00046   if(!(node.Size())){
00047     avlist.push_back(attrfactory->createValue(node, type));
00048   }
00049   else{
00050     for(int i=0; i<node.Size(); i++)
00051       avlist.push_back(attrfactory->createValue(node.Child(i), type));
00052   }
00053 */
00054 }
00055 
00056 RequestAttribute::RequestAttribute() {
00057 
00058 }
00059 
00060 XMLNode RequestAttribute::getNode() {
00061   return node_;
00062 }
00063 
00064 std::string RequestAttribute::getAttributeId () const{
00065   return id;
00066 }
00067 
00068 void RequestAttribute::setAttributeId (const std::string attributeId){
00069   id = attributeId;
00070 }
00071 
00072 std::string RequestAttribute::getDataType () const{
00073   return type;
00074 }
00075 
00076 void RequestAttribute::setDataType (const std::string dataType){
00077   type = dataType;
00078 }
00079 
00080 std::string RequestAttribute::getIssuer () const{
00081   return issuer;
00082 }
00083 
00084 void RequestAttribute::setIssuer (const std::string is){
00085   issuer = is;
00086 }
00087 
00088 /*AttrValList RequestAttribute::getAttributeValueList () const{
00089 }
00090 
00091 void RequestAttribute::setAttributeValueList (const AttrValList& attributeValueList){
00092 }
00093 */
00094 AttributeValue* RequestAttribute::getAttributeValue() const{
00095   return attrval;
00096 }
00097 
00098 AttributeFactory* RequestAttribute::getAttributeFactory() const {
00099   return attrfactory;
00100 }
00101 
00102 RequestAttribute& RequestAttribute::duplicate(RequestAttribute& req_attr) {
00103   id = req_attr.getAttributeId();
00104   type = req_attr.getDataType();
00105   issuer = req_attr.getIssuer();
00106   node_ = req_attr.getNode();
00107   attrval = (req_attr.getAttributeFactory())->createValue(node_, type);
00108   return *this;
00109 }
00110 
00111 
00112 RequestAttribute::~RequestAttribute(){
00113   if(attrval)
00114     delete attrval;
00115   /*while(!avlist.empty()){
00116     delete (*(avlist.back()));
00117     avlist.pop_back();
00118   }
00119   */
00120 }
00121