1 17 package org.apache.ldap.server; 18 19 20 import org.apache.ldap.server.jndi.EnvKeys; 21 22 import javax.naming.*; 23 import java.io.File ; 24 import java.io.IOException ; 25 import java.util.Hashtable ; 26 27 28 35 public class DisableAnonBindTest extends AbstractServerTest 36 { 37 41 public DisableAnonBindTest() throws IOException 42 { 43 doDelete( new File ( "target" + File.separator + "server" ) ); 44 } 45 46 47 52 protected void setUp() throws Exception 53 { 54 if ( getName().equals( "testDisableAnonymousBinds" ) ) 55 { 56 extras.put( EnvKeys.DISABLE_ANONYMOUS, "true" ); 57 } 58 59 super.setUp(); 60 } 61 62 63 69 public void testDisableAnonymousBinds() throws Exception 70 { 71 73 final Hashtable env = new Hashtable (); 74 75 env.put( Context.PROVIDER_URL, "ldap://localhost:" + port + "/ou=system" ); 76 77 env.put( Context.SECURITY_AUTHENTICATION, "none" ); 78 79 env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" ); 80 81 InitialContext ctx = null; 82 83 try 84 { 85 ctx = new InitialContext( env ); 86 87 fail( "If anonymous binds are disabled we should never get here!" ); 88 } 89 catch ( NoPermissionException e ) 90 { 91 assertNull( ctx ); 92 93 assertNotNull( e ); 94 } 95 } 96 } 97 | Popular Tags |