Github user alopresto commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2376#discussion_r159961459
--- Diff:
nifi-toolkit/nifi-toolkit-encrypt-config/src/main/groovy/org/apache/nifi/toolkit/encryptconfig/NiFiRegistryMode.groovy
---
@@ -0,0 +1,383 @@
+/*
+ * 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.
+ */
+package org.apache.nifi.toolkit.encryptconfig
+
+import org.apache.commons.cli.HelpFormatter
+import org.apache.commons.cli.Options
+import org.apache.http.annotation.Experimental
+import org.apache.nifi.properties.AESSensitivePropertyProvider
+import org.apache.nifi.properties.SensitivePropertyProvider
+import org.apache.nifi.toolkit.encryptconfig.util.BootstrapUtil
+import
org.apache.nifi.toolkit.encryptconfig.util.NiFiRegistryAuthorizersXmlEncryptor
+import
org.apache.nifi.toolkit.encryptconfig.util.NiFiRegistryIdentityProvidersXmlEncryptor
+import
org.apache.nifi.toolkit.encryptconfig.util.NiFiRegistryPropertiesEncryptor
+import org.apache.nifi.toolkit.encryptconfig.util.ToolUtilities
+import org.apache.nifi.util.console.TextDevices
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+
+@Experimental
+class NiFiRegistryMode implements ToolMode {
+
+ private static final Logger logger =
LoggerFactory.getLogger(NiFiRegistryMode.class)
+
+ CliBuilder cli
+
+ NiFiRegistryMode() {
+ cli = cliBuilder()
+ }
+
+// private void printUsage(String message = "") {
+// if (message) {
+// System.out.println(message)
+// System.out.println()
+// }
+// cli.usage()
+// }
+
+ @Override
+ void run(String[] args) {
+ logger.warn("The NiFi Registry capabilities of this tool is still
considered experimental. The results should be manually verified.")
+ try {
+
+ def options = cli.parse(args)
+
+ if (!options || options.h) {
+ EncryptConfigMain.printUsageAndExit("",
EncryptConfigMain.EXIT_STATUS_OTHER)
+ }
+
+ EncryptConfigLogger.configureLogger(options.v)
+
+ Configuration config = new Configuration(options)
+ run(config)
+
+ } catch (Exception e) {
+ logger.error("Encountered an error: ${e.getMessage()}")
+ logger.debug("", e) // stack trace only when verbose enabled
+ EncryptConfigMain.printUsageAndExit(e.getMessage(),
EncryptConfigMain.EXIT_STATUS_FAILURE)
+ }
+ }
+
+ void run(Configuration config) throws Exception {
+
+ if (config.usingPassword) {
+ logger.info("Using encryption key derived from password.")
+ } else if (config.usingRawKeyHex) {
+ logger.info("Using encryption key provided.")
+ } else if (config.usingBootstrapKey) {
+ logger.info("Using encryption key from input bootstrap.conf.")
+ }
+
+ logger.debug("(src) bootstrap.conf:
${config.inputBootstrapPath}")
+ logger.debug("(dest) bootstrap.conf:
${config.outputBootstrapPath}")
+ logger.debug("(src) nifi.properties:
${config.inputNiFiRegistryPropertiesPath}")
--- End diff --
This line and the next should print `nifi-registry.properties`.
---