MCPcopy Create free account
hub / github.com/apache/arrow / SerializeToJson

Method SerializeToJson

cpp/src/parquet/encryption/key_material.cc:113–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113std::string KeyMaterial::SerializeToJson(
114 bool is_footer_key, const std::string& kms_instance_id,
115 const std::string& kms_instance_url, const std::string& master_key_id,
116 bool is_double_wrapped, const std::string& kek_id,
117 const std::string& encoded_wrapped_kek, const std::string& encoded_wrapped_dek,
118 bool is_internal_storage) {
119 JsonWriter json_writer;
120
121 json_writer.StartObject();
122
123 json_writer.StringField(kKeyMaterialTypeField, kKeyMaterialType1);
124
125 if (is_internal_storage) {
126 // 1. for internal storage, key material and key metadata are the same.
127 // adding the "internalStorage" field that belongs to KeyMetadata.
128 json_writer.BoolField(KeyMetadata::kKeyMaterialInternalStorageField, true);
129 }
130
131 // 2. Write isFooterKey
132 json_writer.BoolField(kIsFooterKeyField, is_footer_key);
133
134 if (is_footer_key) {
135 // 3. For footer key, write KMS Instance ID
136 json_writer.StringField(kKmsInstanceIdField, kms_instance_id);
137
138 // 4. For footer key, write KMS Instance URL
139 json_writer.StringField(kKmsInstanceUrlField, kms_instance_url);
140 }
141
142 // 5. Write master key ID
143 json_writer.StringField(kMasterKeyIdField, master_key_id);
144
145 // 6. Write wrapped DEK
146 json_writer.StringField(kWrappedDataEncryptionKeyField, encoded_wrapped_dek);
147
148 // 7. Write isDoubleWrapped
149 json_writer.BoolField(kDoubleWrappingField, is_double_wrapped);
150
151 if (is_double_wrapped) {
152 // 8. In double wrapping mode, write KEK ID
153 json_writer.StringField(kKeyEncryptionKeyIdField, kek_id);
154
155 // 9. In double wrapping mode, write wrapped KEK
156 json_writer.StringField(kWrappedKeyEncryptionKeyField, encoded_wrapped_kek);
157 }
158
159 json_writer.EndObject();
160 PARQUET_ASSIGN_OR_THROW(std::string_view json, json_writer.GetString());
161 return std::string(json);
162}
163
164} // namespace parquet::encryption

Callers

nothing calls this directly

Calls 4

StringFieldMethod · 0.80
BoolFieldMethod · 0.80
StartObjectMethod · 0.45
EndObjectMethod · 0.45

Tested by

no test coverage detected