SEC-2308: DefaultSpringSecurityContextSource allow empty baseUrl
This commit is contained in:
parent
f6587c8697
commit
b4cbcee7f0
|
@ -95,6 +95,20 @@ public class DefaultSpringSecurityContextSourceTests extends AbstractLdapIntegra
|
||||||
assertTrue(ctxSrc.isPooled());
|
assertTrue(ctxSrc.isPooled());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SEC-2308
|
||||||
|
@Test
|
||||||
|
public void instantiationSuceedsWithEmtpyBaseDn() throws Exception {
|
||||||
|
String baseDn = "";
|
||||||
|
List<String> serverUrls = new ArrayList<String>();
|
||||||
|
serverUrls.add("ldap://foo:789");
|
||||||
|
serverUrls.add("ldap://bar:389");
|
||||||
|
serverUrls.add("ldaps://blah:636");
|
||||||
|
DefaultSpringSecurityContextSource ctxSrc = new DefaultSpringSecurityContextSource(serverUrls, baseDn);
|
||||||
|
|
||||||
|
assertFalse(ctxSrc.isAnonymousReadOnly());
|
||||||
|
assertTrue(ctxSrc.isPooled());
|
||||||
|
}
|
||||||
|
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void instantiationFailsWithIncorrectServerUrl() throws Exception {
|
public void instantiationFailsWithIncorrectServerUrl() throws Exception {
|
||||||
List<String> serverUrls = new ArrayList<String>();
|
List<String> serverUrls = new ArrayList<String>();
|
||||||
|
|
|
@ -123,9 +123,6 @@ public class DefaultSpringSecurityContextSource extends LdapContextSource {
|
||||||
if ("".equals(trimmedUrl)) {
|
if ("".equals(trimmedUrl)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (trimmedUrl.contains(trimmedBaseDn)) {
|
|
||||||
throw new IllegalArgumentException("LDAP URL string must not include the base DN! '" + trimmedUrl + "'");
|
|
||||||
}
|
|
||||||
|
|
||||||
providerUrl.append(trimmedUrl);
|
providerUrl.append(trimmedUrl);
|
||||||
if (! trimmedUrl.endsWith("/")) {
|
if (! trimmedUrl.endsWith("/")) {
|
||||||
|
|
Loading…
Reference in New Issue