You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2005/03/24 19:10:18 UTC
svn commit: r158929 - in directory/apacheds/trunk/core/src:
main/java/org/apache/ldap/server/AbstractServerTest.java
main/java/org/apache/ldap/server/jndi/ServerContextFactory.java
test/org/apache/ldap/server/jndi/SimpleAuthenticationTest.java
Author: akarasulu
Date: Thu Mar 24 10:10:17 2005
New Revision: 158929
URL: http://svn.apache.org/viewcvs?view=rev&rev=158929
Log:
formating cleanup in SCF and added member for for looking up port in AST
Modified:
directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/AbstractServerTest.java
directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java
directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/SimpleAuthenticationTest.java
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/AbstractServerTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/AbstractServerTest.java?view=diff&r1=158928&r2=158929
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/AbstractServerTest.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/AbstractServerTest.java Thu Mar 24 10:10:17 2005
@@ -63,6 +63,7 @@
/** extra environment parameters that can be added before setUp to override values */
protected Hashtable overrides = new Hashtable();
+ protected int port = -1;
/**
* Get's the initial context factory for the provider's ou=system context
@@ -83,8 +84,8 @@
doDelete( new File( "target" + File.separator + "apacheds" ) );
}
- int port = AvailablePortFinder.getNextAvailable( 1024 );
-
+ port = AvailablePortFinder.getNextAvailable( 1024 );
+
extras.put( EnvKeys.LDAP_PORT, String.valueOf( port ) );
setSysRoot( "uid=admin,ou=system", "secret" );
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java?view=diff&r1=158928&r2=158929
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java Thu Mar 24 10:10:17 2005
@@ -60,9 +60,11 @@
private static ServiceRegistry minaRegistry;
+
static
{
ServiceRegistry tmp = null;
+
try
{
tmp = new SimpleServiceRegistry();
@@ -80,14 +82,6 @@
// ------------------------------------------------------------------------
- /**
- * Default constructor that sets the provider of this ServerContextFactory.
- */
- public ServerContextFactory()
- {
- }
-
-
public Context getInitialContext( Hashtable env ) throws NamingException
{
Context ctx = null;
@@ -103,9 +97,9 @@
{
this.provider.shutdown();
- if ( this.minaRegistry != null )
+ if ( minaRegistry != null )
{
- this.minaRegistry.unbind( minaService );
+ minaRegistry.unbind( minaService );
}
}
catch( NamingException ne )
@@ -115,7 +109,9 @@
catch( Throwable t )
{
NamingException ne = new NamingException( "Failed to shutdown." );
+
ne.setRootCause( t );
+
throw ne;
}
finally
@@ -180,6 +176,7 @@
registry.bind( service, new LdapProtocolProvider( ( Hashtable ) initialEnv.clone() ) );
minaService = service;
+
minaRegistry = registry;
}
catch ( IOException e )
@@ -187,7 +184,9 @@
String msg = "Failed to bind the service to the service registry: " + service;
LdapConfigurationException lce = new LdapConfigurationException( msg );
+
lce.setRootCause( e );
+
throw lce;
}
}
Modified: directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/SimpleAuthenticationTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/SimpleAuthenticationTest.java?view=diff&r1=158928&r2=158929
==============================================================================
--- directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/SimpleAuthenticationTest.java (original)
+++ directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/SimpleAuthenticationTest.java Thu Mar 24 10:10:17 2005
@@ -89,6 +89,11 @@
return;
}
+ if ( getName().equals( "test11DisableAnonymousBinds" ) )
+ {
+ extras.put( EnvKeys.DISABLE_ANONYMOUS, "true" );
+ }
+
super.setUp();
}
@@ -140,7 +145,6 @@
public void test3UseAkarasulu() throws NamingException
{
- // now go in as anonymous user and we should be rejected
Hashtable env = new Hashtable();
env.put( Context.PROVIDER_URL, "ou=system" );
env.put( Context.SECURITY_PRINCIPAL, "uid=akarasulu,ou=users,ou=system" );
@@ -289,13 +293,12 @@
/**
* Tests to make sure we can authenticate after the database has already
- * been build as the admin user when simple authentication is in effect.
+ * been started by the admin user when simple authentication is in effect.
*
* @throws Exception if anything goes wrong
*/
public void test8PassPrincAuthTypeSimple() throws Exception
{
- // now go in as anonymous user and we should be rejected
Hashtable env = new Hashtable();
env.put( Context.PROVIDER_URL, "ou=system" );
env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
@@ -314,7 +317,6 @@
*/
public void test10TestNonAdminUser() throws Exception
{
- // now go in as anonymous user and we should be rejected
Hashtable env = new Hashtable();
env.put( Context.PROVIDER_URL, "ou=system" );
env.put( Context.SECURITY_PRINCIPAL, "uid=akarasulu,ou=users,ou=system" );
@@ -322,5 +324,25 @@
env.put( Context.SECURITY_AUTHENTICATION, "simple" );
env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.ServerContextFactory" );
assertNotNull( new InitialContext( env ) );
+ }
+
+
+ /**
+ * Test to make sure anonymous binds are disabled when going through
+ * the wire protocol.
+ *
+ * @throws Exception if anything goes wrong
+ */
+ public void test11DisableAnonymousBinds() throws Exception
+ {
+ // Use the SUN JNDI provider to hit server port and bind as anonymous
+
+ Hashtable env = new Hashtable();
+ env.put( Context.PROVIDER_URL, "ldap://localhost:" + port + "/ou=system" );
+ env.put( Context.SECURITY_PRINCIPAL, "none" );
+
+ InitialContext ctx = new InitialContext( env );
+
+ assertNotNull( ctx );
}
}