00001
00002
00003 #ifndef __ARC_CLIENTINTERFACE_H__
00004 #define __ARC_CLIENTINTERFACE_H__
00005
00006 #include <string>
00007 #include <list>
00008
00009 #include <inttypes.h>
00010
00011 #include <arc/ArcConfig.h>
00012 #include <arc/DateTime.h>
00013 #include <arc/URL.h>
00014 #include <arc/message/Message.h>
00015 #include <arc/message/MCC_Status.h>
00016 #include <arc/message/PayloadRaw.h>
00017 #include <arc/message/PayloadStream.h>
00018 #include <arc/message/PayloadSOAP.h>
00019
00020 namespace Arc {
00021
00022 class MCCLoader;
00023 class Logger;
00024 class MCC;
00025
00027
00032 class ClientInterface {
00033 public:
00034 ClientInterface()
00035 : loader(NULL) {}
00036 ClientInterface(const BaseConfig& cfg);
00037 virtual ~ClientInterface();
00038 void Overlay(XMLNode cfg);
00039 const Config& GetConfig() const {
00040 return xmlcfg;
00041 }
00042 MessageContext& GetContext() {
00043 return context;
00044 }
00045 virtual bool Load();
00046 protected:
00047 Config xmlcfg;
00048 XMLNode overlay;
00049 MCCLoader *loader;
00050 MessageContext context;
00051 static Logger logger;
00052 static void AddSecHandler(XMLNode mcccfg, XMLNode handlercfg);
00053 static void AddPlugin(XMLNode mcccfg, const std::string& libname, const std::string& libpath = "");
00054 };
00055
00056 enum SecurityLayer {
00057 NoSec, TLSSec, GSISec, SSL3Sec, GSIIOSec
00058 };
00059
00061
00066 class ClientTCP
00067 : public ClientInterface {
00068 public:
00069 ClientTCP()
00070 : tcp_entry(NULL),
00071 tls_entry(NULL) {}
00072 ClientTCP(const BaseConfig& cfg, const std::string& host, int port,
00073 SecurityLayer sec, int timeout = -1, bool no_delay = false);
00074 virtual ~ClientTCP();
00075 MCC_Status process(PayloadRawInterface *request,
00076 PayloadStreamInterface **response, bool tls);
00077 MCC* GetEntry() {
00078 return tls_entry ? tls_entry : tcp_entry;
00079 }
00080 virtual bool Load();
00081 void AddSecHandler(XMLNode handlercfg, SecurityLayer sec, const std::string& libanme = "", const std::string& libpath = "");
00082 protected:
00083 MCC *tcp_entry;
00084 MCC *tls_entry;
00085 };
00086
00087 struct HTTPClientInfo {
00088 int code;
00089 std::string reason;
00090 uint64_t size;
00091 Time lastModified;
00092 std::string type;
00093 std::list<std::string> cookies;
00094 std::string location;
00095 };
00096
00098
00101 class ClientHTTP
00102 : public ClientTCP {
00103 public:
00104 ClientHTTP()
00105 : http_entry(NULL), relative_uri(false), sec(NoSec) {}
00106 ClientHTTP(const BaseConfig& cfg, const URL& url, int timeout = -1, const std::string& proxy_host = "", int proxy_port = 0);
00107 virtual ~ClientHTTP();
00108 MCC_Status process(const std::string& method, PayloadRawInterface *request,
00109 HTTPClientInfo *info, PayloadRawInterface **response);
00110 MCC_Status process(const std::string& method,
00111 std::multimap<std::string, std::string>& attributes,
00112 PayloadRawInterface *request,
00113 HTTPClientInfo *info, PayloadRawInterface **response);
00114 MCC_Status process(const std::string& method, const std::string& path,
00115 PayloadRawInterface *request,
00116 HTTPClientInfo *info, PayloadRawInterface **response);
00117 MCC_Status process(const std::string& method, const std::string& path,
00118 std::multimap<std::string, std::string>& attributes,
00119 PayloadRawInterface *request,
00120 HTTPClientInfo *info, PayloadRawInterface **response);
00121 MCC_Status process(const std::string& method, const std::string& path,
00122 uint64_t range_start, uint64_t range_end,
00123 PayloadRawInterface *request,
00124 HTTPClientInfo *info, PayloadRawInterface **response);
00125 MCC_Status process(const std::string& method, const std::string& path,
00126 std::multimap<std::string, std::string>& attributes,
00127 uint64_t range_start, uint64_t range_end,
00128 PayloadRawInterface *request,
00129 HTTPClientInfo *info, PayloadRawInterface **response);
00130 MCC* GetEntry() {
00131 return http_entry;
00132 }
00133 void AddSecHandler(XMLNode handlercfg, const std::string& libanme = "", const std::string& libpath = "");
00134 virtual bool Load();
00135 void RelativeURI(bool val) { relative_uri=val; };
00136 protected:
00137 MCC *http_entry;
00138 URL default_url;
00139 bool relative_uri;
00140 SecurityLayer sec;
00141 };
00142
00146 class ClientSOAP
00147 : public ClientHTTP {
00148 public:
00150 ClientSOAP()
00151 : soap_entry(NULL) {}
00152 ClientSOAP(const BaseConfig& cfg, const URL& url, int timeout = -1);
00153 virtual ~ClientSOAP();
00155 MCC_Status process(PayloadSOAP *request, PayloadSOAP **response);
00157 MCC_Status process(const std::string& action, PayloadSOAP *request,
00158 PayloadSOAP **response);
00161 MCC* GetEntry() {
00162 return soap_entry;
00163 }
00165 void AddSecHandler(XMLNode handlercfg, const std::string& libanme = "", const std::string& libpath = "");
00167 virtual bool Load();
00168 protected:
00169 MCC *soap_entry;
00170 };
00171
00172
00173
00174 class SecHandlerConfig
00175 : public XMLNode {
00176 public:
00177 SecHandlerConfig(const std::string& name, const std::string& event = "incoming");
00178 };
00179
00180 class DNListHandlerConfig
00181 : public SecHandlerConfig {
00182 public:
00183 DNListHandlerConfig(const std::list<std::string>& dns, const std::string& event = "incoming");
00184 void AddDN(const std::string& dn);
00185 };
00186
00187 class ARCPolicyHandlerConfig
00188 : public SecHandlerConfig {
00189 public:
00190 ARCPolicyHandlerConfig(const std::string& event = "incoming");
00191 ARCPolicyHandlerConfig(XMLNode policy, const std::string& event = "incoming");
00192 void AddPolicy(XMLNode policy);
00193 void AddPolicy(const std::string& policy);
00194 };
00195
00196 }
00197
00198 #endif // __ARC_CLIENTINTERFACE_H__