OGR
cpl_alibaba_oss.h
1 /**********************************************************************
2  * $Id: cpl_alibaba_oss.h e648607661fdd5cbc6bb778c17c20c3e7979a734 2018-04-04 19:27:08 +0200 Even Rouault $
3  *
4  * Name: cpl_alibaba_oss.h
5  * Project: CPL - Common Portability Library
6  * Purpose: Alibaba Cloud Object Storage Service
7  * Author: Even Rouault <even.rouault at spatialys.com>
8  *
9  **********************************************************************
10  * Copyright (c) 2017, Even Rouault <even.rouault at spatialys.com>
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining a
13  * copy of this software and associated documentation files (the "Software"),
14  * to deal in the Software without restriction, including without limitation
15  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16  * and/or sell copies of the Software, and to permit persons to whom the
17  * Software is furnished to do so, subject to the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be included
20  * in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28  * DEALINGS IN THE SOFTWARE.
29  ****************************************************************************/
30 
31 #ifndef CPL_ALIBABA_OSS_INCLUDED_H
32 #define CPL_ALIBABA_OSS_INCLUDED_H
33 
34 #ifndef DOXYGEN_SKIP
35 
36 #include <cstddef>
37 
38 #include "cpl_string.h"
39 
40 #ifdef HAVE_CURL
41 
42 #include <curl/curl.h>
43 #include <map>
44 #include "cpl_aws.h"
45 
46 class VSIOSSHandleHelper final: public IVSIS3LikeHandleHelper
47 {
48  CPLString m_osURL;
49  CPLString m_osSecretAccessKey;
50  CPLString m_osAccessKeyId;
51  CPLString m_osEndpoint;
52  CPLString m_osBucket;
53  CPLString m_osObjectKey;
54  bool m_bUseHTTPS;
55  bool m_bUseVirtualHosting;
56 
57  void RebuildURL() override;
58 
59  static bool GetConfiguration(CSLConstList papszOptions,
60  CPLString& osSecretAccessKey,
61  CPLString& osAccessKeyId);
62 
63  protected:
64 
65  public:
66  VSIOSSHandleHelper(const CPLString& osSecretAccessKey,
67  const CPLString& osAccessKeyId,
68  const CPLString& osEndpoint,
69  const CPLString& osBucket,
70  const CPLString& osObjectKey,
71  bool bUseHTTPS, bool bUseVirtualHosting);
72  ~VSIOSSHandleHelper();
73 
74  static VSIOSSHandleHelper* BuildFromURI(const char* pszURI,
75  const char* pszFSPrefix,
76  bool bAllowNoObject,
77  CSLConstList papszOptions = nullptr);
78  static CPLString BuildURL(const CPLString& osEndpoint,
79  const CPLString& osBucket,
80  const CPLString& osObjectKey,
81  bool bUseHTTPS, bool bUseVirtualHosting);
82 
83  struct curl_slist* GetCurlHeaders(
84  const CPLString& osVerb,
85  const struct curl_slist* psExistingHeaders,
86  const void *pabyDataContent = nullptr,
87  size_t nBytesContent = 0 ) const override;
88 
89  bool CanRestartOnError(const char*, const char* pszHeaders,
90  bool bSetError,
91  bool* pbUpdateMap = nullptr) override;
92 
93  const CPLString& GetURL() const override { return m_osURL; }
94  const CPLString& GetBucket() const { return m_osBucket; }
95  const CPLString& GetObjectKey() const { return m_osObjectKey; }
96  const CPLString& GetEndpoint()const { return m_osEndpoint; }
97  bool GetVirtualHosting() const { return m_bUseVirtualHosting; }
98  void SetEndpoint(const CPLString &osStr);
99  void SetVirtualHosting(bool b);
100 
101  CPLString GetSignedURL(CSLConstList papszOptions);
102 };
103 
104 class VSIOSSUpdateParams
105 {
106  public:
107  CPLString m_osEndpoint;
108 
109  VSIOSSUpdateParams() {}
110 
111  explicit VSIOSSUpdateParams(const VSIOSSHandleHelper* poHelper) :
112  m_osEndpoint(poHelper->GetEndpoint()) {}
113 
114  void UpdateHandlerHelper(VSIOSSHandleHelper* poHelper) {
115  poHelper->SetEndpoint(m_osEndpoint);
116  }
117 };
118 
119 #endif /* HAVE_CURL */
120 
121 #endif /* #ifndef DOXYGEN_SKIP */
122 
123 #endif /* CPL_ALIBABA_OSS_INCLUDED_H */
GByte
unsigned char GByte
Definition: cpl_port.h:213
cpl_minixml.h
CSLFetchNameValueDef
const char * CSLFetchNameValueDef(CSLConstList papszStrList, const char *pszName, const char *pszDefault)
Definition: cpl_string.cpp:1646
CPLString
Convenient string class based on std::string.
Definition: cpl_string.h:336
CPLParseXMLString
CPLXMLNode * CPLParseXMLString(const char *)
Parse an XML string into tree form.
Definition: cpl_minixml.cpp:614
CPLXMLNode
Definition: cpl_minixml.h:66
CPL_FRMT_GIB
#define CPL_FRMT_GIB
Definition: cpl_port.h:314
EQUAL
#define EQUAL(a, b)
Definition: cpl_port.h:559
cpl_http.h
CPLTestBool
bool CPLTestBool(const char *pszValue)
Definition: cpl_string.cpp:1526
CSLConstList
char ** CSLConstList
Definition: cpl_port.h:1184
CPLBase64Encode
char * CPLBase64Encode(int nBytes, const GByte *pabyData)
Definition: cpl_base64.cpp:199
CPLDestroyXMLNode
void CPLDestroyXMLNode(CPLXMLNode *)
Destroy a tree.
Definition: cpl_minixml.cpp:1412
CPLDebug
void CPLDebug(const char *, const char *,...)
Definition: cpl_error.cpp:544
STARTS_WITH
#define STARTS_WITH(a, b)
Definition: cpl_port.h:568
cpl_string.h
CPLSPrintf
const char * CPLSPrintf(const char *fmt,...)
Definition: cpl_string.cpp:977
CPLGetXMLValue
const char * CPLGetXMLValue(const CPLXMLNode *poRoot, const char *pszPath, const char *pszDefault)
Fetch element/attribute value.
Definition: cpl_minixml.cpp:1645
GIntBig
long long GIntBig
Definition: cpl_port.h:246
CSLFetchNameValue
const char * CSLFetchNameValue(CSLConstList papszStrList, const char *pszName)
Definition: cpl_string.cpp:1674
CPLFree
#define CPLFree
Definition: cpl_conv.h:81
CPLGetConfigOption
const char * CPLGetConfigOption(const char *, const char *)
Definition: cpl_conv.cpp:1690

Generated for GDAL by doxygen 1.8.17.