21#ifndef XRDCLS3_S3FACTORY_HH
22#define XRDCLS3_S3FACTORY_HH
27#include <shared_mutex>
52 static bool GenerateHttpUrl(
const std::string &s3_url, std::string &https_url, std::string *obj_result, std::string &err_msg);
58 static std::string_view
TrimView(
const std::string_view str);
64 static bool GenerateV4Signature(
const std::string &url,
const std::string &verb, std::vector<std::pair<std::string, std::string>> &headers, std::string &auth_token, std::string &err_msg);
73 static std::tuple<std::string, std::string, bool>
GetCredentialsForBucket(
const std::string &bucket, std::string &err_msg);
76 static std::string
PathEncode(
const std::string_view url);
85 static void SetEndpoint(
const std::string &endpoint) { m_endpoint = endpoint; }
86 static void SetService(
const std::string &service) { m_service = service; }
87 static void SetRegion(
const std::string ®ion) { m_region = region; }
88 static void SetUrlStyle(
const std::string &url_style) { m_url_style = url_style; }
90 m_default_creds.m_accesskey = access_key;
91 m_default_creds.m_secretkey = secret_key;
93 static void SetBucketCredentials(
const std::string &bucket,
const std::string &access_key,
const std::string &secret_key) {
94 m_bucket_location_map[bucket] = {access_key, secret_key};
97 std::unique_lock lock(m_bucket_auth_map_mutex);
98 m_bucket_auth_map.clear();
105 static void InitS3Config();
108 static std::string CanonicalizeQueryString(
const std::string &url);
110 static bool m_initialized;
112 static std::once_flag m_init_once;
115 static std::string m_endpoint;
116 static std::string m_service;
117 static std::string m_region;
118 static std::string m_url_style;
125 static std::string m_mkdir_sentinel;
129 std::string m_accesskey;
130 std::string m_secretkey;
134 static Credentials m_default_creds;
137 static std::unordered_map<std::string, Credentials> m_bucket_location_map;
140 static std::shared_mutex m_bucket_auth_map_mutex;
143 static std::unordered_map<std::string, std::pair<Credentials, std::chrono::steady_clock::time_point>> m_bucket_auth_map;
static void ResetCredCache()
virtual XrdCl::FilePlugIn * CreateFile(const std::string &url) override
Create a file plug-in for the given URL.
static void SetBucketCredentials(const std::string &bucket, const std::string &access_key, const std::string &secret_key)
static std::string_view ExtractHostname(const std::string_view url)
static void SetEndpoint(const std::string &endpoint)
static std::string PathEncode(const std::string_view url)
static void SetRegion(const std::string ®ion)
static void SetDefaultCredentials(const std::string &access_key, const std::string &secret_key)
static std::string CleanObjectName(const std::string &object)
static bool GenerateHttpUrl(const std::string &s3_url, std::string &https_url, std::string *obj_result, std::string &err_msg)
virtual XrdCl::FileSystemPlugIn * CreateFileSystem(const std::string &url) override
Create a file system plug-in for the given URL.
static std::tuple< std::string, std::string, bool > GetCredentialsForBucket(const std::string &bucket, std::string &err_msg)
static void SetService(const std::string &service)
static bool GenerateV4Signature(const std::string &url, const std::string &verb, std::vector< std::pair< std::string, std::string > > &headers, std::string &auth_token, std::string &err_msg)
static std::string_view TrimView(const std::string_view str)
static const std::string & GetMkdirSentinel()
Factory(const Factory &)=delete
static void SetUrlStyle(const std::string &url_style)
static std::string GetBucketFromHttpsUrl(const std::string &url)
An interface for file plug-ins.
An interface for file plug-ins.
const uint64_t kLogXrdClS3