Back to index

nordugrid-arc-nox  1.1.0~rc6
DelegationSecAttr.cpp
Go to the documentation of this file.
00001 #ifdef HAVE_CONFIG_H
00002 #include <config.h>
00003 #endif
00004 
00005 #include <arc/message/SecAttr.h>
00006 
00007 #include "DelegationSecAttr.h"
00008 
00009 namespace ArcSec {
00010 
00011 using namespace Arc;
00012 
00013 DelegationSecAttr::DelegationSecAttr(void) {
00014 }
00015 
00016 DelegationSecAttr::DelegationSecAttr(const char* policy_str,int policy_size) {
00017   if(policy_str == NULL) return;
00018   XMLNode policy(policy_str,policy_size);
00019   // Only XML policies are accepted
00020   if(!policy) return;
00021   NS ns;
00022   ns["pa"]="http://www.nordugrid.org/schemas/policy-arc";
00023   policy.Namespaces(ns);
00024   // Only ARC Policy is supported so far
00025   if(!MatchXMLName(policy,"pa:Policy")) return;
00026   policy.New(policy_doc_);
00027 }
00028 
00029 DelegationSecAttr::~DelegationSecAttr(void) {
00030 }
00031 
00032 DelegationSecAttr::operator bool(void) const {
00033   return (bool)policy_doc_;
00034 }
00035 
00036 bool DelegationSecAttr::equal(const SecAttr &b) const {
00037   try {
00038     const DelegationSecAttr& a = dynamic_cast<const DelegationSecAttr&>(b);
00039     if (!a) return false;
00040     // ...
00041     return false;
00042   } catch(std::exception&) { };
00043   return false;
00044 }
00045 
00046 bool DelegationSecAttr::Export(SecAttrFormat format,XMLNode &val) const {
00047   if(format == UNDEFINED) {
00048   } else if(format == ARCAuth) {
00049     policy_doc_.New(val);
00050     return true;
00051   } else {
00052   };
00053   return false;
00054 }
00055 
00056 DelegationMultiSecAttr::DelegationMultiSecAttr(void) {
00057 }
00058 
00059 DelegationMultiSecAttr::~DelegationMultiSecAttr(void) {
00060 }
00061 
00062 bool DelegationMultiSecAttr::Add(const char* policy_str,int policy_size) {
00063   SecAttr* sattr = new DelegationSecAttr(policy_str,policy_size);
00064   if(!sattr) return false;
00065   if(!(*sattr)) { delete sattr; return false; };
00066   attrs_.push_back(sattr);
00067   return true;
00068 }
00069 
00070 bool DelegationMultiSecAttr::Export(SecAttrFormat format,XMLNode &val) const {
00071   if(attrs_.size() == 0) return true;
00072   if(attrs_.size() == 1) return (*attrs_.begin())->Export(format,val);
00073   if(!MultiSecAttr::Export(format,val)) return false;
00074   val.Name("Policies");
00075   return true;
00076 }
00077 
00078 }
00079