|
58 | 58 | import java.util.stream.Collectors;
|
59 | 59 | import java.util.stream.Stream;
|
60 | 60 |
|
| 61 | +import com.google.common.annotations.VisibleForTesting; |
61 | 62 | import com.google.common.collect.Lists;
|
62 | 63 | import org.apache.commons.lang3.StringUtils;
|
63 | 64 | import org.apache.logging.log4j.LogManager;
|
@@ -300,6 +301,7 @@ public final class OpenSearchSecurityPlugin extends OpenSearchSecuritySSLPlugin
|
300 | 301 | private volatile PasswordHasher passwordHasher;
|
301 | 302 | private volatile DlsFlsBaseContext dlsFlsBaseContext;
|
302 | 303 | private ResourceSharingIndexManagementRepository resourceSharingIndexManagementRepository;
|
| 304 | + private static final ResourcePluginInfo resourcePluginInfo = new ResourcePluginInfo(); |
303 | 305 |
|
304 | 306 | public static boolean isActionTraceEnabled() {
|
305 | 307 |
|
@@ -771,7 +773,7 @@ public void onIndexModule(IndexModule indexModule) {
|
771 | 773 | if (settings.getAsBoolean(
|
772 | 774 | ConfigConstants.OPENSEARCH_RESOURCE_SHARING_ENABLED,
|
773 | 775 | ConfigConstants.OPENSEARCH_RESOURCE_SHARING_ENABLED_DEFAULT
|
774 |
| - ) && ResourcePluginInfo.getInstance().getResourceIndices().contains(indexModule.getIndex().getName())) { |
| 776 | + ) && resourcePluginInfo.getResourceIndices().contains(indexModule.getIndex().getName())) { |
775 | 777 | indexModule.addIndexOperationListener(resourceIndexListener);
|
776 | 778 | log.info("Security plugin started listening to operations on resource-index {}", indexModule.getIndex().getName());
|
777 | 779 | }
|
@@ -1182,7 +1184,8 @@ public Collection<Object> createComponents(
|
1182 | 1184 |
|
1183 | 1185 | final var resourceSharingIndex = ResourceSharingConstants.OPENSEARCH_RESOURCE_SHARING_INDEX;
|
1184 | 1186 | ResourceSharingIndexHandler rsIndexHandler = new ResourceSharingIndexHandler(resourceSharingIndex, localClient, threadPool);
|
1185 |
| - ResourceAccessHandler resourceAccessHandler = new ResourceAccessHandler(threadPool, rsIndexHandler, adminDns); |
| 1187 | + |
| 1188 | + ResourceAccessHandler resourceAccessHandler = new ResourceAccessHandler(threadPool, rsIndexHandler, adminDns, resourcePluginInfo); |
1186 | 1189 | // Resource Sharing index is enabled by default
|
1187 | 1190 | boolean isResourceSharingEnabled = settings.getAsBoolean(
|
1188 | 1191 | ConfigConstants.OPENSEARCH_RESOURCE_SHARING_ENABLED,
|
@@ -2320,12 +2323,17 @@ public void loadExtensions(ExtensiblePlugin.ExtensionLoader loader) {
|
2320 | 2323 | resourceProviders.put(resourceIndexName, resourceProvider);
|
2321 | 2324 | log.info("Loaded resource sharing extension: {}, index: {}", resourceType, resourceIndexName);
|
2322 | 2325 | }
|
2323 |
| - ResourcePluginInfo.getInstance().setResourceIndices(resourceIndices); |
2324 |
| - ResourcePluginInfo.getInstance().setResourceProviders(resourceProviders); |
| 2326 | + resourcePluginInfo.setResourceIndices(resourceIndices); |
| 2327 | + resourcePluginInfo.setResourceProviders(resourceProviders); |
2325 | 2328 | }
|
2326 | 2329 | }
|
2327 | 2330 | // CS-ENFORCE-SINGLE
|
2328 | 2331 |
|
| 2332 | + @VisibleForTesting |
| 2333 | + public static ResourcePluginInfo getResourcePluginInfo() { |
| 2334 | + return resourcePluginInfo; |
| 2335 | + } |
| 2336 | + |
2329 | 2337 | public static class GuiceHolder implements LifecycleComponent {
|
2330 | 2338 |
|
2331 | 2339 | private static RepositoriesService repositoriesService;
|
|
0 commit comments