|
@@ -4,7 +4,10 @@ import static org.junit.Assert.*;
|
|
|
|
|
|
import java.util.Hashtable;
|
|
|
|
|
|
+import javax.naming.directory.DirContext;
|
|
|
+
|
|
|
import org.junit.Test;
|
|
|
+import org.springframework.ldap.AuthenticationException;
|
|
|
import org.springframework.ldap.core.support.AbstractContextSource;
|
|
|
|
|
|
|
|
@@ -12,7 +15,7 @@ import org.springframework.ldap.core.support.AbstractContextSource;
|
|
|
* @author Luke Taylor
|
|
|
* @version $Id$
|
|
|
*/
|
|
|
-public class DefaultSpringSecurityContextSourceTests {
|
|
|
+public class DefaultSpringSecurityContextSourceTests extends AbstractLdapIntegrationTests {
|
|
|
|
|
|
@Test
|
|
|
public void instantiationSucceedsWithExpectedProperties() {
|
|
@@ -47,6 +50,23 @@ public class DefaultSpringSecurityContextSourceTests {
|
|
|
assertFalse(ctxSrc.getAuthenticatedEnvForTest("user", "password").containsKey(AbstractContextSource.SUN_LDAP_POOLING_FLAG));
|
|
|
}
|
|
|
|
|
|
+ // SEC-1145. Confirms that there is no issue here with pooling.
|
|
|
+ @Test(expected=AuthenticationException.class)
|
|
|
+ public void cantBindWithWrongPasswordImmediatelyAfterSuccessfulBind() throws Exception {
|
|
|
+ DirContext ctx = null;
|
|
|
+ try {
|
|
|
+ ctx = getContextSource().getContext("uid=Bob,ou=people,dc=springframework,dc=org", "bobspassword");
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ assertNotNull(ctx);
|
|
|
+// com.sun.jndi.ldap.LdapPoolManager.showStats(System.out);
|
|
|
+ ctx.close();
|
|
|
+// com.sun.jndi.ldap.LdapPoolManager.showStats(System.out);
|
|
|
+ // Now get it gain, with wrong password. Should fail.
|
|
|
+ ctx = getContextSource().getContext("uid=Bob,ou=people,dc=springframework,dc=org", "wrongpassword");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
static class EnvExposingDefaultSpringSecurityContextSource extends DefaultSpringSecurityContextSource {
|
|
|
public EnvExposingDefaultSpringSecurityContextSource(String providerUrl) {
|
|
|
super(providerUrl);
|