Updated Branches: refs/heads/master f95326ec9 -> 35c4f8296
CAMEL-6424: camel-netty-http added support for basic auth. Work in progress. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/4fbc8a77 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4fbc8a77 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4fbc8a77 Branch: refs/heads/master Commit: 4fbc8a772664e5850395c3a1c8c3a999a21417ab Parents: f95326e Author: Claus Ibsen <davscl...@apache.org> Authored: Mon Jul 15 14:30:49 2013 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Mon Jul 15 14:45:20 2013 +0200 ---------------------------------------------------------------------- components/camel-netty-http/pom.xml | 4 +- .../ConstraintMappingContextPathMatcher.java | 20 ++++- .../netty/http/NettyHttpComponent.java | 26 ++++-- .../component/netty/http/NettyHttpConsumer.java | 2 + .../component/netty/http/NettyHttpEndpoint.java | 23 +++-- .../http/NettyHttpSecurityConfiguration.java | 23 ++++- .../http/handlers/HttpServerChannelHandler.java | 16 +++- .../NettyHttpBasicAuthConstraintMapperTest.java | 94 ++++++++++++++++++++ .../netty/http/NettyHttpBasicAuthTest.java | 85 ++++++++++++++++++ .../http/NettyHttpSimpleBasicAuthTest.java | 18 +--- 10 files changed, 272 insertions(+), 39 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/4fbc8a77/components/camel-netty-http/pom.xml ---------------------------------------------------------------------- diff --git a/components/camel-netty-http/pom.xml b/components/camel-netty-http/pom.xml index f034ebd..4e8057a 100644 --- a/components/camel-netty-http/pom.xml +++ b/components/camel-netty-http/pom.xml @@ -25,7 +25,7 @@ <artifactId>camel-netty-http</artifactId> <packaging>bundle</packaging> - <name>Camel :: Netty</name> + <name>Camel :: Netty HTTP</name> <description>Camel Netty HTTP support</description> <properties> @@ -44,7 +44,7 @@ <!-- testing --> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-test-spring</artifactId> + <artifactId>camel-test</artifactId> <scope>test</scope> </dependency> <dependency> http://git-wip-us.apache.org/repos/asf/camel/blob/4fbc8a77/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/ConstraintMappingContextPathMatcher.java ---------------------------------------------------------------------- diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/ConstraintMappingContextPathMatcher.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/ConstraintMappingContextPathMatcher.java index 11667ae..4a71b64 100644 --- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/ConstraintMappingContextPathMatcher.java +++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/ConstraintMappingContextPathMatcher.java @@ -21,6 +21,22 @@ import java.util.Set; import org.apache.camel.util.EndpointHelper; +/** + * A {@link ContextPathMatcher} which can be used to define a set of mappings to + * as constraints. + * <p/> + * This matcher will match as <tt>true</tt> if no inclusions has been defined. + * First all the inclusions is check for matching. If a inclusion matches, + * then the exclusion is checked, and if any of them matches, then the exclusion + * will override the match and force returning <tt>false</tt>. + * <p/> + * Wildcards and regular expressions is supported as this implementation uses + * {@link EndpointHelper#matchPattern(String, String)} method for matching. + * <p/> + * This constraint matcher allows you to setup context path rules that will restrict + * access to paths, and then override and have exclusions that may allow access to + * public paths. + */ public class ConstraintMappingContextPathMatcher implements ContextPathMatcher { private Set<String> inclusions; @@ -41,8 +57,8 @@ public class ConstraintMappingContextPathMatcher implements ContextPathMatcher { matches = found; } - // any exclusions - if (exclusions != null && !exclusions.isEmpty()) { + // if matches check for any exclusions + if (matches && exclusions != null && !exclusions.isEmpty()) { for (String constraint : exclusions) { if (EndpointHelper.matchPattern(target, constraint)) { // force false if this was an exclusion http://git-wip-us.apache.org/repos/asf/camel/blob/4fbc8a77/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java index 5f92987..1f0fcd2 100644 --- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java +++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java @@ -46,7 +46,7 @@ public class NettyHttpComponent extends NettyComponent implements HeaderFilterSt private final Map<String, HttpServerBootstrapFactory> bootstrapFactories = new HashMap<String, HttpServerBootstrapFactory>(); private NettyHttpBinding nettyHttpBinding; private HeaderFilterStrategy headerFilterStrategy; - private NettyHttpSecurityConfiguration nettyHttpSecurityConfiguration; + private NettyHttpSecurityConfiguration securityConfiguration; public NettyHttpComponent() { // use the http configuration and filter strategy @@ -74,7 +74,15 @@ public class NettyHttpComponent extends NettyComponent implements HeaderFilterSt } // any custom security configuration - NettyHttpSecurityConfiguration securityConfiguration = resolveAndRemoveReferenceParameter(parameters, "nettyHttpSecurityConfiguration", NettyHttpSecurityConfiguration.class); + NettyHttpSecurityConfiguration securityConfiguration = resolveAndRemoveReferenceParameter(parameters, "securityConfiguration", NettyHttpSecurityConfiguration.class); + String realm = getAndRemoveParameter(parameters, "realm", String.class); + if (securityConfiguration != null && realm != null) { + throw new IllegalArgumentException("Cannot have both realm and securityConfiguration options configured"); + } else if (realm != null) { + // use default security configuration with the given realm, as a very easy way of enabling this + securityConfiguration = new NettyHttpSecurityConfiguration(); + securityConfiguration.setRealm(realm); + } config = parseConfiguration(config, remaining, parameters); @@ -108,9 +116,9 @@ public class NettyHttpComponent extends NettyComponent implements HeaderFilterSt } if (securityConfiguration != null) { - answer.setNettyHttpSecurityConfiguration(securityConfiguration); - } else if (answer.getNettyHttpSecurityConfiguration() == null) { - answer.setNettyHttpSecurityConfiguration(getNettyHttpSecurityConfiguration()); + answer.setSecurityConfiguration(securityConfiguration); + } else if (answer.getSecurityConfiguration() == null) { + answer.setSecurityConfiguration(getSecurityConfiguration()); } answer.setNettySharedHttpServer(shared); @@ -151,12 +159,12 @@ public class NettyHttpComponent extends NettyComponent implements HeaderFilterSt this.headerFilterStrategy = headerFilterStrategy; } - public NettyHttpSecurityConfiguration getNettyHttpSecurityConfiguration() { - return nettyHttpSecurityConfiguration; + public NettyHttpSecurityConfiguration getSecurityConfiguration() { + return securityConfiguration; } - public void setNettyHttpSecurityConfiguration(NettyHttpSecurityConfiguration nettyHttpSecurityConfiguration) { - this.nettyHttpSecurityConfiguration = nettyHttpSecurityConfiguration; + public void setSecurityConfiguration(NettyHttpSecurityConfiguration securityConfiguration) { + this.securityConfiguration = securityConfiguration; } public synchronized HttpServerConsumerChannelFactory getMultiplexChannelHandler(int port) { http://git-wip-us.apache.org/repos/asf/camel/blob/4fbc8a77/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConsumer.java ---------------------------------------------------------------------- diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConsumer.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConsumer.java index 2c27204..4943ac3 100644 --- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConsumer.java +++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConsumer.java @@ -45,6 +45,8 @@ public class NettyHttpConsumer extends NettyConsumer { super.doStart(); ObjectHelper.notNull(getNettyServerBootstrapFactory(), "HttpServerBootstrapFactory", this); getNettyServerBootstrapFactory().addConsumer(this); + + } @Override http://git-wip-us.apache.org/repos/asf/camel/blob/4fbc8a77/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpEndpoint.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpEndpoint.java index 1039fcf..b97f12c 100644 --- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpEndpoint.java +++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpEndpoint.java @@ -46,7 +46,7 @@ public class NettyHttpEndpoint extends NettyEndpoint implements HeaderFilterStra private boolean traceEnabled; private String httpMethodRestrict; private NettySharedHttpServer nettySharedHttpServer; - private NettyHttpSecurityConfiguration nettyHttpSecurityConfiguration; + private NettyHttpSecurityConfiguration securityConfiguration; public NettyHttpEndpoint(String endpointUri, NettyHttpComponent component, NettyConfiguration configuration) { super(endpointUri, component, configuration); @@ -172,12 +172,12 @@ public class NettyHttpEndpoint extends NettyEndpoint implements HeaderFilterStra this.nettySharedHttpServer = nettySharedHttpServer; } - public NettyHttpSecurityConfiguration getNettyHttpSecurityConfiguration() { - return nettyHttpSecurityConfiguration; + public NettyHttpSecurityConfiguration getSecurityConfiguration() { + return securityConfiguration; } - public void setNettyHttpSecurityConfiguration(NettyHttpSecurityConfiguration nettyHttpSecurityConfiguration) { - this.nettyHttpSecurityConfiguration = nettyHttpSecurityConfiguration; + public void setSecurityConfiguration(NettyHttpSecurityConfiguration securityConfiguration) { + this.securityConfiguration = securityConfiguration; } @Override @@ -186,5 +186,18 @@ public class NettyHttpEndpoint extends NettyEndpoint implements HeaderFilterStra ObjectHelper.notNull(nettyHttpBinding, "nettyHttpBinding", this); ObjectHelper.notNull(headerFilterStrategy, "headerFilterStrategy", this); + + if (securityConfiguration != null) { + ObjectHelper.notEmpty(securityConfiguration.getRealm(), "realm", securityConfiguration); + ObjectHelper.notEmpty(securityConfiguration.getConstraint(), "constraint", securityConfiguration); + + if (securityConfiguration.getSecurityAuthenticator() == null) { + // setup default JAAS authenticator if none was configured + JAASSecurityAuthenticator jaas = new JAASSecurityAuthenticator(); + jaas.setName(securityConfiguration.getRealm()); + LOG.info("No SecurityAuthenticator configured, using JAASSecurityAuthenticator as authenticator: {}", jaas); + securityConfiguration.setSecurityAuthenticator(jaas); + } + } } } http://git-wip-us.apache.org/repos/asf/camel/blob/4fbc8a77/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpSecurityConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpSecurityConfiguration.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpSecurityConfiguration.java index 9f0ebf9..4beffa9 100644 --- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpSecurityConfiguration.java +++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpSecurityConfiguration.java @@ -22,7 +22,7 @@ package org.apache.camel.component.netty.http; public class NettyHttpSecurityConfiguration { private boolean authenticate = true; - private String constraint = "BASIC"; + private String constraint = "Basic"; private String realm; private ContextPathMatcher contextPathMatcher; private SecurityAuthenticator securityAuthenticator; @@ -31,6 +31,11 @@ public class NettyHttpSecurityConfiguration { return authenticate; } + /** + * Whether to enable authentication + * <p/> + * This is by default enabled. + */ public void setAuthenticate(boolean authenticate) { this.authenticate = authenticate; } @@ -39,6 +44,11 @@ public class NettyHttpSecurityConfiguration { return constraint; } + /** + * The supported constraint. + * <p/> + * Currently only Basic is supported. + */ public void setConstraint(String constraint) { this.constraint = constraint; } @@ -47,6 +57,9 @@ public class NettyHttpSecurityConfiguration { return realm; } + /** + * Sets the name of the realm to use. + */ public void setRealm(String realm) { this.realm = realm; } @@ -55,6 +68,11 @@ public class NettyHttpSecurityConfiguration { return contextPathMatcher; } + /** + * Sets a {@link ContextPathMatcher} to use for matching if a url is restricted or not. + * <p/> + * By default this is <tt>null</tt>, which means all resources is restricted. + */ public void setContextPathMatcher(ContextPathMatcher contextPathMatcher) { this.contextPathMatcher = contextPathMatcher; } @@ -63,6 +81,9 @@ public class NettyHttpSecurityConfiguration { return securityAuthenticator; } + /** + * Sets the {@link SecurityAuthenticator} to use for authenticating the {@link HttpPrincipal}. + */ public void setSecurityAuthenticator(SecurityAuthenticator securityAuthenticator) { this.securityAuthenticator = securityAuthenticator; } http://git-wip-us.apache.org/repos/asf/camel/blob/4fbc8a77/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java ---------------------------------------------------------------------- diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java index 8552f66..144fb82 100644 --- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java +++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java @@ -17,6 +17,7 @@ package org.apache.camel.component.netty.http.handlers; import java.net.SocketAddress; +import java.net.URI; import java.nio.channels.ClosedChannelException; import java.nio.charset.Charset; import javax.security.auth.Subject; @@ -111,12 +112,21 @@ public class HttpServerChannelHandler extends ServerChannelHandler { } // is basic auth configured - NettyHttpSecurityConfiguration security = consumer.getEndpoint().getNettyHttpSecurityConfiguration(); - if (security != null && security.isAuthenticate()) { + NettyHttpSecurityConfiguration security = consumer.getEndpoint().getSecurityConfiguration(); + if (security != null && security.isAuthenticate() && "Basic".equalsIgnoreCase(security.getConstraint())) { String url = request.getUri(); + // drop parameters from url + if (url.contains("?")) { + url = ObjectHelper.before(url, "?"); + } + + // we need the relative path without the hostname and port + URI uri = new URI(request.getUri()); + String target = uri.getPath(); + // is it a restricted resource? - boolean restricted = security.getContextPathMatcher() == null || security.getContextPathMatcher().matches(url); + boolean restricted = security.getContextPathMatcher() == null || security.getContextPathMatcher().matches(target); if (restricted) { // basic auth subject HttpPrincipal principal = extractBasicAuthSubject(request); http://git-wip-us.apache.org/repos/asf/camel/blob/4fbc8a77/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBasicAuthConstraintMapperTest.java ---------------------------------------------------------------------- diff --git a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBasicAuthConstraintMapperTest.java b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBasicAuthConstraintMapperTest.java new file mode 100644 index 0000000..141475b --- /dev/null +++ b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBasicAuthConstraintMapperTest.java @@ -0,0 +1,94 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.netty.http; + +import org.apache.camel.CamelExecutionException; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.impl.JndiRegistry; +import org.junit.Test; + +public class NettyHttpBasicAuthConstraintMapperTest extends BaseNettyTest { + + @Override + public void setUp() throws Exception { + System.setProperty("java.security.auth.login.config", "src/test/resources/myjaas.config"); + super.setUp(); + } + + @Override + public void tearDown() throws Exception { + System.clearProperty("java.security.auth.login.config"); + super.tearDown(); + } + + @Override + protected JndiRegistry createRegistry() throws Exception { + JndiRegistry jndi = super.createRegistry(); + + NettyHttpSecurityConfiguration security = new NettyHttpSecurityConfiguration(); + security.setRealm("karaf"); + SecurityAuthenticator auth = new JAASSecurityAuthenticator(); + auth.setName("karaf"); + security.setSecurityAuthenticator(auth); + + ConstraintMappingContextPathMatcher matcher = new ConstraintMappingContextPathMatcher(); + matcher.addInclusion("/foo/*"); + matcher.addExclusion("/foo/public/*"); + security.setContextPathMatcher(matcher); + + jndi.bind("mySecurityConfig", security); + + return jndi; + } + + @Test + public void testBasicAuth() throws Exception { + getMockEndpoint("mock:input").expectedBodiesReceived("Hello Public", "Hello World"); + + // we dont need auth for the public page + String out = template.requestBody("netty-http:http://localhost:{{port}}/foo/public/hello.txt", "Hello Public", String.class); + assertEquals("Bye World", out); + + try { + template.requestBody("netty-http:http://localhost:{{port}}/foo", "Hello World", String.class); + fail("Should send back 401"); + } catch (CamelExecutionException e) { + NettyHttpOperationFailedException cause = assertIsInstanceOf(NettyHttpOperationFailedException.class, e.getCause()); + assertEquals(401, cause.getStatusCode()); + } + + // username:password is scott:secret + String auth = "Basic c2NvdHQ6c2VjcmV0"; + out = template.requestBodyAndHeader("netty-http:http://localhost:{{port}}/foo", "Hello World", "Authorization", auth, String.class); + assertEquals("Bye World", out); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("netty-http:http://0.0.0.0:{{port}}/foo?matchOnUriPrefix=true&securityConfiguration=#mySecurityConfig") + .to("mock:input") + .transform().constant("Bye World"); + } + }; + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/4fbc8a77/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBasicAuthTest.java ---------------------------------------------------------------------- diff --git a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBasicAuthTest.java b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBasicAuthTest.java new file mode 100644 index 0000000..1775084 --- /dev/null +++ b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBasicAuthTest.java @@ -0,0 +1,85 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.netty.http; + +import org.apache.camel.CamelExecutionException; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.impl.JndiRegistry; +import org.junit.Test; + +public class NettyHttpBasicAuthTest extends BaseNettyTest { + + @Override + public void setUp() throws Exception { + System.setProperty("java.security.auth.login.config", "src/test/resources/myjaas.config"); + super.setUp(); + } + + @Override + public void tearDown() throws Exception { + System.clearProperty("java.security.auth.login.config"); + super.tearDown(); + } + + @Override + protected JndiRegistry createRegistry() throws Exception { + JndiRegistry jndi = super.createRegistry(); + + NettyHttpSecurityConfiguration security = new NettyHttpSecurityConfiguration(); + security.setRealm("karaf"); + SecurityAuthenticator auth = new JAASSecurityAuthenticator(); + auth.setName("karaf"); + security.setSecurityAuthenticator(auth); + + jndi.bind("mySecurityConfig", security); + + return jndi; + } + + @Test + public void testBasicAuth() throws Exception { + try { + template.requestBody("netty-http:http://localhost:{{port}}/foo", "Hello World", String.class); + fail("Should send back 401"); + } catch (CamelExecutionException e) { + NettyHttpOperationFailedException cause = assertIsInstanceOf(NettyHttpOperationFailedException.class, e.getCause()); + assertEquals(401, cause.getStatusCode()); + } + + getMockEndpoint("mock:input").expectedBodiesReceived("Hello World"); + + // username:password is scott:secret + String auth = "Basic c2NvdHQ6c2VjcmV0"; + String out = template.requestBodyAndHeader("netty-http:http://localhost:{{port}}/foo", "Hello World", "Authorization", auth, String.class); + assertEquals("Bye World", out); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("netty-http:http://0.0.0.0:{{port}}/foo?securityConfiguration=#mySecurityConfig") + .to("mock:input") + .transform().constant("Bye World"); + } + }; + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/4fbc8a77/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpSimpleBasicAuthTest.java ---------------------------------------------------------------------- diff --git a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpSimpleBasicAuthTest.java b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpSimpleBasicAuthTest.java index d4e0b6e..0e7668f 100644 --- a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpSimpleBasicAuthTest.java +++ b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpSimpleBasicAuthTest.java @@ -18,7 +18,6 @@ package org.apache.camel.component.netty.http; import org.apache.camel.CamelExecutionException; import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.impl.JndiRegistry; import org.junit.Test; public class NettyHttpSimpleBasicAuthTest extends BaseNettyTest { @@ -35,21 +34,6 @@ public class NettyHttpSimpleBasicAuthTest extends BaseNettyTest { super.tearDown(); } - @Override - protected JndiRegistry createRegistry() throws Exception { - JndiRegistry jndi = super.createRegistry(); - - NettyHttpSecurityConfiguration security = new NettyHttpSecurityConfiguration(); - security.setRealm("karaf"); - SecurityAuthenticator auth = new JAASSecurityAuthenticator(); - auth.setName("karaf"); - security.setSecurityAuthenticator(auth); - - jndi.bind("mySecurityConfig", security); - - return jndi; - } - @Test public void testBasicAuth() throws Exception { try { @@ -75,7 +59,7 @@ public class NettyHttpSimpleBasicAuthTest extends BaseNettyTest { return new RouteBuilder() { @Override public void configure() throws Exception { - from("netty-http:http://0.0.0.0:{{port}}/foo?nettyHttpSecurityConfiguration=#mySecurityConfig") + from("netty-http:http://0.0.0.0:{{port}}/foo?realm=karaf") .to("mock:input") .transform().constant("Bye World"); }