|
16 | 16 |
|
17 | 17 | package org.springframework.ldap.core.support;
|
18 | 18 |
|
| 19 | +import java.net.URI; |
| 20 | +import java.net.URISyntaxException; |
| 21 | +import java.util.Hashtable; |
| 22 | +import java.util.ListIterator; |
| 23 | +import java.util.Map; |
| 24 | + |
| 25 | +import javax.naming.Context; |
| 26 | +import javax.naming.NamingEnumeration; |
| 27 | +import javax.naming.NamingException; |
| 28 | +import javax.naming.directory.Attribute; |
| 29 | +import javax.naming.directory.Attributes; |
| 30 | +import javax.naming.directory.DirContext; |
| 31 | +import javax.naming.ldap.LdapName; |
| 32 | +import javax.naming.ldap.Rdn; |
| 33 | + |
19 | 34 | import org.slf4j.Logger;
|
20 | 35 | import org.slf4j.LoggerFactory;
|
| 36 | + |
21 | 37 | import org.springframework.beans.factory.InitializingBean;
|
22 | 38 | import org.springframework.ldap.UncategorizedLdapException;
|
23 | 39 | import org.springframework.ldap.core.AuthenticationSource;
|
|
28 | 44 | import org.springframework.util.ObjectUtils;
|
29 | 45 | import org.springframework.util.StringUtils;
|
30 | 46 |
|
31 |
| -import javax.naming.Context; |
32 |
| -import javax.naming.NamingEnumeration; |
33 |
| -import javax.naming.NamingException; |
34 |
| -import javax.naming.directory.Attribute; |
35 |
| -import javax.naming.directory.Attributes; |
36 |
| -import javax.naming.directory.DirContext; |
37 |
| -import javax.naming.ldap.LdapName; |
38 |
| -import javax.naming.ldap.Rdn; |
39 |
| - |
40 |
| -import java.net.URI; |
41 |
| -import java.net.URISyntaxException; |
42 |
| -import java.util.Hashtable; |
43 |
| -import java.util.ListIterator; |
44 |
| -import java.util.Map; |
45 |
| - |
46 | 47 | /**
|
47 | 48 | * Abstract implementation of the {@link ContextSource} interface. By default,
|
48 | 49 | * returns an authenticated
|
@@ -424,8 +425,13 @@ public void afterPropertiesSet() {
|
424 | 425 | LOG.info("Property 'userDn' not set - " + "anonymous context will be used for read-write operations");
|
425 | 426 | anonymousReadOnly = true;
|
426 | 427 | }
|
427 |
| - else if (!StringUtils.hasText(password)) { |
428 |
| - LOG.info("Property 'password' not set - " + "blank password will be used"); |
| 428 | + if (!anonymousReadOnly) { |
| 429 | + if (password == null) { |
| 430 | + throw new IllegalArgumentException("Property 'password' cannot be null. To use a blank password, please ensure it is set to \"\""); |
| 431 | + } |
| 432 | + if (!StringUtils.hasText(password)) { |
| 433 | + LOG.info("Property 'password' not set - " + "blank password will be used"); |
| 434 | + } |
429 | 435 | }
|
430 | 436 | authenticationSource = new SimpleAuthenticationSource();
|
431 | 437 | }
|
|
0 commit comments