From 469502f30ca01953bceabca590bea8e183ed2c7d Mon Sep 17 00:00:00 2001 From: Matt Gilman Date: Tue, 23 Dec 2014 13:00:38 -0500 Subject: [PATCH] NIFI-65: - Code clean up. - Updating authorizeDownload(...) to accept the dnChain in the appropriate order. --- .../org/apache/nifi/web/controller/ControllerFacade.java | 5 ++--- .../org/apache/nifi/authorization/AuthorityProvider.java | 7 ++++--- .../apache/nifi/authorization/DownloadAuthorization.java | 5 +++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java b/nar-bundles/framework-bundle/framework/web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java index 99440bc6ae..07e3150241 100644 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java @@ -26,7 +26,6 @@ import java.util.Comparator; import java.util.Date; import java.util.HashMap; import java.util.HashSet; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; @@ -796,13 +795,13 @@ public class ControllerFacade implements ControllerServiceProvider { final Map attributes = event.getAttributes(); // calculate the dn chain - final LinkedList dnChain = new LinkedList<>(); + final List dnChain = new ArrayList<>(); // build the dn chain NiFiUser chainedUser = user; do { // add the entry for this user - dnChain.push(chainedUser.getDn()); + dnChain.add(chainedUser.getDn()); // go to the next user in the chain chainedUser = chainedUser.getChain(); diff --git a/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorityProvider.java b/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorityProvider.java index da536c24ff..7754c3502a 100644 --- a/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorityProvider.java +++ b/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorityProvider.java @@ -142,9 +142,10 @@ public interface AuthorityProvider { * Determines whether the user in the specified dnChain should be able to * download the content for the flowfile with the specified attributes. * - * The last dn in the chain is the end user that the request was issued on - * behalf of. The previous dn's in the chain represent entities proxying the - * user's request. + * The first dn in the chain is the end user that the request was issued on + * behalf of. The subsequent dn's in the chain represent entities proxying + * the user's request with the last being the proxy that sent the current + * request. * * @param dnChain * @param attributes diff --git a/nifi-api/src/main/java/org/apache/nifi/authorization/DownloadAuthorization.java b/nifi-api/src/main/java/org/apache/nifi/authorization/DownloadAuthorization.java index 3855817917..08695fa91e 100644 --- a/nifi-api/src/main/java/org/apache/nifi/authorization/DownloadAuthorization.java +++ b/nifi-api/src/main/java/org/apache/nifi/authorization/DownloadAuthorization.java @@ -39,7 +39,7 @@ public class DownloadAuthorization { */ private DownloadAuthorization(Result result, String explanation) { if (Result.Denied.equals(result) && explanation == null) { - throw new IllegalArgumentException("An explanation is request when the download request is denied."); + throw new IllegalArgumentException("An explanation is required when the download request is denied."); } this.result = result; @@ -74,10 +74,11 @@ public class DownloadAuthorization { } /** - * Creates a new denied DownloadAuthorization with the specified exlanation. + * Creates a new denied DownloadAuthorization with the specified explanation. * * @param explanation * @return + * @throws IllegalArgumentException if explanation is null */ public static DownloadAuthorization denied(String explanation) { return new DownloadAuthorization(Result.Denied, explanation);