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);
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";
192 accessKey, secretKey, token);
208 if (rex[1].BeginsWith(
"gs"))
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;
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.