AuthenticationInterceptor authInterceptor = ( AuthenticationInterceptor ) ldapServer.getDirectoryService()
.getInterceptor( InterceptorEnum.AUTHENTICATION_INTERCEPTOR.getName() );
authInterceptor.destroy();
authInterceptor.setAuthenticators( new Authenticator[]
{ new StrongAuthenticator() } );
try
{
connection.bind( "uid=hacker", "badsecret" );
fail();
}
catch ( LdapAuthenticationException lae )
{
//Expected
}
// Try with an existing user
try
{
connection.bind( "uid=admin,ou=system", "secret" );
fail();
}
catch ( LdapAuthenticationException lae )
{
//Expected
}
assertFalse( connection.isAuthenticated() );
connection.close();
// Reset the authenticators
authInterceptor.destroy();
authInterceptor.setAuthenticators( new Authenticator[]
{ new StrongAuthenticator(), new SimpleAuthenticator(), new AnonymousAuthenticator() } );
}