GDAL

cpl_swift.h
1/**********************************************************************
2 * Project: CPL - Common Portability Library
3 * Purpose: OpenStack Swift Object Storage routines
4 * Author: Even Rouault <even.rouault at spatialys.com>
5 *
6 **********************************************************************
7 * Copyright (c) 2018, Even Rouault <even.rouault at spatialys.com>
8 *
9 * SPDX-License-Identifier: MIT
10 ****************************************************************************/
11
12#ifndef CPL_SWIFT_INCLUDED_H
13#define CPL_SWIFT_INCLUDED_H
14
15#ifndef DOXYGEN_SKIP
16
17#ifdef HAVE_CURL
18
19#include <curl/curl.h>
20#include "cpl_http.h"
21#include "cpl_aws.h"
22#include "cpl_json.h"
23#include <map>
24
25 class VSISwiftHandleHelper final : public IVSIS3LikeHandleHelper
26{
27 std::string m_osURL;
28 std::string m_osStorageURL;
29 std::string m_osAuthToken;
30 std::string m_osBucket;
31 std::string m_osObjectKey;
32
33 static bool GetConfiguration(const std::string &osPathForOption,
34 std::string &osStorageURL,
35 std::string &osAuthToken);
36
37 static bool GetCached(const std::string &osPathForOption,
38 const char *pszURLKey, const char *pszUserKey,
39 const char *pszPasswordKey, std::string &osStorageURL,
40 std::string &osAuthToken);
41
42 static std::string BuildURL(const std::string &osStorageURL,
43 const std::string &osBucket,
44 const std::string &osObjectKey);
45
46 void RebuildURL() override;
47
48 // V1 Authentication
49 static bool CheckCredentialsV1(const std::string &osPathForOption);
50 static bool AuthV1(const std::string &osPathForOption,
51 std::string &osStorageURL, std::string &osAuthToken);
52
53 // V3 Authentication
54 static bool CheckCredentialsV3(const std::string &osPathForOption,
55 const std::string &osAuthType);
56 static bool AuthV3(const std::string &osPathForOption,
57 const std::string &osAuthType, std::string &osStorageURL,
58 std::string &osAuthToken);
59 static CPLJSONObject
60 CreateAuthV3RequestObject(const std::string &osPathForOption,
61 const std::string &osAuthType);
62 static bool GetAuthV3StorageURL(const std::string &osPathForOption,
63 const CPLHTTPResult *psResult,
64 std::string &storageURL);
65
66 public:
67 VSISwiftHandleHelper(const std::string &osStorageURL,
68 const std::string &osAuthToken,
69 const std::string &osBucket,
70 const std::string &osObjectKey);
71 ~VSISwiftHandleHelper() override;
72
73 bool Authenticate(const std::string &osPathForOption);
74
75 static VSISwiftHandleHelper *BuildFromURI(const char *pszURI,
76 const char *pszFSPrefix);
77
78 struct curl_slist *GetCurlHeaders(const std::string &osVerbosVerb,
79 struct curl_slist *psHeaders,
80 const void *pabyDataContent = nullptr,
81 size_t nBytesContent = 0) const override;
82
83 const std::string &GetURL() const override
84 {
85 return m_osURL;
86 }
87
88 static void CleanMutex();
89 static void ClearCache();
90};
91
92#endif /* HAVE_CURL */
93
94#endif /* #ifndef DOXYGEN_SKIP */
95
96#endif /* CPL_SWIFT_INCLUDED_H */
CPLJSONObject
The CPLJSONArray class holds JSON object from CPLJSONDocument.
Definition cpl_json.h:56
cpl_http.h
Interface for downloading HTTP, FTP documents.
cpl_json.h
Interface for read and write JSON documents.
CPLHTTPResult
Definition cpl_http.h:51