kevdoran commented on a change in pull request #302:
URL: https://github.com/apache/nifi-registry/pull/302#discussion_r490533774



##########
File path: 
nifi-registry-core/nifi-registry-security-utils/src/main/java/org/apache/nifi/registry/security/util/ProxiedEntitiesUtils.java
##########
@@ -39,6 +41,55 @@
 
     private static final String ANONYMOUS_CHAIN = "<>";
 
+    /**
+     * Formats a list of DN/usernames to be set as a HTTP header using well 
known conventions.
+     *
+     * @param proxiedEntities the raw identities (usernames and DNs) to be 
formatted as a chain
+     * @return the value to use in the X-ProxiedEntitiesChain header
+     */
+    public static String getProxiedEntitiesChain(final String[] 
proxiedEntities) {
+        if (proxiedEntities == null) {
+            return null;
+        }
+
+        final List<String> proxiedEntityChain = Arrays.stream(proxiedEntities)
+                .map(ProxiedEntitiesUtils::formatProxyDn)
+                .collect(Collectors.toList());
+        return StringUtils.join(proxiedEntityChain, "");
+    }
+
+    /**
+     * Tokenizes the specified proxy chain.
+     *
+     * @param rawProxyChain raw chain
+     * @return tokenized proxy chain
+     */
+    public static List<String> tokenizeProxiedEntitiesChain(final String 
rawProxyChain) {
+        final List<String> proxyChain = new ArrayList<>();
+        if (!StringUtils.isEmpty(rawProxyChain)) {
+            // Split the String on the >< token
+            rawProxyChain.split("><");

Review comment:
       This was unintentional. I had started refactoring code to remove the dep 
on commons, but the commons method semantics are necessary. Good catch, I will 
remove this.




----------------------------------------------------------------
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