Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions cpp/src/parquet/encryption/encryption.cc
Original file line number Diff line number Diff line change
Expand Up @@ -324,4 +324,52 @@ FileEncryptionProperties::FileEncryptionProperties(
}
}

ExternalFileEncryptionProperties::Builder* ExternalFileEncryptionProperties::Builder::app_context(
const std::string& context) {
if (!app_context_.empty()) {
throw ParquetException("App context already set");
}

if (context.empty()) {
return this;
}

app_context_ = context;
return this;
}

ExternalFileEncryptionProperties::Builder*
ExternalFileEncryptionProperties::Builder::connection_config(
const std::map<std::string, std::string>& config) {
if (connection_config_.size() != 0) {
throw ParquetException("Connection config already set");
}

if (config.size() == 0) {
return this;
}

connection_config_ = config;
return this;
}

std::shared_ptr<ExternalFileEncryptionProperties>
ExternalFileEncryptionProperties::Builder::build_external() {
return std::shared_ptr<ExternalFileEncryptionProperties>(new ExternalFileEncryptionProperties(
parquet_cipher_, footer_key_, footer_key_metadata_, encrypted_footer_, aad_prefix_,
store_aad_prefix_in_file_, encrypted_columns_, app_context_, connection_config_));
}

ExternalFileEncryptionProperties::ExternalFileEncryptionProperties(
ParquetCipher::type cipher, const std::string& footer_key,
const std::string& footer_key_metadata, bool encrypted_footer,
const std::string& aad_prefix, bool store_aad_prefix_in_file,
const ColumnPathToEncryptionPropertiesMap& encrypted_columns,
const std::string& app_context,
const std::map<std::string, std::string>& connection_config)
: FileEncryptionProperties(cipher, footer_key, footer_key_metadata, encrypted_footer,
aad_prefix, store_aad_prefix_in_file, encrypted_columns),
app_context_(app_context),
connection_config_(connection_config) {}

} // namespace parquet
48 changes: 47 additions & 1 deletion cpp/src/parquet/encryption/encryption.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ class PARQUET_EXPORT FileEncryptionProperties {
aad_prefix_, store_aad_prefix_in_file_, encrypted_columns_));
}

private:
protected:
ParquetCipher::type parquet_cipher_;
bool encrypted_footer_;
std::string footer_key_;
Expand Down Expand Up @@ -450,10 +450,56 @@ class PARQUET_EXPORT FileEncryptionProperties {
bool store_aad_prefix_in_file_;
ColumnPathToEncryptionPropertiesMap encrypted_columns_;

protected:
FileEncryptionProperties(ParquetCipher::type cipher, const std::string& footer_key,
const std::string& footer_key_metadata, bool encrypted_footer,
const std::string& aad_prefix, bool store_aad_prefix_in_file,
const ColumnPathToEncryptionPropertiesMap& encrypted_columns);
};

class PARQUET_EXPORT ExternalFileEncryptionProperties : public FileEncryptionProperties {
public:

class PARQUET_EXPORT Builder : public FileEncryptionProperties::Builder {
public:

explicit Builder(const std::string& footer_key)
: FileEncryptionProperties::Builder(footer_key) {}

/// Valid JSON string with additional application context needed for security checks.
Builder* app_context(const std::string& context);

/// Key/value map of the location of configuration files needed by the external
/// encryption service, including location of a dynamically-linked library, or config files
/// where the external service can find urls, certificates, and parameters needed to make a
/// remote service call.
Builder* connection_config(const std::map<std::string, std::string>& config);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: for a while (since the design discussion), I have been debating the name of this field. 'connection_config' implies going over a network (not always the case). One just came to mind: 'instantiation_config' may be a better name. Not a blocker for this PR, this is "easily" changeable in a later iteration.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack. I prefer connection_config, but we can discuss later.


std::shared_ptr<ExternalFileEncryptionProperties> build_external();

private:
std::string app_context_;
std::map<std::string, std::string> connection_config_;
};

const std::string& app_context() const {
return app_context_;
}

const std::map<std::string, std::string>& connection_config() const {
return connection_config_;
}

private:
std::string app_context_;
std::map<std::string, std::string> connection_config_;

ExternalFileEncryptionProperties(ParquetCipher::type cipher, const std::string& footer_key,
const std::string& footer_key_metadata, bool encrypted_footer,
const std::string& aad_prefix, bool store_aad_prefix_in_file,
const ColumnPathToEncryptionPropertiesMap& encrypted_columns,
const std::string& app_context,
const std::map<std::string, std::string>& connection_config);
};

} // namespace parquet
Loading