diff --git a/spring-boot-actuator/pom.xml b/spring-boot-actuator/pom.xml
index bcb23ce313..3204b8fc08 100644
--- a/spring-boot-actuator/pom.xml
+++ b/spring-boot-actuator/pom.xml
@@ -166,6 +166,11 @@
spring-data-couchbase
true
+
+ org.springframework.data
+ spring-data-ldap
+ true
+
org.springframework.data
spring-data-mongodb
diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfiguration.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfiguration.java
index e838233479..de30335deb 100644
--- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfiguration.java
+++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfiguration.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2016 the original author or authors.
+ * Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,6 +39,7 @@ import org.springframework.boot.actuate.health.DiskSpaceHealthIndicatorPropertie
import org.springframework.boot.actuate.health.HealthAggregator;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.boot.actuate.health.JmsHealthIndicator;
+import org.springframework.boot.actuate.health.LdapHealthIndicator;
import org.springframework.boot.actuate.health.MailHealthIndicator;
import org.springframework.boot.actuate.health.MongoHealthIndicator;
import org.springframework.boot.actuate.health.OrderedHealthAggregator;
@@ -56,6 +57,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
import org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration;
import org.springframework.boot.autoconfigure.data.couchbase.CouchbaseDataAutoConfiguration;
import org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration;
+import org.springframework.boot.autoconfigure.data.ldap.LdapDataAutoConfiguration;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.autoconfigure.elasticsearch.jest.JestAutoConfiguration;
@@ -77,6 +79,7 @@ import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
+import org.springframework.ldap.core.LdapOperations;
import org.springframework.mail.javamail.JavaMailSenderImpl;
/**
@@ -96,9 +99,10 @@ import org.springframework.mail.javamail.JavaMailSenderImpl;
CassandraDataAutoConfiguration.class, CouchbaseDataAutoConfiguration.class,
DataSourceAutoConfiguration.class, ElasticsearchAutoConfiguration.class,
JestAutoConfiguration.class, JmsAutoConfiguration.class,
- MailSenderAutoConfiguration.class, MongoAutoConfiguration.class,
- MongoDataAutoConfiguration.class, RabbitAutoConfiguration.class,
- RedisAutoConfiguration.class, SolrAutoConfiguration.class })
+ LdapDataAutoConfiguration.class, MailSenderAutoConfiguration.class,
+ MongoAutoConfiguration.class, MongoDataAutoConfiguration.class,
+ RabbitAutoConfiguration.class, RedisAutoConfiguration.class,
+ SolrAutoConfiguration.class })
@EnableConfigurationProperties({ HealthIndicatorProperties.class })
@Import({
ElasticsearchHealthIndicatorConfiguration.ElasticsearchClientHealthIndicatorConfiguration.class,
@@ -231,6 +235,27 @@ public class HealthIndicatorAutoConfiguration {
}
+ @Configuration
+ @ConditionalOnClass(LdapOperations.class)
+ @ConditionalOnBean(LdapOperations.class)
+ @ConditionalOnEnabledHealthIndicator("ldap")
+ public static class LdapHealthIndicatorConfiguration extends
+ CompositeHealthIndicatorConfiguration {
+
+ private final Map ldapOperations;
+
+ public LdapHealthIndicatorConfiguration(Map ldapOperations) {
+ this.ldapOperations = ldapOperations;
+ }
+
+ @Bean
+ @ConditionalOnMissingBean(name = "ldapHealthIndicator")
+ public HealthIndicator ldapHealthIndicator() {
+ return createHealthIndicator(this.ldapOperations);
+ }
+
+ }
+
@Configuration
@ConditionalOnBean(MongoTemplate.class)
@ConditionalOnEnabledHealthIndicator("mongo")
diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/LdapHealthIndicator.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/LdapHealthIndicator.java
new file mode 100644
index 0000000000..5e0befbd4e
--- /dev/null
+++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/LdapHealthIndicator.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2012-2017 the original author or authors.
+ *
+ * Licensed 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.springframework.boot.actuate.health;
+
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+
+import org.springframework.ldap.core.ContextExecutor;
+import org.springframework.ldap.core.LdapOperations;
+import org.springframework.util.Assert;
+
+/**
+ * {@link HealthIndicator} for configured LDAP server(s).
+ *
+ * @author Eddú Meléndez
+ * @version 1.5.0
+ */
+public class LdapHealthIndicator extends AbstractHealthIndicator {
+
+ private final LdapOperations ldapOperations;
+
+ public LdapHealthIndicator(LdapOperations ldapOperations) {
+ Assert.notNull(ldapOperations, "LdapOperations must not be null");
+ this.ldapOperations = ldapOperations;
+ }
+
+ @Override
+ protected void doHealthCheck(Health.Builder builder) throws Exception {
+ String version = (String) this.ldapOperations.executeReadOnly(new ContextExecutor