160 TPMERegexp rex(
"^([a]?s3|s3http[s]?|gs|gshttp[s]?){1}://([^/]+)/([^/]+)/([^/].*)",
"i");
163 doMakeZombie =
kTRUE;
165 else if (!
ParseOptions(options, accessKey, secretKey, token)) {
167 doMakeZombie =
kTRUE;
172 Error(
"TS3WebFile",
"%s", (
const char*)errorMsg);
190 (
const char*)rex[2], (
const char*)rex[3], (
const char*)rex[4]));
195 const char* kAccessKeyEnv =
"S3_ACCESS_KEY";
196 const char* kSecretKeyEnv =
"S3_SECRET_KEY";
197 const char* kSessionToken =
"S3_SESSION_TOKEN";
200 accessKey, secretKey, token);
216 if (rex[1].BeginsWith(
"gs"))
234 Error(
"TS3WebFile",
"could not find authentication info in "\
235 "'options' argument and at least one of the environment variables '%s' or '%s' is not set",
236 kAccessKeyEnv, kSecretKeyEnv);
255 TString optStr = (
const char*)options;
265 TPMERegexp rex_token(
"(^TOKEN=|^.* TOKEN=)([\\S]+)[\\s]*.*$",
"i");
266 if (rex_token.
Match(optStr) == 3) {
267 token = rex_token[2];
269 TPMERegexp rex(
"(^AUTH=|^.* AUTH=)([a-z0-9]+):([a-z0-9+/]+)[\\s]*.*$",
"i");
270 if (rex.
Match(optStr) == 4) {
275 Info(
"ParseOptions",
"using authentication information from 'options' argument");
322 for (
Int_t i=0, offset=0; i < nbuf; i++) {
324 pos[i], pos[i] + len[i] - 1);
326 if (
GetFromWeb10(&buf[offset], len[i], s3Request) == -1)
347 if (rex.
Match(headerLine) != 2)
354 TString serverId = rex[1].ReplaceAll(
"\r",
"").ReplaceAll(
"\n",
"");
365 const char* tokenEnv,
TString& outAccessKey,
377 outAccessKey = accKey;
378 outSecretKey = secKey;
380 Info(
"GetCredentialsFromEnv",
"using authentication information from environmental variables '%s' and '%s'",
381 accessKeyEnv, secretKeyEnv);
390 Warning(
"SetAuthKeys",
"usage of S3_ACCESS_ID and S3_ACCESS_KEY environmental variables is deprecated.");
391 Warning(
"SetAuthKeys",
"please use S3_ACCESS_KEY and S3_SECRET_KEY environmental variables.");
392 outAccessKey = accKey;
393 outSecretKey = secKey;
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
R__EXTERN TSystem * gSystem
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
R__ALWAYS_INLINE Bool_t IsZombie() const
Wrapper for PCRE library (Perl Compatible Regular Expressions).
Int_t Match(const TString &s, UInt_t start=0)
Runs a match on s against the regex 'this' was created with.
TS3HTTPRequest & SetObjectKey(const TString &objectKey)
TString GetRequest(TS3HTTPRequest::EHTTPVerb httpVerb, Bool_t appendCRLF=kTRUE)
Returns the HTTP request ready to be sent to the server.
TS3HTTPRequest & SetAuthKeys(const TString &accessKey, const TString &secretKey)
TS3HTTPRequest & SetBucket(const TString &bucket)
TS3HTTPRequest & SetSessionToken(const TString &token)
TS3HTTPRequest & SetAuthType(TS3HTTPRequest::EAuthType authType)
TS3HTTPRequest & SetHost(const TString &host)
TS3HTTPRequest fS3Request
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.
virtual Int_t GetHead()
Overwrites TWebFile::GetHead() for retrieving the HTTP headers of this file.
virtual void ProcessHttpHeader(const TString &headerLine)
This method is called by the super-class TWebFile when a HTTP header for this file is retrieved.
virtual void SetMsgReadBuffer10(const char *redirectLocation=0, Bool_t tempRedirect=kFALSE)
Overwrites TWebFile::SetMsgReadBuffer10() for setting the HTTP GET request compliant to the authentic...
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 Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
Read specified byte ranges from remote file via HTTP daemon.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual const char * Getenv(const char *env)
Get environment variable.
void SetUrl(const char *url, Bool_t defaultIsFile=kFALSE)
Parse url character string and split in its different subcomponents.
const char * GetHost() const
virtual Int_t GetHead()
Get the HTTP header.
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 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 CheckProxy()
Check if shell var "http_proxy" has been set and should be used.
virtual void Init(Bool_t readHeadOnly)
Initialize a TWebFile object.
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.