Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:12

0001 /*
0002  * This File is part of Davix, The IO library for HTTP based protocols
0003  * Copyright (C) CERN 2018
0004  * Author: Georgios Bitzes <georgios.bitzes@cern.ch>
0005  *
0006  * This library is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Lesser General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2.1 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Lesser General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Lesser General Public
0017  * License along with this library; if not, write to the Free Software
0018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0019  *
0020  */
0021 
0022 #ifndef DAVIX_GCLOUD_UTILS_HPP
0023 #define DAVIX_GCLOUD_UTILS_HPP
0024 
0025 #include <params/davixrequestparams.hpp>
0026 
0027 namespace Davix {
0028 namespace gcloud {
0029 
0030 class CredentialsInternal;
0031 class CredentialProvider;
0032 
0033 ///
0034 /// @class Credentials
0035 /// @brief Gcloud credentials
0036 ///
0037 /// Gcloud credentials
0038 class DAVIX_EXPORT Credentials {
0039 public:
0040   Credentials();
0041 
0042   void setPrivateKey(const std::string &key);
0043   std::string getPrivateKey() const;
0044 
0045   void setClientEmail(const std::string &key);
0046   std::string getClientEmail() const;
0047 
0048   bool isEmpty() const;
0049 
0050   // Rule of five:
0051   Credentials(const Credentials&);                   // Copy constructor
0052   Credentials(Credentials&&);                        // Move constructor
0053   Credentials& operator=(const Credentials&);        // Copy assignment operator
0054   Credentials& operator=(Credentials&&);             // Move assignment operator
0055   virtual ~Credentials();                            // Destructor
0056 
0057 private:
0058   CredentialsInternal *internal;
0059 };
0060 
0061 ///
0062 /// @class CredentialProvider
0063 /// @brief Gcloud credential provider
0064 ///
0065 /// Gcloud credential provider
0066 class DAVIX_EXPORT CredentialProvider {
0067 public:
0068   CredentialProvider();
0069   Credentials fromJSONString(const std::string &str);
0070   Credentials fromFile(const std::string &path);
0071 };
0072 
0073 std::string getStringToSign(const std::string &verb, const Uri &url, const HeaderVec &headers, const time_t signDuration);
0074 Uri signURI(const Credentials& creds, const std::string &verb, const Uri &url, const HeaderVec &headers, const time_t signDuration);
0075 Uri signURIFixedTimeout(const Credentials& creds, const std::string &verb, const Uri &url, const HeaderVec &headers, const time_t signDuration);
0076 
0077 Uri getListingURI(const Uri & original_url, const RequestParams & params);
0078 
0079 std::string extract_bucket(const Uri & uri);
0080 std::string extract_path(const Uri & uri);
0081 
0082 } // gcloud
0083 } // Davix
0084 
0085 
0086 
0087 #endif // DAVIX_GCLOUD_UTILS_HPP