|
12 | 12 | import org.elasticsearch.action.search.SearchRequest;
|
13 | 13 | import org.elasticsearch.action.support.ContextPreservingActionListener;
|
14 | 14 | import org.elasticsearch.client.Client;
|
| 15 | +import org.elasticsearch.cluster.health.ClusterHealthStatus; |
15 | 16 | import org.elasticsearch.cluster.health.ClusterIndexHealth;
|
16 | 17 | import org.elasticsearch.common.CheckedBiConsumer;
|
17 | 18 | import org.elasticsearch.common.bytes.BytesReference;
|
|
38 | 39 | import org.elasticsearch.xpack.security.SecurityLifecycleService;
|
39 | 40 | import org.elasticsearch.xpack.security.authc.support.CachingUsernamePasswordRealm;
|
40 | 41 | import org.elasticsearch.xpack.security.authc.support.UserRoleMapper;
|
| 42 | +import org.elasticsearch.xpack.security.support.SecurityIndexManager; |
41 | 43 |
|
42 | 44 | import java.io.IOException;
|
43 | 45 | import java.io.InputStream;
|
|
61 | 63 | import static org.elasticsearch.xpack.core.ClientHelper.executeAsyncWithOrigin;
|
62 | 64 | import static org.elasticsearch.xpack.core.ClientHelper.stashWithOrigin;
|
63 | 65 | import static org.elasticsearch.xpack.security.SecurityLifecycleService.SECURITY_INDEX_NAME;
|
64 |
| -import static org.elasticsearch.xpack.security.SecurityLifecycleService.isIndexDeleted; |
65 |
| -import static org.elasticsearch.xpack.security.SecurityLifecycleService.isMoveFromRedToNonRed; |
| 66 | +import static org.elasticsearch.xpack.security.support.SecurityIndexManager.isIndexDeleted; |
| 67 | +import static org.elasticsearch.xpack.security.support.SecurityIndexManager.isMoveFromRedToNonRed; |
66 | 68 |
|
67 | 69 | /**
|
68 | 70 | * This store reads + writes {@link ExpressionRoleMapping role mappings} in an Elasticsearch
|
@@ -316,17 +318,13 @@ private void reportStats(ActionListener<Map<String, Object>> listener, List<Expr
|
316 | 318 | listener.onResponse(usageStats);
|
317 | 319 | }
|
318 | 320 |
|
319 |
| - public void onSecurityIndexHealthChange(ClusterIndexHealth previousHealth, ClusterIndexHealth currentHealth) { |
320 |
| - if (isMoveFromRedToNonRed(previousHealth, currentHealth) || isIndexDeleted(previousHealth, currentHealth)) { |
| 321 | + public void onSecurityIndexStateChange(SecurityIndexManager.State previousState, SecurityIndexManager.State currentState) { |
| 322 | + if (isMoveFromRedToNonRed(previousState, currentState) || isIndexDeleted(previousState, currentState) || |
| 323 | + previousState.isIndexUpToDate != currentState.isIndexUpToDate) { |
321 | 324 | refreshRealms(NO_OP_ACTION_LISTENER, null);
|
322 | 325 | }
|
323 | 326 | }
|
324 | 327 |
|
325 |
| - public void onSecurityIndexOutOfDateChange(boolean prevOutOfDate, boolean outOfDate) { |
326 |
| - assert prevOutOfDate != outOfDate : "this method should only be called if the two values are different"; |
327 |
| - refreshRealms(NO_OP_ACTION_LISTENER, null); |
328 |
| - } |
329 |
| - |
330 | 328 | private <Result> void refreshRealms(ActionListener<Result> listener, Result result) {
|
331 | 329 | String[] realmNames = this.realmsToRefresh.toArray(new String[realmsToRefresh.size()]);
|
332 | 330 | final SecurityClient securityClient = new SecurityClient(client);
|
|
0 commit comments