* Tests bind operation on a server where the SimpleAuthenticator is disabled
*/
@Test
public void testBindSimpleAuthenticatorDisabled() throws Exception
{
LdapConnection connection = new LdapNetworkConnection( "localhost", getLdapServer().getPort() );
connection.setTimeOut( 0 );
try
{
connection.bind( "uid=hacker", "badsecret" );
fail();
}
catch ( LdapAuthenticationException lae )
{
//Expected
}
assertFalse( connection.isAuthenticated() );
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() } );