|
26 | 26 | import org.opensearch.security.configuration.AdminDNs;
|
27 | 27 | import org.opensearch.security.spi.resources.ShareableResource;
|
28 | 28 | import org.opensearch.security.spi.resources.ShareableResourceParser;
|
| 29 | +import org.opensearch.security.spi.resources.exceptions.ResourceNotFoundException; |
29 | 30 | import org.opensearch.security.spi.resources.exceptions.ResourceSharingException;
|
| 31 | +import org.opensearch.security.spi.resources.exceptions.UnauthenticatedResourceAccessException; |
| 32 | +import org.opensearch.security.spi.resources.exceptions.UnauthorizedResourceAccessException; |
30 | 33 | import org.opensearch.security.spi.resources.sharing.Recipient;
|
31 | 34 | import org.opensearch.security.spi.resources.sharing.RecipientType;
|
32 | 35 | import org.opensearch.security.spi.resources.sharing.RecipientTypeRegistry;
|
@@ -250,7 +253,7 @@ public void hasPermission(String resourceId, String resourceIndex, Set<String> s
|
250 | 253 | if (document == null) {
|
251 | 254 | LOGGER.warn("ShareableResource '{}' not found in index '{}'", resourceId, resourceIndex);
|
252 | 255 | listener.onFailure(
|
253 |
| - new ResourceSharingException("ShareableResource " + resourceId + " not found in index " + resourceIndex) |
| 256 | + new ResourceNotFoundException("ShareableResource " + resourceId + " not found in index " + resourceIndex) |
254 | 257 | );
|
255 | 258 | return;
|
256 | 259 | }
|
@@ -299,7 +302,9 @@ public void shareWith(String resourceId, String resourceIndex, ShareWith shareWi
|
299 | 302 |
|
300 | 303 | if (user == null) {
|
301 | 304 | LOGGER.warn("No authenticated user found. Failed to share resource {}", resourceId);
|
302 |
| - listener.onFailure(new ResourceSharingException("No authenticated user found. Failed to share resource " + resourceId)); |
| 305 | + listener.onFailure( |
| 306 | + new UnauthenticatedResourceAccessException("No authenticated user found. Failed to share resource " + resourceId) |
| 307 | + ); |
303 | 308 | return;
|
304 | 309 | }
|
305 | 310 |
|
@@ -349,7 +354,7 @@ public void revokeAccess(
|
349 | 354 | if (user == null) {
|
350 | 355 | LOGGER.warn("No authenticated user found. Failed to revoker access to resource {}", resourceId);
|
351 | 356 | listener.onFailure(
|
352 |
| - new ResourceSharingException("No authenticated user found. Failed to revoke access to resource {}" + resourceId) |
| 357 | + new UnauthorizedResourceAccessException("No authenticated user found. Failed to revoke access to resource {}" + resourceId) |
353 | 358 | );
|
354 | 359 | return;
|
355 | 360 | }
|
@@ -407,7 +412,7 @@ public void deleteAllResourceSharingRecordsForCurrentUser(ActionListener<Boolean
|
407 | 412 | final User user = (userSubject == null) ? null : userSubject.getUser();
|
408 | 413 |
|
409 | 414 | if (user == null) {
|
410 |
| - listener.onFailure(new ResourceSharingException("No authenticated user available.")); |
| 415 | + listener.onFailure(new UnauthenticatedResourceAccessException("No authenticated user available.")); |
411 | 416 | return;
|
412 | 417 | }
|
413 | 418 |
|
|
0 commit comments