/usr/include/arc/communication/ClientInterface.h is in nordugrid-arc-dev 4.2.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | // -*- indent-tabs-mode: nil -*-
#ifndef __ARC_CLIENTINTERFACE_H__
#define __ARC_CLIENTINTERFACE_H__
#include <string>
#include <list>
#include <inttypes.h>
#include <arc/ArcConfig.h>
#include <arc/DateTime.h>
#include <arc/URL.h>
#include <arc/message/Message.h>
#include <arc/message/MCC_Status.h>
#include <arc/message/PayloadRaw.h>
#include <arc/message/PayloadStream.h>
#include <arc/message/PayloadSOAP.h>
namespace Arc {
class MCCLoader;
class Logger;
class MCC;
//! Utility base class for MCC
/** The ClientInterface class is a utility base class used for
* configuring a client side Message Chain Component (MCC) chain
* and loading it into memory. It has several specializations of
* increasing complexity of the MCC chains.
* This class is not supposed to be used directly. Instead its
* descendants like ClientTCP, ClientHTTP, etc. must be used.
**/
class ClientInterface {
public:
ClientInterface()
: loader(NULL) {}
ClientInterface(const BaseConfig& cfg);
virtual ~ClientInterface();
void Overlay(XMLNode cfg);
const Config& GetConfig() const {
return xmlcfg;
}
MessageContext& GetContext() {
return context;
}
/// Initializes communication chain for this object.
/// Call to this method in derived class is not needed
/// if process() methods are used. It is only needed if
/// GetEntry() is used before process() is called.
virtual MCC_Status Load();
protected:
Config xmlcfg;
XMLNode overlay;
MCCLoader *loader;
MessageContext context;
static Logger logger;
static void AddSecHandler(XMLNode mcccfg, XMLNode handlercfg);
static void AddPlugin(XMLNode mcccfg, const std::string& libname, const std::string& libpath = "");
};
enum SecurityLayer {
NoSec, TLSSec, GSISec, SSL3Sec, GSIIOSec
};
enum EncryptionLevel {
NoEnc, RequireEnc, PreferEnc, OptionalEnc
};
class TCPSec {
public:
SecurityLayer sec;
EncryptionLevel enc;
TCPSec(void):sec(NoSec),enc(NoEnc) { };
TCPSec(SecurityLayer s):sec(s),enc((s==NoSec)?NoEnc:RequireEnc) { };
TCPSec(SecurityLayer s, EncryptionLevel e):sec(s),enc(e) { };
};
//! Class for setting up a MCC chain for TCP communication
/** The ClientTCP class is a specialization of the ClientInterface
* which sets up a client MCC chain for TCP communication, and
* optionally with a security layer on top which can be either TLS,
* GSI or SSL3.
**/
class ClientTCP
: public ClientInterface {
public:
ClientTCP()
: tcp_entry(NULL),
tls_entry(NULL) {}
ClientTCP(const BaseConfig& cfg, const std::string& host, int port,
TCPSec sec, int timeout = -1, bool no_delay = false);
virtual ~ClientTCP();
MCC_Status process(PayloadRawInterface *request,
PayloadStreamInterface **response, bool tls);
MCC_Status process(PayloadStreamInterface *request,
PayloadStreamInterface **response, bool tls);
/** Returns entry point to TCP or TLS MCC in configured chain.
To initialize entry point Load() method must be called. */
MCC* GetEntry() {
return tls_entry ? tls_entry : tcp_entry;
}
virtual MCC_Status Load();
void AddSecHandler(XMLNode handlercfg, TCPSec sec, const std::string& libanme = "", const std::string& libpath = "");
protected:
MCC *tcp_entry;
MCC *tls_entry;
};
struct HTTPClientInfo {
int code; /// HTTP response code
std::string reason; /// HTTP response reason
uint64_t size; /// Size of body (content-length)
Time lastModified; /// Reported modification time
std::string type; /// Content-type
std::list<std::string> cookies; /// All collected cookies
/// All returned headers
/**
* \since Added in 4.1.0.
**/
std::multimap<std::string, std::string> headers;
std::string location; /// Value of location attribute in HTTP response
};
class ClientHTTP;
//! Proxy class for handling request parameters
/** The purpose of this calss is to reduce number of methods
in ClientHTTP class. Use only for temporary variables. */
class ClientHTTPAttributes {
friend class ClientHTTP;
public:
ClientHTTPAttributes(const std::string& method);
ClientHTTPAttributes(const std::string& method,
std::multimap<std::string, std::string>& attributes);
ClientHTTPAttributes(const std::string& method, const std::string& path);
ClientHTTPAttributes(const std::string& method, const std::string& path,
std::multimap<std::string, std::string>& attributes);
ClientHTTPAttributes(const std::string& method, const std::string& path,
uint64_t range_start, uint64_t range_end);
ClientHTTPAttributes(const std::string& method, const std::string& path,
std::multimap<std::string, std::string>& attributes,
uint64_t range_start, uint64_t range_end);
protected:
const std::string default_path_;
std::multimap<std::string, std::string> default_attributes_;
const std::string& method_;
const std::string& path_;
std::multimap<std::string, std::string>& attributes_;
uint64_t range_start_;
uint64_t range_end_;
};
//! Class for setting up a MCC chain for HTTP communication
/** The ClientHTTP class inherits from the ClientTCP class and adds
* an HTTP MCC to the chain.
**/
class ClientHTTP
: public ClientTCP {
public:
ClientHTTP()
: http_entry(NULL), relative_uri(false), sec(NoSec) {}
ClientHTTP(const BaseConfig& cfg, const URL& url, int timeout = -1, const std::string& proxy_host = "", int proxy_port = 0);
virtual ~ClientHTTP();
MCC_Status process(const std::string& method, PayloadRawInterface *request,
HTTPClientInfo *info, PayloadRawInterface **response);
MCC_Status process(const std::string& method,
std::multimap<std::string, std::string>& attributes,
PayloadRawInterface *request,
HTTPClientInfo *info, PayloadRawInterface **response);
MCC_Status process(const std::string& method, const std::string& path,
PayloadRawInterface *request,
HTTPClientInfo *info, PayloadRawInterface **response);
MCC_Status process(const std::string& method, const std::string& path,
std::multimap<std::string, std::string>& attributes,
PayloadRawInterface *request,
HTTPClientInfo *info, PayloadRawInterface **response);
MCC_Status process(const std::string& method, const std::string& path,
uint64_t range_start, uint64_t range_end,
PayloadRawInterface *request,
HTTPClientInfo *info, PayloadRawInterface **response);
MCC_Status process(const std::string& method, const std::string& path,
std::multimap<std::string, std::string>& attributes,
uint64_t range_start, uint64_t range_end,
PayloadRawInterface *request,
HTTPClientInfo *info, PayloadRawInterface **response);
MCC_Status process(const ClientHTTPAttributes &reqattr,
PayloadRawInterface *request,
HTTPClientInfo *info, PayloadRawInterface **response);
MCC_Status process(const ClientHTTPAttributes &reqattr,
PayloadStreamInterface *request,
HTTPClientInfo *info, PayloadRawInterface **response);
MCC_Status process(const ClientHTTPAttributes &reqattr,
PayloadRawInterface *request,
HTTPClientInfo *info, PayloadStreamInterface **response);
MCC_Status process(const ClientHTTPAttributes &reqattr,
PayloadStreamInterface *request,
HTTPClientInfo *info, PayloadStreamInterface **response);
/** Returns entry point to HTTP MCC in configured chain.
To initialize entry point Load() method must be called. */
MCC* GetEntry() {
return http_entry;
}
void AddSecHandler(XMLNode handlercfg, const std::string& libanme = "", const std::string& libpath = "");
virtual MCC_Status Load();
void RelativeURI(bool val) { relative_uri=val; };
const URL& GetURL() const { return default_url; };
protected:
MCC *http_entry;
URL default_url;
bool relative_uri;
TCPSec sec;
MCC_Status process(const std::string& method, const std::string& path,
std::multimap<std::string, std::string>& attributes,
uint64_t range_start, uint64_t range_end,
MessagePayload *request,
HTTPClientInfo *info, MessagePayload **response);
};
/** Class with easy interface for sending/receiving SOAP messages
over HTTP(S/G).
It takes care of configuring MCC chain and making an entry point. */
class ClientSOAP
: public ClientHTTP {
public:
/** Constructor creates MCC chain and connects to server. */
ClientSOAP()
: soap_entry(NULL) {}
ClientSOAP(const BaseConfig& cfg, const URL& url, int timeout = -1);
virtual ~ClientSOAP();
/** Send SOAP request and receive response. */
MCC_Status process(PayloadSOAP *request, PayloadSOAP **response);
/** Send SOAP request with specified SOAP action and receive response. */
MCC_Status process(const std::string& action, PayloadSOAP *request,
PayloadSOAP **response);
/** Returns entry point to SOAP MCC in configured chain.
To initialize entry point Load() method must be called. */
MCC* GetEntry() {
return soap_entry;
}
/** Adds security handler to configuration of SOAP MCC */
void AddSecHandler(XMLNode handlercfg, const std::string& libanme = "", const std::string& libpath = "");
/** Instantiates pluggable elements according to generated configuration */
virtual MCC_Status Load();
protected:
MCC *soap_entry;
};
// Convenience base class for creating configuration
// security handlers.
class SecHandlerConfig
: public XMLNode {
public:
SecHandlerConfig(const std::string& name, const std::string& event = "incoming");
};
class DNListHandlerConfig
: public SecHandlerConfig {
public:
DNListHandlerConfig(const std::list<std::string>& dns, const std::string& event = "incoming");
void AddDN(const std::string& dn);
};
class ARCPolicyHandlerConfig
: public SecHandlerConfig {
public:
ARCPolicyHandlerConfig(const std::string& event = "incoming");
ARCPolicyHandlerConfig(XMLNode policy, const std::string& event = "incoming");
void AddPolicy(XMLNode policy);
void AddPolicy(const std::string& policy);
};
} // namespace Arc
#endif // __ARC_CLIENTINTERFACE_H__
|