139 TPMERegexp rex(
"^([a]?s3|s3http[s]?|gs|gshttp[s]?){1}://([^/]+)/([^/]+)/([^/].*)",
"i");
142 doMakeZombie =
kTRUE;
144 else if (!ParseOptions(options, accessKey, secretKey)) {
146 doMakeZombie =
kTRUE;
151 Error(
"TS3WebFile",
"%s", (
const char*)errorMsg);
159 fS3Request.SetBucket(rex[3]);
169 (
const char*)rex[2], (
const char*)rex[3], (
const char*)rex[4]));
174 const char* kAccessKeyEnv =
"S3_ACCESS_KEY";
175 const char* kSecretKeyEnv =
"S3_SECRET_KEY";
177 GetCredentialsFromEnv(kAccessKeyEnv, kSecretKeyEnv, accessKey, secretKey);
180 fS3Request.SetHost(fUrl.GetHost());
190 fS3Request.SetAuthKeys(accessKey, secretKey);
206 if (IsZombie() && (accessKey.
IsNull() || secretKey.
IsNull())) {
209 Error(
"TS3WebFile",
"could not find authentication info in "\
210 "'options' argument and at least one of the environment variables '%s' or '%s' is not set",
211 kAccessKeyEnv, kSecretKeyEnv);
228 TString optStr = (
const char*)options;
238 TPMERegexp rex(
"(^AUTH=|^.* AUTH=)([a-z0-9]+):([a-z0-9+/]+)[\\s]*.*$",
"i");
239 if (rex.
Match(optStr) < 4) {
240 Error(
"ParseOptions",
"expecting options of the form \"AUTH=myAccessKey:mySecretKey\"");
246 Info(
"ParseOptions",
"using authentication information from 'options' argument");
295 pos[i], pos[i] + len[i] - 1);
318 if (rex.
Match(headerLine) != 2)
325 TString serverId = rex[1].ReplaceAll(
"\r",
"").ReplaceAll(
"\n",
"");
343 outAccessKey = accKey;
344 outSecretKey = secKey;
346 Info(
"GetCredentialsFromEnv",
"using authentication information from environmental variables '%s' and '%s'",
347 accessKeyEnv, secretKeyEnv);
356 Warning(
"SetAuthKeys",
"usage of S3_ACCESS_ID and S3_ACCESS_KEY environmental variables is deprecated.");
357 Warning(
"SetAuthKeys",
"please use S3_ACCESS_KEY and S3_SECRET_KEY environmental variables.");
358 outAccessKey = accKey;
359 outSecretKey = secKey;
virtual Int_t GetHead()
Overwrites TWebFile::GetHead() for retrieving the HTTP headers of this file.
TS3HTTPRequest fS3Request
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
virtual void SetMsgReadBuffer10(const char *redirectLocation=0, Bool_t tempRedirect=kFALSE)
Set GET command for use by ReadBuffer(s)10(), handle redirection if needed.
virtual Int_t GetFromWeb10(char *buf, Int_t len, const TString &msg)
Read multiple byte range request from web server.
ClassImp(TS3WebFile) TS3WebFile
Construct a TS3WebFile object.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
virtual const char * Getenv(const char *env)
Get environment variable.
virtual Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
Read specified byte ranges from remote file via HTTP daemon.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
void Error(const char *location, const char *msgfmt,...)
R__EXTERN TSystem * gSystem
TString GetRequest(TS3HTTPRequest::EHTTPVerb httpVerb, Bool_t appendCRLF=kTRUE)
Returns the HTTP request ready to be sent to the server.
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
Bool_t GetCredentialsFromEnv(const char *accessKeyEnv, const char *secretKeyEnv, TString &outAccessKey, TString &outSecretKey)
Sets the access and secret keys from the environmental variables, if they are both set...
virtual void SetMsgReadBuffer10(const char *redirectLocation=0, Bool_t tempRedirect=kFALSE)
Overwrites TWebFile::SetMsgReadBuffer10() for setting the HTTP GET request compliant to the authentic...
virtual void CheckProxy()
Check if shell var "http_proxy" has been set and should be used.
virtual void ProcessHttpHeader(const TString &headerLine)
This method is called by the super-class TWebFile when a HTTP header for this file is retrieved...
Bool_t ParseOptions(Option_t *options, TString &accessKey, TString &secretKey)
Extracts the S3 authentication key pair (access key and secret key) from the options.
Int_t Match(const TString &s, UInt_t start=0)
Runs a match on s against the regex 'this' was created with.
Wrapper for PCRE library (Perl Compatible Regular Expressions).
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
Read specified byte ranges from remote file via HTTP daemon.
virtual Int_t GetHead()
Get the HTTP header.
virtual void Init(Bool_t readHeadOnly)
Initialize a TWebFile object.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.