4141import org .elasticsearch .common .regex .Regex ;
4242import org .elasticsearch .common .settings .Settings ;
4343import org .elasticsearch .common .util .CachedSupplier ;
44- import org .elasticsearch .common .util .concurrent .ListenableFuture ;
4544import org .elasticsearch .common .util .set .Sets ;
4645import org .elasticsearch .index .Index ;
4746import org .elasticsearch .index .shard .ShardId ;
@@ -328,12 +327,12 @@ public SubscribableListener<IndexAuthorizationResult> authorizeIndexAction(
328327 try {
329328 role = ensureRBAC (authorizationInfo ).getRole ();
330329 } catch (Exception e ) {
331- return ListenableFuture .newFailed (e );
330+ return SubscribableListener .newFailed (e );
332331 }
333332 if (TransportActionProxy .isProxyAction (action ) || shouldAuthorizeIndexActionNameOnly (action , request )) {
334333 // we've already validated that the request is a proxy request so we can skip that but we still
335334 // need to validate that the action is allowed and then move on
336- return ListenableFuture .newSucceeded (
335+ return SubscribableListener .newSucceeded (
337336 role .checkIndicesAction (action ) ? IndexAuthorizationResult .EMPTY : IndexAuthorizationResult .DENIED
338337 );
339338 } else if (request instanceof IndicesRequest == false ) {
@@ -353,7 +352,7 @@ public SubscribableListener<IndexAuthorizationResult> authorizeIndexAction(
353352 // index and if they cannot, we can fail the request early before we allow the execution of the action and in
354353 // turn the shard actions
355354 if (TransportSearchScrollAction .TYPE .name ().equals (action )) {
356- final ListenableFuture <IndexAuthorizationResult > listener = new ListenableFuture <>();
355+ final SubscribableListener <IndexAuthorizationResult > listener = new SubscribableListener <>();
357356 ActionRunnable .supply (listener .delegateFailureAndWrap ((l , parsedScrollId ) -> {
358357 if (parsedScrollId .hasLocalIndices ()) {
359358 l .onResponse (
@@ -373,42 +372,42 @@ public SubscribableListener<IndexAuthorizationResult> authorizeIndexAction(
373372 // The DLS/FLS permissions are used inside the {@code DirectoryReader} that {@code SecurityIndexReaderWrapper}
374373 // built while handling the initial search request. In addition, for consistency, the DLS/FLS permissions from
375374 // the originating search request are attached to the thread context upon validating the scroll.
376- return ListenableFuture .newSucceeded (IndexAuthorizationResult .EMPTY );
375+ return SubscribableListener .newSucceeded (IndexAuthorizationResult .EMPTY );
377376 }
378377 } else if (isAsyncRelatedAction (action )) {
379378 if (SubmitAsyncSearchAction .NAME .equals (action )) {
380379 // authorize submit async search but don't fill in the DLS/FLS permissions
381380 // the `null` IndicesAccessControl parameter indicates that this action has *not* determined
382381 // which DLS/FLS controls should be applied to this action
383- return ListenableFuture .newSucceeded (IndexAuthorizationResult .EMPTY );
382+ return SubscribableListener .newSucceeded (IndexAuthorizationResult .EMPTY );
384383 } else {
385384 // async-search actions other than submit have a custom security layer that checks if the current user is
386385 // the same as the user that submitted the original request so no additional checks are needed here.
387- return ListenableFuture .newSucceeded (IndexAuthorizationResult .ALLOW_NO_INDICES );
386+ return SubscribableListener .newSucceeded (IndexAuthorizationResult .ALLOW_NO_INDICES );
388387 }
389388 } else if (action .equals (TransportClosePointInTimeAction .TYPE .name ())) {
390- return ListenableFuture .newSucceeded (IndexAuthorizationResult .ALLOW_NO_INDICES );
389+ return SubscribableListener .newSucceeded (IndexAuthorizationResult .ALLOW_NO_INDICES );
391390 } else {
392391 assert false
393392 : "only scroll and async-search related requests are known indices api that don't "
394393 + "support retrieving the indices they relate to" ;
395- return ListenableFuture .newFailed (
394+ return SubscribableListener .newFailed (
396395 new IllegalStateException (
397396 "only scroll and async-search related requests are known indices "
398397 + "api that don't support retrieving the indices they relate to"
399398 )
400399 );
401400 }
402401 } else if (isChildActionAuthorizedByParentOnLocalNode (requestInfo , authorizationInfo )) {
403- return ListenableFuture .newSucceeded (
402+ return SubscribableListener .newSucceeded (
404403 new IndexAuthorizationResult (requestInfo .getOriginatingAuthorizationContext ().getIndicesAccessControl ())
405404 );
406405 } else if (PreAuthorizationUtils .shouldPreAuthorizeChildByParentAction (requestInfo , authorizationInfo )) {
407406 // We only pre-authorize child actions if DLS/FLS is not configured,
408407 // hence we can allow here access for all requested indices.
409- return ListenableFuture .newSucceeded (new IndexAuthorizationResult (IndicesAccessControl .allowAll ()));
408+ return SubscribableListener .newSucceeded (new IndexAuthorizationResult (IndicesAccessControl .allowAll ()));
410409 } else if (allowsRemoteIndices (request ) || role .checkIndicesAction (action )) {
411- final ListenableFuture <IndexAuthorizationResult > listener = new ListenableFuture <>();
410+ final SubscribableListener <IndexAuthorizationResult > listener = new SubscribableListener <>();
412411 indicesAsyncSupplier .getAsync ().addListener (listener .delegateFailureAndWrap ((delegateListener , resolvedIndices ) -> {
413412 assert resolvedIndices .isEmpty () == false
414413 : "every indices request needs to have its indices set thus the resolved indices must not be empty" ;
@@ -446,7 +445,7 @@ public SubscribableListener<IndexAuthorizationResult> authorizeIndexAction(
446445 }));
447446 return listener ;
448447 } else {
449- return ListenableFuture .newSucceeded (IndexAuthorizationResult .DENIED );
448+ return SubscribableListener .newSucceeded (IndexAuthorizationResult .DENIED );
450449 }
451450 }
452451
0 commit comments