From 9ffb7cb36349d00ab31538c85bae597e5d10062b Mon Sep 17 00:00:00 2001 From: Jan Srnicek Date: Fri, 30 Jun 2017 13:46:26 +0200 Subject: HONEYCOMB-360 - Common northbound configuration Change-Id: Iefa1c4a7388c628c9527a00b13be59d98db640ec Signed-off-by: Jan Srnicek Signed-off-by: Marek Gradzki --- .../fd/honeycomb/infra/distro/restconf/JettyServerProvider.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/restconf/JettyServerProvider.java') 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 { @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 { // 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 { 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("/*"); -- cgit 1.2.3-korg