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

Method SerializeToJson

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

SetStringMethod · 0.45
SetBoolMethod · 0.45
SerializeMethod · 0.45

Tested by

no test coverage detected