[
https://issues.apache.org/jira/browse/NIFI-4708?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16313911#comment-16313911
]
ASF GitHub Bot commented on NIFI-4708:
--------------------------------------
Github user alopresto commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2376#discussion_r159982754
--- Diff:
nifi-toolkit/nifi-toolkit-encrypt-config/src/main/groovy/org/apache/nifi/toolkit/encryptconfig/util/NiFiRegistryAuthorizersXmlEncryptor.groovy
---
@@ -0,0 +1,106 @@
+/*
+ * 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.util
+
+import groovy.xml.XmlUtil
+import org.apache.nifi.properties.SensitivePropertyProvider
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+import org.xml.sax.SAXException
+
+class NiFiRegistryAuthorizersXmlEncryptor extends XmlEncryptor {
+
+ private static final Logger logger =
LoggerFactory.getLogger(NiFiRegistryAuthorizersXmlEncryptor.class)
+
+ private static final String LDAP_USER_GROUP_PROVIDER_CLASS =
"org.apache.nifi.registry.security.ldap.tenants.LdapUserGroupProvider"
+ private static final String LDAP_USER_GROUP_PROVIDER_REGEX =
+
/(?s)<userGroupProvider>(?:(?!<userGroupProvider>).)*?<class>\s*org\.apache\.nifi\.registry\.security\.ldap\.tenants\.LdapUserGroupProvider.*?<\/userGroupProvider>/
+ /* Explanation of LDAP_USER_GROUP_PROVIDER_REGEX:
+ * (?s) -> single-line mode (i.e., `.`
in regex matches newlines)
+ * <userGroupProvider> -> find occurrence of
`<userGroupProvider>` literally (case-sensitive)
+ * (?: ... ) -> group but do not capture
submatch
+ * (?! ... ) -> negative lookahead
+ * (?:(?!<userGroupProvider>).)*? -> find everything until a new
`<userGroupProvider>` starts. This is for not selecting multiple
userGroupProviders in one match
+ * <class> -> find occurrence of `<class>`
literally (case-sensitive)
+ * \s* -> find any whitespace
+ *
org\.apache\.nifi\.registry\.security\.ldap\.tenants\.LdapUserGroupProvider
+ * -> find occurrence of
`org.apache.nifi.registry.security.ldap.tenants.LdapUserGroupProvider`
literally (case-sensitive)
+ * .*?</userGroupProvider> -> find everything as needed up
until and including occurrence of '</userGroupProvider>'
+ */
+
+ NiFiRegistryAuthorizersXmlEncryptor(SensitivePropertyProvider
encryptionProvider, SensitivePropertyProvider decryptionProvider) {
+ super(encryptionProvider, decryptionProvider)
+ }
+
+ @Override
--- End diff --
Add Javadoc explaining operation of overriding method and why custom
implementation is necessary.
> Add support for NiFi Registry to the encrypt-config tool in NiFi Toolkit
> ------------------------------------------------------------------------
>
> Key: NIFI-4708
> URL: https://issues.apache.org/jira/browse/NIFI-4708
> Project: Apache NiFi
> Issue Type: Improvement
> Reporter: Kevin Doran
> Assignee: Kevin Doran
> Fix For: 1.5.0
>
>
> NiFi Registry now supports loading encrypted config files (e.g.,
> nifi-registry.properties, authorizers.xml, login-identity-providers.xml).
> These files are very difficult to encrypt by hand, and is not recommended.
> Because NiFi Registry utilizes the same encryption algorithms supported by
> NiFi, the easiest way to build a tool for encrypting NiFi Registry config
> properties is to extend the the encrypt-config tool in NiFi Toolkit to
> support NiFi Registry as well.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)