6868import org .elasticsearch .xpack .core .XPackField ;
6969import org .elasticsearch .xpack .core .XPackSettings ;
7070import org .elasticsearch .xpack .core .security .ScrollHelper ;
71- import org .elasticsearch .xpack .core .security .SecurityLifecycleServiceField ;
7271import org .elasticsearch .xpack .core .security .authc .Authentication ;
7372import org .elasticsearch .xpack .core .security .authc .KeyAndTimestamp ;
7473import org .elasticsearch .xpack .core .security .authc .TokenMetaData ;
118117import static org .elasticsearch .gateway .GatewayService .STATE_NOT_RECOVERED_BLOCK ;
119118import static org .elasticsearch .xpack .core .ClientHelper .SECURITY_ORIGIN ;
120119import static org .elasticsearch .xpack .core .ClientHelper .executeAsyncWithOrigin ;
120+ import static org .elasticsearch .xpack .security .SecurityLifecycleService .SECURITY_INDEX_NAME ;
121121
122122/**
123123 * Service responsible for the creation, validation, and other management of {@link UserToken}
@@ -256,7 +256,7 @@ public void createUserToken(Authentication authentication, Authentication origin
256256 .endObject ();
257257 builder .endObject ();
258258 IndexRequest request =
259- client .prepareIndex (SecurityLifecycleServiceField . SECURITY_INDEX_NAME , TYPE , getTokenDocumentId (userToken ))
259+ client .prepareIndex (SECURITY_INDEX_NAME , TYPE , getTokenDocumentId (userToken ))
260260 .setOpType (OpType .CREATE )
261261 .setSource (builder )
262262 .setRefreshPolicy (RefreshPolicy .WAIT_UNTIL )
@@ -372,7 +372,7 @@ void decodeToken(String token, ActionListener<UserToken> listener) throws IOExce
372372 decryptTokenId (in , cipher , version , ActionListener .wrap (tokenId ->
373373 lifecycleService .securityIndex ().prepareIndexIfNeededThenExecute (listener ::onFailure , () -> {
374374 final GetRequest getRequest =
375- client .prepareGet (SecurityLifecycleServiceField . SECURITY_INDEX_NAME , TYPE ,
375+ client .prepareGet (SECURITY_INDEX_NAME , TYPE ,
376376 getTokenDocumentId (tokenId )).request ();
377377 executeAsyncWithOrigin (client .threadPool ().getThreadContext (), SECURITY_ORIGIN , getRequest ,
378378 ActionListener .<GetResponse >wrap (response -> {
@@ -533,7 +533,7 @@ private void indexBwcInvalidation(UserToken userToken, ActionListener<Boolean> l
533533 listener .onFailure (invalidGrantException ("failed to invalidate token" ));
534534 } else {
535535 final String invalidatedTokenId = getInvalidatedTokenDocumentId (userToken );
536- IndexRequest indexRequest = client .prepareIndex (SecurityLifecycleServiceField . SECURITY_INDEX_NAME , TYPE , invalidatedTokenId )
536+ IndexRequest indexRequest = client .prepareIndex (SECURITY_INDEX_NAME , TYPE , invalidatedTokenId )
537537 .setOpType (OpType .CREATE )
538538 .setSource ("doc_type" , INVALIDATED_TOKEN_DOC_TYPE , "expiration_time" , expirationEpochMilli )
539539 .setRefreshPolicy (RefreshPolicy .WAIT_UNTIL )
@@ -577,7 +577,7 @@ private void indexInvalidation(String tokenDocId, Version version, ActionListene
577577 if (attemptCount .get () > 5 ) {
578578 listener .onFailure (invalidGrantException ("failed to invalidate token" ));
579579 } else {
580- UpdateRequest request = client .prepareUpdate (SecurityLifecycleServiceField . SECURITY_INDEX_NAME , TYPE , tokenDocId )
580+ UpdateRequest request = client .prepareUpdate (SECURITY_INDEX_NAME , TYPE , tokenDocId )
581581 .setDoc (srcPrefix , Collections .singletonMap ("invalidated" , true ))
582582 .setVersion (documentVersion )
583583 .setRefreshPolicy (RefreshPolicy .WAIT_UNTIL )
@@ -609,7 +609,7 @@ private void indexInvalidation(String tokenDocId, Version version, ActionListene
609609 || isShardNotAvailableException (cause )) {
610610 attemptCount .incrementAndGet ();
611611 executeAsyncWithOrigin (client .threadPool ().getThreadContext (), SECURITY_ORIGIN ,
612- client .prepareGet (SecurityLifecycleServiceField . SECURITY_INDEX_NAME , TYPE , tokenDocId ).request (),
612+ client .prepareGet (SECURITY_INDEX_NAME , TYPE , tokenDocId ).request (),
613613 ActionListener .<GetResponse >wrap (getResult -> {
614614 if (getResult .isExists ()) {
615615 Map <String , Object > source = getResult .getSource ();
@@ -674,7 +674,7 @@ private void findTokenFromRefreshToken(String refreshToken, ActionListener<Tuple
674674 if (attemptCount .get () > 5 ) {
675675 listener .onFailure (invalidGrantException ("could not refresh the requested token" ));
676676 } else {
677- SearchRequest request = client .prepareSearch (SecurityLifecycleServiceField . SECURITY_INDEX_NAME )
677+ SearchRequest request = client .prepareSearch (SECURITY_INDEX_NAME )
678678 .setQuery (QueryBuilders .boolQuery ()
679679 .filter (QueryBuilders .termQuery ("doc_type" , "token" ))
680680 .filter (QueryBuilders .termQuery ("refresh_token.token" , refreshToken )))
@@ -718,7 +718,7 @@ private void innerRefresh(String tokenDocId, Authentication userAuth, ActionList
718718 if (attemptCount .getAndIncrement () > 5 ) {
719719 listener .onFailure (invalidGrantException ("could not refresh the requested token" ));
720720 } else {
721- GetRequest getRequest = client .prepareGet (SecurityLifecycleServiceField . SECURITY_INDEX_NAME , TYPE , tokenDocId ).request ();
721+ GetRequest getRequest = client .prepareGet (SECURITY_INDEX_NAME , TYPE , tokenDocId ).request ();
722722 executeAsyncWithOrigin (client .threadPool ().getThreadContext (), SECURITY_ORIGIN , getRequest ,
723723 ActionListener .<GetResponse >wrap (response -> {
724724 if (response .isExists ()) {
@@ -739,7 +739,7 @@ private void innerRefresh(String tokenDocId, Authentication userAuth, ActionList
739739 in .setVersion (authVersion );
740740 Authentication authentication = new Authentication (in );
741741 UpdateRequest updateRequest =
742- client .prepareUpdate (SecurityLifecycleServiceField . SECURITY_INDEX_NAME , TYPE , tokenDocId )
742+ client .prepareUpdate (SECURITY_INDEX_NAME , TYPE , tokenDocId )
743743 .setVersion (response .getVersion ())
744744 .setDoc ("refresh_token" , Collections .singletonMap ("refreshed" , true ))
745745 .setRefreshPolicy (RefreshPolicy .WAIT_UNTIL )
@@ -854,7 +854,7 @@ public void findActiveTokensForRealm(String realmName, ActionListener<Collection
854854 .should (QueryBuilders .termQuery ("refresh_token.invalidated" , false ))
855855 );
856856
857- final SearchRequest request = client .prepareSearch (SecurityLifecycleServiceField . SECURITY_INDEX_NAME )
857+ final SearchRequest request = client .prepareSearch (SECURITY_INDEX_NAME )
858858 .setScroll (TimeValue .timeValueSeconds (10L ))
859859 .setQuery (boolQuery )
860860 .setVersion (false )
@@ -936,8 +936,8 @@ private void checkIfTokenIsRevoked(UserToken userToken, ActionListener<UserToken
936936 } else {
937937 lifecycleService .securityIndex ().prepareIndexIfNeededThenExecute (listener ::onFailure , () -> {
938938 MultiGetRequest mGetRequest = client .prepareMultiGet ()
939- .add (SecurityLifecycleServiceField . SECURITY_INDEX_NAME , TYPE , getInvalidatedTokenDocumentId (userToken ))
940- .add (SecurityLifecycleServiceField . SECURITY_INDEX_NAME , TYPE , getTokenDocumentId (userToken ))
939+ .add (SECURITY_INDEX_NAME , TYPE , getInvalidatedTokenDocumentId (userToken ))
940+ .add (SECURITY_INDEX_NAME , TYPE , getTokenDocumentId (userToken ))
941941 .request ();
942942 executeAsyncWithOrigin (client .threadPool ().getThreadContext (), SECURITY_ORIGIN ,
943943 mGetRequest ,
0 commit comments