Back to index

nordugrid-arc-nox  1.1.0~rc6
DelegationInterface.h
Go to the documentation of this file.
00001 #ifndef __ARC_DELEGATIONINTERFACE_H__
00002 #define __ARC_DELEGATIONINTERFACE_H__
00003 
00004 #include <string>
00005 #include <list>
00006 #include <map>
00007 
00008 #include <arc/Thread.h>
00009 #include <arc/message/SOAPEnvelope.h>
00010 #include <arc/message/MCC.h>
00011 #include <arc/message/Message.h>
00012 
00013 namespace Arc {
00014 
00015 typedef std::map<std::string,std::string> DelegationRestrictions;
00016 
00024 class DelegationConsumer {
00025  protected:
00026   void* key_; 
00027   bool Generate(void); 
00028   void LogError(void);
00029  public:
00031   DelegationConsumer(void);
00033   DelegationConsumer(const std::string& content);
00034   ~DelegationConsumer(void);
00035   operator bool(void) { return key_ != NULL; };
00036   bool operator!(void) { return key_ == NULL; };
00038   const std::string& ID(void);
00040   bool Backup(std::string& content);
00042   bool Restore(const std::string& content);
00044   bool Request(std::string& content);
00047   bool Acquire(std::string& content);
00050   bool Acquire(std::string& content,std::string& identity);
00051 };
00052 
00056 class DelegationProvider {
00057   void* key_; 
00058   void* cert_; 
00059   void* chain_; 
00060   void LogError(void);
00061   void CleanError(void);
00062  public:
00067   DelegationProvider(const std::string& credentials);
00072   DelegationProvider(const std::string& cert_file,const std::string& key_file,std::istream* inpwd = NULL);
00073   ~DelegationProvider(void);
00074   operator bool(void) { return key_ != NULL; };
00075   bool operator!(void) { return key_ == NULL; };
00080   std::string Delegate(const std::string& request,const DelegationRestrictions& restrictions = DelegationRestrictions());
00081 };
00082 
00086 class DelegationConsumerSOAP: public DelegationConsumer {
00087  protected:
00088  public:
00090   DelegationConsumerSOAP(void);
00092   DelegationConsumerSOAP(const std::string& content);
00093   ~DelegationConsumerSOAP(void);
00098   bool DelegateCredentialsInit(const std::string& id,const SOAPEnvelope& in,SOAPEnvelope& out);
00102   bool UpdateCredentials(std::string& credentials,const SOAPEnvelope& in,SOAPEnvelope& out);
00105   bool UpdateCredentials(std::string& credentials,std::string& identity,const SOAPEnvelope& in,SOAPEnvelope& out);
00107   bool DelegatedToken(std::string& credentials,XMLNode token);
00108   bool DelegatedToken(std::string& credentials,std::string& identity,XMLNode token);
00109 };
00110 
00114 class DelegationProviderSOAP: public DelegationProvider {
00115  protected:
00116   std::string request_;
00117   std::string id_;
00118  public:
00121   DelegationProviderSOAP(const std::string& credentials);
00126   DelegationProviderSOAP(const std::string& cert_file,const std::string& key_file,std::istream* inpwd = NULL);
00127   ~DelegationProviderSOAP(void);
00131   bool DelegateCredentialsInit(MCCInterface& mcc_interface,MessageContext* context);
00135   bool DelegateCredentialsInit(MCCInterface& mcc_interface,MessageAttributes* attributes_in,MessageAttributes* attributes_out,MessageContext* context);
00140   bool UpdateCredentials(MCCInterface& mcc_interface,MessageContext* context,const DelegationRestrictions& restrictions = DelegationRestrictions());
00144   bool UpdateCredentials(MCCInterface& mcc_interface,MessageAttributes* attributes_in,MessageAttributes* attributes_out,MessageContext* context,const DelegationRestrictions& restrictions = DelegationRestrictions());
00148   bool DelegatedToken(XMLNode parent);
00152   const std::string& ID(void) { return id_;};
00153 };
00154 
00160 class DelegationContainerSOAP {
00161  private:
00162   class Consumer;
00163   typedef std::map<std::string,Consumer> ConsumerMap;
00164   typedef ConsumerMap::iterator ConsumerIterator;
00165   ConsumerMap consumers_;
00166   ConsumerIterator consumers_first_;
00167   ConsumerIterator consumers_last_;
00168   void AddConsumer(const std::string& id,DelegationConsumerSOAP* consumer);
00169   void TouchConsumer(ConsumerIterator i);
00170   ConsumerIterator RemoveConsumer(ConsumerIterator i);
00171   void CheckConsumers(void);
00172  protected:
00173   Glib::Mutex lock_;
00175   int max_size_;
00177   int max_duration_;
00179   int max_usage_;
00181   bool context_lock_;
00183   bool restricted_;
00184  public:
00185   DelegationContainerSOAP(void);
00186   ~DelegationContainerSOAP(void);
00188   bool DelegateCredentialsInit(const SOAPEnvelope& in,SOAPEnvelope& out);
00190   bool UpdateCredentials(std::string& credentials,const SOAPEnvelope& in,SOAPEnvelope& out);
00191   bool UpdateCredentials(std::string& credentials,std::string& identity,const SOAPEnvelope& in,SOAPEnvelope& out);
00193   bool DelegatedToken(std::string& credentials,XMLNode token);
00194   bool DelegatedToken(std::string& credentials,std::string& identity,XMLNode token);
00195 };
00196 
00197 } // namespace Arc
00198 
00199 
00200 #endif /* __ARC_DELEGATIONINTERFACE_H__ */