diff --git a/server/src/internalClusterTest/java/org/opensearch/accesscontrol/resources/testplugins/TestResourcePlugin.java b/server/src/internalClusterTest/java/org/opensearch/accesscontrol/resources/testplugins/TestResourcePlugin.java index f340f6d56e221..a198d9e78f2d9 100644 --- a/server/src/internalClusterTest/java/org/opensearch/accesscontrol/resources/testplugins/TestResourcePlugin.java +++ b/server/src/internalClusterTest/java/org/opensearch/accesscontrol/resources/testplugins/TestResourcePlugin.java @@ -8,6 +8,7 @@ package org.opensearch.accesscontrol.resources.testplugins; +import org.opensearch.accesscontrol.resources.Resource; import org.opensearch.accesscontrol.resources.ResourceService; import org.opensearch.common.inject.Inject; import org.opensearch.common.lifecycle.Lifecycle; @@ -77,7 +78,7 @@ public void stop() {} } - public static class TestResource { + public static class TestResource implements Resource { public String id; public String name; diff --git a/server/src/main/java/org/opensearch/accesscontrol/resources/Resource.java b/server/src/main/java/org/opensearch/accesscontrol/resources/Resource.java new file mode 100644 index 0000000000000..376aceed80548 --- /dev/null +++ b/server/src/main/java/org/opensearch/accesscontrol/resources/Resource.java @@ -0,0 +1,14 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.accesscontrol.resources; + +/** + * Marker interface for all resources + */ +public interface Resource {} diff --git a/server/src/main/java/org/opensearch/accesscontrol/resources/fallback/DefaultResourceAccessControlPlugin.java b/server/src/main/java/org/opensearch/accesscontrol/resources/fallback/DefaultResourceAccessControlPlugin.java index 246de3763aed6..2efc519e05852 100644 --- a/server/src/main/java/org/opensearch/accesscontrol/resources/fallback/DefaultResourceAccessControlPlugin.java +++ b/server/src/main/java/org/opensearch/accesscontrol/resources/fallback/DefaultResourceAccessControlPlugin.java @@ -13,6 +13,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.opensearch.OpenSearchException; +import org.opensearch.accesscontrol.resources.Resource; import org.opensearch.action.search.ClearScrollRequest; import org.opensearch.action.search.SearchRequest; import org.opensearch.action.search.SearchResponse; @@ -66,7 +67,7 @@ public DefaultResourceAccessControlPlugin(Client client, ThreadPool threadPool) * @return Set of resource ids */ @Override - public Set getAccessibleResourcesForCurrentUser(String resourceIndex, Class clazz) { + public Set getAccessibleResourcesForCurrentUser(String resourceIndex, Class clazz) { final Set documents = new HashSet<>(); final TimeValue scrollTimeout = TimeValue.timeValueMinutes(1); String scrollId; diff --git a/server/src/main/java/org/opensearch/plugins/ResourceAccessControlPlugin.java b/server/src/main/java/org/opensearch/plugins/ResourceAccessControlPlugin.java index ebdff187691b9..663f786323b6b 100644 --- a/server/src/main/java/org/opensearch/plugins/ResourceAccessControlPlugin.java +++ b/server/src/main/java/org/opensearch/plugins/ResourceAccessControlPlugin.java @@ -9,6 +9,7 @@ package org.opensearch.plugins; import org.opensearch.accesscontrol.resources.EntityType; +import org.opensearch.accesscontrol.resources.Resource; import org.opensearch.accesscontrol.resources.ResourceSharing; import org.opensearch.accesscontrol.resources.ShareWith; @@ -27,10 +28,10 @@ public interface ResourceAccessControlPlugin { /** * Returns all accessible resources for current user for a given plugin index. * @param resourceIndex index where the resource exists - * @param clazz class of the resource. Required to parse the resource object retrieved from resourceIndex + * @param clazz class of the resource. Required to parse the resource object retrieved from resourceIndex. Must be a type of {@link Resource} * @return set of {@link ResourceSharing} items accessible by current user. */ - default Set getAccessibleResourcesForCurrentUser(String resourceIndex, Class clazz) { + default Set getAccessibleResourcesForCurrentUser(String resourceIndex, Class clazz) { return Set.of(); }