- Code clean up.
- Updating authorizeDownload(...) to accept the dnChain in the appropriate order.
This commit is contained in:
Matt Gilman 2014-12-23 13:00:38 -05:00
parent 7a29166d9c
commit 469502f30c
3 changed files with 9 additions and 8 deletions

View File

@ -26,7 +26,6 @@ import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -796,13 +795,13 @@ public class ControllerFacade implements ControllerServiceProvider {
final Map<String, String> attributes = event.getAttributes(); final Map<String, String> attributes = event.getAttributes();
// calculate the dn chain // calculate the dn chain
final LinkedList<String> dnChain = new LinkedList<>(); final List<String> dnChain = new ArrayList<>();
// build the dn chain // build the dn chain
NiFiUser chainedUser = user; NiFiUser chainedUser = user;
do { do {
// add the entry for this user // add the entry for this user
dnChain.push(chainedUser.getDn()); dnChain.add(chainedUser.getDn());
// go to the next user in the chain // go to the next user in the chain
chainedUser = chainedUser.getChain(); chainedUser = chainedUser.getChain();

View File

@ -142,9 +142,10 @@ public interface AuthorityProvider {
* Determines whether the user in the specified dnChain should be able to * Determines whether the user in the specified dnChain should be able to
* download the content for the flowfile with the specified attributes. * 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 * The first 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 * behalf of. The subsequent dn's in the chain represent entities proxying
* user's request. * the user's request with the last being the proxy that sent the current
* request.
* *
* @param dnChain * @param dnChain
* @param attributes * @param attributes

View File

@ -39,7 +39,7 @@ public class DownloadAuthorization {
*/ */
private DownloadAuthorization(Result result, String explanation) { private DownloadAuthorization(Result result, String explanation) {
if (Result.Denied.equals(result) && explanation == null) { 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; 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 * @param explanation
* @return * @return
* @throws IllegalArgumentException if explanation is null
*/ */
public static DownloadAuthorization denied(String explanation) { public static DownloadAuthorization denied(String explanation) {
return new DownloadAuthorization(Result.Denied, explanation); return new DownloadAuthorization(Result.Denied, explanation);