diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/embedded/EmbeddedLdapAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/embedded/EmbeddedLdapAutoConfiguration.java index c7805d123e6..54e5ae5724a 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/embedded/EmbeddedLdapAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/embedded/EmbeddedLdapAutoConfiguration.java @@ -113,15 +113,17 @@ public class EmbeddedLdapAutoConfiguration { if (!this.embeddedProperties.getValidation().isEnabled()) { config.setSchema(null); } - else if (this.embeddedProperties.getValidation().getSchema() != null) { - Resource schemaLocation = this.embeddedProperties.getValidation().getSchema(); - try { - config.setSchema(Schema.mergeSchemas(Schema.getDefaultStandardSchema(), - Schema.getSchema(schemaLocation.getFile()))); - } - catch (Exception ex) { - throw new IllegalStateException( - "Unable to load schema " + schemaLocation.getDescription(), ex); + else { + Resource schema = this.embeddedProperties.getValidation().getSchema(); + if (schema != null) { + try { + config.setSchema(Schema.mergeSchemas(Schema.getDefaultStandardSchema(), + Schema.getSchema(schema.getInputStream()))); + } + catch (Exception ex) { + throw new IllegalStateException( + "Unable to load schema " + schema.getDescription(), ex); + } } } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/embedded/EmbeddedLdapProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/embedded/EmbeddedLdapProperties.java index 8e4d0b69276..bd4de81fa34 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/embedded/EmbeddedLdapProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/embedded/EmbeddedLdapProperties.java @@ -50,7 +50,7 @@ public class EmbeddedLdapProperties { private String ldif = "classpath:schema.ldif"; /** - * Schema validation + * Schema validation. */ private Validation validation = new Validation(); @@ -90,7 +90,7 @@ public class EmbeddedLdapProperties { return this.validation; } - static class Credential { + public static class Credential { /** * Embedded LDAP username. @@ -120,15 +120,15 @@ public class EmbeddedLdapProperties { } - static class Validation { + public static class Validation { /** - * Enable LDAP schema validation + * Enable LDAP schema validation. */ private boolean enabled = true; /** - * Path to the custom schema file + * Path to the custom schema. */ private Resource schema; diff --git a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index 069b24e7573..9adba7f7219 100644 --- a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -323,11 +323,13 @@ content into your application; rather pick only the properties that you need. spring.ldap.base-environment.*= # LDAP specification settings. # EMBEDDED LDAP ({sc-spring-boot-autoconfigure}/ldap/embedded/EmbeddedLdapProperties.{sc-ext}[EmbeddedLdapProperties]) - spring.ldap.embedded.port= # Embedded LDAP port. + spring.ldap.embedded.base-dn= # The base DN spring.ldap.embedded.credential.username= # Embedded LDAP username. spring.ldap.embedded.credential.password= # Embedded LDAP password. - spring.ldap.embedded.base-dn= # The base DN spring.ldap.embedded.ldif=classpath:schema.ldif # Schema (LDIF) script resource reference. + spring.ldap.embedded.port= # Embedded LDAP port. + spring.ldap.embedded.validation.enabled=true # Enable LDAP schema validation. + spring.ldap.embedded.validation.schema= # Path to the custom schema. # SPRING MOBILE DEVICE VIEWS ({sc-spring-boot-autoconfigure}/mobile/DeviceDelegatingViewResolverAutoConfiguration.{sc-ext}[DeviceDelegatingViewResolverAutoConfiguration]) spring.mobile.devicedelegatingviewresolver.enable-fallback=false # Enable support for fallback resolution. diff --git a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index 561eafb7ee4..ed1c8f6e261 100644 --- a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -3991,6 +3991,10 @@ If there is a `schema.ldif` file on your classpath it will be used to initialize server. You can also use the `spring.ldap.embedded.ldif` property if you want to load the initialization script from a different resource. +By default, a standard schema will be used to validate `LDIF` files, you can turn off +validation altogether using the `spring.ldap.embedded.validation.enabled` property. If +you have custom attributes, you can use `spring.ldap.embedded.validation.schema` to define +your custom attribute types or object classes. [[boot-features-caching]]