ggershinsky commented on a change in pull request #8023:
URL: https://github.com/apache/arrow/pull/8023#discussion_r485567679



##########
File path: cpp/src/parquet/properties_driven_crypto_factory.cc
##########
@@ -0,0 +1,278 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <sstream>
+
+#include "arrow/result.h"
+#include "arrow/util/logging.h"
+#include "arrow/util/string.h"
+
+#include "parquet/encryption_internal.h"
+#include "parquet/file_key_material_store.h"
+#include "parquet/file_key_unwrapper.h"
+#include "parquet/properties_driven_crypto_factory.h"
+
+namespace parquet {
+namespace encryption {
+
+constexpr const int32_t 
PropertiesDrivenCryptoFactory::kAcceptableDataKeyLengths[];
+
+EncryptionConfiguration::Builder* 
EncryptionConfiguration::Builder::column_keys(
+    const std::string& column_keys) {
+  DCHECK(!column_keys.empty());
+  if (uniform_encryption_) {
+    throw ParquetException(
+        "Cannot call both column_keys(const std::string&) and 
uniform_encryption()");
+  }
+  column_keys_ = column_keys;
+  return this;
+}
+
+EncryptionConfiguration::Builder* 
EncryptionConfiguration::Builder::uniform_encryption() {
+  if (!column_keys_.empty()) {
+    throw ParquetException(
+        "Cannot call both column_keys(const std::string&) and 
uniform_encryption()");
+  }
+  uniform_encryption_ = true;
+  return this;
+}
+
+EncryptionConfiguration::Builder* 
EncryptionConfiguration::Builder::encryption_algorithm(
+    ParquetCipher::type algo) {
+  encryption_algorithm_ = algo;
+  return this;
+}
+
+EncryptionConfiguration::Builder* 
EncryptionConfiguration::Builder::plaintext_footer(
+    bool plaintext_footer) {
+  plaintext_footer_ = plaintext_footer;
+  return this;
+}
+
+EncryptionConfiguration::Builder* 
EncryptionConfiguration::Builder::double_wrapping(
+    bool double_wrapping) {
+  double_wrapping_ = double_wrapping;
+  return this;
+}
+
+EncryptionConfiguration::Builder* 
EncryptionConfiguration::Builder::wrap_locally(
+    bool wrap_locally) {
+  wrap_locally_ = wrap_locally;
+  return this;
+}
+
+EncryptionConfiguration::Builder*
+EncryptionConfiguration::Builder::cache_lifetime_seconds(
+    uint64_t cache_lifetime_seconds) {
+  cache_lifetime_seconds_ = cache_lifetime_seconds;
+  return this;
+}
+
+EncryptionConfiguration::Builder* 
EncryptionConfiguration::Builder::internal_key_material(
+    bool internal_key_material) {
+  internal_key_material_ = internal_key_material;
+  return this;
+}
+
+EncryptionConfiguration::Builder* 
EncryptionConfiguration::Builder::data_key_length_bits(
+    int32_t data_key_length_bits) {
+  data_key_length_bits_ = data_key_length_bits;
+  return this;
+}
+
+std::shared_ptr<EncryptionConfiguration> 
EncryptionConfiguration::Builder::build() {
+  if (!uniform_encryption_ && column_keys_.empty()) {
+    throw ParquetException(
+        "Either column_keys(const std::string&) or uniform_encryption() must 
be "
+        "called.");
+  }
+
+  return std::make_shared<EncryptionConfiguration>(
+      footer_key_, column_keys_, encryption_algorithm_, plaintext_footer_,
+      double_wrapping_, wrap_locally_, cache_lifetime_seconds_, 
internal_key_material_,
+      uniform_encryption_, data_key_length_bits_);
+}
+
+DecryptionConfiguration::Builder* 
DecryptionConfiguration::Builder::wrap_locally(
+    bool wrap_locally) {
+  wrap_locally_ = wrap_locally;
+  return this;
+}
+
+DecryptionConfiguration::Builder*
+DecryptionConfiguration::Builder::cache_lifetime_seconds(
+    uint64_t cache_lifetime_seconds) {
+  cache_lifetime_seconds_ = cache_lifetime_seconds;
+  return this;
+}
+
+std::shared_ptr<DecryptionConfiguration> 
DecryptionConfiguration::Builder::build() {
+  return std::make_shared<DecryptionConfiguration>(wrap_locally_,
+                                                   cache_lifetime_seconds_);
+}
+
+void PropertiesDrivenCryptoFactory::kms_client_factory(

Review comment:
       I think it's better called "register_kms_client_factory" or 
"set_kms_client_factory". Also, can be made to throw an exception if already 
set, so a user won't override it by mistake.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to