XRootD
Loading...
Searching...
No Matches
XrdClS3::Factory Class Referencefinal

#include <XrdClS3Factory.hh>

Inheritance diagram for XrdClS3::Factory:
Collaboration diagram for XrdClS3::Factory:

Public Member Functions

 Factory ()
 Factory (const Factory &)=delete
virtual ~Factory ()
virtual XrdCl::FilePlugInCreateFile (const std::string &url) override
 Create a file plug-in for the given URL.
virtual XrdCl::FileSystemPlugInCreateFileSystem (const std::string &url) override
 Create a file system plug-in for the given URL.
Public Member Functions inherited from XrdCl::PlugInFactory
virtual ~PlugInFactory ()
 Destructor.

Static Public Member Functions

static std::string CleanObjectName (const std::string &object)
static std::string_view ExtractHostname (const std::string_view url)
static bool GenerateHttpUrl (const std::string &s3_url, std::string &https_url, std::string *obj_result, std::string &err_msg)
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 GetBucketFromHttpsUrl (const std::string &url)
static std::tuple< std::string, std::string, bool > GetCredentialsForBucket (const std::string &bucket, std::string &err_msg)
static const std::string & GetMkdirSentinel ()
static std::string PathEncode (const std::string_view url)
static void ResetCredCache ()
static void SetBucketCredentials (const std::string &bucket, const std::string &access_key, const std::string &secret_key)
static void SetDefaultCredentials (const std::string &access_key, const std::string &secret_key)
static void SetEndpoint (const std::string &endpoint)
static void SetRegion (const std::string &region)
static void SetService (const std::string &service)
static void SetUrlStyle (const std::string &url_style)
static std::string_view TrimView (const std::string_view str)

Detailed Description

Definition at line 39 of file XrdClS3Factory.hh.

Constructor & Destructor Documentation

◆ Factory() [1/2]

Factory::Factory ( )

Definition at line 83 of file XrdClS3Factory.cc.

83 {
84 std::call_once(m_init_once, [&] {
86 if (!m_log) {
87 return;
88 }
89 m_log->SetTopicName(kLogXrdClS3, "XrdClS3");
90
91 auto env = XrdCl::DefaultEnv::GetEnv();
92 if (!env) {
93 return;
94 }
95 InitS3Config();
96 m_initialized = true;
97 });
98}
static Log * GetLog()
Get default log.
static Env * GetEnv()
Get default client environment.
const uint64_t kLogXrdClS3

References Factory(), XrdCl::DefaultEnv::GetEnv(), XrdCl::DefaultEnv::GetLog(), and XrdClS3::kLogXrdClS3.

Referenced by Factory(), and Factory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~Factory()

virtual XrdClS3::Factory::~Factory ( )
inlinevirtual

Definition at line 42 of file XrdClS3Factory.hh.

42{}

◆ Factory() [2/2]

XrdClS3::Factory::Factory ( const Factory & )
delete

References Factory().

Here is the call graph for this function:

Member Function Documentation

◆ CleanObjectName()

std::string Factory::CleanObjectName ( const std::string & object)
static

Definition at line 291 of file XrdClS3Factory.cc.

291 {
292 std::string obj = input_obj;
293 auto loc = input_obj.find('?');
294 if (loc != std::string::npos) {
295 auto query = std::string_view(input_obj).substr(loc + 1);
296 obj = obj.substr(0, loc);
297 bool added_query = false;
298 while (!query.empty()) {
299 auto next_query_loc = query.find('&');
300 auto current_query = (next_query_loc == std::string::npos) ? query : query.substr(0, next_query_loc);
301 query = (next_query_loc == std::string::npos) ? "" : query.substr(next_query_loc + 1);
302 if (current_query.empty()) {
303 continue;
304 }
305 auto equal_loc = current_query.find('=');
306 if (equal_loc != std::string::npos) {
307 auto key = current_query.substr(0, equal_loc);
308 if (key != "authz") {
309 obj += (added_query ? "&" : "?") + std::string(current_query);
310 added_query = true;
311 }
312 } else if (current_query != "authz") {
313 obj += (added_query ? "&" : "?") + std::string(current_query);
314 added_query = true;
315 }
316 }
317 } else {
318 obj = input_obj;
319 }
320 return obj;
321}
if(ec< 0) ec

References CleanObjectName().

Referenced by CleanObjectName(), GenerateHttpUrl(), XrdClS3::Filesystem::Locate(), XrdClS3::Filesystem::Query(), XrdClS3::Filesystem::Rm(), and XrdClS3::Filesystem::Stat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateFile()

virtual XrdCl::FilePlugIn * XrdClS3::Factory::CreateFile ( const std::string & url)
overridevirtual

Create a file plug-in for the given URL.

Implements XrdCl::PlugInFactory.

◆ CreateFileSystem()

XrdCl::FileSystemPlugIn * Factory::CreateFileSystem ( const std::string & url)
overridevirtual

Create a file system plug-in for the given URL.

Implements XrdCl::PlugInFactory.

Definition at line 347 of file XrdClHttpFactory.cc.

347 {
348 Initialize();
349 if (!m_initialized) {return nullptr;}
350 return new Filesystem(url, m_queue, m_log);
351}

References CreateFileSystem().

Referenced by CreateFileSystem().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExtractHostname()

std::string_view Factory::ExtractHostname ( const std::string_view url)
static

Definition at line 324 of file XrdClS3Factory.cc.

324 {
325 auto loc = url.find("://");
326 if (loc == std::string_view::npos) {
327 return {};
328 }
329 loc += 3; // Move past "://"
330 auto slash_loc = url.find('/', loc);
331 auto query_loc = url.find('?', loc);
332 if (query_loc != std::string_view::npos && (slash_loc == std::string_view::npos || query_loc < slash_loc)) {
333 slash_loc = query_loc; // If there's a query, we stop at it
334 }
335 auto authority = url.substr(loc, slash_loc - loc);
336 if (authority.empty()) {
337 return {};
338 }
339 auto at_loc = authority.find('@');
340 if (at_loc != std::string_view::npos) {
341 // If there's an '@', we have user info, so we skip it
342 authority = authority.substr(at_loc + 1);
343 }
344 // If the authority contains a port, we need to strip it
345 auto colon_loc = authority.find(':');
346 if (colon_loc != std::string_view::npos) {
347 authority = authority.substr(0, colon_loc);
348 }
349 return authority;
350}

References ExtractHostname().

Referenced by ExtractHostname(), GenerateHttpUrl(), GenerateV4Signature(), and GetBucketFromHttpsUrl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GenerateHttpUrl()

bool Factory::GenerateHttpUrl ( const std::string & s3_url,
std::string & https_url,
std::string * obj_result,
std::string & err_msg )
static

Definition at line 411 of file XrdClS3Factory.cc.

411 {
412 if (s3_url.substr(0, 5) != "s3://") {
413 err_msg = "Provided URL does not start with s3://";
414 return false;
415 }
416 auto loc = s3_url.find('/', 5);
417 auto bucket = s3_url.substr(5, loc - 5);
418 auto at_loc = bucket.find('@');
419 if (at_loc != std::string::npos) {
420 std::string login = "";
421 login = bucket.substr(0, at_loc);
422 bucket = bucket.substr(at_loc + 1);
423 }
424 std::string endpoint = m_endpoint;
425 std::string region = m_region;
426 if ((bucket == m_endpoint) || m_endpoint.empty()) {
427 endpoint = bucket;
428 auto old_loc = loc + 1;
429 loc = s3_url.find('/', loc + 1);
430 if (loc == std::string::npos) {
431 err_msg = "Provided S3 URL does not contain a bucket in path";
432 return false;
433 }
434 bucket = s3_url.substr(old_loc, loc - old_loc);
435 } else {
436 auto authority = ExtractHostname(s3_url);
437 std::string test_endpoint = "." + endpoint;
438 if (!m_region.empty()) {
439 auto bucket_loc = authority.rfind("." + m_region + test_endpoint);
440 if (bucket_loc != std::string::npos) {
441 bucket = authority.substr(0, bucket_loc);
442 } else {
443 auto bucket_loc = authority.rfind(test_endpoint);
444 if (bucket_loc != std::string::npos) {
445 bucket = authority.substr(0, bucket_loc);
446 }
447 }
448 } else {
449 auto bucket_loc = authority.rfind(test_endpoint);
450 if (bucket_loc != std::string::npos) {
451 bucket = authority.substr(0, bucket_loc);
452 }
453 }
454 }
455 std::string obj;
456 if (loc != std::string::npos) {
457 obj = s3_url.substr(loc + 1);
458 }
459 // Strip out "authz" query parameters; those are internal to XRootD.
460 obj = CleanObjectName(obj);
461 if (obj_result) {
462 *obj_result = obj;
463 }
464 if (m_url_style == "virtual" || m_url_style.empty()) {
465 https_url = "https://" + bucket + "." + m_region + "." + endpoint + (obj_result ? "" : ("/" + obj));
466 return true;
467 } else if (m_url_style == "path") {
468 if (m_region.empty()) {
469 https_url = "https://" + m_region + "." + endpoint + "/" + bucket + (obj_result ? "" : ("/" + obj));
470 } else {
471 https_url = "https://" + endpoint + "/" + bucket + (obj_result ? "" : ("/" + obj));
472 }
473 return true;
474 } else {
475 err_msg = "Server configuration has invalid setting for URL style";
476 return false;
477 }
478}
static std::string_view ExtractHostname(const std::string_view url)
static std::string CleanObjectName(const std::string &object)

References CleanObjectName(), ExtractHostname(), and GenerateHttpUrl().

Referenced by XrdClS3::Filesystem::DirList(), GenerateHttpUrl(), and XrdClS3::Filesystem::MkDir().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GenerateV4Signature()

bool Factory::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

Definition at line 481 of file XrdClS3Factory.cc.

481 {
482 auto bucket = GetBucketFromHttpsUrl(url);
483
484 // If we're using temporary credentials, we need to add the token
485 // header here as well. We set saKey and keyID here (well before
486 // necessary) since we'll get them for free when we get the token.
487 auto [keyId, secretKey, ok] = GetCredentialsForBucket(bucket, err_msg);
488 if (!ok) {
489 return false;
490 }
491
492 if (secretKey.empty()) {
493 auth_token = "";
494 return true;
495 }
496
497 //
498 // Create task 1's inputs.
499 //
500
501 auto canonicalURI = PathEncode(url);
502
503 // The canonical query string is the alphabetically sorted list of
504 // URI-encoded parameter names '=' values, separated by '&'s.
505 auto canonicalQueryString = CanonicalizeQueryString(url);
506
507 // The canonical headers must include the Host header, so add that
508 // now if we don't have it.
509 if (std::find_if(headers.begin(), headers.end(),
510 [](const auto &pair) { return pair.first == "Host"; }) == headers.end()) {
511 auto host = ExtractHostname(url);
512 if (host.empty()) {
513 err_msg = "Unable to extract hostname from URL: " + url;
514 return false;
515 }
516 headers.emplace_back("Host", host);
517 }
518
519 // S3 complains if x-amz-date isn't signed, so do this early.
520 auto iter = std::find_if(headers.begin(), headers.end(),
521 [](const auto &pair) { return !strcasecmp(pair.first.c_str(), "X-Amz-Date"); });
522 std::string date_time;
523 char date_char[] = "YYYYMMDD";
524 if (iter == headers.end()) {
525 time_t now;
526 time(&now);
527 struct tm brokenDownTime;
528 gmtime_r(&now, &brokenDownTime);
529
530 date_time = "YYYYMMDDThhmmssZ";
531 strftime(date_time.data(), date_time.size(), "%Y%m%dT%H%M%SZ", &brokenDownTime);
532 headers.emplace_back("X-Amz-Date", date_time);
533 strftime(date_char, sizeof(date_char), "%Y%m%d", &brokenDownTime);
534 } else {
535 date_time = iter->second;
536 auto loc = date_time.find('T', 0);
537 if (loc != 8) {
538 err_msg = "Invalid value for X-Amz-Date";
539 return false;
540 }
541 memcpy(date_char, date_time.c_str(), 8);
542 }
543
544 // The canonical payload hash is the lowercase hexadecimal string of the
545 // (SHA256) hash value of the payload or "UNSIGNED-PAYLOAD" if
546 // we are not signing the payload.
547 std::string payload_hash = "UNSIGNED-PAYLOAD";
548 iter = std::find_if(headers.begin(), headers.end(),
549 [](const auto &pair) { return !strcasecmp(pair.first.c_str(), "X-Amz-Content-Sha256"); });
550 if (iter == headers.end()) {
551 headers.emplace_back("X-Amz-Content-Sha256", payload_hash);
552 } else {
553 payload_hash = iter->second;
554 }
555
556 // The canonical list of headers is a sorted list of lowercase header
557 // names paired via ':' with the trimmed header value, each pair
558 // terminated with a newline.
559 std::vector<std::pair<std::string, std::string>> transformed_headers;
560 transformed_headers.reserve(headers.size());
561 for (const auto &info : headers) {
562 std::string header = info.first;
563 std::transform(header.begin(), header.end(), header.begin(), &tolower);
564
565 std::string value = info.second;
566 if (value.empty()) {
567 continue;
568 }
569 auto value_trimmed = std::string(TrimView(value));
570
571 // Convert internal runs of spaces into single spaces.
572 unsigned left = 1;
573 unsigned right = 1;
574 bool inSpaces = false;
575 while (right < value_trimmed.length()) {
576 if (!inSpaces) {
577 if (value_trimmed[right] == ' ') {
578 inSpaces = true;
579 left = right;
580 ++right;
581 } else {
582 ++right;
583 }
584 } else {
585 if (value_trimmed[right] == ' ') {
586 ++right;
587 } else {
588 inSpaces = false;
589 value_trimmed.erase(left, right - left - 1);
590 right = left + 1;
591 }
592 }
593 }
594
595 transformed_headers.emplace_back(header, value);
596 }
597 std::sort(transformed_headers.begin(), transformed_headers.end(),
598 [](const auto &a, const auto &b) { return a.first < b.first; });
599
600 // The canonical list of signed headers is trivial to generate while
601 // generating the list of headers.
602 std::string signedHeaders, canonicalHeaders;
603 for (const auto &info : transformed_headers) {
604 canonicalHeaders += info.first + ":" + info.second + "\n";
605 signedHeaders += info.first + ";";
606 }
607 signedHeaders.erase(signedHeaders.end() - 1);
608
609 // Task 1: create the canonical request.
610 auto canonicalRequest =
611 verb + "\n" + canonicalURI + "\n" + canonicalQueryString + "\n" +
612 canonicalHeaders + "\n" + signedHeaders + "\n" + payload_hash;
613
614 //
615 // Create task 2's inputs.
616 //
617
618 // Hash the canonical request the way we did the payload.
619 std::string canonicalRequestHash;
620 std::vector<unsigned char> messageDigest;
621 messageDigest.resize(EVP_MAX_MD_SIZE);
622 if (!ComputeSHA256(canonicalRequest, messageDigest)) {
623 err_msg = "Unable to hash canonical request.";
624 return false;
625 }
626 MessageDigestAsHex(messageDigest, canonicalRequestHash);
627
628 // Task 2: create the string to sign.
629 auto credentialScope = std::string(date_char) + "/" + m_region + "/" + m_service + "/aws4_request";
630 auto stringToSign = std::string("AWS4-HMAC-SHA256\n") + date_time + "\n" + credentialScope + "\n" + canonicalRequestHash;
631
632 //
633 // Creating task 3's inputs was done when we checked to see if we needed
634 // to get the security token, since they come along for free when we do.
635 //
636
637 // Task 3: calculate the signature.
638 auto saKey = std::string("AWS4") + secretKey;
639 unsigned int mdLength = 0;
640 const unsigned char *hmac =
641 HMAC(EVP_sha256(), saKey.c_str(), saKey.length(), (unsigned char *)date_char,
642 sizeof(date_char) - 1, messageDigest.data(), &mdLength);
643 if (hmac == NULL) {
644 err_msg = "Unable to calculate HMAC for date.";
645 return false;
646 }
647
648 unsigned int md2Length = 0;
649 unsigned char messageDigest2[EVP_MAX_MD_SIZE];
650 hmac = HMAC(EVP_sha256(), messageDigest.data(), mdLength,
651 reinterpret_cast<unsigned char *>(m_region.data()), m_region.size(), messageDigest2,
652 &md2Length);
653 if (hmac == NULL) {
654 err_msg = "Unable to calculate HMAC for region.";
655 return false;
656 }
657
658 hmac = HMAC(EVP_sha256(), messageDigest2, md2Length,
659 reinterpret_cast<unsigned char *>(m_service.data()), m_service.size(), messageDigest.data(),
660 &mdLength);
661 if (hmac == NULL) {
662 err_msg = "Unable to calculate HMAC for service.";
663 return false;
664 }
665
666 const char request_char[] = "aws4_request";
667 hmac = HMAC(EVP_sha256(), messageDigest.data(), messageDigest.size(), reinterpret_cast<const unsigned char *>(request_char),
668 sizeof(request_char) - 1, messageDigest2, &md2Length);
669 if (hmac == NULL) {
670 err_msg = "Unable to calculate HMAC for request.";
671 return false;
672 }
673
674 hmac = HMAC(EVP_sha256(), messageDigest2, md2Length,
675 reinterpret_cast<unsigned char *>(stringToSign.data()),
676 stringToSign.size(), messageDigest.data(), &mdLength);
677 if (hmac == NULL) {
678 err_msg = "Unable to calculate HMAC for request string.";
679 return false;
680 }
681
682 std::string signature;
683 MessageDigestAsHex(messageDigest, signature);
684
685 auth_token =
686 std::string("AWS4-HMAC-SHA256 Credential=") + keyId + "/" + credentialScope +
687 ",SignedHeaders=" + signedHeaders + ",Signature=" + signature;
688 return true;
689}
static std::string PathEncode(const std::string_view url)
static std::tuple< std::string, std::string, bool > GetCredentialsForBucket(const std::string &bucket, std::string &err_msg)
static std::string_view TrimView(const std::string_view str)
static std::string GetBucketFromHttpsUrl(const std::string &url)

References ExtractHostname(), GenerateV4Signature(), GetBucketFromHttpsUrl(), GetCredentialsForBucket(), PathEncode(), and TrimView().

Referenced by GenerateV4Signature().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetBucketFromHttpsUrl()

std::string Factory::GetBucketFromHttpsUrl ( const std::string & url)
static

Definition at line 692 of file XrdClS3Factory.cc.

692 {
693 if (m_url_style == "virtual" || m_url_style.empty()) {
694 // Virtual-hosted-style URLs are of the form https://bucket.region.endpoint/object
695 auto hostname = ExtractHostname(url);
696 if (hostname.empty()) {
697 return {};
698 }
699 auto test_endpoint = "." + m_endpoint;
700 if (!m_region.empty()) test_endpoint = "." + m_region + test_endpoint;
701 auto loc = hostname.rfind(test_endpoint);
702 if (loc == std::string::npos) {
703 if (!m_region.empty()) {
704 loc = hostname.rfind("." + m_endpoint);
705 if (loc != std::string::npos) {
706 return std::string(hostname.substr(0, loc));
707 }
708 }
709 return {};
710 }
711 return std::string(hostname.substr(0, loc));
712 } else if (m_url_style == "path") {
713 // Path style URLs are of the form https://region.endpoint/bucket/object
714 auto loc = url.find("://");
715 if (loc == std::string::npos) {
716 return {};
717 }
718 loc += 3; // Move past "://"
719 auto slash_loc = url.find('/', loc);
720 if (slash_loc == std::string::npos) {
721 return {};
722 }
723 auto bucket_start = slash_loc + 1;
724 auto bucket_end = url.find('/', bucket_start);
725 if (bucket_end == std::string::npos) {
726 return url.substr(bucket_start);
727 }
728 return url.substr(bucket_start, bucket_end - bucket_start);
729 } else {
730 // Invalid URL style
731 return {};
732 }
733}

References ExtractHostname(), and GetBucketFromHttpsUrl().

Referenced by GenerateV4Signature(), and GetBucketFromHttpsUrl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetCredentialsForBucket()

std::tuple< std::string, std::string, bool > Factory::GetCredentialsForBucket ( const std::string & bucket,
std::string & err_msg )
static

Definition at line 736 of file XrdClS3Factory.cc.

737{
738 auto now = std::chrono::steady_clock::now();
739 {
740 std::shared_lock lock(m_bucket_auth_map_mutex);
741 auto iter = m_bucket_auth_map.find(bucket);
742 if (iter != m_bucket_auth_map.end()) {
743 // If we have credentials for this bucket, check if they are still valid.
744 auto &creds = iter->second.first;
745 auto &expiration = iter->second.second;
746 if (now < expiration) {
747 // Credentials are still valid, return them.
748 return {creds.m_accesskey, creds.m_secretkey, true};
749 }
750 }
751 }
752
753 std::unique_lock lock(m_bucket_auth_map_mutex);
754 auto iter = m_bucket_location_map.find(bucket);
755 std::string access_key_location, secret_key_location;
756 if (iter == m_bucket_location_map.end()) {
757 // If we don't have credentials for this bucket, use the default.
758 if (m_default_creds.m_accesskey.empty() || m_default_creds.m_secretkey.empty()) {
759 // No credentials at all, so we assume public access.
760 m_bucket_auth_map[bucket] = {{"", ""}, now + std::chrono::minutes(1)};
761 return {"", "", true};
762 }
763 access_key_location = m_default_creds.m_accesskey;
764 secret_key_location = m_default_creds.m_secretkey;
765 } else {
766 access_key_location = iter->second.m_accesskey;
767 secret_key_location = iter->second.m_secretkey;
768 }
769 if (access_key_location.empty() && secret_key_location.empty()) {
770 // If both are empty, we assume public access.
771 m_bucket_auth_map[bucket] = {{"", ""}, now + std::chrono::minutes(1)};
772 return {"", "", true};
773 }
774 if (access_key_location.empty() || secret_key_location.empty()) {
775 err_msg = "No credentials available for bucket: " + bucket;
776 m_bucket_auth_map[bucket] = {{"", ""}, now + std::chrono::seconds(10)};
777 return {"", "", false};
778 }
779
780 std::string access_key, secret_key;
781 if (!ReadShortFile(access_key_location, access_key, err_msg)) {
782 m_bucket_auth_map[bucket] = {{"", ""}, now + std::chrono::seconds(10)};
783 return {"", "", false};
784 }
785 access_key = TrimView(access_key);
786
787 if (!ReadShortFile(secret_key_location, secret_key, err_msg)) {
788 m_bucket_auth_map[bucket] = {{"", ""}, now + std::chrono::seconds(10)};
789 return {"", "", false};
790 }
791 secret_key = TrimView(secret_key);
792
793 if (access_key.empty() || secret_key.empty()) {
794 err_msg = "Credentials for bucket '" + bucket + "' are empty.";
795 m_bucket_auth_map[bucket] = {{"", ""}, now + std::chrono::seconds(10)};
796 return {"", "", false};
797 }
798 m_bucket_auth_map[bucket] = {{access_key, secret_key}, now + std::chrono::minutes(1)};
799 return {access_key, secret_key, true};
800}

References GetCredentialsForBucket(), and TrimView().

Referenced by GenerateV4Signature(), and GetCredentialsForBucket().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMkdirSentinel()

const std::string & XrdClS3::Factory::GetMkdirSentinel ( )
inlinestatic

Definition at line 81 of file XrdClS3Factory.hh.

81{return m_mkdir_sentinel;}

Referenced by XrdClS3::Filesystem::MkDir(), and XrdClS3::Filesystem::RmDir().

Here is the caller graph for this function:

◆ PathEncode()

std::string Factory::PathEncode ( const std::string_view url)
static

Definition at line 803 of file XrdClS3Factory.cc.

803 {
804 auto loc = url.find("://");
805 if (loc == std::string_view::npos) {
806 return "";
807 }
808 auto path_loc = url.find("/", loc + 3);
809 auto query_loc = url.find("?", loc + 3);
810 if (query_loc != std::string_view::npos && (path_loc == std::string_view::npos || query_loc < path_loc)) {
811 // No path, just a query string
812 return "/";
813 }
814 auto path = url.substr(path_loc, query_loc - path_loc);
815 std::string segment;
816 std::string encoded;
817
818 size_t next = 0;
819 size_t offset = 0;
820 const auto length = path.size();
821 while (offset < length) {
822 next = strcspn(path.data() + offset, "/");
823 if (next == 0) {
824 encoded += "/";
825 offset += 1;
826 continue;
827 }
828 if (offset + next >= length) {
829 next = length - offset;
830 }
831
832 segment = std::string(path.data() + offset, next);
833 encoded += AmazonURLEncode(segment);
834
835 offset += next;
836 }
837 return encoded;
838}

References PathEncode().

Referenced by GenerateV4Signature(), and PathEncode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ResetCredCache()

void XrdClS3::Factory::ResetCredCache ( )
inlinestatic

Definition at line 96 of file XrdClS3Factory.hh.

96 {
97 std::unique_lock lock(m_bucket_auth_map_mutex);
98 m_bucket_auth_map.clear();
99 }

◆ SetBucketCredentials()

void XrdClS3::Factory::SetBucketCredentials ( const std::string & bucket,
const std::string & access_key,
const std::string & secret_key )
inlinestatic

Definition at line 93 of file XrdClS3Factory.hh.

93 {
94 m_bucket_location_map[bucket] = {access_key, secret_key};
95 }

◆ SetDefaultCredentials()

void XrdClS3::Factory::SetDefaultCredentials ( const std::string & access_key,
const std::string & secret_key )
inlinestatic

Definition at line 89 of file XrdClS3Factory.hh.

89 {
90 m_default_creds.m_accesskey = access_key;
91 m_default_creds.m_secretkey = secret_key;
92 }

◆ SetEndpoint()

void XrdClS3::Factory::SetEndpoint ( const std::string & endpoint)
inlinestatic

Definition at line 85 of file XrdClS3Factory.hh.

85{ m_endpoint = endpoint; }

◆ SetRegion()

void XrdClS3::Factory::SetRegion ( const std::string & region)
inlinestatic

Definition at line 87 of file XrdClS3Factory.hh.

87{ m_region = region; }

◆ SetService()

void XrdClS3::Factory::SetService ( const std::string & service)
inlinestatic

Definition at line 86 of file XrdClS3Factory.hh.

86{ m_service = service; }

◆ SetUrlStyle()

void XrdClS3::Factory::SetUrlStyle ( const std::string & url_style)
inlinestatic

Definition at line 88 of file XrdClS3Factory.hh.

88{ m_url_style = url_style; }

◆ TrimView()

std::string_view Factory::TrimView ( const std::string_view str)
static

Definition at line 842 of file XrdClS3Factory.cc.

842 {
843 auto view = ltrim_view(input_view);
844 for (size_t idx = 0; idx < input_view.size(); idx++) {
845 if (!isspace(view[view.size() - 1 - idx])) {
846 return view.substr(0, view.size() - idx);
847 }
848 }
849 return "";
850}
std::string_view ltrim_view(const std::string_view &input_view)

References TrimView().

Referenced by GenerateV4Signature(), GetCredentialsForBucket(), and TrimView().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: