diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexFromRemoteWithAuthTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexFromRemoteWithAuthTests.java index 74033cda742..585809a7444 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexFromRemoteWithAuthTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexFromRemoteWithAuthTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.index.reindex; import org.apache.lucene.util.SetOnce; -import org.elasticsearch.ElasticsearchSecurityException; +import org.elasticsearch.OpenSearchSecurityException; import org.elasticsearch.ElasticsearchStatusException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionRequest; @@ -208,13 +208,13 @@ public class ReindexFromRemoteWithAuthTests extends ESSingleNodeTestCase { } String auth = context.getHeader(AUTHORIZATION_HEADER); if (auth == null) { - ElasticsearchSecurityException e = new ElasticsearchSecurityException("Authentication required", + OpenSearchSecurityException e = new OpenSearchSecurityException("Authentication required", RestStatus.UNAUTHORIZED); e.addHeader("WWW-Authenticate", "Basic realm=auth-realm"); throw e; } if (false == REQUIRED_AUTH.equals(auth)) { - throw new ElasticsearchSecurityException("Bad Authorization", RestStatus.FORBIDDEN); + throw new OpenSearchSecurityException("Bad Authorization", RestStatus.FORBIDDEN); } chain.proceed(task, action, request, listener); } diff --git a/server/src/main/java/org/elasticsearch/OpenSearchException.java b/server/src/main/java/org/elasticsearch/OpenSearchException.java index e2fa896de3e..1be5877b609 100644 --- a/server/src/main/java/org/elasticsearch/OpenSearchException.java +++ b/server/src/main/java/org/elasticsearch/OpenSearchException.java @@ -740,8 +740,8 @@ public class OpenSearchException extends RuntimeException implements ToXContentF org.elasticsearch.common.util.CancellableThreads.ExecutionCancelledException::new, 2, UNKNOWN_VERSION_ADDED), MASTER_NOT_DISCOVERED_EXCEPTION(org.elasticsearch.discovery.MasterNotDiscoveredException.class, org.elasticsearch.discovery.MasterNotDiscoveredException::new, 3, UNKNOWN_VERSION_ADDED), - ELASTICSEARCH_SECURITY_EXCEPTION(org.elasticsearch.ElasticsearchSecurityException.class, - org.elasticsearch.ElasticsearchSecurityException::new, 4, UNKNOWN_VERSION_ADDED), + ELASTICSEARCH_SECURITY_EXCEPTION(org.elasticsearch.OpenSearchSecurityException.class, + org.elasticsearch.OpenSearchSecurityException::new, 4, UNKNOWN_VERSION_ADDED), INDEX_SHARD_RESTORE_EXCEPTION(org.elasticsearch.index.snapshots.IndexShardRestoreException.class, org.elasticsearch.index.snapshots.IndexShardRestoreException::new, 5, UNKNOWN_VERSION_ADDED), INDEX_CLOSED_EXCEPTION(org.elasticsearch.indices.IndexClosedException.class, diff --git a/server/src/main/java/org/elasticsearch/ElasticsearchSecurityException.java b/server/src/main/java/org/elasticsearch/OpenSearchSecurityException.java similarity index 75% rename from server/src/main/java/org/elasticsearch/ElasticsearchSecurityException.java rename to server/src/main/java/org/elasticsearch/OpenSearchSecurityException.java index 0cf5fb474e0..b8708a23c71 100644 --- a/server/src/main/java/org/elasticsearch/ElasticsearchSecurityException.java +++ b/server/src/main/java/org/elasticsearch/OpenSearchSecurityException.java @@ -26,39 +26,39 @@ import java.io.IOException; /** * Generic security exception */ -public class ElasticsearchSecurityException extends ElasticsearchStatusException { +public class OpenSearchSecurityException extends ElasticsearchStatusException { /** * Build the exception with a specific status and cause. */ - public ElasticsearchSecurityException(String msg, RestStatus status, Throwable cause, Object... args) { + public OpenSearchSecurityException(String msg, RestStatus status, Throwable cause, Object... args) { super(msg, status, cause, args); } /** * Build the exception with the status derived from the cause. */ - public ElasticsearchSecurityException(String msg, Exception cause, Object... args) { + public OpenSearchSecurityException(String msg, Exception cause, Object... args) { this(msg, ExceptionsHelper.status(cause), cause, args); } /** * Build the exception with a status of {@link RestStatus#INTERNAL_SERVER_ERROR} without a cause. */ - public ElasticsearchSecurityException(String msg, Object... args) { + public OpenSearchSecurityException(String msg, Object... args) { this(msg, RestStatus.INTERNAL_SERVER_ERROR, args); } /** * Build the exception without a cause. */ - public ElasticsearchSecurityException(String msg, RestStatus status, Object... args) { + public OpenSearchSecurityException(String msg, RestStatus status, Object... args) { super(msg, status, args); } /** * Read from a stream. */ - public ElasticsearchSecurityException(StreamInput in) throws IOException { + public OpenSearchSecurityException(StreamInput in) throws IOException { super(in); } } diff --git a/server/src/main/java/org/elasticsearch/tasks/TaskCancellationService.java b/server/src/main/java/org/elasticsearch/tasks/TaskCancellationService.java index 6ab511d3de3..69dbc9916da 100644 --- a/server/src/main/java/org/elasticsearch/tasks/TaskCancellationService.java +++ b/server/src/main/java/org/elasticsearch/tasks/TaskCancellationService.java @@ -21,7 +21,7 @@ package org.elasticsearch.tasks; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.elasticsearch.ElasticsearchSecurityException; +import org.elasticsearch.OpenSearchSecurityException; import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; @@ -124,7 +124,7 @@ public class TaskCancellationService { @Override public void handleException(TransportException exp) { - assert ExceptionsHelper.unwrapCause(exp) instanceof ElasticsearchSecurityException == false; + assert ExceptionsHelper.unwrapCause(exp) instanceof OpenSearchSecurityException == false; logger.warn("Cannot send ban for tasks with the parent [{}] to the node [{}]", taskId, node); groupedListener.onFailure(exp); } @@ -140,7 +140,7 @@ public class TaskCancellationService { transportService.sendRequest(node, BAN_PARENT_ACTION_NAME, request, new EmptyTransportResponseHandler(ThreadPool.Names.SAME) { @Override public void handleException(TransportException exp) { - assert ExceptionsHelper.unwrapCause(exp) instanceof ElasticsearchSecurityException == false; + assert ExceptionsHelper.unwrapCause(exp) instanceof OpenSearchSecurityException == false; logger.info("failed to remove the parent ban for task {} on node {}", request.parentTaskId, node); } }); diff --git a/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java b/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java index 9baae64937a..ad15af168e4 100644 --- a/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java +++ b/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java @@ -559,7 +559,7 @@ public class ExceptionSerializationTests extends ESTestCase { new IllegalArgumentException("alalaal"), new NullPointerException("boom"), new EOFException("dadada"), - new ElasticsearchSecurityException("nono!"), + new OpenSearchSecurityException("nono!"), new NumberFormatException("not a number"), new CorruptIndexException("baaaam booom", "this is my resource"), new IndexFormatTooNewException("tooo new", 1, 2, 3), @@ -647,8 +647,8 @@ public class ExceptionSerializationTests extends ESTestCase { } public void testElasticsearchSecurityException() throws IOException { - ElasticsearchSecurityException ex = new ElasticsearchSecurityException("user [{}] is not allowed", RestStatus.UNAUTHORIZED, "foo"); - ElasticsearchSecurityException e = serialize(ex); + OpenSearchSecurityException ex = new OpenSearchSecurityException("user [{}] is not allowed", RestStatus.UNAUTHORIZED, "foo"); + OpenSearchSecurityException e = serialize(ex); assertEquals(ex.status(), e.status()); assertEquals(RestStatus.UNAUTHORIZED, e.status()); } @@ -678,7 +678,7 @@ public class ExceptionSerializationTests extends ESTestCase { ids.put(1, org.elasticsearch.search.dfs.DfsPhaseExecutionException.class); ids.put(2, org.elasticsearch.common.util.CancellableThreads.ExecutionCancelledException.class); ids.put(3, org.elasticsearch.discovery.MasterNotDiscoveredException.class); - ids.put(4, org.elasticsearch.ElasticsearchSecurityException.class); + ids.put(4, org.elasticsearch.OpenSearchSecurityException.class); ids.put(5, org.elasticsearch.index.snapshots.IndexShardRestoreException.class); ids.put(6, org.elasticsearch.indices.IndexClosedException.class); ids.put(7, org.elasticsearch.http.BindHttpException.class);