Skip to content

Commit cc16e9d

Browse files
committed
Update AuthSchemeResolverBase.h from UnorderedMap to Array
1 parent a93b84a commit cc16e9d

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/aws-cpp-sdk-core/include/smithy/identity/auth/AuthSchemeResolverBase.h

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,21 @@
88
#include <smithy/identity/signer/AwsSignerBase.h>
99

1010
#include <aws/crt/Variant.h>
11-
#include <aws/core/utils/memory/stl/AWSMap.h>
1211
#include <aws/core/utils/memory/stl/AWSVector.h>
1312

1413
namespace smithy {
1514

16-
static char SIGV4_PREFERENCE[] = "sigv4";
17-
static char SIGV4A_PREFERENCE[] = "sigv4a";
18-
static char BEARER_PREFERENCE[] = "bearer";
19-
static char NO_AUTH_PREFERENCE[] = "noauth";
15+
static const char SIGV4_PREFERENCE[] = "sigv4";
16+
static const char SIGV4A_PREFERENCE[] = "sigv4a";
17+
static const char BEARER_PREFERENCE[] = "bearer";
18+
static const char NO_AUTH_PREFERENCE[] = "noauth";
2019

2120
// Global map from auth scheme name (trimmed ID) to full ID for case insensitive lookup
22-
static const Aws::UnorderedMap<Aws::String, Aws::String> AUTH_SCHEME_NAME_TO_ID = {
23-
{SIGV4_PREFERENCE, "aws.auth#sigv4"},
24-
{SIGV4A_PREFERENCE, "aws.auth#sigv4a"},
25-
{BEARER_PREFERENCE, "smithy.api#HTTPBearerAuth"},
26-
{NO_AUTH_PREFERENCE, "smithy.api#noAuth"}
21+
static const Aws::Array<std::pair<const char*, const char*>, 4> AUTH_SCHEME_NAME_TO_ID = {
22+
std::make_pair(SIGV4_PREFERENCE, "aws.auth#sigv4"),
23+
std::make_pair(SIGV4A_PREFERENCE, "aws.auth#sigv4a"),
24+
std::make_pair(BEARER_PREFERENCE, "smithy.api#HTTPBearerAuth"),
25+
std::make_pair(NO_AUTH_PREFERENCE, "smithy.api#noAuth")
2726
};
2827

2928
/**
@@ -73,10 +72,10 @@ class AuthSchemeResolverBase
7372

7473
Aws::Vector<AuthSchemeOption> filtered;
7574
for (const auto& pref : preferences) {
76-
auto prefSchemeIt = AUTH_SCHEME_NAME_TO_ID.find(Aws::Utils::StringUtils::ToLower(pref.c_str()));
75+
auto prefSchemeIt = find_if(AUTH_SCHEME_NAME_TO_ID.begin(), AUTH_SCHEME_NAME_TO_ID.end(), [&](const std::pair<const char*, const char*> &pair) { return Aws::Utils::StringUtils::ToLower(pref.c_str()) == pair.first; });
7776
if (prefSchemeIt == AUTH_SCHEME_NAME_TO_ID.end()) continue;
7877
for (const auto& option : options) {
79-
if (option.schemeId == prefSchemeIt->second) {
78+
if (strcmp(option.schemeId, prefSchemeIt->second) == 0) {
8079
filtered.push_back(option);
8180
break;
8281
}

0 commit comments

Comments
 (0)