4646import org .elasticsearch .rest .RestStatus ;
4747import org .elasticsearch .threadpool .Scheduler ;
4848import org .elasticsearch .xcontent .XContentType ;
49- import org .elasticsearch .xpack .core .security .authc .support .mapper .ExpressionRoleMapping ;
5049import org .elasticsearch .xpack .core .security .authz .RoleMappingMetadata ;
5150import org .elasticsearch .xpack .security .SecurityFeatures ;
5251import org .elasticsearch .xpack .security .action .rolemapping .ReservedRoleMappingAction ;
@@ -288,11 +287,12 @@ public void clusterChanged(ClusterChangedEvent event) {
288287 Tuple <Boolean , Boolean > available = checkIndexAvailable (event .state ());
289288 final boolean indexAvailableForWrite = available .v1 ();
290289 final boolean indexAvailableForSearch = available .v2 ();
291- final Set <ExpressionRoleMapping > reservedStateRoleMappings = RoleMappingMetadata .getFromClusterState (event .state ())
292- .getRoleMappings ();
293- final boolean clusterStateRoleMappingsSynced = reservedStateRoleMappings .size () == ReservedRoleMappingAction
294- .getFileSettingsMetadataHandlerRoleMappingKeys (event .state ())
295- .size ();
290+ final Set <String > reservedStateRoleMappingNames = ReservedRoleMappingAction .getFileSettingsMetadataHandlerRoleMappingKeys (
291+ event .state ()
292+ );
293+ final boolean clusterStateRoleMappingsSynced = reservedStateRoleMappingNames .size () == RoleMappingMetadata .getFromClusterState (
294+ event .state ()
295+ ).getRoleMappings ().size ();
296296 final boolean mappingIsUpToDate = indexMetadata == null || checkIndexMappingUpToDate (event .state ());
297297 final int migrationsVersion = getMigrationVersionFromIndexMetadata (indexMetadata );
298298 final SystemIndexDescriptor .MappingsVersion minClusterMappingVersion = getMinSecurityIndexMappingVersion (event .state ());
@@ -334,7 +334,7 @@ public void clusterChanged(ClusterChangedEvent event) {
334334 allSecurityFeatures .stream ()
335335 .filter (feature -> featureService .clusterHasFeature (event .state (), feature ))
336336 .collect (Collectors .toSet ()),
337- reservedStateRoleMappings
337+ reservedStateRoleMappingNames
338338 );
339339 this .state = newState ;
340340
@@ -345,8 +345,8 @@ public void clusterChanged(ClusterChangedEvent event) {
345345 }
346346 }
347347
348- public Set <ExpressionRoleMapping > getReservedStateRoleMappings () {
349- return state .reservedStateRoleMappings ;
348+ public Set <String > getReservedStateRoleMappingNames () {
349+ return state .reservedStateRoleMappingNames ;
350350 }
351351
352352 public static int getMigrationVersionFromIndexMetadata (IndexMetadata indexMetadata ) {
@@ -715,7 +715,7 @@ public static class State {
715715 public final IndexMetadata .State indexState ;
716716 public final String indexUUID ;
717717 public final Set <NodeFeature > securityFeatures ;
718- public final Set <ExpressionRoleMapping > reservedStateRoleMappings ;
718+ public final Set <String > reservedStateRoleMappingNames ;
719719
720720 public State (
721721 Instant creationTime ,
@@ -733,7 +733,7 @@ public State(
733733 IndexMetadata .State indexState ,
734734 String indexUUID ,
735735 Set <NodeFeature > securityFeatures ,
736- Set <ExpressionRoleMapping > reservedStateRoleMappings
736+ Set <String > reservedStateRoleMappingNames
737737 ) {
738738 this .creationTime = creationTime ;
739739 this .isIndexUpToDate = isIndexUpToDate ;
@@ -750,7 +750,7 @@ public State(
750750 this .indexState = indexState ;
751751 this .indexUUID = indexUUID ;
752752 this .securityFeatures = securityFeatures ;
753- this .reservedStateRoleMappings = reservedStateRoleMappings ;
753+ this .reservedStateRoleMappingNames = reservedStateRoleMappingNames ;
754754 }
755755
756756 @ Override
@@ -772,7 +772,7 @@ public boolean equals(Object o) {
772772 && indexHealth == state .indexHealth
773773 && indexState == state .indexState
774774 && Objects .equals (securityFeatures , state .securityFeatures )
775- && Objects .equals (reservedStateRoleMappings , state .reservedStateRoleMappings );
775+ && Objects .equals (reservedStateRoleMappingNames , state .reservedStateRoleMappingNames );
776776 }
777777
778778 public boolean indexExists () {
@@ -795,7 +795,7 @@ public int hashCode() {
795795 concreteIndexName ,
796796 indexHealth ,
797797 securityFeatures ,
798- reservedStateRoleMappings
798+ reservedStateRoleMappingNames
799799 );
800800 }
801801
@@ -835,7 +835,7 @@ public String toString() {
835835 + ", securityFeatures="
836836 + securityFeatures
837837 + ", reservedStateRoleMappingNames=["
838- + Arrays .toString (reservedStateRoleMappings . stream (). map ( ExpressionRoleMapping :: getName ) .toArray (String []::new ))
838+ + Arrays .toString (reservedStateRoleMappingNames .toArray (String []::new ))
839839 + "]"
840840 + '}' ;
841841 }
0 commit comments