Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Rename] ElasticsearchSecurityException class in server module #170

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -208,13 +208,13 @@ public <Request extends ActionRequest, Response extends ActionResponse> void app
}
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -740,8 +740,8 @@ private enum ElasticsearchExceptionHandle {
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(OpenSearchSecurityException.class,
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,39 +26,39 @@
/**
* 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

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;
Expand Down Expand Up @@ -124,7 +124,7 @@ public void handleResponse(TransportResponse.Empty response) {

@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);
}
Expand All @@ -140,7 +140,7 @@ private void removeBanOnNodes(CancellableTask task, Collection<DiscoveryNode> ch
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);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ public void testWriteThrowable() throws IOException {
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),
Expand Down Expand Up @@ -647,8 +647,8 @@ public RestStatus status() {
}

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());
}
Expand Down Expand Up @@ -678,7 +678,7 @@ public void testIds() {
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, 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);
Expand Down