summaryrefslogtreecommitdiffstats
path: root/infra/minimal-distribution-core
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2017-06-30 13:46:26 +0200
committerMarek Gradzki <mgradzki@cisco.com>2017-06-30 22:19:00 +0200
commit9ffb7cb36349d00ab31538c85bae597e5d10062b (patch)
treecd68783486c431f298658de5eac9ab0edb0d8c84 /infra/minimal-distribution-core
parent5952721d74f9e1af59c3deb1018054aa4424c461 (diff)
HONEYCOMB-360 - Common northbound configuration
Change-Id: Iefa1c4a7388c628c9527a00b13be59d98db640ec Signed-off-by: Jan Srnicek <jsrnicek@cisco.com> Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'infra/minimal-distribution-core')
-rw-r--r--infra/minimal-distribution-core/pom.xml7
-rw-r--r--infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/HoneycombConfiguration.java6
-rw-r--r--infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfSshServerProvider.java9
-rw-r--r--infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/restconf/JettyServerProvider.java9
4 files changed, 20 insertions, 11 deletions
diff --git a/infra/minimal-distribution-core/pom.xml b/infra/minimal-distribution-core/pom.xml
index 117ec11..1763cce 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 cc46f7b..f7d5ca5 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 ba36a26..8d86677 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 bc5fe8b..0c80873 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("/*");