31 #ifndef CPL_AWS_INCLUDED_H 32 #define CPL_AWS_INCLUDED_H 42 #include <curl/curl.h> 45 CPLString CPLGetLowerCaseHexSHA256(
const void *pabyData,
size_t nBytes );
52 CPLString CPLAWSGetHeaderVal(
const struct curl_slist* psExistingHeaders,
56 CPLGetAWS_SIGN4_Signature(
const CPLString& osSecretAccessKey,
62 const struct curl_slist* psExistingHeaders,
77 const struct curl_slist* psExistingHeaders,
84 class IVSIS3LikeHandleHelper
89 std::map<CPLString, CPLString> m_oMapQueryParameters{};
91 virtual void RebuildURL() = 0;
92 CPLString GetQueryString(
bool bAddEmptyValueAfterEqual)
const;
95 IVSIS3LikeHandleHelper() =
default;
96 virtual ~IVSIS3LikeHandleHelper() =
default;
98 void ResetQueryParameters();
101 virtual struct curl_slist* GetCurlHeaders(
const CPLString& osVerb,
102 const struct curl_slist* psExistingHeaders,
103 const void *pabyDataContent =
nullptr,
104 size_t nBytesContent = 0)
const = 0;
106 virtual bool AllowAutomaticRedirection() {
return true; }
107 virtual bool CanRestartOnError(
const char*,
const char* ,
108 bool ,
bool* =
nullptr) {
return false;}
110 virtual const CPLString& GetURL()
const = 0;
112 static bool GetBucketAndObjectKey(
const char* pszURI,
113 const char* pszFSPrefix,
118 static CPLString BuildCanonicalizedHeaders(
119 std::map<CPLString, CPLString>& oSortedMapHeaders,
120 const struct curl_slist* psExistingHeaders,
121 const char* pszHeaderPrefix);
126 class VSIS3HandleHelper final:
public IVSIS3LikeHandleHelper
139 bool m_bUseHTTPS =
false;
140 bool m_bUseVirtualHosting =
false;
141 bool m_bFromEC2 =
false;
143 void RebuildURL()
override;
145 static bool GetConfigurationFromEC2(
CPLString& osSecretAccessKey,
149 static bool GetConfigurationFromAWSConfigFiles(
165 VSIS3HandleHelper(
const CPLString& osSecretAccessKey,
173 bool bUseHTTPS,
bool bUseVirtualHosting,
bool bFromEC2);
174 ~VSIS3HandleHelper();
176 static VSIS3HandleHelper* BuildFromURI(
const char* pszURI,
177 const char* pszFSPrefix,
183 bool bUseHTTPS,
bool bUseVirtualHosting);
185 struct curl_slist* GetCurlHeaders(
187 const struct curl_slist* psExistingHeaders,
188 const void *pabyDataContent =
nullptr,
189 size_t nBytesContent = 0)
const override;
191 bool AllowAutomaticRedirection()
override {
return false; }
192 bool CanRestartOnError(
const char*,
const char* pszHeaders,
194 bool* pbUpdateMap =
nullptr)
override;
196 const CPLString& GetURL()
const override {
return m_osURL; }
197 const CPLString& GetBucket()
const {
return m_osBucket; }
198 const CPLString& GetObjectKey()
const {
return m_osObjectKey; }
199 const CPLString& GetEndpoint()
const {
return m_osEndpoint; }
200 const CPLString& GetRegion()
const {
return m_osRegion; }
201 const CPLString& GetRequestPayer()
const {
return m_osRequestPayer; }
202 bool GetVirtualHosting()
const {
return m_bUseVirtualHosting; }
203 void SetEndpoint(
const CPLString &osStr);
205 void SetRequestPayer(
const CPLString &osStr);
206 void SetVirtualHosting(
bool b);
210 static void CleanMutex();
211 static void ClearCache();
214 class VSIS3UpdateParams
220 bool m_bUseVirtualHosting =
false;
222 VSIS3UpdateParams() =
default;
224 explicit VSIS3UpdateParams(
const VSIS3HandleHelper* poHelper) :
225 m_osRegion(poHelper->GetRegion()),
226 m_osEndpoint(poHelper->GetEndpoint()),
227 m_osRequestPayer(poHelper->GetRequestPayer()),
228 m_bUseVirtualHosting(poHelper->GetVirtualHosting()) {}
230 void UpdateHandlerHelper(VSIS3HandleHelper* poHelper) {
231 poHelper->SetRegion(m_osRegion);
232 poHelper->SetEndpoint(m_osEndpoint);
233 poHelper->SetRequestPayer(m_osRequestPayer);
234 poHelper->SetVirtualHosting(m_bUseVirtualHosting);
Convenient string class based on std::string.
Definition: cpl_string.h:329
Various convenience functions for working with strings and string lists.
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1186
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition: cpl_port.h:989