3131
3232#include " iceberg/catalog/rest/auth/auth_properties.h"
3333#include " iceberg/catalog/rest/endpoint.h"
34+ #include " iceberg/util/checked_cast.h"
3435#include " iceberg/util/macros.h"
3536#include " iceberg/util/string_util.h"
3637
@@ -207,8 +208,7 @@ Result<std::shared_ptr<AuthSession>> SigV4AuthManager::CatalogSession(
207208Result<std::shared_ptr<AuthSession>> SigV4AuthManager::ContextualSession (
208209 const std::unordered_map<std::string, std::string>& context,
209210 std::shared_ptr<AuthSession> parent) {
210- auto * sigv4_parent = dynamic_cast <SigV4AuthSession*>(parent.get ());
211- ICEBERG_PRECHECK (sigv4_parent != nullptr , " Parent session is not SigV4" );
211+ auto sigv4_parent = internal::checked_pointer_cast<SigV4AuthSession>(std::move (parent));
212212
213213 ICEBERG_ASSIGN_OR_RAISE (auto delegate_session, delegate_->ContextualSession (
214214 context, sigv4_parent->delegate ()));
@@ -221,8 +221,7 @@ Result<std::shared_ptr<AuthSession>> SigV4AuthManager::TableSession(
221221 const TableIdentifier& table,
222222 const std::unordered_map<std::string, std::string>& properties,
223223 std::shared_ptr<AuthSession> parent) {
224- auto * sigv4_parent = dynamic_cast <SigV4AuthSession*>(parent.get ());
225- ICEBERG_PRECHECK (sigv4_parent != nullptr , " Parent session is not SigV4" );
224+ auto sigv4_parent = internal::checked_pointer_cast<SigV4AuthSession>(std::move (parent));
226225
227226 ICEBERG_ASSIGN_OR_RAISE (
228227 auto delegate_session,
@@ -248,15 +247,12 @@ SigV4AuthManager::MakeCredentialsProvider(
248247 AuthProperties::kSigV4AccessKeyId , AuthProperties::kSigV4SecretAccessKey );
249248
250249 if (has_ak) {
250+ Aws::Auth::AWSCredentials credentials (access_key_it->second .c_str (),
251+ secret_key_it->second .c_str ());
251252 auto session_token_it = properties.find (AuthProperties::kSigV4SessionToken );
252253 if (session_token_it != properties.end () && !session_token_it->second .empty ()) {
253- Aws::Auth::AWSCredentials credentials (access_key_it->second .c_str (),
254- secret_key_it->second .c_str (),
255- session_token_it->second .c_str ());
256- return std::make_shared<Aws::Auth::SimpleAWSCredentialsProvider>(credentials);
254+ credentials.SetSessionToken (session_token_it->second .c_str ());
257255 }
258- Aws::Auth::AWSCredentials credentials (access_key_it->second .c_str (),
259- secret_key_it->second .c_str ());
260256 return std::make_shared<Aws::Auth::SimpleAWSCredentialsProvider>(credentials);
261257 }
262258
0 commit comments