adamdebreceni commented on a change in pull request #937: URL: https://github.com/apache/nifi-minifi-cpp/pull/937#discussion_r533149990
########## File path: extensions/http-curl/tests/C2ConfigEncryption.cpp ########## @@ -0,0 +1,58 @@ +/** + * + * 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. + */ + +#undef NDEBUG +#include <iterator> +#include <fstream> +#include "HTTPIntegrationBase.h" +#include "HTTPHandlers.h" +#include "utils/IntegrationTestUtils.h" +#include "utils/EncryptionProvider.h" + +int main(int argc, char **argv) { + const cmd_args args = parse_cmdline_args(argc, argv, "update"); + TestController controller; + // copy config file to temporary location as it will get overridden + char tmp_format[] = "/var/tmp/c2.XXXXXX"; + std::string home_path = controller.createTempDirectory(tmp_format); + std::string live_config_file = utils::file::FileUtils::concat_path(home_path, "config.yml"); + utils::file::FileUtils::copy_file(args.test_file, live_config_file); + // the C2 server will update the flow with the contents of args.test_file + // which will be encrypted and persisted to the temporary live_config_file + C2UpdateHandler handler(args.test_file); + VerifyC2Update harness(10000); + harness.getConfiguration()->set(minifi::Configure::nifi_flow_configuration_encrypt, "true"); + harness.setKeyDir(args.key_dir); + harness.setUrl(args.url, &handler); + handler.setC2RestResponse(harness.getC2RestUrl(), "configuration", "true"); + + const auto start = std::chrono::system_clock::now(); Review comment: remove ########## File path: libminifi/src/utils/EncryptionProvider.cpp ########## @@ -33,22 +40,19 @@ constexpr const char* CONFIG_ENCRYPTION_KEY_PROPERTY_NAME = "nifi.bootstrap.sens } // namespace -namespace org { -namespace apache { -namespace nifi { -namespace minifi { - -utils::optional<minifi::Decryptor> Decryptor::create(const std::string& minifi_home) { +utils::optional<EncryptionProvider> EncryptionProvider::create(const std::string& home_path) { minifi::Properties bootstrap_conf; - bootstrap_conf.setHome(minifi_home); + bootstrap_conf.setHome(home_path); bootstrap_conf.loadConfigureFile(DEFAULT_NIFI_BOOTSTRAP_FILE); return bootstrap_conf.getString(CONFIG_ENCRYPTION_KEY_PROPERTY_NAME) - | utils::map([](const std::string& encryption_key_hex) { return utils::StringUtils::from_hex(encryption_key_hex); }) - | utils::map(&utils::crypto::stringToBytes) - | utils::map([](const utils::crypto::Bytes& encryption_key_bytes) { return minifi::Decryptor{encryption_key_bytes}; }); + | utils::map([](const std::string &encryption_key_hex) { return utils::StringUtils::from_hex(encryption_key_hex); }) + | utils::map(&utils::crypto::stringToBytes) + | utils::map([](const utils::crypto::Bytes &encryption_key_bytes) { return EncryptionProvider{encryption_key_bytes}; }); Review comment: done ---------------------------------------------------------------- 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: [email protected]
