152 TPMERegexp rex(
"^([a]?s3|s3http[s]?|gs|gshttp[s]?){1}://([^/]+)/([^/]+)/([^/].*)",
"i");
155 doMakeZombie =
kTRUE;
157 else if (!ParseOptions(options, accessKey, secretKey, token)) {
159 doMakeZombie =
kTRUE;
164 Error(
"TS3WebFile",
"%s", (
const char*)errorMsg);
172 fS3Request.SetBucket(rex[3]);
182 (
const char*)rex[2], (
const char*)rex[3], (
const char*)rex[4]));
187 const char* kAccessKeyEnv =
"S3_ACCESS_KEY";
188 const char* kSecretKeyEnv =
"S3_SECRET_KEY";
189 const char* kSessionToken =
"S3_SESSION_TOKEN";
191 GetCredentialsFromEnv(kAccessKeyEnv, kSecretKeyEnv, kSessionToken,
192 accessKey, secretKey, token);
195 fS3Request.SetHost(fUrl.GetHost());
205 fS3Request.SetAuthKeys(accessKey, secretKey);
207 fS3Request.SetSessionToken(token);
208 if (rex[1].BeginsWith(
"gs"))
223 if (IsZombie() && (accessKey.
IsNull() || secretKey.
IsNull())) {
226 Error(
"TS3WebFile",
"could not find authentication info in "\
227 "'options' argument and at least one of the environment variables '%s' or '%s' is not set",
228 kAccessKeyEnv, kSecretKeyEnv);
247 TString optStr = (
const char*)options;
257 TPMERegexp rex_token(
"(^TOKEN=|^.* TOKEN=)([\\S]+)[\\s]*.*$",
"i");
258 if (rex_token.
Match(optStr) == 3) {
259 token = rex_token[2];
261 TPMERegexp rex(
"(^AUTH=|^.* AUTH=)([a-z0-9]+):([a-z0-9+/]+)[\\s]*.*$",
"i");
262 if (rex.
Match(optStr) == 4) {
267 Info(
"ParseOptions",
"using authentication information from 'options' argument");
314 for (
Int_t i=0, offset=0; i < nbuf; i++) {
316 pos[i], pos[i] + len[i] - 1);
318 if (
GetFromWeb10(&buf[offset], len[i], s3Request) == -1)
339 if (rex.
Match(headerLine) != 2)
346 TString serverId = rex[1].ReplaceAll(
"\r",
"").ReplaceAll(
"\n",
"");
357 const char* tokenEnv,
TString& outAccessKey,
369 outAccessKey = accKey;
370 outSecretKey = secKey;
372 Info(
"GetCredentialsFromEnv",
"using authentication information from environmental variables '%s' and '%s'",
373 accessKeyEnv, secretKeyEnv);
382 Warning(
"SetAuthKeys",
"usage of S3_ACCESS_ID and S3_ACCESS_KEY environmental variables is deprecated.");
383 Warning(
"SetAuthKeys",
"please use S3_ACCESS_KEY and S3_SECRET_KEY environmental variables.");
384 outAccessKey = accKey;
385 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.
Bool_t ParseOptions(Option_t *options, TString &accessKey, TString &secretKey, TString &token)
Extracts the S3 authentication key pair (access key and secret key) from the options.
Bool_t GetCredentialsFromEnv(const char *accessKeyEnv, const char *secretKeyEnv, const char *tokenEnv, TString &outAccessKey, TString &outSecretKey, TString &outToken)
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)
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, Int_t nseg=0, Long64_t *seg_pos=0, Int_t *seg_len=0)
Read multiple byte range request from web server.
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.
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.
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 Contains(const char *pat, ECaseCompare cmp=kExact) const
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).
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.