|
8 | 8 | #include <smithy/identity/signer/AwsSignerBase.h> |
9 | 9 |
|
10 | 10 | #include <aws/crt/Variant.h> |
11 | | -#include <aws/core/utils/memory/stl/AWSMap.h> |
12 | 11 | #include <aws/core/utils/memory/stl/AWSVector.h> |
13 | 12 |
|
14 | 13 | namespace smithy { |
15 | 14 |
|
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"; |
20 | 19 |
|
21 | 20 | // 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") |
27 | 26 | }; |
28 | 27 |
|
29 | 28 | /** |
@@ -73,10 +72,10 @@ class AuthSchemeResolverBase |
73 | 72 |
|
74 | 73 | Aws::Vector<AuthSchemeOption> filtered; |
75 | 74 | 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; }); |
77 | 76 | if (prefSchemeIt == AUTH_SCHEME_NAME_TO_ID.end()) continue; |
78 | 77 | for (const auto& option : options) { |
79 | | - if (option.schemeId == prefSchemeIt->second) { |
| 78 | + if (strcmp(option.schemeId, prefSchemeIt->second) == 0) { |
80 | 79 | filtered.push_back(option); |
81 | 80 | break; |
82 | 81 | } |
|
0 commit comments