GDAL
cpl_google_cloud.h
1 /**********************************************************************
2  * Project: CPL - Common Portability Library
3  * Purpose: Google Cloud Storage routines
4  * Author: Even Rouault <even.rouault at spatialys.com>
5  *
6  **********************************************************************
7  * Copyright (c) 2017, Even Rouault <even.rouault at spatialys.com>
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a
10  * copy of this software and associated documentation files (the "Software"),
11  * to deal in the Software without restriction, including without limitation
12  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  * and/or sell copies of the Software, and to permit persons to whom the
14  * Software is furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included
17  * in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25  * DEALINGS IN THE SOFTWARE.
26  ****************************************************************************/
27 
28 #ifndef CPL_GOOGLE_CLOUD_INCLUDED_H
29 #define CPL_GOOGLE_CLOUD_INCLUDED_H
30 
31 #ifndef DOXYGEN_SKIP
32 
33 #include <cstddef>
34 
35 #include "cpl_string.h"
36 
37 #ifdef HAVE_CURL
38 
39 #include <curl/curl.h>
40 #include "cpl_http.h"
41 #include "cpl_aws.h"
42 #include <map>
43 
44 class VSIGSHandleHelper: public IVSIS3LikeHandleHelper
45 {
46  CPLString m_osURL;
47  CPLString m_osEndpoint;
48  CPLString m_osBucketObjectKey;
49  CPLString m_osSecretAccessKey;
50  CPLString m_osAccessKeyId;
51  bool m_bUseHeaderFile;
52  GOA2Manager m_oManager;
53 
54  static bool GetConfiguration(CPLString& osSecretAccessKey,
55  CPLString& osAccessKeyId,
56  CPLString& osHeaderFile,
57  GOA2Manager& oManager);
58 
59  static bool GetConfigurationFromConfigFile(
60  CPLString& osSecretAccessKey,
61  CPLString& osAccessKeyId,
62  CPLString& osOAuth2RefreshToken,
63  CPLString& osOAuth2ClientId,
64  CPLString& osOAuth2ClientSecret,
65  CPLString& osCredentials);
66 
67  virtual void RebuildURL() CPL_OVERRIDE;
68 
69  public:
70  VSIGSHandleHelper(const CPLString& osEndpoint,
71  const CPLString& osBucketObjectKey,
72  const CPLString& osSecretAccessKey,
73  const CPLString& osAccessKeyId,
74  bool bUseHeaderFile,
75  const GOA2Manager& oManager);
76  ~VSIGSHandleHelper();
77 
78  static VSIGSHandleHelper* BuildFromURI(const char* pszURI,
79  const char* pszFSPrefix);
80 
81  struct curl_slist* GetCurlHeaders(const CPLString& osVerbosVerb,
82  const struct curl_slist* psExistingHeaders,
83  const void *pabyDataContent = nullptr,
84  size_t nBytesContent = 0) const CPL_OVERRIDE;
85 
86  const CPLString& GetURL() const CPL_OVERRIDE { return m_osURL; }
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_GOOGLE_CLOUD_INCLUDED_H */
#define CPL_OVERRIDE
To be used in public headers only.
Definition: cpl_port.h:989
Convenient string class based on std::string.
Definition: cpl_string.h:338
Various convenience functions for working with strings and string lists.
Interface for downloading HTTP, FTP documents.
Manager of Google OAuth2 authentication.
Definition: cpl_http.h:140

Generated for GDAL by doxygen 1.8.8.