diff options
Diffstat (limited to 'infra/minimal-distribution-core')
4 files changed, 20 insertions, 11 deletions
diff --git a/infra/minimal-distribution-core/pom.xml b/infra/minimal-distribution-core/pom.xml index 117ec1113..1763cce5e 100644 --- a/infra/minimal-distribution-core/pom.xml +++ b/infra/minimal-distribution-core/pom.xml @@ -138,6 +138,13 @@ <version>${osgi.core.version}</version> </dependency> + <!-- Northbound --> + <dependency> + <groupId>io.fd.honeycomb.northbound</groupId> + <artifactId>common</artifactId> + <version>${project.version}</version> + </dependency> + <!-- HC --> <dependency> <groupId>${project.groupId}</groupId> diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/HoneycombConfiguration.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/HoneycombConfiguration.java index cc46f7b8e..f7d5ca52a 100644 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/HoneycombConfiguration.java +++ b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/HoneycombConfiguration.java @@ -138,10 +138,6 @@ public class HoneycombConfiguration { public Optional<Integer> netconfSshBindingPort; @InjectConfig("netconf-notification-stream-name") public Optional<String> netconfNotificationStreamName = Optional.of("honeycomb"); - @InjectConfig("username") - public String username; - @InjectConfig("password") - public String password; @Override public String toString() { @@ -178,8 +174,6 @@ public class HoneycombConfiguration { .add("netconfSshBindingAddress", netconfSshBindingAddress) .add("netconfSshBindingPort", netconfSshBindingPort) .add("netconfNotificationStreamName", netconfNotificationStreamName) - .add("username", username) - .add("password", password) .toString(); } } diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfSshServerProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfSshServerProvider.java index ba36a266b..8d86677d3 100644 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfSshServerProvider.java +++ b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfSshServerProvider.java @@ -21,6 +21,7 @@ import com.google.inject.Inject; import io.fd.honeycomb.infra.distro.InitializationException; import io.fd.honeycomb.infra.distro.ProviderTrait; import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration; +import io.fd.honeycomb.northbound.CredentialsConfiguration; import io.netty.channel.ChannelFuture; import io.netty.channel.local.LocalAddress; import io.netty.channel.nio.NioEventLoopGroup; @@ -51,6 +52,8 @@ public final class NetconfSshServerProvider extends ProviderTrait<NetconfSshServ private HoneycombConfiguration cfgAttributes; @Inject private NioEventLoopGroup nettyThreadgroup; + @Inject + private CredentialsConfiguration credentialsCfg; private ScheduledExecutorService pool = Executors.newScheduledThreadPool(1, new ThreadFactoryBuilder().setNameFormat("netconf-ssh-%d").build()); @@ -76,7 +79,7 @@ public final class NetconfSshServerProvider extends ProviderTrait<NetconfSshServ sshConfigBuilder.setBindingAddress(bindingAddress); sshConfigBuilder.setLocalAddress(localAddress); // Only simple authProvider checking ConfigAttributes, checking the config file - sshConfigBuilder.setAuthenticator(new SimplelAuthProvider(cfgAttributes)); + sshConfigBuilder.setAuthenticator(new SimplelAuthProvider(credentialsCfg)); sshConfigBuilder.setIdleTimeout(Integer.MAX_VALUE); sshConfigBuilder.setKeyPairProvider(new PEMGeneratorHostKeyProvider()); @@ -106,9 +109,9 @@ public final class NetconfSshServerProvider extends ProviderTrait<NetconfSshServ private static final class SimplelAuthProvider implements AuthProvider { - private final HoneycombConfiguration cfgAttributes; + private final CredentialsConfiguration cfgAttributes; - SimplelAuthProvider(final HoneycombConfiguration cfgAttributes) { + SimplelAuthProvider(final CredentialsConfiguration cfgAttributes) { this.cfgAttributes = cfgAttributes; } diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/restconf/JettyServerProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/restconf/JettyServerProvider.java index bc5fe8bc3..0c8087360 100644 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/restconf/JettyServerProvider.java +++ b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/restconf/JettyServerProvider.java @@ -19,6 +19,7 @@ package io.fd.honeycomb.infra.distro.restconf; import com.google.inject.Inject; import io.fd.honeycomb.infra.distro.ProviderTrait; import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration; +import io.fd.honeycomb.northbound.CredentialsConfiguration; import java.net.URL; import java.util.Collections; import org.eclipse.jetty.security.ConstraintMapping; @@ -45,6 +46,9 @@ final class JettyServerProvider extends ProviderTrait<Server> { @Inject private HoneycombConfiguration cfg; + @Inject + private CredentialsConfiguration credentialsCfg; + @Override protected Server create() { Server server = new Server(new QueuedThreadPool(cfg.restPoolMaxSize.get(), cfg.restPoolMinSize.get())); @@ -52,7 +56,8 @@ final class JettyServerProvider extends ProviderTrait<Server> { // Load Realm for basic auth HashLoginService service = new HashLoginService(REALM); // Reusing the name as role - service.putUser(cfg.username, new Password(cfg.password), new String[]{cfg.username}); + service.putUser(credentialsCfg.username, new Password(credentialsCfg.password), + new String[]{credentialsCfg.username}); server.addBean(service); final URL resource = getClass().getResource("/"); @@ -73,7 +78,7 @@ final class JettyServerProvider extends ProviderTrait<Server> { Constraint constraint = new Constraint(); constraint.setName("auth"); constraint.setAuthenticate(true); - constraint.setRoles(new String[]{cfg.username}); + constraint.setRoles(new String[]{credentialsCfg.username}); ConstraintMapping mapping = new ConstraintMapping(); mapping.setPathSpec("/*"); |