|
@@ -15,6 +15,18 @@
|
|
|
*/
|
|
|
package org.springframework.security.ldap.authentication.ad;
|
|
|
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.Hashtable;
|
|
|
+import javax.naming.AuthenticationException;
|
|
|
+import javax.naming.CommunicationException;
|
|
|
+import javax.naming.Name;
|
|
|
+import javax.naming.NameNotFoundException;
|
|
|
+import javax.naming.NamingEnumeration;
|
|
|
+import javax.naming.NamingException;
|
|
|
+import javax.naming.directory.DirContext;
|
|
|
+import javax.naming.directory.SearchControls;
|
|
|
+import javax.naming.directory.SearchResult;
|
|
|
+
|
|
|
import org.apache.directory.shared.ldap.util.EmptyEnumeration;
|
|
|
import org.hamcrest.BaseMatcher;
|
|
|
import org.hamcrest.CoreMatchers;
|
|
@@ -25,6 +37,7 @@ import org.junit.Rule;
|
|
|
import org.junit.Test;
|
|
|
import org.junit.rules.ExpectedException;
|
|
|
import org.mockito.ArgumentCaptor;
|
|
|
+
|
|
|
import org.springframework.dao.IncorrectResultSizeDataAccessException;
|
|
|
import org.springframework.ldap.core.DirContextAdapter;
|
|
|
import org.springframework.ldap.core.DistinguishedName;
|
|
@@ -37,21 +50,13 @@ import org.springframework.security.authentication.LockedException;
|
|
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
|
|
import org.springframework.security.core.Authentication;
|
|
|
|
|
|
-import javax.naming.AuthenticationException;
|
|
|
-import javax.naming.CommunicationException;
|
|
|
-import javax.naming.Name;
|
|
|
-import javax.naming.NameNotFoundException;
|
|
|
-import javax.naming.NamingEnumeration;
|
|
|
-import javax.naming.NamingException;
|
|
|
-import javax.naming.directory.DirContext;
|
|
|
-import javax.naming.directory.SearchControls;
|
|
|
-import javax.naming.directory.SearchResult;
|
|
|
-
|
|
|
-import java.util.Hashtable;
|
|
|
-
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
import static org.assertj.core.api.Assertions.fail;
|
|
|
-import static org.mockito.Mockito.*;
|
|
|
+import static org.mockito.Mockito.any;
|
|
|
+import static org.mockito.Mockito.eq;
|
|
|
+import static org.mockito.Mockito.mock;
|
|
|
+import static org.mockito.Mockito.verify;
|
|
|
+import static org.mockito.Mockito.when;
|
|
|
import static org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider.ContextFactory;
|
|
|
|
|
|
/**
|
|
@@ -398,6 +403,8 @@ public class ActiveDirectoryLdapAuthenticationProviderTests {
|
|
|
public void connectionExceptionIsWrappedInInternalException() throws Exception {
|
|
|
ActiveDirectoryLdapAuthenticationProvider noneReachableProvider = new ActiveDirectoryLdapAuthenticationProvider(
|
|
|
"mydomain.eu", NON_EXISTING_LDAP_PROVIDER, "dc=ad,dc=eu,dc=mydomain");
|
|
|
+ noneReachableProvider.setContextEnvironmentProperties(
|
|
|
+ Collections.singletonMap("com.sun.jndi.ldap.connect.timeout", "5"));
|
|
|
noneReachableProvider.doAuthentication(joe);
|
|
|
}
|
|
|
|