diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/Security.java b/plugin/src/main/java/org/elasticsearch/xpack/security/Security.java index 9f35890cc48..a434d067029 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/Security.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/security/Security.java @@ -394,7 +394,7 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin { securityInterceptor.set(new SecurityServerTransportInterceptor(settings, threadPool, authcService.get(), authzService, licenseState, sslService, securityContext.get(), destructiveOperations)); - BootstrapElasticPassword bootstrapElasticPassword = new BootstrapElasticPassword(settings, logger, clusterService, reservedRealm, + BootstrapElasticPassword bootstrapElasticPassword = new BootstrapElasticPassword(settings, clusterService, reservedRealm, securityLifecycleService); bootstrapElasticPassword.initiatePasswordBootstrap(); diff --git a/plugin/src/main/java/org/elasticsearch/xpack/security/bootstrap/BootstrapElasticPassword.java b/plugin/src/main/java/org/elasticsearch/xpack/security/bootstrap/BootstrapElasticPassword.java index db15acc2029..19a95e13122 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/security/bootstrap/BootstrapElasticPassword.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/security/bootstrap/BootstrapElasticPassword.java @@ -12,6 +12,7 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.cluster.ClusterChangedEvent; import org.elasticsearch.cluster.ClusterStateListener; import org.elasticsearch.cluster.service.ClusterService; +import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.gateway.GatewayService; @@ -38,11 +39,11 @@ public final class BootstrapElasticPassword { private final SecurityLifecycleService lifecycleService; private final boolean reservedRealmDisabled; - public BootstrapElasticPassword(Settings settings, Logger logger, ClusterService clusterService, ReservedRealm reservedRealm, + public BootstrapElasticPassword(Settings settings, ClusterService clusterService, ReservedRealm reservedRealm, SecurityLifecycleService lifecycleService) { this.reservedRealmDisabled = XPackSettings.RESERVED_REALM_ENABLED_SETTING.get(settings) == false; this.settings = settings; - this.logger = logger; + this.logger = Loggers.getLogger(BootstrapElasticPassword.class, settings); this.clusterService = clusterService; this.reservedRealm = reservedRealm; this.lifecycleService = lifecycleService; @@ -98,7 +99,9 @@ public final class BootstrapElasticPassword { @Override public void onResponse(Boolean passwordSet) { cleanup(); - if (passwordSet == false) { + if (passwordSet) { + logger.info("elastic password was bootstrapped successfully"); + } else { logger.warn("elastic password was not bootstrapped because its password was already set"); } semaphore.release(); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/security/bootstrap/BootstrapElasticPasswordTests.java b/plugin/src/test/java/org/elasticsearch/xpack/security/bootstrap/BootstrapElasticPasswordTests.java index 4607b84ebfc..122001f81bf 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/security/bootstrap/BootstrapElasticPasswordTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/security/bootstrap/BootstrapElasticPasswordTests.java @@ -50,7 +50,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase { } public void testNoListenerAttachedWhenNoBootstrapPassword() { - BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(Settings.EMPTY, logger, clusterService, realm, lifecycle); + BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(Settings.EMPTY, clusterService, realm, lifecycle); bootstrap.initiatePasswordBootstrap(); @@ -64,7 +64,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase { .setSecureSettings(secureSettings) .put(XPackSettings.RESERVED_REALM_ENABLED_SETTING.getKey(), false) .build(); - BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle); + BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle); bootstrap.initiatePasswordBootstrap(); @@ -77,7 +77,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase { Settings settings = Settings.builder() .setSecureSettings(secureSettings) .build(); - BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle); + BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle); expectThrows(ValidationException.class, bootstrap::initiatePasswordBootstrap); @@ -90,7 +90,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase { Settings settings = Settings.builder() .setSecureSettings(secureSettings) .build(); - BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle); + BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle); bootstrap.initiatePasswordBootstrap(); @@ -118,7 +118,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase { Settings settings = Settings.builder() .setSecureSettings(secureSettings) .build(); - BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle); + BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle); bootstrap.initiatePasswordBootstrap(); @@ -143,7 +143,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase { Settings settings = Settings.builder() .setSecureSettings(secureSettings) .build(); - BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle); + BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle); bootstrap.initiatePasswordBootstrap(); @@ -168,7 +168,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase { Settings settings = Settings.builder() .setSecureSettings(secureSettings) .build(); - BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle); + BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle); bootstrap.initiatePasswordBootstrap(); @@ -193,7 +193,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase { Settings settings = Settings.builder() .setSecureSettings(secureSettings) .build(); - BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle); + BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle); bootstrap.initiatePasswordBootstrap(); @@ -228,7 +228,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase { Settings settings = Settings.builder() .setSecureSettings(secureSettings) .build(); - BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle); + BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle); bootstrap.initiatePasswordBootstrap(); @@ -255,7 +255,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase { Settings settings = Settings.builder() .setSecureSettings(secureSettings) .build(); - BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle); + BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle); bootstrap.initiatePasswordBootstrap(); @@ -308,7 +308,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase { Settings settings = Settings.builder() .setSecureSettings(secureSettings) .build(); - BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle); + BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle); bootstrap.initiatePasswordBootstrap();