|
|
|
|
@ -22,6 +22,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -22,6 +22,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; |
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
|
|
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
|
|
|
|
import org.springframework.boot.context.properties.PropertyMapper; |
|
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
|
import org.springframework.core.env.Environment; |
|
|
|
|
@ -46,12 +47,14 @@ public class LdapAutoConfiguration {
@@ -46,12 +47,14 @@ public class LdapAutoConfiguration {
|
|
|
|
|
@ConditionalOnMissingBean |
|
|
|
|
public LdapContextSource ldapContextSource(LdapProperties properties, Environment environment) { |
|
|
|
|
LdapContextSource source = new LdapContextSource(); |
|
|
|
|
source.setUserDn(properties.getUsername()); |
|
|
|
|
source.setPassword(properties.getPassword()); |
|
|
|
|
source.setAnonymousReadOnly(properties.getAnonymousReadOnly()); |
|
|
|
|
source.setBase(properties.getBase()); |
|
|
|
|
source.setUrls(properties.determineUrls(environment)); |
|
|
|
|
source.setBaseEnvironmentProperties(Collections.unmodifiableMap(properties.getBaseEnvironment())); |
|
|
|
|
PropertyMapper propertyMapper = PropertyMapper.get().alwaysApplyingWhenNonNull(); |
|
|
|
|
propertyMapper.from(properties.getUsername()).to(source::setUserDn); |
|
|
|
|
propertyMapper.from(properties.getPassword()).to(source::setPassword); |
|
|
|
|
propertyMapper.from(properties.getAnonymousReadOnly()).to(source::setAnonymousReadOnly); |
|
|
|
|
propertyMapper.from(properties.getBase()).to(source::setBase); |
|
|
|
|
propertyMapper.from(properties.determineUrls(environment)).to(source::setUrls); |
|
|
|
|
propertyMapper.from(properties.getBaseEnvironment()).to( |
|
|
|
|
(baseEnvironment) -> source.setBaseEnvironmentProperties(Collections.unmodifiableMap(baseEnvironment))); |
|
|
|
|
return source; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|