You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by tr...@apache.org on 2005/06/14 07:09:31 UTC
svn commit: r190555 [4/4] - in /directory: apacheds/branches/
apacheds/branches/direve-158/ apacheds/trunk/ apacheds/trunk/core/
apacheds/trunk/core/src/main/aspects/org/apache/ldap/server/jndi/
apacheds/trunk/core/src/main/java/org/apache/ldap/server/
apacheds/trunk/core/src/main/java/org/apache/ldap/server/authn/
apacheds/trunk/core/src/main/java/org/apache/ldap/server/configuration/
apacheds/trunk/core/src/main/java/org/apache/ldap/server/db/
apacheds/trunk/core/src/main/java/org/apache/ldap/server/db/gui/
apacheds/trunk/core/src/main/java/org/apache/ldap/server/db/jdbm/
apacheds/trunk/core/src/main/java/org/apache/ldap/server/interceptor/
apacheds/trunk/core/src/main/java/org/apache/ldap/server/invocation/
apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/
apacheds/trunk/core/src/main/java/org/apache/ldap/server/normalization/
apacheds/trunk/core/src/main/java/org/apache/ldap/server/prefs/
apacheds/trunk/core/src/main/java/org/apache/ldap/server/schema/
apacheds/trunk/core/src/main/java/org/apache/ldap/server/schema/bootstrap/
apacheds/trunk/core/src/test/org/apache/ldap/server/authn/
apacheds/trunk/core/src/test/org/apache/ldap/server/authz/
apacheds/trunk/core/src/test/org/apache/ldap/server/exception/
apacheds/trunk/core/src/test/org/apache/ldap/server/interceptor/
apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/
apacheds/trunk/core/src/test/org/apache/ldap/server/operational/
apacheds/trunk/core/src/test/org/apache/ldap/server/prefs/
apacheds/trunk/core/src/test/org/apache/ldap/server/schema/bootstrap/
apacheds/trunk/main/
apacheds/trunk/main/src/main/java/org/apache/ldap/server/
apacheds/trunk/main/src/main/java/org/apache/ldap/server/configuration/
apacheds/trunk/main/src/main/java/org/apache/ldap/server/jndi/
apacheds/trunk/main/src/test/org/apache/ldap/server/
apacheds/trunk/main/src/test/org/apache/ldap/server/jndi/
protocol-providers/ldap/branches/direve-158/ protocol-providers/ldap/trunk/
protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/
Modified: directory/apacheds/trunk/main/src/test/org/apache/ldap/server/AbstractServerTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/main/src/test/org/apache/ldap/server/AbstractServerTest.java?rev=190555&r1=190554&r2=190555&view=diff
==============================================================================
--- directory/apacheds/trunk/main/src/test/org/apache/ldap/server/AbstractServerTest.java (original)
+++ directory/apacheds/trunk/main/src/test/org/apache/ldap/server/AbstractServerTest.java Mon Jun 13 22:09:25 2005
@@ -17,7 +17,21 @@
package org.apache.ldap.server;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
+
import junit.framework.TestCase;
+
import org.apache.commons.io.FileUtils;
import org.apache.ldap.common.exception.LdapConfigurationException;
import org.apache.ldap.common.ldif.LdifIterator;
@@ -25,21 +39,11 @@
import org.apache.ldap.common.ldif.LdifParserImpl;
import org.apache.ldap.common.message.LockableAttributesImpl;
import org.apache.ldap.common.name.LdapName;
-import org.apache.ldap.server.jndi.EnvKeys;
+import org.apache.ldap.server.configuration.MutableServerStartupConfiguration;
+import org.apache.ldap.server.configuration.ShutdownConfiguration;
+import org.apache.ldap.server.jndi.ServerContextFactory;
import org.apache.mina.util.AvailablePortFinder;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.Name;
-import javax.naming.NamingException;
-import javax.naming.directory.Attributes;
-import javax.naming.ldap.InitialLdapContext;
-import javax.naming.ldap.LdapContext;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Hashtable;
-
/**
* A simple testcase for testing JNDI provider functionality.
@@ -55,11 +59,7 @@
/** flag whether to delete database files for each test or not */
protected boolean doDelete = true;
- /** extra environment parameters that can be added before setUp */
- protected Hashtable extras = new Hashtable();
-
- /** extra environment parameters that can be added before setUp to override values */
- protected Hashtable overrides = new Hashtable();
+ protected MutableServerStartupConfiguration configuration = new MutableServerStartupConfiguration();
protected int port = -1;
@@ -73,18 +73,9 @@
{
super.setUp();
- if ( overrides.containsKey( EnvKeys.WKDIR ) )
- {
- doDelete( new File( ( String ) overrides.get( EnvKeys.WKDIR ) ) );
- }
- else
- {
- doDelete( new File( "target" + File.separator + "apacheds" ) );
- }
-
+ doDelete( configuration.getWorkingDirectory() );
port = AvailablePortFinder.getNextAvailable( 1024 );
-
- extras.put( EnvKeys.LDAP_PORT, String.valueOf( port ) );
+ configuration.setLdapPort( port );
setSysRoot( "uid=admin,ou=system", "secret" );
}
@@ -121,11 +112,11 @@
*/
protected LdapContext setSysRoot( String user, String passwd ) throws NamingException
{
- Hashtable env = new Hashtable();
+ Hashtable env = new Hashtable( configuration.toJndiEnvironment() );
env.put( Context.SECURITY_PRINCIPAL, user );
-
env.put( Context.SECURITY_CREDENTIALS, passwd );
+ env.put( Context.SECURITY_AUTHENTICATION, "simple" );
return setSysRoot( env );
}
@@ -142,25 +133,14 @@
*/
protected LdapContext setSysRoot( Hashtable env ) throws NamingException
{
- Hashtable envFinal = new Hashtable();
-
- envFinal.putAll( extras );
-
- envFinal.putAll( env );
-
+ Hashtable envFinal = new Hashtable( env );
envFinal.put( Context.PROVIDER_URL, "ou=system" );
-
- envFinal.put( EnvKeys.WKDIR, "target" + File.separator + "apacheds" );
-
- envFinal.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.ServerContextFactory" );
-
- envFinal.putAll( overrides );
+ envFinal.put( Context.INITIAL_CONTEXT_FACTORY, ServerContextFactory.class.getName() );
return sysRoot = new InitialLdapContext( envFinal, null );
}
-
/**
* Sets the system context root to null.
*
@@ -176,7 +156,7 @@
env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.ServerContextFactory" );
- env.put( EnvKeys.SHUTDOWN, "" );
+ env.putAll( new ShutdownConfiguration().toJndiEnvironment() );
env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
@@ -185,8 +165,8 @@
try { new InitialContext( env ); } catch( Exception e ) {}
sysRoot = null;
-
- Runtime.getRuntime().gc();
+ doDelete( configuration.getWorkingDirectory() );
+ configuration = new MutableServerStartupConfiguration();
}
Propchange: directory/apacheds/trunk/main/src/test/org/apache/ldap/server/AbstractServerTest.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Jun 13 22:09:25 2005
@@ -1 +1 @@
-Rev
+HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
Modified: directory/apacheds/trunk/main/src/test/org/apache/ldap/server/DisableAnonBindTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/main/src/test/org/apache/ldap/server/DisableAnonBindTest.java?rev=190555&r1=190554&r2=190555&view=diff
==============================================================================
--- directory/apacheds/trunk/main/src/test/org/apache/ldap/server/DisableAnonBindTest.java (original)
+++ directory/apacheds/trunk/main/src/test/org/apache/ldap/server/DisableAnonBindTest.java Mon Jun 13 22:09:25 2005
@@ -17,13 +17,12 @@
package org.apache.ldap.server;
-import org.apache.ldap.server.jndi.EnvKeys;
-
-import javax.naming.*;
-import java.io.File;
-import java.io.IOException;
import java.util.Hashtable;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NoPermissionException;
+
/**
* A set of simple tests to make sure simple authentication is working as it
@@ -36,11 +35,9 @@
{
/**
* Cleans up old database files on creation.
- * @throws IOException
*/
- public DisableAnonBindTest() throws IOException
+ public DisableAnonBindTest()
{
- doDelete( new File( "target" + File.separator + "server" ) );
}
@@ -49,13 +46,9 @@
*
* @throws Exception
*/
- protected void setUp() throws Exception
+ public void setUp() throws Exception
{
- if ( getName().equals( "testDisableAnonymousBinds" ) )
- {
- extras.put( EnvKeys.DISABLE_ANONYMOUS, "true" );
- }
-
+ configuration.setAllowAnonymousAccess( false );
super.setUp();
}
@@ -73,24 +66,16 @@
final Hashtable env = new Hashtable();
env.put( Context.PROVIDER_URL, "ldap://localhost:" + port + "/ou=system" );
-
env.put( Context.SECURITY_AUTHENTICATION, "none" );
-
env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
- InitialContext ctx = null;
-
try
{
- ctx = new InitialContext( env );
-
+ new InitialContext( env );
fail( "If anonymous binds are disabled we should never get here!" );
}
catch ( NoPermissionException e )
{
- assertNull( ctx );
-
- assertNotNull( e );
}
}
}
Propchange: directory/apacheds/trunk/main/src/test/org/apache/ldap/server/DisableAnonBindTest.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Jun 13 22:09:25 2005
@@ -1 +1 @@
-Rev
+HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
Modified: directory/apacheds/trunk/main/src/test/org/apache/ldap/server/jndi/ServerContextFactoryTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/main/src/test/org/apache/ldap/server/jndi/ServerContextFactoryTest.java?rev=190555&r1=190554&r2=190555&view=diff
==============================================================================
--- directory/apacheds/trunk/main/src/test/org/apache/ldap/server/jndi/ServerContextFactoryTest.java (original)
+++ directory/apacheds/trunk/main/src/test/org/apache/ldap/server/jndi/ServerContextFactoryTest.java Mon Jun 13 22:09:25 2005
@@ -17,13 +17,21 @@
package org.apache.ldap.server.jndi;
-import org.apache.ldap.server.AbstractCoreTest;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Set;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
-import javax.naming.directory.*;
-import java.util.Hashtable;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+
+import org.apache.ldap.server.AbstractAdminTestCase;
+import org.apache.ldap.server.configuration.MutableContextPartitionConfiguration;
/**
@@ -32,86 +40,95 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class ServerContextFactoryTest extends AbstractCoreTest
+public class ServerContextFactoryTest extends AbstractAdminTestCase
{
public ServerContextFactoryTest()
{
- BasicAttributes attrs = new BasicAttributes( true );
+ }
- BasicAttribute attr = new BasicAttribute( "objectClass" );
+ public void setUp() throws Exception
+ {
+ BasicAttributes attrs;
+ Set indexedAttrs;
+ Set pcfgs = new HashSet();
+
+ MutableContextPartitionConfiguration pcfg;
+
+ // Add partition 'testing'
+ pcfg = new MutableContextPartitionConfiguration();
+ pcfg.setName( "testing" );
+ pcfg.setSuffix( "ou=testing" );
+
+ indexedAttrs = new HashSet();
+ indexedAttrs.add( "ou" );
+ indexedAttrs.add( "objectClass" );
+ pcfg.setIndexedAttributes( indexedAttrs );
+ attrs = new BasicAttributes( true );
+ BasicAttribute attr = new BasicAttribute( "objectClass" );
attr.add( "top" );
-
attr.add( "organizationalUnit" );
-
attr.add( "extensibleObject" );
-
attrs.put( attr );
-
attr = new BasicAttribute( "ou" );
-
attr.add( "testing" );
-
attrs.put( attr );
-
- extras.put( EnvKeys.PARTITIONS, "testing example MixedCase" );
-
- extras.put( EnvKeys.SUFFIX + "testing", "ou=testing" );
-
- extras.put( EnvKeys.INDICES + "testing", "ou objectClass" );
-
- extras.put( EnvKeys.ATTRIBUTES + "testing", attrs );
-
+ pcfg.setContextEntry( attrs );
+
+ pcfgs.add( pcfg );
+
+ // Add partition 'example'
+ pcfg = new MutableContextPartitionConfiguration();
+ pcfg.setName( "example" );
+ pcfg.setSuffix( "dc=example" );
+
+ indexedAttrs = new HashSet();
+ indexedAttrs.add( "ou" );
+ indexedAttrs.add( "dc" );
+ indexedAttrs.add( "objectClass" );
+ pcfg.setIndexedAttributes( indexedAttrs );
+
attrs = new BasicAttributes( true );
-
attr = new BasicAttribute( "objectClass" );
-
attr.add( "top" );
-
attr.add( "domain" );
-
attr.add( "extensibleObject" );
-
attrs.put( attr );
-
attr = new BasicAttribute( "dc" );
-
attr.add( "example" );
-
attrs.put( attr );
-
- extras.put( EnvKeys.SUFFIX + "example", "dc=example" );
-
- extras.put( EnvKeys.INDICES + "example", "ou dc objectClass" );
-
- extras.put( EnvKeys.ATTRIBUTES + "example", attrs );
+ pcfg.setContextEntry( attrs );
+
+ pcfgs.add( pcfg );
+
+ // Add partition 'MixedCase'
+ pcfg = new MutableContextPartitionConfiguration();
+ pcfg.setName( "example" );
+ pcfg.setSuffix( "dc=MixedCase" );
+
+ indexedAttrs = new HashSet();
+ indexedAttrs.add( "dc" );
+ indexedAttrs.add( "objectClass" );
+ pcfg.setIndexedAttributes( indexedAttrs );
attrs = new BasicAttributes( true );
-
attr = new BasicAttribute( "objectClass" );
-
attr.add( "top" );
-
attr.add( "domain" );
-
attr.add( "extensibleObject" );
-
attrs.put( attr );
-
attr = new BasicAttribute( "dc" );
-
attr.add( "MixedCase" );
-
attrs.put( attr );
+ pcfg.setContextEntry( attrs );
+
+ pcfgs.add( pcfg );
+
+ configuration.setContextPartitionConfigurations( pcfgs );
- extras.put( EnvKeys.SUFFIX + "MixedCase", "dc=MixedCase" );
-
- extras.put( EnvKeys.INDICES + "MixedCase", "dc objectClass" );
-
- extras.put( EnvKeys.ATTRIBUTES + "MixedCase", attrs );
+ super.setUp();
}
-
/**
* Makes sure the system context has the right attributes and values.
*
@@ -164,14 +181,12 @@
public void testAppPartitionExample() throws NamingException
{
- Hashtable env = new Hashtable();
+ Hashtable env = new Hashtable( configuration.toJndiEnvironment() );
env.put( Context.PROVIDER_URL, "dc=example" );
-
env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
-
env.put( Context.SECURITY_CREDENTIALS, "secret" );
-
+ env.put( Context.SECURITY_AUTHENTICATION, "simple" );
env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.ServerContextFactory" );
InitialContext initialContext = new InitialContext( env );
@@ -198,14 +213,12 @@
public void testAppPartitionTesting() throws NamingException
{
- Hashtable env = new Hashtable();
+ Hashtable env = new Hashtable( configuration.toJndiEnvironment() );
env.put( Context.PROVIDER_URL, "ou=testing" );
-
env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
-
env.put( Context.SECURITY_CREDENTIALS, "secret" );
-
+ env.put( Context.SECURITY_AUTHENTICATION, "simple" );
env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.ServerContextFactory" );
InitialContext initialContext = new InitialContext( env );
@@ -232,14 +245,12 @@
public void testAppPartitionMixedCase() throws NamingException
{
- Hashtable env = new Hashtable();
+ Hashtable env = new Hashtable( configuration.toJndiEnvironment() );
env.put( Context.PROVIDER_URL, "dc=MixedCase" );
-
env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
-
env.put( Context.SECURITY_CREDENTIALS, "secret" );
-
+ env.put( Context.SECURITY_AUTHENTICATION, "simple" );
env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.ServerContextFactory" );
InitialContext initialContext = new InitialContext( env );
Propchange: directory/apacheds/trunk/main/src/test/org/apache/ldap/server/jndi/ServerContextFactoryTest.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Jun 13 22:09:25 2005
@@ -1 +1 @@
-Rev
+HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
Modified: directory/apacheds/trunk/project.properties
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/project.properties?rev=190555&r1=190554&r2=190555&view=diff
==============================================================================
--- directory/apacheds/trunk/project.properties (original)
+++ directory/apacheds/trunk/project.properties Mon Jun 13 22:09:25 2005
@@ -1,3 +1,6 @@
+maven.compile.source = 1.4
+maven.compile.target = 1.4
+
maven.junit.fork=yes
maven.changelog.factory=org.apache.maven.svnlib.SvnChangeLogFactory
Modified: directory/protocol-providers/ldap/trunk/project.xml
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ldap/trunk/project.xml?rev=190555&r1=190554&r2=190555&view=diff
==============================================================================
--- directory/protocol-providers/ldap/trunk/project.xml (original)
+++ directory/protocol-providers/ldap/trunk/project.xml Mon Jun 13 22:09:25 2005
@@ -154,6 +154,12 @@
<url>http://directory.apache.org/subprojects/ldap/common</url>
</dependency>
<dependency>
+ <groupId>directory</groupId>
+ <artifactId>apacheds-core</artifactId>
+ <version>0.9.1-SNAPSHOT</version>
+ <url>http://directory.apache.org/subprojects/apacheds</url>
+ </dependency>
+ <dependency>
<groupId>directory-network</groupId>
<artifactId>mina</artifactId>
<version>0.7</version>
Modified: directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/BindHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/BindHandler.java?rev=190555&r1=190554&r2=190555&view=diff
==============================================================================
--- directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/BindHandler.java (original)
+++ directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/BindHandler.java Mon Jun 13 22:09:25 2005
@@ -34,6 +34,8 @@
import org.apache.ldap.common.message.LdapResultImpl;
import org.apache.ldap.common.message.ResultCodeEnum;
import org.apache.ldap.common.util.ExceptionUtils;
+import org.apache.ldap.server.configuration.Configuration;
+import org.apache.ldap.server.configuration.StartupConfiguration;
import org.apache.mina.protocol.ProtocolSession;
import org.apache.mina.protocol.handler.MessageHandler;
@@ -63,7 +65,7 @@
resp.setLdapResult( result );
Hashtable env = SessionRegistry.getSingleton().getEnvironment();
-
+ StartupConfiguration cfg = ( StartupConfiguration ) Configuration.toConfiguration( env );
// if the bind request is not simple then we freak: no strong auth yet
if ( ! req.isSimple() )
{
@@ -76,15 +78,8 @@
return;
}
- boolean allowAnonymousBinds = true;
-
- if ( env.containsKey( "server.disable.anonymous" ) )
- {
- allowAnonymousBinds = false;
- }
-
+ boolean allowAnonymousBinds = cfg.isAllowAnonymousAccess();
boolean emptyCredentials = req.getCredentials() == null || req.getCredentials().length == 0;
-
boolean emptyDn = req.getName() == null || req.getName().length() == 0;
if ( emptyCredentials && emptyDn && ! allowAnonymousBinds )
@@ -107,11 +102,8 @@
byte[] creds = req.getCredentials();
Hashtable cloned = ( Hashtable ) env.clone();
-
cloned.put( Context.SECURITY_PRINCIPAL, dn );
-
cloned.put( Context.SECURITY_CREDENTIALS, creds );
-
cloned.put( Context.SECURITY_AUTHENTICATION, "simple" );
Control[] connCtls = ( Control[] ) req.getControls().toArray( EMPTY );