Skip to content

Commit 62aecfd

Browse files
dobrosidobrosi.andras
authored andcommitted
New LdapAutoConfiguration.referral property in LdapAutoConfiguration.java
Signed-off-by: Andras, Dobrosi <[email protected]>
1 parent f8047ff commit 62aecfd

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/LdapAutoConfiguration.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public LdapContextSource ldapContextSource(LdapConnectionDetails connectionDetai
6767
propertyMapper.from(connectionDetails.getUsername()).to(source::setUserDn);
6868
propertyMapper.from(connectionDetails.getPassword()).to(source::setPassword);
6969
propertyMapper.from(properties.getAnonymousReadOnly()).to(source::setAnonymousReadOnly);
70+
propertyMapper.from(properties.getReferral()).to(source::setReferral);
7071
propertyMapper.from(connectionDetails.getBase()).to(source::setBase);
7172
propertyMapper.from(connectionDetails.getUrls()).to(source::setUrls);
7273
propertyMapper.from(properties.getBaseEnvironment())

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/LdapProperties.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ public class LdapProperties {
6262
*/
6363
private Boolean anonymousReadOnly;
6464

65+
/**
66+
* Set the method to handle referrals.
67+
*/
68+
private String referral;
69+
6570
/**
6671
* LDAP specification settings.
6772
*/
@@ -109,6 +114,14 @@ public void setAnonymousReadOnly(Boolean anonymousReadOnly) {
109114
this.anonymousReadOnly = anonymousReadOnly;
110115
}
111116

117+
public String getReferral() {
118+
return this.referral;
119+
}
120+
121+
public void setReferral(String referral) {
122+
this.referral = referral;
123+
}
124+
112125
public Map<String, String> getBaseEnvironment() {
113126
return this.baseEnvironment;
114127
}

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ldap/LdapAutoConfigurationTests.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
import static org.assertj.core.api.Assertions.assertThat;
4040
import static org.mockito.Mockito.mock;
41+
import static org.springframework.test.util.ReflectionTestUtils.getField;
4142

4243
/**
4344
* Tests for {@link LdapAutoConfiguration}.
@@ -88,6 +89,14 @@ void contextSourceWithUserDoesNotEnableAnonymousReadOnly() {
8889
});
8990
}
9091

92+
@Test
93+
void contextSourceWithReferral() {
94+
this.contextRunner.withPropertyValues("spring.ldap.referral:ignore").run((context) -> {
95+
LdapContextSource contextSource = context.getBean(LdapContextSource.class);
96+
assertThat(getField(contextSource, "referral")).isEqualTo("ignore");
97+
});
98+
}
99+
91100
@Test
92101
void contextSourceWithExtraCustomization() {
93102
this.contextRunner

0 commit comments

Comments
 (0)