File indexing completed on 2026-04-17 08:28:53
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #pragma once
0019
0020 #include <memory>
0021 #include <string>
0022 #include <unordered_map>
0023
0024 #include "arrow/util/mutex.h"
0025 #include "arrow/util/secure_string.h"
0026
0027 #include "parquet/exception.h"
0028 #include "parquet/platform.h"
0029
0030 namespace parquet::encryption {
0031
0032
0033
0034
0035 class PARQUET_EXPORT KeyAccessToken {
0036 public:
0037 KeyAccessToken() = default;
0038
0039 explicit KeyAccessToken(const std::string value) : value_(value) {}
0040
0041 void Refresh(const std::string& new_value) {
0042 auto lock = mutex_.Lock();
0043 value_ = new_value;
0044 }
0045
0046 const std::string& value() const {
0047 auto lock = mutex_.Lock();
0048 return value_;
0049 }
0050
0051 private:
0052 std::string value_;
0053 mutable ::arrow::util::Mutex mutex_;
0054 };
0055
0056 struct PARQUET_EXPORT KmsConnectionConfig {
0057 std::string kms_instance_id;
0058 std::string kms_instance_url;
0059
0060
0061 std::shared_ptr<KeyAccessToken> refreshable_key_access_token;
0062 std::unordered_map<std::string, std::string> custom_kms_conf;
0063
0064 KmsConnectionConfig();
0065
0066 const std::string& key_access_token() const {
0067 if (refreshable_key_access_token == NULLPTR ||
0068 refreshable_key_access_token->value().empty()) {
0069 throw ParquetException("key access token is not set!");
0070 }
0071 return refreshable_key_access_token->value();
0072 }
0073
0074 void SetDefaultIfEmpty();
0075 };
0076
0077 class PARQUET_EXPORT KmsClient {
0078 public:
0079 static constexpr const char kKmsInstanceIdDefault[] = "DEFAULT";
0080 static constexpr const char kKmsInstanceUrlDefault[] = "DEFAULT";
0081 static constexpr const char kKeyAccessTokenDefault[] = "DEFAULT";
0082
0083
0084
0085
0086
0087 virtual std::string WrapKey(const ::arrow::util::SecureString& key_bytes,
0088 const std::string& master_key_identifier) = 0;
0089
0090
0091 virtual ::arrow::util::SecureString UnwrapKey(
0092 const std::string& wrapped_key, const std::string& master_key_identifier) = 0;
0093
0094 virtual ~KmsClient() {}
0095 };
0096
0097 }