You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ma...@apache.org on 2018/03/28 16:15:29 UTC

nifi git commit: NIFI-4993: Accept null user at querying ProvenanceRepository

Repository: nifi
Updated Branches:
  refs/heads/master f394c874e -> 641ba29cc


NIFI-4993: Accept null user at querying ProvenanceRepository

Pass null user from ReportLineageToAtlas.

Address NullPointer dereferences

This closes #2589.

Signed-off-by: Mark Payne <ma...@hotmail.com>


Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/641ba29c
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/641ba29c
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/641ba29c

Branch: refs/heads/master
Commit: 641ba29cc8a9b2790aa66ef8a26a35e11f44912b
Parents: f394c87
Author: Mark Payne <ma...@hotmail.com>
Authored: Fri Mar 23 13:24:55 2018 -0400
Committer: Mark Payne <ma...@hotmail.com>
Committed: Wed Mar 28 12:15:05 2018 -0400

----------------------------------------------------------------------
 .../provenance/ProvenanceEventRepository.java   |  4 +-
 .../nifi/provenance/ProvenanceRepository.java   | 40 ++++++++++++++++----
 .../provenance/StandardAnalysisContext.java     | 36 +-----------------
 .../PersistentProvenanceRepository.java         | 16 ++++----
 .../WriteAheadProvenanceRepository.java         |  4 +-
 .../index/lucene/LuceneEventIndex.java          | 10 ++---
 .../VolatileProvenanceRepository.java           | 21 +++++-----
 7 files changed, 62 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/641ba29c/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventRepository.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventRepository.java b/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventRepository.java
index 14991ad..e9d3b14 100644
--- a/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventRepository.java
+++ b/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventRepository.java
@@ -77,9 +77,7 @@ public interface ProvenanceEventRepository {
     Long getMaxEventId();
 
     /**
-     * Retrieves the Provenance Event with the given ID. The event will be returned only
-     * if the given user is authorized to access the event. Otherwise, an
-     * AccessDeniedException or ResourceNotFoundException will be thrown, as appropriate
+     * Retrieves the Provenance Event with the given ID.
      *
      * @param id to lookup
      * @return the Provenance Event Record with the given ID, if it exists, or

http://git-wip-us.apache.org/repos/asf/nifi/blob/641ba29c/nifi-framework-api/src/main/java/org/apache/nifi/provenance/ProvenanceRepository.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/provenance/ProvenanceRepository.java b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/ProvenanceRepository.java
index 73d207e..bbde0c7 100644
--- a/nifi-framework-api/src/main/java/org/apache/nifi/provenance/ProvenanceRepository.java
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/ProvenanceRepository.java
@@ -44,6 +44,19 @@ public interface ProvenanceRepository extends ProvenanceEventRepository {
     void initialize(EventReporter eventReporter, Authorizer authorizer, ProvenanceAuthorizableFactory resourceFactory, IdentifierLookup identifierLookup) throws IOException;
 
 
+    /**
+     * Retrieves the Provenance Event with the given ID. The event will be returned only
+     * if the given user is authorized to access the event.
+     * Otherwise, an AccessDeniedException will be thrown.
+     * If the component for the event no longer exists, ResourceNotFoundException will be thrown.
+     *
+     * @param id to lookup
+     * @param user The NiFi user that the event should be authorized against.
+     *             It can be {@code null} if called by NiFi components internally where authorization is not required.
+     * @return the Provenance Event Record with the given ID, if it exists, or
+     *         {@code null} otherwise
+     * @throws IOException if failure while retrieving event
+     */
     ProvenanceEventRecord getEvent(long id, NiFiUser user) throws IOException;
 
     /**
@@ -55,7 +68,9 @@ public interface ProvenanceRepository extends ProvenanceEventRepository {
      *
      * @param firstRecordId id of the first record to retrieve
      * @param maxRecords    maximum number of records to retrieve
-     * @param user          the NiFi user that the events should be authorized against
+     * @param user          The NiFi user that the events should be authorized against.
+     *                      It can be {@code null} if called by NiFi components internally
+     *                      where authorization is not required.
      * @return records
      * @throws java.io.IOException if error reading from repository
      */
@@ -71,7 +86,8 @@ public interface ProvenanceRepository extends ProvenanceEventRepository {
      * identifier that can be used to fetch the results at a later time
      *
      * @param query to submit
-     * @param user the NiFi User to authorize the events against
+     * @param user The NiFi User to authorize the events against.
+     *             It can be {@code null} if called by NiFi components internally where authorization is not required.
      *
      * @return an identifier that can be used to fetch the results at a later
      *         time
@@ -80,7 +96,9 @@ public interface ProvenanceRepository extends ProvenanceEventRepository {
 
     /**
      * @param queryIdentifier of the query
-     * @param user the user who is retrieving the query
+     * @param user The user who is retrieving the query.
+     *             It can be {@code null} if the request was made by NiFi components internally where authorization is not required.
+     *             If the queried user and the retrieved user do not match, AccessDeniedException will be thrown.
      *
      * @return the QueryResult associated with the given identifier, if the
      *         query has finished processing. If the query has not yet finished running,
@@ -101,7 +119,8 @@ public interface ProvenanceRepository extends ProvenanceEventRepository {
      *
      * @param flowFileUuid the UUID of the FlowFile for which the Lineage should
      *            be calculated
-     * @param user the NiFi User to authorize events against
+     * @param user The NiFi User to authorize the events against.
+     *             It can be {@code null} if called by NiFi components internally where authorization is not required.
      *
      * @return a {@link ComputeLineageSubmission} object that can be used to
      *         check if the computing is complete and if so get the results
@@ -124,7 +143,8 @@ public interface ProvenanceRepository extends ProvenanceEventRepository {
      * available.
      *
      * @param eventId the numeric ID of the event that the lineage is for
-     * @param user the NiFi User to authorize events against
+     * @param user The NiFi User to authorize the events against.
+     *             It can be {@code null} if called by NiFi components internally where authorization is not required.
      *
      * @return a {@link ComputeLineageSubmission} object that can be used to
      *         check if the computing is complete and if so get the results
@@ -133,7 +153,9 @@ public interface ProvenanceRepository extends ProvenanceEventRepository {
 
     /**
      * @param lineageIdentifier identifier of lineage to compute
-     * @param user the user who is retrieving the lineage submission
+     * @param user The user who is retrieving the lineage submission.
+     *             It can be {@code null} if the request was made by NiFi components internally where authorization is not required.
+     *             If the queried user and the retrieved user do not match, AccessDeniedException will be thrown.
      *
      * @return the {@link ComputeLineageSubmission} associated with the given
      *         identifier
@@ -146,7 +168,8 @@ public interface ProvenanceRepository extends ProvenanceEventRepository {
      * the ID of the component that emitted the event.
      *
      * @param eventId the one-up id of the Event to expand
-     * @param user the NiFi user to authorize events against
+     * @param user The NiFi user to authorize events against.
+     *             It can be {@code null} if called by NiFi components internally where authorization is not required.
      * @return a submission which can be checked for status
      *
      * @throws IllegalArgumentException if the given identifier identifies a
@@ -161,7 +184,8 @@ public interface ProvenanceRepository extends ProvenanceEventRepository {
      * the ID of the component that emitted the event.
      *
      * @param eventId the one-up id of the Event
-     * @param user the NiFi user to authorize events against
+     * @param user The NiFi user to authorize events against.
+     *             It can be {@code null} if called by NiFi components internally where authorization is not required.
      *
      * @return a submission which can be checked for status
      *

http://git-wip-us.apache.org/repos/asf/nifi/blob/641ba29c/nifi-nar-bundles/nifi-atlas-bundle/nifi-atlas-reporting-task/src/main/java/org/apache/nifi/atlas/provenance/StandardAnalysisContext.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-atlas-bundle/nifi-atlas-reporting-task/src/main/java/org/apache/nifi/atlas/provenance/StandardAnalysisContext.java b/nifi-nar-bundles/nifi-atlas-bundle/nifi-atlas-reporting-task/src/main/java/org/apache/nifi/atlas/provenance/StandardAnalysisContext.java
index 7442d95..1f76126 100644
--- a/nifi-nar-bundles/nifi-atlas-bundle/nifi-atlas-reporting-task/src/main/java/org/apache/nifi/atlas/provenance/StandardAnalysisContext.java
+++ b/nifi-nar-bundles/nifi-atlas-bundle/nifi-atlas-reporting-task/src/main/java/org/apache/nifi/atlas/provenance/StandardAnalysisContext.java
@@ -18,7 +18,6 @@ package org.apache.nifi.atlas.provenance;
 
 import org.apache.nifi.atlas.NiFiFlow;
 import org.apache.nifi.atlas.resolver.ClusterResolver;
-import org.apache.nifi.authorization.user.NiFiUser;
 import org.apache.nifi.controller.status.ConnectionStatus;
 import org.apache.nifi.provenance.ProvenanceEventRecord;
 import org.apache.nifi.provenance.ProvenanceRepository;
@@ -28,9 +27,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
-import java.util.Collections;
 import java.util.List;
-import java.util.Set;
 import java.util.concurrent.TimeUnit;
 
 public class StandardAnalysisContext implements AnalysisContext {
@@ -85,44 +82,15 @@ public class StandardAnalysisContext implements AnalysisContext {
 
     @Override
     public ComputeLineageResult queryLineage(long eventId) {
-        final ComputeLineageSubmission submission = provenanceRepository.submitLineageComputation(eventId, NIFI_USER);
+        final ComputeLineageSubmission submission = provenanceRepository.submitLineageComputation(eventId, null);
         return getLineageResult(eventId, submission);
     }
 
     public ComputeLineageResult findParents(long eventId) {
-        final ComputeLineageSubmission submission = provenanceRepository.submitExpandParents(eventId, NIFI_USER);
+        final ComputeLineageSubmission submission = provenanceRepository.submitExpandParents(eventId, null);
         return getLineageResult(eventId, submission);
     }
 
-    // NOTE: This user is required to avoid NullPointerException at PersistentProvenanceRepository.submitLineageComputation
-    private static final QueryNiFiUser NIFI_USER = new QueryNiFiUser();
-    private static class QueryNiFiUser implements NiFiUser {
-        @Override
-        public String getIdentity() {
-            return StandardAnalysisContext.class.getSimpleName();
-        }
-
-        @Override
-        public Set<String> getGroups() {
-            return Collections.emptySet();
-        }
-
-        @Override
-        public NiFiUser getChain() {
-            return null;
-        }
-
-        @Override
-        public boolean isAnonymous() {
-            return true;
-        }
-
-        @Override
-        public String getClientAddress() {
-            return null;
-        }
-    }
-
     @Override
     public ProvenanceEventRecord getProvenanceEvent(long eventId) {
         try {

http://git-wip-us.apache.org/repos/asf/nifi/blob/641ba29c/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/PersistentProvenanceRepository.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/PersistentProvenanceRepository.java b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/PersistentProvenanceRepository.java
index 5c3d4d9..6f48e50 100644
--- a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/PersistentProvenanceRepository.java
+++ b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/PersistentProvenanceRepository.java
@@ -399,7 +399,7 @@ public class PersistentProvenanceRepository implements ProvenanceRepository {
     }
 
     public void authorize(final ProvenanceEventRecord event, final NiFiUser user) {
-        if (authorizer == null) {
+        if (authorizer == null || user == null) {
             return;
         }
 
@@ -2004,7 +2004,7 @@ public class PersistentProvenanceRepository implements ProvenanceRepository {
 
     @Override
     public QuerySubmission submitQuery(final Query query, final NiFiUser user) {
-        final String userId = user.getIdentity();
+        final String userId = user == null ? null : user.getIdentity();
         final int numQueries = querySubmissionMap.size();
 
         if (numQueries > MAX_UNDELETED_QUERY_RESULTS) {
@@ -2262,13 +2262,15 @@ public class PersistentProvenanceRepository implements ProvenanceRepository {
             event = getEvent(eventId);
         } catch (final Exception e) {
             logger.error("Failed to retrieve Provenance Event with ID " + eventId + " to calculate data lineage due to: " + e, e);
-            final AsyncLineageSubmission result = new AsyncLineageSubmission(LineageComputationType.FLOWFILE_LINEAGE, eventId, Collections.<String>emptySet(), 1, user.getIdentity());
+            final AsyncLineageSubmission result = new AsyncLineageSubmission(LineageComputationType.FLOWFILE_LINEAGE, eventId,
+                Collections.<String> emptySet(), 1, user == null ? null : user.getIdentity());
             result.getResult().setError("Failed to retrieve Provenance Event with ID " + eventId + ". See logs for more information.");
             return result;
         }
 
         if (event == null) {
-            final AsyncLineageSubmission result = new AsyncLineageSubmission(LineageComputationType.FLOWFILE_LINEAGE, eventId, Collections.<String>emptySet(), 1, user.getIdentity());
+            final AsyncLineageSubmission result = new AsyncLineageSubmission(LineageComputationType.FLOWFILE_LINEAGE, eventId,
+                Collections.<String> emptySet(), 1, user == null ? null : user.getIdentity());
             result.getResult().setError("Could not find Provenance Event with ID " + eventId);
             lineageSubmissionMap.put(result.getLineageIdentifier(), result);
             return result;
@@ -2285,7 +2287,7 @@ public class PersistentProvenanceRepository implements ProvenanceRepository {
     private AsyncLineageSubmission submitLineageComputation(final Collection<String> flowFileUuids, final NiFiUser user, final LineageComputationType computationType,
             final Long eventId, final long startTimestamp, final long endTimestamp) {
         final List<File> indexDirs = indexConfig.getIndexDirectories(startTimestamp, endTimestamp);
-        final AsyncLineageSubmission result = new AsyncLineageSubmission(computationType, eventId, flowFileUuids, indexDirs.size(), user.getIdentity());
+        final AsyncLineageSubmission result = new AsyncLineageSubmission(computationType, eventId, flowFileUuids, indexDirs.size(), user == null ? null : user.getIdentity());
         lineageSubmissionMap.put(result.getLineageIdentifier(), result);
 
         for (final File indexDir : indexDirs) {
@@ -2297,7 +2299,7 @@ public class PersistentProvenanceRepository implements ProvenanceRepository {
 
     @Override
     public AsyncLineageSubmission submitExpandChildren(final long eventId, final NiFiUser user) {
-        final String userId = user.getIdentity();
+        final String userId = user == null ? null : user.getIdentity();
 
         try {
             final ProvenanceEventRecord event = getEvent(eventId);
@@ -2336,7 +2338,7 @@ public class PersistentProvenanceRepository implements ProvenanceRepository {
 
     @Override
     public AsyncLineageSubmission submitExpandParents(final long eventId, final NiFiUser user) {
-        final String userId = user.getIdentity();
+        final String userId = user == null ? null : user.getIdentity();
 
         try {
             final ProvenanceEventRecord event = getEvent(eventId);

http://git-wip-us.apache.org/repos/asf/nifi/blob/641ba29c/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/WriteAheadProvenanceRepository.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/WriteAheadProvenanceRepository.java b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/WriteAheadProvenanceRepository.java
index 28c1a7f..ab7dfae 100644
--- a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/WriteAheadProvenanceRepository.java
+++ b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/WriteAheadProvenanceRepository.java
@@ -222,7 +222,7 @@ public class WriteAheadProvenanceRepository implements ProvenanceRepository {
     }
 
     private void authorize(final ProvenanceEventRecord event, final NiFiUser user) {
-        if (authorizer == null) {
+        if (authorizer == null || user == null) {
             return;
         }
 
@@ -253,7 +253,7 @@ public class WriteAheadProvenanceRepository implements ProvenanceRepository {
 
     @Override
     public QuerySubmission submitQuery(final Query query, final NiFiUser user) {
-        return eventIndex.submitQuery(query, createEventAuthorizer(user), user.getIdentity());
+        return eventIndex.submitQuery(query, createEventAuthorizer(user), user == null ? null : user.getIdentity());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/nifi/blob/641ba29c/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/index/lucene/LuceneEventIndex.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/index/lucene/LuceneEventIndex.java b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/index/lucene/LuceneEventIndex.java
index c44c7d2..d1a9714 100644
--- a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/index/lucene/LuceneEventIndex.java
+++ b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/index/lucene/LuceneEventIndex.java
@@ -356,13 +356,13 @@ public class LuceneEventIndex implements EventIndex {
             eventOption = eventStore.getEvent(eventId);
         } catch (final Exception e) {
             logger.error("Failed to retrieve Provenance Event with ID " + eventId + " to calculate data lineage due to: " + e, e);
-            final AsyncLineageSubmission result = new AsyncLineageSubmission(LineageComputationType.FLOWFILE_LINEAGE, eventId, Collections.emptySet(), 1, user.getIdentity());
+            final AsyncLineageSubmission result = new AsyncLineageSubmission(LineageComputationType.FLOWFILE_LINEAGE, eventId, Collections.emptySet(), 1, user == null ? null : user.getIdentity());
             result.getResult().setError("Failed to retrieve Provenance Event with ID " + eventId + ". See logs for more information.");
             return result;
         }
 
         if (!eventOption.isPresent()) {
-            final AsyncLineageSubmission result = new AsyncLineageSubmission(LineageComputationType.FLOWFILE_LINEAGE, eventId, Collections.emptySet(), 1, user.getIdentity());
+            final AsyncLineageSubmission result = new AsyncLineageSubmission(LineageComputationType.FLOWFILE_LINEAGE, eventId, Collections.emptySet(), 1, user == null ? null : user.getIdentity());
             result.getResult().setError("Could not find Provenance Event with ID " + eventId);
             lineageSubmissionMap.put(result.getLineageIdentifier(), result);
             return result;
@@ -378,7 +378,7 @@ public class LuceneEventIndex implements EventIndex {
         final LineageComputationType computationType, final Long eventId, final long startTimestamp, final long endTimestamp) {
 
         final List<File> indexDirs = directoryManager.getDirectories(startTimestamp, endTimestamp);
-        final AsyncLineageSubmission submission = new AsyncLineageSubmission(computationType, eventId, flowFileUuids, indexDirs.size(), user.getIdentity());
+        final AsyncLineageSubmission submission = new AsyncLineageSubmission(computationType, eventId, flowFileUuids, indexDirs.size(), user == null ? null : user.getIdentity());
         lineageSubmissionMap.put(submission.getLineageIdentifier(), submission);
 
         final BooleanQuery lineageQuery = buildLineageQuery(flowFileUuids);
@@ -501,7 +501,7 @@ public class LuceneEventIndex implements EventIndex {
 
     @Override
     public ComputeLineageSubmission submitExpandChildren(final long eventId, final NiFiUser user, final EventAuthorizer authorizer) {
-        final String userId = user.getIdentity();
+        final String userId = user == null ? null : user.getIdentity();
 
         try {
             final Optional<ProvenanceEventRecord> eventOption = eventStore.getEvent(eventId);
@@ -541,7 +541,7 @@ public class LuceneEventIndex implements EventIndex {
 
     @Override
     public ComputeLineageSubmission submitExpandParents(final long eventId, final NiFiUser user, final EventAuthorizer authorizer) {
-        final String userId = user.getIdentity();
+        final String userId = user == null ? null : user.getIdentity();
 
         try {
             final Optional<ProvenanceEventRecord> eventOption = eventStore.getEvent(eventId);

http://git-wip-us.apache.org/repos/asf/nifi/blob/641ba29c/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-volatile-provenance-repository/src/main/java/org/apache/nifi/provenance/VolatileProvenanceRepository.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-volatile-provenance-repository/src/main/java/org/apache/nifi/provenance/VolatileProvenanceRepository.java b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-volatile-provenance-repository/src/main/java/org/apache/nifi/provenance/VolatileProvenanceRepository.java
index 950448c..1ac6723 100644
--- a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-volatile-provenance-repository/src/main/java/org/apache/nifi/provenance/VolatileProvenanceRepository.java
+++ b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-volatile-provenance-repository/src/main/java/org/apache/nifi/provenance/VolatileProvenanceRepository.java
@@ -174,7 +174,7 @@ public class VolatileProvenanceRepository implements ProvenanceRepository {
         return ringBuffer.getSelectedElements(new Filter<ProvenanceEventRecord>() {
             @Override
             public boolean select(final ProvenanceEventRecord value) {
-                if (user != null && !isAuthorized(value, user)) {
+                if (!isAuthorized(value, user)) {
                     return false;
                 }
 
@@ -256,7 +256,7 @@ public class VolatileProvenanceRepository implements ProvenanceRepository {
     }
 
     public boolean isAuthorized(final ProvenanceEventRecord event, final NiFiUser user) {
-        if (authorizer == null) {
+        if (authorizer == null || user == null) {
             return true;
         }
 
@@ -276,7 +276,7 @@ public class VolatileProvenanceRepository implements ProvenanceRepository {
     }
 
     protected void authorize(final ProvenanceEventRecord event, final NiFiUser user) {
-        if (authorizer == null) {
+        if (authorizer == null || user == null) {
             return;
         }
 
@@ -442,14 +442,15 @@ public class VolatileProvenanceRepository implements ProvenanceRepository {
             throw new IllegalArgumentException("Query End Time cannot be before Query Start Time");
         }
 
+        final String userId = user == null ? null : user.getIdentity();
         if (query.getSearchTerms().isEmpty() && query.getStartDate() == null && query.getEndDate() == null) {
-            final AsyncQuerySubmission result = new AsyncQuerySubmission(query, 1, user.getIdentity());
+            final AsyncQuerySubmission result = new AsyncQuerySubmission(query, 1, userId);
             queryExecService.submit(new QueryRunnable(ringBuffer, createFilter(query, user), query.getMaxResults(), result));
             querySubmissionMap.put(query.getIdentifier(), result);
             return result;
         }
 
-        final AsyncQuerySubmission result = new AsyncQuerySubmission(query, 1, user.getIdentity());
+        final AsyncQuerySubmission result = new AsyncQuerySubmission(query, 1, userId);
         querySubmissionMap.put(query.getIdentifier(), result);
         queryExecService.submit(new QueryRunnable(ringBuffer, createFilter(query, user), query.getMaxResults(), result));
 
@@ -501,7 +502,7 @@ public class VolatileProvenanceRepository implements ProvenanceRepository {
     public ComputeLineageSubmission submitLineageComputation(final long eventId, final NiFiUser user) {
         final ProvenanceEventRecord event = getEvent(eventId);
         if (event == null) {
-            final String userId = user.getIdentity();
+            final String userId = user == null ? null : user.getIdentity();
             final AsyncLineageSubmission result = new AsyncLineageSubmission(LineageComputationType.FLOWFILE_LINEAGE, eventId, Collections.emptySet(), 1, userId);
             result.getResult().setError("Could not find event with ID " + eventId);
             lineageSubmissionMap.put(result.getLineageIdentifier(), result);
@@ -542,7 +543,7 @@ public class VolatileProvenanceRepository implements ProvenanceRepository {
 
     @Override
     public ComputeLineageSubmission submitExpandParents(final long eventId, final NiFiUser user) {
-        final String userId = user.getIdentity();
+        final String userId = user == null ? null : user.getIdentity();
 
         final ProvenanceEventRecord event = getEvent(eventId, user);
         if (event == null) {
@@ -573,7 +574,7 @@ public class VolatileProvenanceRepository implements ProvenanceRepository {
 
     @Override
     public ComputeLineageSubmission submitExpandChildren(final long eventId, final NiFiUser user) {
-        final String userId = user.getIdentity();
+        final String userId = user == null ? null : user.getIdentity();
 
         final ProvenanceEventRecord event = getEvent(eventId, user);
         if (event == null) {
@@ -619,14 +620,14 @@ public class VolatileProvenanceRepository implements ProvenanceRepository {
 
 
     private AsyncLineageSubmission submitLineageComputation(final Collection<String> flowFileUuids, final NiFiUser user, final LineageComputationType computationType, final Long eventId) {
-        final String userId = user.getIdentity();
+        final String userId = user == null ? null : user.getIdentity();
         final AsyncLineageSubmission result = new AsyncLineageSubmission(computationType, eventId, flowFileUuids, 1, userId);
         lineageSubmissionMap.put(result.getLineageIdentifier(), result);
 
         final Filter<ProvenanceEventRecord> filter = new Filter<ProvenanceEventRecord>() {
             @Override
             public boolean select(final ProvenanceEventRecord event) {
-                if (user != null && !isAuthorized(event, user)) {
+                if (!isAuthorized(event, user)) {
                     return false;
                 }