diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/XPackPlugin.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/XPackPlugin.java index 29b65b277bc..63225b03fd2 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/XPackPlugin.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/XPackPlugin.java @@ -476,9 +476,9 @@ public class XPackPlugin extends Plugin implements ScriptPlugin, ActionPlugin, I CircuitBreakerService circuitBreakerService, NamedWriteableRegistry namedWriteableRegistry, NamedXContentRegistry xContentRegistry, - NetworkService networkService) { + NetworkService networkService, HttpServerTransport.Dispatcher dispatcher) { return security.getHttpTransports(settings, threadPool, bigArrays, circuitBreakerService, namedWriteableRegistry, xContentRegistry, - networkService); + networkService, dispatcher); } @Override diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/extensions/InstallXPackExtensionCommand.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/extensions/InstallXPackExtensionCommand.java index 092d2f72e05..d7d4100b4d7 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/extensions/InstallXPackExtensionCommand.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/extensions/InstallXPackExtensionCommand.java @@ -15,9 +15,7 @@ import org.elasticsearch.cli.EnvironmentAwareCommand; import org.elasticsearch.cli.Terminal; import org.elasticsearch.cli.UserException; import org.elasticsearch.common.io.FileSystemUtils; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; -import org.elasticsearch.node.internal.InternalSettingsPreparer; import java.io.IOException; import java.io.InputStream; @@ -29,7 +27,6 @@ import java.nio.file.Path; import java.nio.file.StandardCopyOption; import java.util.Arrays; -import java.util.Map; import java.util.List; import java.util.ArrayList; import java.util.Comparator; diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/extensions/ListXPackExtensionCommand.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/extensions/ListXPackExtensionCommand.java index 6d5a8f3b675..405fde6c40c 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/extensions/ListXPackExtensionCommand.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/extensions/ListXPackExtensionCommand.java @@ -8,9 +8,7 @@ package org.elasticsearch.xpack.extensions; import joptsimple.OptionSet; import org.elasticsearch.cli.EnvironmentAwareCommand; import org.elasticsearch.cli.Terminal; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; -import org.elasticsearch.node.internal.InternalSettingsPreparer; import java.io.IOException; import java.nio.file.DirectoryStream; @@ -19,7 +17,6 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.Map; import static org.elasticsearch.cli.Terminal.Verbosity.VERBOSE; import static org.elasticsearch.xpack.XPackPlugin.resolveXPackExtensionsFile; diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/extensions/RemoveXPackExtensionCommand.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/extensions/RemoveXPackExtensionCommand.java index 9d7a202cab0..9c34bd44163 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/extensions/RemoveXPackExtensionCommand.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/extensions/RemoveXPackExtensionCommand.java @@ -13,16 +13,13 @@ import org.elasticsearch.cli.EnvironmentAwareCommand; import org.elasticsearch.cli.Terminal; import org.elasticsearch.cli.UserException; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; -import org.elasticsearch.node.internal.InternalSettingsPreparer; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardCopyOption; import java.util.ArrayList; import java.util.List; -import java.util.Map; import static org.elasticsearch.cli.Terminal.Verbosity.VERBOSE; import static org.elasticsearch.xpack.XPackPlugin.resolveXPackExtensionsFile; diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/security/Security.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/security/Security.java index ae552465114..f2653b971ad 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/security/Security.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/security/Security.java @@ -721,13 +721,15 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin { @Override public Map> getHttpTransports(Settings settings, ThreadPool threadPool, BigArrays bigArrays, - CircuitBreakerService circuitBreakerService, NamedWriteableRegistry namedWriteableRegistry, - NamedXContentRegistry xContentRegistry, NetworkService networkService) { + CircuitBreakerService circuitBreakerService, + NamedWriteableRegistry namedWriteableRegistry, + NamedXContentRegistry xContentRegistry, + NetworkService networkService, HttpServerTransport.Dispatcher dispatcher) { if (enabled == false) { // don't register anything if we are not enabled return Collections.emptyMap(); } return Collections.singletonMap(Security.NAME4, () -> new SecurityNetty4HttpServerTransport(settings, networkService, bigArrays, - ipFilter.get(), sslService, threadPool, xContentRegistry)); + ipFilter.get(), sslService, threadPool, xContentRegistry, dispatcher)); } @Override diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/security/authc/file/tool/UsersTool.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/security/authc/file/tool/UsersTool.java index 35c5fbce33e..e27a20c7963 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/security/authc/file/tool/UsersTool.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/security/authc/file/tool/UsersTool.java @@ -16,7 +16,6 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.set.Sets; import org.elasticsearch.env.Environment; -import org.elasticsearch.node.internal.InternalSettingsPreparer; import org.elasticsearch.xpack.XPackSettings; import org.elasticsearch.xpack.security.authc.file.FileUserPasswdStore; import org.elasticsearch.xpack.security.authc.file.FileUserRolesStore; diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/security/crypto/tool/SystemKeyTool.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/security/crypto/tool/SystemKeyTool.java index eadebd105db..ff6a7756e78 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/security/crypto/tool/SystemKeyTool.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/security/crypto/tool/SystemKeyTool.java @@ -13,10 +13,8 @@ import org.elasticsearch.cli.Terminal; import org.elasticsearch.cli.UserException; import org.elasticsearch.common.SuppressForbidden; import org.elasticsearch.common.io.PathUtils; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.set.Sets; import org.elasticsearch.env.Environment; -import org.elasticsearch.node.internal.InternalSettingsPreparer; import org.elasticsearch.xpack.security.crypto.CryptoService; import java.nio.file.Files; @@ -26,7 +24,6 @@ import java.nio.file.attribute.PosixFileAttributeView; import java.nio.file.attribute.PosixFilePermission; import java.util.List; import java.util.Locale; -import java.util.Map; import java.util.Set; public class SystemKeyTool extends EnvironmentAwareCommand { diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4HttpServerTransport.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4HttpServerTransport.java index b66f622913a..c9706771627 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4HttpServerTransport.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4HttpServerTransport.java @@ -16,6 +16,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.BigArrays; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.http.netty4.Netty4HttpServerTransport; +import org.elasticsearch.rest.RestController; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.netty4.Netty4Utils; import org.elasticsearch.xpack.ssl.SSLService; @@ -35,8 +36,9 @@ public class SecurityNetty4HttpServerTransport extends Netty4HttpServerTransport private final boolean ssl; public SecurityNetty4HttpServerTransport(Settings settings, NetworkService networkService, BigArrays bigArrays, IPFilter ipFilter, - SSLService sslService, ThreadPool threadPool, NamedXContentRegistry xContentRegistry) { - super(settings, networkService, bigArrays, threadPool, xContentRegistry); + SSLService sslService, ThreadPool threadPool, NamedXContentRegistry xContentRegistry, + Dispatcher dispatcher) { + super(settings, networkService, bigArrays, threadPool, xContentRegistry, dispatcher); this.ipFilter = ipFilter; this.ssl = HTTP_SSL_ENABLED.get(settings); this.sslService = sslService; diff --git a/elasticsearch/src/test/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4HttpServerTransportTests.java b/elasticsearch/src/test/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4HttpServerTransportTests.java index 92f5cc86423..9b4fb531e74 100644 --- a/elasticsearch/src/test/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4HttpServerTransportTests.java +++ b/elasticsearch/src/test/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4HttpServerTransportTests.java @@ -57,7 +57,8 @@ public class SecurityNetty4HttpServerTransportTests extends ESTestCase { .put(XPackSettings.HTTP_SSL_ENABLED.getKey(), true).build(); sslService = new SSLService(settings, env); SecurityNetty4HttpServerTransport transport = new SecurityNetty4HttpServerTransport(settings, mock(NetworkService.class), - mock(BigArrays.class), mock(IPFilter.class), sslService, mock(ThreadPool.class), xContentRegistry()); + mock(BigArrays.class), mock(IPFilter.class), sslService, mock(ThreadPool.class), xContentRegistry(), + (request, channel, context) -> {}); Netty4HttpMockUtil.setOpenChannelsHandlerToMock(transport); ChannelHandler handler = transport.configureServerChannelHandler(); final EmbeddedChannel ch = new EmbeddedChannel(handler); @@ -73,7 +74,8 @@ public class SecurityNetty4HttpServerTransportTests extends ESTestCase { .put("xpack.security.http.ssl.client_authentication", value).build(); sslService = new SSLService(settings, env); SecurityNetty4HttpServerTransport transport = new SecurityNetty4HttpServerTransport(settings, mock(NetworkService.class), - mock(BigArrays.class), mock(IPFilter.class), sslService, mock(ThreadPool.class), xContentRegistry()); + mock(BigArrays.class), mock(IPFilter.class), sslService, mock(ThreadPool.class), xContentRegistry(), + (request, channel, context) -> {}); Netty4HttpMockUtil.setOpenChannelsHandlerToMock(transport); ChannelHandler handler = transport.configureServerChannelHandler(); final EmbeddedChannel ch = new EmbeddedChannel(handler); @@ -89,7 +91,8 @@ public class SecurityNetty4HttpServerTransportTests extends ESTestCase { .put("xpack.security.http.ssl.client_authentication", value).build(); sslService = new SSLService(settings, env); SecurityNetty4HttpServerTransport transport = new SecurityNetty4HttpServerTransport(settings, mock(NetworkService.class), - mock(BigArrays.class), mock(IPFilter.class), sslService, mock(ThreadPool.class), xContentRegistry()); + mock(BigArrays.class), mock(IPFilter.class), sslService, mock(ThreadPool.class), xContentRegistry(), + (request, channel, context) -> {}); Netty4HttpMockUtil.setOpenChannelsHandlerToMock(transport); ChannelHandler handler = transport.configureServerChannelHandler(); final EmbeddedChannel ch = new EmbeddedChannel(handler); @@ -105,7 +108,8 @@ public class SecurityNetty4HttpServerTransportTests extends ESTestCase { .put("xpack.security.http.ssl.client_authentication", value).build(); sslService = new SSLService(settings, env); SecurityNetty4HttpServerTransport transport = new SecurityNetty4HttpServerTransport(settings, mock(NetworkService.class), - mock(BigArrays.class), mock(IPFilter.class), sslService, mock(ThreadPool.class), xContentRegistry()); + mock(BigArrays.class), mock(IPFilter.class), sslService, mock(ThreadPool.class), xContentRegistry(), + (request, channel, context) -> {}); Netty4HttpMockUtil.setOpenChannelsHandlerToMock(transport); ChannelHandler handler = transport.configureServerChannelHandler(); final EmbeddedChannel ch = new EmbeddedChannel(handler); @@ -119,7 +123,8 @@ public class SecurityNetty4HttpServerTransportTests extends ESTestCase { .put(XPackSettings.HTTP_SSL_ENABLED.getKey(), true).build(); sslService = new SSLService(settings, env); SecurityNetty4HttpServerTransport transport = new SecurityNetty4HttpServerTransport(settings, mock(NetworkService.class), - mock(BigArrays.class), mock(IPFilter.class), sslService, mock(ThreadPool.class), xContentRegistry()); + mock(BigArrays.class), mock(IPFilter.class), sslService, mock(ThreadPool.class), xContentRegistry(), + (request, channel, context) -> {}); Netty4HttpMockUtil.setOpenChannelsHandlerToMock(transport); ChannelHandler handler = transport.configureServerChannelHandler(); EmbeddedChannel ch = new EmbeddedChannel(handler); @@ -132,7 +137,8 @@ public class SecurityNetty4HttpServerTransportTests extends ESTestCase { .build(); sslService = new SSLService(settings, new Environment(settings)); transport = new SecurityNetty4HttpServerTransport(settings, mock(NetworkService.class), - mock(BigArrays.class), mock(IPFilter.class), sslService, mock(ThreadPool.class), xContentRegistry()); + mock(BigArrays.class), mock(IPFilter.class), sslService, mock(ThreadPool.class), xContentRegistry(), + (request, channel, context) -> {}); Netty4HttpMockUtil.setOpenChannelsHandlerToMock(transport); handler = transport.configureServerChannelHandler(); ch = new EmbeddedChannel(handler); @@ -180,7 +186,8 @@ public class SecurityNetty4HttpServerTransportTests extends ESTestCase { env = new Environment(settings); sslService = new SSLService(settings, env); SecurityNetty4HttpServerTransport transport = new SecurityNetty4HttpServerTransport(settings, mock(NetworkService.class), - mock(BigArrays.class), mock(IPFilter.class), sslService, mock(ThreadPool.class), xContentRegistry()); + mock(BigArrays.class), mock(IPFilter.class), sslService, mock(ThreadPool.class), xContentRegistry(), + (request, channel, context) -> {}); IllegalArgumentException e = expectThrows(IllegalArgumentException.class, transport::configureServerChannelHandler); assertThat(e.getMessage(), containsString("key must be provided")); } @@ -195,7 +202,8 @@ public class SecurityNetty4HttpServerTransportTests extends ESTestCase { env = new Environment(settings); sslService = new SSLService(settings, env); SecurityNetty4HttpServerTransport transport = new SecurityNetty4HttpServerTransport(settings, mock(NetworkService.class), - mock(BigArrays.class), mock(IPFilter.class), sslService, mock(ThreadPool.class), xContentRegistry()); + mock(BigArrays.class), mock(IPFilter.class), sslService, mock(ThreadPool.class), xContentRegistry(), + (request, channel, context) -> {}); assertNotNull(transport.configureServerChannelHandler()); } }