Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
04b63cda
Commit
04b63cda
authored
Aug 17, 2019
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.1.x'
Closes gh-17889
parents
76dfe1aa
3a20b1d9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
6 deletions
+20
-6
LdapAutoConfiguration.java
...mework/boot/autoconfigure/ldap/LdapAutoConfiguration.java
+9
-6
LdapAutoConfigurationTests.java
...k/boot/autoconfigure/ldap/LdapAutoConfigurationTests.java
+11
-0
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/LdapAutoConfiguration.java
View file @
04b63cda
...
...
@@ -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 {
@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
;
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ldap/LdapAutoConfigurationTests.java
View file @
04b63cda
...
...
@@ -87,6 +87,17 @@ class LdapAutoConfigurationTests {
});
}
@Test
void
contextSourceWithNoCustomization
()
{
this
.
contextRunner
.
run
((
context
)
->
{
LdapContextSource
contextSource
=
context
.
getBean
(
LdapContextSource
.
class
);
assertThat
(
contextSource
.
getUserDn
()).
isEqualTo
(
""
);
assertThat
(
contextSource
.
getPassword
()).
isEqualTo
(
""
);
assertThat
(
contextSource
.
isAnonymousReadOnly
()).
isFalse
();
assertThat
(
contextSource
.
getBaseLdapPathAsString
()).
isEqualTo
(
""
);
});
}
@Test
void
templateExists
()
{
this
.
contextRunner
.
withPropertyValues
(
"spring.ldap.urls:ldap://localhost:389"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment