Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TS3WebFile.h
Go to the documentation of this file.
1// @(#)root/net:$Id: TS3WebFile.h$
2// Author: Fabio Hernandez 22/01/2013
3// extending an initial version by Marcelo Sousa (class TAS3File)
4
5/*************************************************************************
6 * Copyright (C) 1995-2011, Rene Brun and Fons Rademakers. *
7 * All rights reserved. *
8 * *
9 * For the licensing terms see $ROOTSYS/LICENSE. *
10 * For the list of contributors see $ROOTSYS/README/CREDITS. *
11 *************************************************************************/
12
13#ifndef ROOT_TS3WebFile
14#define ROOT_TS3WebFile
15
16//////////////////////////////////////////////////////////////////////////
17// //
18// TS3WebFile //
19// //
20// A TS3WebFile is a TWebFile which retrieves the file contents from a //
21// web server implementing the REST API of the Amazon S3 protocol. This //
22// class is meant to be as generic as possible to be used with files //
23// hosted not only by Amazon S3 servers but also by other providers //
24// implementing the core of the S3 protocol. //
25// //
26// The S3 protocol works on top of HTTPS (and HTTP) and imposes that //
27// each HTTP request be signed using a specific convention: the request //
28// must include an 'Authorization' header which contains the signature //
29// of a concatenation of selected request fields. For signing the //
30// request, an 'Access Key Id' and a 'Secret Access Key' need to be //
31// known. These keys are used by the S3 servers to identify the client //
32// and to authenticate the request as genuine. //
33// //
34// As an end user, you must know the Access Key and Secret Access Key //
35// in order to access each S3 file. They are provided to you by your S3 //
36// service provider. Those two keys can be provided to ROOT when //
37// initializing an object of this class by two means: //
38// a) by using the environmental variables S3_ACCESS_KEY and //
39// S3_SECRET_KEY, or //
40// b) by specifying them as an argument when opening each file. //
41// //
42// The first method is convenient if all the S3 files you want to //
43// access are hosted by a single provider. The second one is more //
44// flexible as it allows you to specify which credentials to use //
45// on a per-file basis. See the documentation of the constructor of //
46// this class for details on the syntax. //
47// //
48// For generating and signing the HTTP request, this class uses //
49// TS3HTTPRequest. //
50// //
51// For more information on the details of S3 protocol please refer to: //
52// "Amazon Simple Storage Service Developer Guide": //
53// http://docs.amazonwebservices.com/AmazonS3/latest/dev/Welcome.html //
54// //
55// "Amazon Simple Storage Service REST API Reference" //
56// http://docs.amazonwebservices.com/AmazonS3/latest/API/APIRest.html //
57//////////////////////////////////////////////////////////////////////////
58
59#include "TWebFile.h"
60
61#include "TUrl.h"
62
63#include "TString.h"
64
65#include "TS3HTTPRequest.h"
66
67namespace ROOT::Deprecated {
68
69class TS3WebFile: public TWebFile {
70
71private:
74 Bool_t GetCredentialsFromEnv(const char* accessKeyEnv, const char* secretKeyEnv, const char* tokenEnv,
76
77protected:
78 // Super-class methods extended by this class
79 Int_t GetHead() override;
80 void SetMsgReadBuffer10(const char* redirectLocation = nullptr, Bool_t tempRedirect = kFALSE) override;
81 void ProcessHttpHeader(const TString& headerLine) override;
82
83 // Modifiers of data members (to be used mainly by subclasses)
86
87 // Data members
88 TS3HTTPRequest fS3Request; // S3 HTTP request
89 Bool_t fUseMultiRange; // Is the S3 server capable of serving multirange requests?
90
91public:
92 // Constructors & Destructor
93 TS3WebFile(const char* url, Option_t* options="");
94 virtual ~TS3WebFile() {}
95
96 // Selectors
97 const TString& GetAccessKey() const { return fS3Request.GetAccessKey(); }
98 const TString& GetSecretKey() const { return fS3Request.GetSecretKey(); }
99 const TString& GetBucket() const { return fS3Request.GetBucket(); }
100 const TString& GetObjectKey() const { return fS3Request.GetObjectKey(); }
101 const TUrl& GetUrl() const { return fUrl; }
102
103 // Modifiers
104 Bool_t ReadBuffers(char* buf, Long64_t* pos, Int_t* len, Int_t nbuf) override;
105
106 ClassDefOverride(TS3WebFile, 0) // Read a ROOT file from a S3 server
107};
108
109} // namespace ROOT::Deprecated
110
111using TS3WebFile R__DEPRECATED(6, 42, "TS3WebFile is deprecated") = ROOT::Deprecated::TS3WebFile;
112
113#endif // ROOT_TS3WebFile
#define R__DEPRECATED(MAJOR, MINOR, REASON)
Definition RConfig.hxx:510
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
const TString & GetSecretKey() const
const TString & GetBucket() const
TS3HTTPRequest & SetSecretKey(const TString &secretKey)
TS3HTTPRequest & SetAccessKey(const TString &accessKey)
const TString & GetObjectKey() const
const TString & GetAccessKey() const
Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf) override
Read the nbuf blocks described in arrays pos and len.
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.
void SetMsgReadBuffer10(const char *redirectLocation=nullptr, Bool_t tempRedirect=kFALSE) override
Overwrites TWebFile::SetMsgReadBuffer10() for setting the HTTP GET request compliant to the authentic...
const TString & GetAccessKey() const
Definition TS3WebFile.h:97
const TString & GetObjectKey() const
Definition TS3WebFile.h:100
Int_t GetHead() override
Overwrites TWebFile::GetHead() for retrieving the HTTP headers of this file.
void SetSecretKey(const TString &secretKey)
Definition TS3WebFile.h:85
const TString & GetSecretKey() const
Definition TS3WebFile.h:98
const TUrl & GetUrl() const
Definition TS3WebFile.h:101
void SetAccessKey(const TString &accessKey)
Definition TS3WebFile.h:84
void ProcessHttpHeader(const TString &headerLine) override
This method is called by the super-class TWebFile when a HTTP header for this file is retrieved.
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.
const TString & GetBucket() const
Definition TS3WebFile.h:99
TUrl fUrl
!URL of file
Definition TFile.h:188
Basic string class.
Definition TString.h:138
This class represents a WWW compatible URL.
Definition TUrl.h:33