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:
00119 typedef enum {
00120 ARCDelegation,
00121 GDS10,
00122 GDS10RENEW,
00123 GDS20,
00124 GDS20RENEW,
00125 EMIES
00126 } ServiceType;
00129 DelegationProviderSOAP(const std::string& credentials);
00134 DelegationProviderSOAP(const std::string& cert_file,const std::string& key_file,std::istream* inpwd = NULL);
00135 ~DelegationProviderSOAP(void);
00139 bool DelegateCredentialsInit(MCCInterface& mcc_interface,MessageContext* context,ServiceType stype = ARCDelegation);
00143 bool DelegateCredentialsInit(MCCInterface& mcc_interface,MessageAttributes* attributes_in,MessageAttributes* attributes_out,MessageContext* context,ServiceType stype = ARCDelegation);
00148 bool UpdateCredentials(MCCInterface& mcc_interface,MessageContext* context,const DelegationRestrictions& restrictions = DelegationRestrictions(),ServiceType stype = ARCDelegation);
00152 bool UpdateCredentials(MCCInterface& mcc_interface,MessageAttributes* attributes_in,MessageAttributes* attributes_out,MessageContext* context,const DelegationRestrictions& restrictions = DelegationRestrictions(),ServiceType stype = ARCDelegation);
00156 bool DelegatedToken(XMLNode parent);
00160 const std::string& ID(void) { return id_;};
00161 };
00162
00168 class DelegationContainerSOAP {
00169 protected:
00170
00171 Glib::Mutex lock_;
00172 class Consumer;
00173 typedef std::map<std::string,Consumer> ConsumerMap;
00174 typedef ConsumerMap::iterator ConsumerIterator;
00175 ConsumerMap consumers_;
00176 ConsumerIterator consumers_first_;
00177 ConsumerIterator consumers_last_;
00178 ConsumerIterator find(DelegationConsumerSOAP* c);
00179 bool remove(ConsumerIterator i);
00181 int max_size_;
00183 int max_duration_;
00185 int max_usage_;
00187 bool context_lock_;
00188
00189
00191 virtual DelegationConsumerSOAP* AddConsumer(std::string& id,const std::string& client);
00193 virtual DelegationConsumerSOAP* FindConsumer(const std::string& id,const std::string& client);
00195 virtual bool TouchConsumer(DelegationConsumerSOAP* c,const std::string& credentials);
00197 virtual bool QueryConsumer(DelegationConsumerSOAP* c,std::string& credentials);
00199 virtual void ReleaseConsumer(DelegationConsumerSOAP* c);
00201 virtual void RemoveConsumer(DelegationConsumerSOAP* c);
00203 virtual void CheckConsumers(void);
00204
00205
00206
00210 bool DelegateCredentialsInit(const SOAPEnvelope& in,SOAPEnvelope& out,const std::string& client = "");
00211
00213 bool UpdateCredentials(std::string& credentials,const SOAPEnvelope& in,SOAPEnvelope& out,const std::string& client = "");
00214 bool UpdateCredentials(std::string& credentials,std::string& identity,const SOAPEnvelope& in,SOAPEnvelope& out,const std::string& client = "");
00215
00216 public:
00217 DelegationContainerSOAP(void);
00218 virtual ~DelegationContainerSOAP(void);
00219
00221 bool DelegatedToken(std::string& credentials,XMLNode token,const std::string& client = "");
00222 bool DelegatedToken(std::string& credentials,std::string& identity,XMLNode token,const std::string& client = "");
00223
00224 bool Process(const SOAPEnvelope& in,SOAPEnvelope& out,const std::string& client = "");
00225 bool Process(std::string& credentials,const SOAPEnvelope& in,SOAPEnvelope& out,const std::string& client = "");
00226 bool MatchNamespace(const SOAPEnvelope& in);
00227 };
00228
00229 }
00230
00231
00232 #endif