68
68
import org .elasticsearch .xpack .core .XPackField ;
69
69
import org .elasticsearch .xpack .core .XPackSettings ;
70
70
import org .elasticsearch .xpack .core .security .ScrollHelper ;
71
- import org .elasticsearch .xpack .core .security .SecurityLifecycleServiceField ;
72
71
import org .elasticsearch .xpack .core .security .authc .Authentication ;
73
72
import org .elasticsearch .xpack .core .security .authc .KeyAndTimestamp ;
74
73
import org .elasticsearch .xpack .core .security .authc .TokenMetaData ;
118
117
import static org .elasticsearch .gateway .GatewayService .STATE_NOT_RECOVERED_BLOCK ;
119
118
import static org .elasticsearch .xpack .core .ClientHelper .SECURITY_ORIGIN ;
120
119
import static org .elasticsearch .xpack .core .ClientHelper .executeAsyncWithOrigin ;
120
+ import static org .elasticsearch .xpack .security .SecurityLifecycleService .SECURITY_INDEX_NAME ;
121
121
122
122
/**
123
123
* Service responsible for the creation, validation, and other management of {@link UserToken}
@@ -256,7 +256,7 @@ public void createUserToken(Authentication authentication, Authentication origin
256
256
.endObject ();
257
257
builder .endObject ();
258
258
IndexRequest request =
259
- client .prepareIndex (SecurityLifecycleServiceField . SECURITY_INDEX_NAME , TYPE , getTokenDocumentId (userToken ))
259
+ client .prepareIndex (SECURITY_INDEX_NAME , TYPE , getTokenDocumentId (userToken ))
260
260
.setOpType (OpType .CREATE )
261
261
.setSource (builder )
262
262
.setRefreshPolicy (RefreshPolicy .WAIT_UNTIL )
@@ -372,7 +372,7 @@ void decodeToken(String token, ActionListener<UserToken> listener) throws IOExce
372
372
decryptTokenId (in , cipher , version , ActionListener .wrap (tokenId ->
373
373
lifecycleService .securityIndex ().prepareIndexIfNeededThenExecute (listener ::onFailure , () -> {
374
374
final GetRequest getRequest =
375
- client .prepareGet (SecurityLifecycleServiceField . SECURITY_INDEX_NAME , TYPE ,
375
+ client .prepareGet (SECURITY_INDEX_NAME , TYPE ,
376
376
getTokenDocumentId (tokenId )).request ();
377
377
executeAsyncWithOrigin (client .threadPool ().getThreadContext (), SECURITY_ORIGIN , getRequest ,
378
378
ActionListener .<GetResponse >wrap (response -> {
@@ -533,7 +533,7 @@ private void indexBwcInvalidation(UserToken userToken, ActionListener<Boolean> l
533
533
listener .onFailure (invalidGrantException ("failed to invalidate token" ));
534
534
} else {
535
535
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 )
537
537
.setOpType (OpType .CREATE )
538
538
.setSource ("doc_type" , INVALIDATED_TOKEN_DOC_TYPE , "expiration_time" , expirationEpochMilli )
539
539
.setRefreshPolicy (RefreshPolicy .WAIT_UNTIL )
@@ -577,7 +577,7 @@ private void indexInvalidation(String tokenDocId, Version version, ActionListene
577
577
if (attemptCount .get () > 5 ) {
578
578
listener .onFailure (invalidGrantException ("failed to invalidate token" ));
579
579
} else {
580
- UpdateRequest request = client .prepareUpdate (SecurityLifecycleServiceField . SECURITY_INDEX_NAME , TYPE , tokenDocId )
580
+ UpdateRequest request = client .prepareUpdate (SECURITY_INDEX_NAME , TYPE , tokenDocId )
581
581
.setDoc (srcPrefix , Collections .singletonMap ("invalidated" , true ))
582
582
.setVersion (documentVersion )
583
583
.setRefreshPolicy (RefreshPolicy .WAIT_UNTIL )
@@ -609,7 +609,7 @@ private void indexInvalidation(String tokenDocId, Version version, ActionListene
609
609
|| isShardNotAvailableException (cause )) {
610
610
attemptCount .incrementAndGet ();
611
611
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 (),
613
613
ActionListener .<GetResponse >wrap (getResult -> {
614
614
if (getResult .isExists ()) {
615
615
Map <String , Object > source = getResult .getSource ();
@@ -674,7 +674,7 @@ private void findTokenFromRefreshToken(String refreshToken, ActionListener<Tuple
674
674
if (attemptCount .get () > 5 ) {
675
675
listener .onFailure (invalidGrantException ("could not refresh the requested token" ));
676
676
} else {
677
- SearchRequest request = client .prepareSearch (SecurityLifecycleServiceField . SECURITY_INDEX_NAME )
677
+ SearchRequest request = client .prepareSearch (SECURITY_INDEX_NAME )
678
678
.setQuery (QueryBuilders .boolQuery ()
679
679
.filter (QueryBuilders .termQuery ("doc_type" , "token" ))
680
680
.filter (QueryBuilders .termQuery ("refresh_token.token" , refreshToken )))
@@ -718,7 +718,7 @@ private void innerRefresh(String tokenDocId, Authentication userAuth, ActionList
718
718
if (attemptCount .getAndIncrement () > 5 ) {
719
719
listener .onFailure (invalidGrantException ("could not refresh the requested token" ));
720
720
} else {
721
- GetRequest getRequest = client .prepareGet (SecurityLifecycleServiceField . SECURITY_INDEX_NAME , TYPE , tokenDocId ).request ();
721
+ GetRequest getRequest = client .prepareGet (SECURITY_INDEX_NAME , TYPE , tokenDocId ).request ();
722
722
executeAsyncWithOrigin (client .threadPool ().getThreadContext (), SECURITY_ORIGIN , getRequest ,
723
723
ActionListener .<GetResponse >wrap (response -> {
724
724
if (response .isExists ()) {
@@ -739,7 +739,7 @@ private void innerRefresh(String tokenDocId, Authentication userAuth, ActionList
739
739
in .setVersion (authVersion );
740
740
Authentication authentication = new Authentication (in );
741
741
UpdateRequest updateRequest =
742
- client .prepareUpdate (SecurityLifecycleServiceField . SECURITY_INDEX_NAME , TYPE , tokenDocId )
742
+ client .prepareUpdate (SECURITY_INDEX_NAME , TYPE , tokenDocId )
743
743
.setVersion (response .getVersion ())
744
744
.setDoc ("refresh_token" , Collections .singletonMap ("refreshed" , true ))
745
745
.setRefreshPolicy (RefreshPolicy .WAIT_UNTIL )
@@ -854,7 +854,7 @@ public void findActiveTokensForRealm(String realmName, ActionListener<Collection
854
854
.should (QueryBuilders .termQuery ("refresh_token.invalidated" , false ))
855
855
);
856
856
857
- final SearchRequest request = client .prepareSearch (SecurityLifecycleServiceField . SECURITY_INDEX_NAME )
857
+ final SearchRequest request = client .prepareSearch (SECURITY_INDEX_NAME )
858
858
.setScroll (TimeValue .timeValueSeconds (10L ))
859
859
.setQuery (boolQuery )
860
860
.setVersion (false )
@@ -936,8 +936,8 @@ private void checkIfTokenIsRevoked(UserToken userToken, ActionListener<UserToken
936
936
} else {
937
937
lifecycleService .securityIndex ().prepareIndexIfNeededThenExecute (listener ::onFailure , () -> {
938
938
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 ))
941
941
.request ();
942
942
executeAsyncWithOrigin (client .threadPool ().getThreadContext (), SECURITY_ORIGIN ,
943
943
mGetRequest ,
0 commit comments